Exemplo n.º 1
0
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 std::string StringMarkupParser::Parse(const std::string& in_string, const MarkupFoundDelegate& in_callback)
 {
     std::string out_string;
     u32 index = 0;
     
     auto it = in_string.begin();
     while(it < in_string.end())
     {
         auto character = UTF8StringUtils::Next(it);
         
         if(character != k_markupStart)
         {
             UTF8StringUtils::Append(character, out_string);
             if(character != ' ' && character != '\t' && character != '\n')
             {
                 ++index;
             }
         }
         else
         {
             // Found a mark up, check it
             ParseRecursive(index, it, out_string, in_callback);
         }
     }
     
     return out_string;
 }
Exemplo n.º 2
0
void NMEAParser::Parse(const char *buf, const unsigned int bufSize)
{
//	m_outputFile.Write(buf, bufSize);
//printf("Parsing\n");
	for( unsigned int i = 0; i < bufSize; i++ )
		ParseRecursive(buf[i]);
}
Exemplo n.º 3
0
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 std::string StringMarkupParser::ParseRecursive(u32 in_indexInString, std::string::const_iterator& out_iterator, std::string& out_string, const MarkupFoundDelegate& in_callback)
 {
     // Found some mark-up. What type is it?
     std::string type;
     UTF8Char nextChar = '\0';
     
     while (nextChar != k_markupSeparator)
     {
         nextChar = UTF8StringUtils::Next(out_iterator);
         
         if(nextChar != k_markupSeparator && nextChar != ' ')
         {
             type += nextChar;
         }
     }
     
     // Variable type has been located
     std::string varName;
     
     // There may be some whitespace that we need to ignore
     nextChar = UTF8StringUtils::Next(out_iterator);
     if(nextChar != ' ')
     {
         varName += nextChar;
     }
     
     // Find the closing bracket
     while (nextChar != k_markupEnd)
     {
         nextChar = UTF8StringUtils::Next(out_iterator);
         
         if(nextChar != k_markupEnd && nextChar != k_markupStart && nextChar != ' ')
         {
             varName += nextChar;
         }
         
         // Nested variable
         if(nextChar == k_markupStart)
         {
             std::string variableName;
             
             const auto& subType = ParseRecursive(in_indexInString, out_iterator, variableName, in_callback);
             
             // Check if the keyword is nestable
             if(m_markupDef.HasKeyword(subType))
             {
                 CS_ASSERT(m_markupDef.IsKeywordNestable(subType) == true, "Keyword \"" + subType + "\" isn't a nestable type");
             }
             
             varName += variableName;
         }
     }
     
     if(m_markupDef.HasKeyword(type))
     {
         const auto& variable = in_callback(type, varName, in_indexInString);
         out_string.append(variable);
     }
     else
     {
         out_string.append(k_markupStart + type + k_markupSeparator + varName + k_markupEnd);
     }
     
     return type;
 }