MCPcopy Create free account
hub / github.com/ComodoSecurity/openedr / work_with_string

Function work_with_string

edrav2/eprj/boost/libs/python/test/str.cpp:20–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20void work_with_string(object print)
21{
22 str data("this is a demo string");
23 print(data.split(" "));
24 print(data.split(" ",3));
25 print(str("<->").join(data.split(" ")));
26 print(data.capitalize());
27 print('[' + data.center(30) + ']');
28 print(data.count("t"));
29#if PY_VERSION_HEX < 0x03000000
30 print(data.encode("utf-8"));
31 print(data.decode("utf-8"));
32#else
33 print(data.encode("utf-8").attr("decode")("utf-8"));
34 print(data.encode("utf-8").attr("decode")("utf-8"));
35#endif
36
37 BOOST_ASSERT(!data.endswith("xx"));
38 BOOST_ASSERT(!data.startswith("test"));
39
40 print(data.splitlines());
41 print(data.strip());
42 print(data.swapcase());
43 print(data.title());
44
45 print("find");
46 print(data.find("demo"));
47 print(data.find("demo"),3,5);
48 print(data.find(std::string("demo")));
49 print(data.find(std::string("demo"),9));
50
51 print("expandtabs");
52 str tabstr("\t\ttab\tdemo\t!");
53 print(tabstr.expandtabs());
54 print(tabstr.expandtabs(4));
55 print(tabstr.expandtabs(7L));
56
57 print("operators");
58 print( str("part1") + str("part2") );
59// print( str("a test string").slice(3,_) );
60// print( str("another test")[5] );
61
62 print(data.replace("demo",std::string("blabla")));
63 print(data.rfind("i",5));
64 print(data.rindex("i",5));
65
66 BOOST_ASSERT(!data.startswith("asdf"));
67 BOOST_ASSERT(!data.endswith("asdf"));
68
69 print(data.translate(str('a')*256));
70
71
72 bool tmp = data.isalnum() || data.isalpha() || data.isdigit() || data.islower() ||
73 data.isspace() || data.istitle() || data.isupper();
74 (void)tmp; // ignored.
75}
76
77

Callers

nothing calls this directly

Calls 15

attrMethod · 0.80
endswithMethod · 0.80
startswithMethod · 0.80
splitlinesMethod · 0.80
rindexMethod · 0.80
istitleMethod · 0.80
printFunction · 0.50
strFunction · 0.50
stringFunction · 0.50
splitMethod · 0.45
joinMethod · 0.45
centerMethod · 0.45

Tested by

no test coverage detected