本文整理汇总了C++中ogre::String::at方法的典型用法代码示例。如果您正苦于以下问题:C++ String::at方法的具体用法?C++ String::at怎么用?C++ String::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::String
的用法示例。
在下文中一共展示了String::at方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
float
ParseKeyFrameTime( const float length, const Ogre::String& string )
{
float res = 0;
if( string.at( string.size() - 1 ) == '%' )
{
res = length * Ogre::StringConverter::parseReal( string.substr( 0, string.size() - 1 ) ) / 100;
}
else
{
res = Ogre::StringConverter::parseReal( string );
}
return res;
}
示例2: position
Ogre::StringVector
StringTokenise(const Ogre::String& str, const Ogre::String& delimiters, const Ogre::String& delimiters_preserve, const Ogre::String& quote, const Ogre::String& esc)
{
Ogre::StringVector ret;
Ogre::String::size_type pos = 0; // the current position (char) in the string
char ch = 0; // buffer for the current character
char delimiter = 0; // the buffer for the delimiter char which
// will be added to the tokens if the delimiter
// is preserved
char current_quote = 0; // the char of the current open quote
bool quoted = false; // indicator if there is an open quote
Ogre::String token; // string buffer for the token
bool token_complete = false; // indicates if the current token is
// read to be added to the result vector
Ogre::String::size_type len = str.length(); // length of the input-string
// for every char in the input-string
while(len > pos)
{
// get the character of the string and reset the delimiter buffer
ch = str.at(pos);
delimiter = 0;
// assume ch isn't a delimiter
bool add_char = true;
// check ...
// ... if the delimiter is an escaped character
bool escaped = false; // indicates if the next char is protected
if(esc.empty() == false) // check if esc-chars are provided
{
if(esc.find_first_of(ch) != std::string::npos)
{
// get the escaped char
++pos;
if(pos < len) // if there are more chars left
{
// get the next one
ch = str.at(pos);
// add the escaped character to the token
add_char = true;
}
else // cannot get any more characters
{
// don't add the esc-char
add_char = false;
}
// ignore the remaining delimiter checks
escaped = true;
}
}
// ... if the delimiter is a quote
if(quote.empty() == false && escaped == false)
{
// if quote chars are provided and the char isn't protected
if(quote.find_first_of(ch) != std::string::npos)
{
// if not quoted, set state to open quote and set
// the quote character
if(quoted == false)
{
quoted = true;
current_quote = ch;
// don't add the quote-char to the token
add_char = false;
}
else // if quote is open already
{
// check if it is the matching character to close it
if(current_quote == ch)
{
// close quote and reset the quote character
quoted = false;
current_quote = 0;
// don't add the quote-char to the token
add_char = false;
}
}
}
}
// if the delimiter isn't preserved
if(delimiters.empty() == false && escaped == false && quoted == false)
{
// if a delimiter is provided and the char isn't protected by
// quote or escape char
if(delimiters.find_first_of(ch) != std::string::npos)
{
// if ch is a delimiter and the token string isn't empty
// the token is complete
if(token.empty() == false)
{
token_complete = true;
//.........这里部分代码省略.........