本文整理汇总了C++中KKStr::Append方法的典型用法代码示例。如果您正苦于以下问题:C++ KKStr::Append方法的具体用法?C++ KKStr::Append怎么用?C++ KKStr::Append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KKStr
的用法示例。
在下文中一共展示了KKStr::Append方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadWholeTag
void ReadWholeTag (istream& i,
KKStr& tagStr
)
{
tagStr = "";
while (!i.eof ())
{
char nextCh = i.get ();
if (nextCh != 0)
tagStr.Append (nextCh);
if (nextCh == '>')
break;
}
return;
} /* ReadWholeTag */
示例2: GetRestOfLine
KKStr KKStrParser::GetRestOfLine ()
{
if (trimWhiteSpace)
{
while ((nextPos < len) && (strchr (whiteSpace, str[nextPos]) != NULL))
nextPos++;
}
if (nextPos >= len)
return KKStr::EmptyStr ();
KKStr result (1 + len - nextPos);
char lastChar = 0;
while (nextPos < len)
{
lastChar = str[nextPos];
if (lastChar == '\n')
break;
else if (lastChar == '\r')
break;
result.Append (lastChar);
nextPos++;
}
if (nextPos < len)
{
if (lastChar == '\n')
{
if (str[nextPos] == '\r')
nextPos++;
}
else if (lastChar == '\r')
{
if (str[nextPos] == '\n')
nextPos ++;
}
}
if (trimWhiteSpace)
result.TrimRight (whiteSpace);
return result;
} /* GetRestOfLine */
示例3: ReadHeaderOneLine
void ScannerFile::ReadHeaderOneLine (FILE* f,
bool& endOfText,
KKStr& line
)
{
char ch;
line = "";
endOfText = false;
kkint32 bytesReturned = fread (&ch, 1, 1, f);
while ((ch != 0) && (ch != '\n') && (bytesReturned > 0))
{
line.Append (ch);
bytesReturned = fread (&ch, 1, 1, f);
}
if ((ch == 0) || (bytesReturned == 0))
endOfText = true;
} /* ReadHeaderOneLine */
示例4: SubStrPart
KKStr KKStrParser::SubStrPart (kkuint32 firstChar,
kkuint32 lastChar
) const
{
if (lastChar < firstChar)
return KKStr::EmptyStr ();
kkuint32 subStrLen = (1 + lastChar - firstChar);
KKStr result (subStrLen + 1);
if (lastChar >= len)
lastChar = len - 1;
kkuint32 idx = 0;
for (idx = firstChar; idx <= lastChar; idx++)
result.Append (str[idx]);
return result;
}
示例5: ToString
KKStr ParameterJob::ToString ()
{
KKStr statusStr ("");
statusStr.Append (curStatus);
statusStr << "\t" << processNum
<< "\t" << jobId
<< "\t" << cParm
<< "\t" << gammaParm
<< "\t" << aParm
<< "\t" << accuracy
<< "\t" << trainTime
<< "\t" << classTime
<< "\t" << numSVs;
return statusStr;
} /* ToString */
示例6: GetLine
void FeatureFileIO::GetLine (istream& _in,
KKStr& _line,
bool& _eof
)
{
_line = "";
if (_in.eof ())
{
_eof = true;
return;
}
kkint32 ch = _in.peek ();
while ((ch != '\n') && (ch != '\r') && (!_in.eof ()))
{
ch = _in.get ();
_line.Append ((char)ch);
ch = _in.peek ();
}
if (!_in.eof ())
{
_in.get (); // Skip over end of line character.
if (ch == '\n')
{
ch = _in.peek ();
if (ch == '\r')
_in.get (); // line is terminated by LineFeed + CarrageReturn; we need to skip over both.
}
else if (ch == '\r')
{
ch = _in.peek ();
if (ch == '\n')
_in.get (); // line is terminated by CarrageReturn + LineFeed; we need to skip over both.
}
}
_eof = false;
return;
} /* GetLine */
示例7: GetRestOfStr
KKStr KKStrParser::GetRestOfStr ()
{
if (trimWhiteSpace)
{
while ((nextPos < len) && (strchr (whiteSpace, str[nextPos]) != NULL))
nextPos++;
}
if (nextPos >= len)
return KKStr::EmptyStr ();
KKStr result (1 + len - nextPos);
while (nextPos < len)
{
result.Append (str[nextPos]);
nextPos++;
}
if (trimWhiteSpace)
result.TrimRight (whiteSpace);
return result;
} /* GetRestOfStr */
示例8: GetToken
void FeatureFileIO::GetToken (istream& _in,
const char* _delimiters,
KKStr& _token,
bool& _eof,
bool& _eol
)
{
_token = "";
_eof = false;
_eol = false;
if (_in.eof ())
{
_eof = true;
_eol = true;
return;
}
kkint32 ch;
// Skip past any leading white space.
ch = _in.peek ();
while ((ch == ' ') && (!_in.eof ()))
{
_in.get ();
ch = _in.peek ();
}
if (_in.eof ())
{
_eof = true;
_eol = true;
return;
}
if (ch == '\n')
{
_eol = true;
_in.get ();
if (_in.peek () == '\r')
_in.get ();
return;
}
if (ch == '\r')
{
_eol = true;
_in.get ();
if (_in.peek () == '\n')
_in.get ();
return;
}
while ((!_in.eof ()) && (ch != '\n') && (ch != '\r') && (strchr (_delimiters, ch) == NULL))
{
_in.get ();
_token.Append ((char)ch);
ch = _in.peek ();
}
if (strchr (_delimiters, ch) != NULL)
{
// the next character was a delimiter; in this case we want to remove from stream.
_in.get ();
}
return;
} /* GetToken */
示例9: PeekNextToken
/**
*@brief Returns what the next token that 'GetNextToken' will without updating the position in the string buffer.
*@details Allows you to see what the token would be without updating the KKStrParser instance.
*@param[in] delStr List of delimiting characters.
*@returns Next Token to be returned by 'GetNextToken'.
*/
KKStr KKStrParser::PeekNextToken (const char* delStr) const
{
kkuint32 nextPosP = nextPos;
if (trimWhiteSpace)
{
while ((nextPos < len) && (strchr (whiteSpace, str[nextPosP]) != NULL))
nextPosP++;
}
if (nextPosP >= len)
return KKStr::EmptyStr ();
kkuint32 startPos = nextPosP;
kkuint32 endPos = startPos;
char ch = str[endPos];
if ((ch == '\'') || (ch == '"'))
{
KKStr token (30);
// Token is a string
char quoteChar = ch;
// We have a quoted String need to skip to end of quote.
++endPos;
while (endPos < len)
{
ch = str[endPos];
if (ch == quoteChar)
{
++endPos;
break;
}
if ((ch == '\\') && (endPos < (len - 1)))
{
++endPos;
char ec = str[endPos];
switch (ec)
{
case '"': ch = '"'; break;
case '\\': ch = '\\'; break;
case 'r': ch = '\r'; break;
case 'n': ch = '\n'; break;
case 't': ch = '\t'; break;
}
}
token.Append (ch);
++endPos;
}
return token;
}
else
{
// scan until end of string or next delimiter
while (endPos < len)
{
ch = str[endPos];
if (strchr (delStr, ch) != NULL)
{
break;
}
++endPos;
}
endPos--; // Move endPos back to last character in token.
if (trimWhiteSpace)
{
while ((endPos >= startPos) && (strchr (whiteSpace, str[endPos]) != NULL))
endPos--;
}
return KKStr (str, startPos, endPos);
}
} /* PeekNextToken */
示例10: GetNextToken
KKStr KKStrParser::GetNextToken (const char* delStr)
{
lastDelimiter = 0;
if (trimWhiteSpace)
{
while ((nextPos < len) && (strchr (whiteSpace, str[nextPos]) != NULL))
nextPos++;
}
if (nextPos >= len)
return KKStr::EmptyStr ();
kkuint32 startPos = nextPos;
kkuint32 endPos = startPos;
char ch = str[endPos];
if ((ch == '\'') || (ch == '"'))
{
KKStr token (30);
// Token is a string
char quoteChar = ch;
// We have a quoted String need to skip to end of quote.
++endPos; // Skipped past initial quote character.
while (endPos < len)
{
ch = str[endPos];
if (ch == quoteChar)
break;
if ((ch == '\\') && (endPos < (len - 1)))
{
++endPos;
char ec = str[endPos];
switch (ec)
{
case '\\': ch = '\\'; break;
case '"': ch = '"'; break;
case 'r': ch = '\r'; break;
case 'n': ch = '\n'; break;
case 't': ch = '\t'; break;
}
}
token.Append (ch);
++endPos;
}
if (endPos >= len)
{
nextPos = len;
}
else
{
// Now that we are at the end of the quoted String we need set the next character pointer to just past the following delimiter character.
nextPos = endPos + 1;
if (trimWhiteSpace)
{
while ((nextPos < len) && (strchr (whiteSpace, str[nextPos]) != NULL))
nextPos++;
}
if ((nextPos < len) && (strchr (delStr, str[nextPos]) != NULL))
{
lastDelimiter = str[nextPos];
++nextPos;
}
}
return token;
}
else
{
// scan until end of string or next delimiter
kkuint32 delimeterIdx = 0;
bool delimeterFound = false;
while (endPos < len)
{
ch = str[endPos];
if (strchr (delStr, ch) != NULL)
{
lastDelimiter = ch;
delimeterFound = true;
delimeterIdx = endPos;
break;
}
++endPos;
}
endPos--; // Move endPos back to last character in token.
if (trimWhiteSpace)
{
while ((endPos >= startPos) && (strchr (whiteSpace, str[endPos]) != NULL))
endPos--;
}
if (delimeterFound)
//.........这里部分代码省略.........