MCPcopy Create free account
hub / github.com/acl-dev/acl / main

Function main

lib_acl_cpp/samples/string/string6/main.cpp:7–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include "acl_cpp/lib_acl.hpp"
6
7int main()
8{
9 acl::string s = "hello world!";
10
11 std::cout << s << std::endl;
12
13 std::string s1 = "Hello, you're welcome!";
14 s = s1;
15 std::cout << s << std::endl;
16
17 if (s == s1) {
18 std::cout << "s == s1\r\n";
19 } else {
20 std::cout << "s != s1\r\n";
21 }
22
23 if (s1 == s) {
24 std::cout << "s1 == s\r\n";
25 } else {
26 std::cout << "s1 != s\r\n";
27 }
28
29#if 1
30 std::string s2 = s;
31#else
32 // This'll be failed because it's ambiguous with 'operator const char*() const' in acl::string.
33 std::string s2;
34 s2 = s;
35#endif
36 std::cout << "after std::string=acl::string: " << s2 << std::endl;
37
38 std::cout << "Before pop_back, s: " << s << ", size: " << s.size() << std::endl;
39
40 char ch = s.back();
41 if (ch == (char) -1) {
42 std::cout << "back nil!\r\n";
43 } else {
44 s.pop_back();
45
46 std::cout << "pop_back one char: " << (char) (ch)
47 << ", left: " << s << ", left size: " << s.size()
48 << std::endl;
49 }
50
51 s.clear();
52 ch = s.back();
53 if (ch == (char) -1) {
54 std::cout << "no char\r\n";
55 } else {
56 std::cout << "back char: " << ch << std::endl;
57 }
58
59 s = "www.google.com:80";
60 std::cout << "s: " << s << "; len: " << s.length() << std::endl;
61
62 int p = s.find(':');
63 if (p > 0) {
64 acl::string port;

Callers

nothing calls this directly

Calls 8

backMethod · 0.80
substrMethod · 0.80
sizeMethod · 0.45
pop_backMethod · 0.45
clearMethod · 0.45
lengthMethod · 0.45
findMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…