cbsatplugin/atmisccmdplugin/src/atcommandparser.cpp
branchRCL_3
changeset 64 1934667b0e2b
parent 61 269724087bed
child 72 4b59561a31c0
equal deleted inserted replaced
61:269724087bed 64:1934667b0e2b
   252     TChar chr = 0;
   252     TChar chr = 0;
   253     
   253     
   254     if(!iCmd.Eos())
   254     if(!iCmd.Eos())
   255         {
   255         {
   256         chr = iCmd.Peek();
   256         chr = iCmd.Peek();
   257         while(!iCmd.Eos() && chr != ',' && !chr.IsSpace() && !chr.IsControl())
   257         while(!iCmd.Eos() && chr != ',' && !chr.IsControl())
   258             {// Stop at any of those chars: comma, space or control
   258             {// Stop at any comma or control character
   259             iCmd.Inc();
   259             iCmd.Inc();
   260             chr = iCmd.Peek();
   260             chr = iCmd.Peek();
   261             }
   261             }
   262         }
   262         }
   263     
   263     
   264     // Extract the token at this point            
   264     // Extract the token at this point            
   265     TPtrC8 retVal = iCmd.MarkedToken();
   265     TPtrC8 retVal = iCmd.MarkedToken();
   266     
   266     
       
   267 	//ignore all space characters at the end
       
   268     if(retVal.Length() > 1)
       
   269     {
       
   270         TInt pos = retVal.Length() - 1; 
       
   271         for ( ; pos >= 0; pos-- )
       
   272             {
       
   273             const TChar ch( retVal[pos] );
       
   274             if( !ch.IsSpace() )
       
   275                 {
       
   276                 break;
       
   277                 }
       
   278             }
       
   279         retVal.Set( retVal.Mid( 0, pos + 1 ) );
       
   280     }
       
   281     
       
   282     
   267     // Skip comma, space and control chars
   283     // Skip comma, space and control chars
   268     while(!iCmd.Eos() && (chr == ',' || chr.IsSpace() || chr.IsControl()))
   284     do
   269         {
   285       {
   270         iCmd.Inc();
   286       iCmd.Inc();
   271         chr = iCmd.Peek();
   287       chr = iCmd.Peek();
   272         }
   288       }
       
   289     while(!iCmd.Eos() && (chr.IsSpace() || chr.IsControl()));
       
   290     
   273     TRACE_FUNC_EXIT
   291     TRACE_FUNC_EXIT
   274     return retVal;
   292     return retVal;
   275     }
   293     }
   276 
   294 
   277 TInt TAtCommandParser::NextTextParam(TPtrC8& aParam)
   295 TInt TAtCommandParser::NextTextParam(TPtrC8& aParam)
   308         {
   326         {
   309         retVal = KErrNotFound;
   327         retVal = KErrNotFound;
   310         }
   328         }
   311     else
   329     else
   312         {
   330         {
   313         TLex8 lex(param);
   331         //check if param contains only digits - TLex doesn't do that
   314         retVal = lex.Val(aValue);
   332         for(TInt pos = param.Length() - 1; pos >= 0; pos--)
       
   333             {
       
   334             if(( param[pos] < '0' ) || ( param[pos] > '9' ))
       
   335                 {
       
   336                 retVal = KErrArgument;
       
   337                 break;
       
   338                 }
       
   339             }
       
   340         
       
   341         if(retVal == KErrNone)
       
   342             {
       
   343             TLex8 lex(param);
       
   344             retVal = lex.Val(aValue);
       
   345             }
   315         }
   346         }
   316     TRACE_FUNC_EXIT
   347     TRACE_FUNC_EXIT
   317     return retVal;
   348     return retVal;
   318     }
   349     }
   319 
   350