secureswitools/swisistools/source/interpretsislib/expressionevaluator.cpp
branchRCL_3
changeset 81 42552535c1ac
parent 66 8b7f4e561641
equal deleted inserted replaced
73:79647526f98c 81:42552535c1ac
   106     {
   106     {
   107 	if (++iExpressionDepth > KMaxExpressionDepth)
   107 	if (++iExpressionDepth > KMaxExpressionDepth)
   108 	    {
   108 	    {
   109 		iExpressionDepth=0;
   109 		iExpressionDepth=0;
   110 		std::string error = "SIS File expression too complex\n";
   110 		std::string error = "SIS File expression too complex\n";
   111 		std::string x = wstring2string(iExpEnv.GetPackageName());
   111 		std::string x;
   112         //
   112         //
   113 		throw InvalidSis(x, error, SIS_NOT_SUPPORTED);
   113 		throw InvalidSis(Ucs2ToUtf8(iExpEnv.GetPackageName(),x), error, SIS_NOT_SUPPORTED);
   114 	    }
   114 	    }
   115 
   115 
   116 	switch (aExpression.Operator())
   116 	switch (aExpression.Operator())
   117 	    {
   117 	    {
   118 	case CSISExpression::EBinOpEqual:
   118 	case CSISExpression::EBinOpEqual:
   246 
   246 
   247 	case CSISExpression::EPrimTypeOption:
   247 	case CSISExpression::EPrimTypeOption:
   248 		{
   248 		{
   249 		iExpressionDepth=0;
   249 		iExpressionDepth=0;
   250 		std::string error = "SIS File contains user options\n";
   250 		std::string error = "SIS File contains user options\n";
   251 		std::string x = wstring2string(iExpEnv.GetPackageName());
   251 		std::string x;
   252         //
   252         //
   253 		throw InvalidSis(x, error, SIS_NOT_SUPPORTED);
   253 		throw InvalidSis(Ucs2ToUtf8(iExpEnv.GetPackageName(),x), error, SIS_NOT_SUPPORTED);
   254 		}
   254 		}
   255 
   255 
   256 	case CSISExpression::EPrimTypeNumber:
   256 	case CSISExpression::EPrimTypeNumber:
   257 		iTempResult = ExpressionResult(aExpression.IntValue());
   257 		iTempResult = ExpressionResult(aExpression.IntValue());
   258 		break;
   258 		break;
   259 
   259 
   260 	default:
   260 	default:
   261 		{
   261 		{
   262 		iExpressionDepth=0;
   262 		iExpressionDepth=0;
   263 		std::string error = "SIS File contains unknown expression\n";
   263 		std::string error = "SIS File contains unknown expression\n";
   264 		std::string x = wstring2string(iExpEnv.GetPackageName());
   264 		std::string x;
   265         //
   265         //
   266 		throw InvalidSis(x, error, SIS_NOT_SUPPORTED);
   266 		throw InvalidSis(Ucs2ToUtf8(iExpEnv.GetPackageName(),x), error, SIS_NOT_SUPPORTED);
   267 		}
   267 		}
   268     	}
   268     	}
   269 
   269 
   270 	--iExpressionDepth;
   270 	--iExpressionDepth;
   271 	return iTempResult;
   271 	return iTempResult;
   314 			}  		
   314 			}  		
   315         fileName = L"Z:" + fileName;
   315         fileName = L"Z:" + fileName;
   316         }
   316         }
   317 
   317 
   318     // Require for invalid file exception (also helps with debugging)
   318     // Require for invalid file exception (also helps with debugging)
   319 	    std::string narrowFileName = wstring2string( fileName );
   319     std::string narrowFileName;
       
   320     narrowFileName = Ucs2ToUtf8( fileName, narrowFileName );
   320 
   321 
   321     // Now continue with file, assuming we've fixed up the path or then
   322     // Now continue with file, assuming we've fixed up the path or then
   322     // have enough characters to process
   323     // have enough characters to process
   323     bool startsWithDrive = StringUtils::StartsWithDrive( fileName );
   324     bool startsWithDrive = StringUtils::StartsWithDrive( fileName );
   324     if  ( startsWithDrive )
   325     if  ( startsWithDrive )
   342             // File is on 'C:' so merge with C-drive specification and
   343             // File is on 'C:' so merge with C-drive specification and
   343             // use native FileExists() check
   344             // use native FileExists() check
   344             ConvertToLocalPath( fileName, iCDrive );
   345             ConvertToLocalPath( fileName, iCDrive );
   345 
   346 
   346             // For debugging
   347             // For debugging
   347 			narrowFileName = wstring2string( fileName );
   348             narrowFileName = Ucs2ToUtf8( fileName, narrowFileName );
       
   349 
   348             fileExists = FileExists( fileName );
   350             fileExists = FileExists( fileName );
   349             break;
   351             break;
   350             }
   352             }
   351             }
   353             }
   352         }
   354         }
   359 	if(aLogInfo)
   361 	if(aLogInfo)
   360 		{
   362 		{
   361 		std::ostringstream stream;
   363 		std::ostringstream stream;
   362 		stream << "\tIF EXISTS(\'" << narrowFileName << "\') => " << fileExists;
   364 		stream << "\tIF EXISTS(\'" << narrowFileName << "\') => " << fileExists;
   363 		std::string msg = stream.str();
   365 		std::string msg = stream.str();
   364 		std::wstring finalMessage = string2wstring( msg );
   366 		std::wstring finalMessage = Utf8ToUcs2( msg );
   365 		LINFO( finalMessage );
   367 		LINFO( finalMessage );
   366 		}
   368 		}
   367     //
   369     //
   368     return fileExists;
   370     return fileExists;
   369     }
   371     }
   424 				if(aLogInfo)
   426 				if(aLogInfo)
   425 					{
   427 					{
   426 					std::ostringstream stream;
   428 					std::ostringstream stream;
   427 					stream << "Input language " << result << " is not supported by SIS file. Using first language " <<firstLanguage;
   429 					stream << "Input language " << result << " is not supported by SIS file. Using first language " <<firstLanguage;
   428 					std::string msg = stream.str();
   430 					std::string msg = stream.str();
   429 					std::wstring finalMessage = string2wstring( msg );
   431 					std::wstring finalMessage = Utf8ToUcs2( msg );
   430 					LWARN( finalMessage );	
   432 					LWARN( finalMessage );	
   431 					}
   433 					}
   432 				result = firstLanguage;
   434 				result = firstLanguage;
   433 				}
   435 				}
   434 			}
   436 			}
   435         if(aLogInfo)
   437         if(aLogInfo)
   436 			{
   438 			{
   437 			std::ostringstream stream;
   439 			std::ostringstream stream;
   438 			stream << "\tIF " << attributeName << " ... where [" << attributeName << " = " << result << "]";
   440 			stream << "\tIF " << attributeName << " ... where [" << attributeName << " = " << result << "]";
   439 			std::string msg = stream.str();
   441 			std::string msg = stream.str();
   440 			std::wstring finalMessage = string2wstring( msg );
   442 			std::wstring finalMessage = Utf8ToUcs2( msg );
   441 			LINFO( finalMessage );
   443 			LINFO( finalMessage );
   442 			}
   444 			}
   443         }
   445         }
   444 	else if ( aVariableId == KVariableLanguage )
   446 	else if ( aVariableId == KVariableLanguage )
   445     	{
   447     	{
   449 			}
   451 			}
   450 		result = 1;
   452 		result = 1;
   451     	}
   453     	}
   452     else
   454     else
   453         {
   455         {
   454         std::string packageName = wstring2string( GetPackageName() );
   456         std::string packageName;
       
   457         packageName = Ucs2ToUtf8( GetPackageName(), packageName );
   455         //
   458         //
   456 		std::string error = "SIS File contains HAL attributes\n";
   459 		std::string error = "SIS File contains HAL attributes\n";
   457 		throw InvalidSis( packageName, error, SIS_NOT_SUPPORTED );
   460 		throw InvalidSis( packageName, error, SIS_NOT_SUPPORTED );
   458         }
   461         }
   459     //
   462     //