本文整理汇总了C++中CL_String::Split方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_String::Split方法的具体用法?C++ CL_String::Split怎么用?C++ CL_String::Split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CL_String
的用法示例。
在下文中一共展示了CL_String::Split方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseAndConvert
long CL_TimeOfDay::ParseAndConvert (const CL_String& s)
{
CL_String fld[4];
short hour, min, sec;
short n;
if ((n = s.Split (fld, 4, ":")) == 2 || n == 3) {
hour = (short) fld[0].AsLong ();
min = (short) fld[1].AsLong ();
sec = (short) fld[2].AsLong ();
}
else if (s.Split (fld, 4, ": ") == 3) {
hour = (short) fld[0].AsLong ();
min = (short) fld[1].AsLong ();
sec = 0;
if (fld[2] == "pm")
hour += 12;
}
else {
// Assume that it's either four or six digits, and try to parse it.
for (short i = 0; i < s.Size(); i++) {
if (s[i] > '9' || s[i] < '0') {
return -1;
}
}
hour = (s[0]-'0')*10 + s[1]-'0';
min = (s[2]-'0')*10 + s[3]-'0';
if (s.Size() == 6) {
sec = (s[4]-'0')*10 + s[5]-'0';
}
else
sec = 0;
}
if (! (hour >= 0 && hour < 24) ) {
return -1;
}
if (! (min >= 0 && min < 60) ) {
return -1;
}
if (! (sec >= 0 && sec < 60) ) {
return -1;
}
return (hour * 3600L + min * 60 + sec);
}