本文整理汇总了C++中Poco::trim方法的典型用法代码示例。如果您正苦于以下问题:C++ Poco::trim方法的具体用法?C++ Poco::trim怎么用?C++ Poco::trim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Poco
的用法示例。
在下文中一共展示了Poco::trim方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testTrim
void StringTest::testTrim()
{
{
std::string s = "abc";
assert (trim(s) == "abc");
}
{
std::string s = "abc ";
assert (trim(s) == "abc");
}
{
std::string s = " ab c ";
assert (trim(s) == "ab c");
}
}
示例2: createDirectory
// create a directory if it doesnt exist yet.
bool createDirectory(string dir, bool relativeToDataDir, bool createSubDirectories) {
try {
trim(dir);
if(relativeToDataDir) {
dir = getDataPath() +dir;
}
Poco::File f(dir);
try {
if(f.isDirectory()) { // throws!
return true;
}
}
catch(...) {
if(createSubDirectories) {
f.createDirectories();
}
else {
f.createDirectory();
}
}
}
catch(Poco::FileException& ex) {
printf("Cannot create directory: '%s' reason:'%s'\n"
,dir.c_str()
,ex.displayText().c_str()
);
return false;
}
return true;
}
示例3: tryParse
bool IPAddress::tryParse(const std::string& addr, IPAddress& result)
{
IPv4AddressImpl impl4(IPv4AddressImpl::parse(addr));
if (impl4 != IPv4AddressImpl() || trim(addr) == "0.0.0.0")
{
result.newIPv4(impl4.addr());
return true;
}
#if defined(POCO_HAVE_IPv6)
IPv6AddressImpl impl6(IPv6AddressImpl::parse(addr));
if (impl6 != IPv6AddressImpl())
{
result.newIPv6(impl6.addr(), impl6.scope());
return true;
}
#endif
return false;
}
示例4: main
int main(int argc, char** argv) {
string hello(" Hello, world! ");
cout << hello << "\n";
string s1(trimLeft(hello)); // "Hello, world! "
cout << s1 << "\n";
trimRightInPlace(s1); // "Hello, world!"
cout << s1 << "\n";
string s2(trim(hello)); // "Hello, world!"
cout << s2 << "\n";
return 0;
}