secureswitools/swisistools/source/interpretsislib/expressionevaluator.cpp
branchRCL_3
changeset 62 5cc91383ab1e
parent 34 741e5bba2bd1
child 65 7333d7932ef7
equal deleted inserted replaced
61:cd189dac02f7 62:5cc91383ab1e
   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;
   111 		std::string x = wstring2string(iExpEnv.GetPackageName());
   112         //
   112         //
   113 		throw InvalidSis(Ucs2ToUtf8(iExpEnv.GetPackageName(),x), error, SIS_NOT_SUPPORTED);
   113 		throw InvalidSis(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;
   251 		std::string x = wstring2string(iExpEnv.GetPackageName());
   252         //
   252         //
   253 		throw InvalidSis(Ucs2ToUtf8(iExpEnv.GetPackageName(),x), error, SIS_NOT_SUPPORTED);
   253 		throw InvalidSis(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;
   264 		std::string x = wstring2string(iExpEnv.GetPackageName());
   265         //
   265         //
   266 		throw InvalidSis(Ucs2ToUtf8(iExpEnv.GetPackageName(),x), error, SIS_NOT_SUPPORTED);
   266 		throw InvalidSis(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;
   319 	    std::string narrowFileName = wstring2string( fileName );
   320     narrowFileName = Ucs2ToUtf8( fileName, narrowFileName );
       
   321 
   320 
   322     // Now continue with file, assuming we've fixed up the path or then
   321     // Now continue with file, assuming we've fixed up the path or then
   323     // have enough characters to process
   322     // have enough characters to process
   324     bool startsWithDrive = StringUtils::StartsWithDrive( fileName );
   323     bool startsWithDrive = StringUtils::StartsWithDrive( fileName );
   325     if  ( startsWithDrive )
   324     if  ( startsWithDrive )
   343             // File is on 'C:' so merge with C-drive specification and
   342             // File is on 'C:' so merge with C-drive specification and
   344             // use native FileExists() check
   343             // use native FileExists() check
   345             ConvertToLocalPath( fileName, iCDrive );
   344             ConvertToLocalPath( fileName, iCDrive );
   346 
   345 
   347             // For debugging
   346             // For debugging
   348             narrowFileName = Ucs2ToUtf8( fileName, narrowFileName );
   347 			narrowFileName = wstring2string( fileName );
   349 
       
   350             fileExists = FileExists( fileName );
   348             fileExists = FileExists( fileName );
   351             break;
   349             break;
   352             }
   350             }
   353             }
   351             }
   354         }
   352         }
   361 	if(aLogInfo)
   359 	if(aLogInfo)
   362 		{
   360 		{
   363 		std::ostringstream stream;
   361 		std::ostringstream stream;
   364 		stream << "\tIF EXISTS(\'" << narrowFileName << "\') => " << fileExists;
   362 		stream << "\tIF EXISTS(\'" << narrowFileName << "\') => " << fileExists;
   365 		std::string msg = stream.str();
   363 		std::string msg = stream.str();
   366 		std::wstring finalMessage = Utf8ToUcs2( msg );
   364 		std::wstring finalMessage = string2wstring( msg );
   367 		LINFO( finalMessage );
   365 		LINFO( finalMessage );
   368 		}
   366 		}
   369     //
   367     //
   370     return fileExists;
   368     return fileExists;
   371     }
   369     }
   426 				if(aLogInfo)
   424 				if(aLogInfo)
   427 					{
   425 					{
   428 					std::ostringstream stream;
   426 					std::ostringstream stream;
   429 					stream << "Input language " << result << " is not supported by SIS file. Using first language " <<firstLanguage;
   427 					stream << "Input language " << result << " is not supported by SIS file. Using first language " <<firstLanguage;
   430 					std::string msg = stream.str();
   428 					std::string msg = stream.str();
   431 					std::wstring finalMessage = Utf8ToUcs2( msg );
   429 					std::wstring finalMessage = string2wstring( msg );
   432 					LWARN( finalMessage );	
   430 					LWARN( finalMessage );	
   433 					}
   431 					}
   434 				result = firstLanguage;
   432 				result = firstLanguage;
   435 				}
   433 				}
   436 			}
   434 			}
   437         if(aLogInfo)
   435         if(aLogInfo)
   438 			{
   436 			{
   439 			std::ostringstream stream;
   437 			std::ostringstream stream;
   440 			stream << "\tIF " << attributeName << " ... where [" << attributeName << " = " << result << "]";
   438 			stream << "\tIF " << attributeName << " ... where [" << attributeName << " = " << result << "]";
   441 			std::string msg = stream.str();
   439 			std::string msg = stream.str();
   442 			std::wstring finalMessage = Utf8ToUcs2( msg );
   440 			std::wstring finalMessage = string2wstring( msg );
   443 			LINFO( finalMessage );
   441 			LINFO( finalMessage );
   444 			}
   442 			}
   445         }
   443         }
   446 	else if ( aVariableId == KVariableLanguage )
   444 	else if ( aVariableId == KVariableLanguage )
   447     	{
   445     	{
   451 			}
   449 			}
   452 		result = 1;
   450 		result = 1;
   453     	}
   451     	}
   454     else
   452     else
   455         {
   453         {
   456         std::string packageName;
   454         std::string packageName = wstring2string( GetPackageName() );
   457         packageName = Ucs2ToUtf8( GetPackageName(), packageName );
       
   458         //
   455         //
   459 		std::string error = "SIS File contains HAL attributes\n";
   456 		std::string error = "SIS File contains HAL attributes\n";
   460 		throw InvalidSis( packageName, error, SIS_NOT_SUPPORTED );
   457 		throw InvalidSis( packageName, error, SIS_NOT_SUPPORTED );
   461         }
   458         }
   462     //
   459     //