FdoLiteralValue* ExpressionFunctionLookup::Evaluate(FdoLiteralValueCollection *literalValues) { // make sure we have 2 or more arguments, and that there are 2 plus a multiple of 2 if (literalValues->GetCount() < 2 || (literalValues->GetCount()-2) % 2 != 0) { MgResources* resources = MgResources::GetInstance(); assert(NULL != resources); STRING message = MgUtil::GetResourceMessage(MgResources::Stylization, L"MgIncorrectNumberOfArguments"); MgStringCollection arguments; arguments.Add(L"LOOKUP"); // NOXLATE message = resources->FormatMessage(message, &arguments); throw FdoExpressionException::Create(message.c_str()); } // the first parameter is the key we seek FdoPtr<FdoLiteralValue> key = literalValues->GetItem(0); // look for our key in remaining pairs, return matching value if found for (int i=2; i<literalValues->GetCount(); i += 2) { FdoPtr<FdoLiteralValue> thisKey = literalValues->GetItem(i); if (ExpressionHelper::Compare(key, thisKey) == 0) return literalValues->GetItem(i+1); } // we didn't find a match - return the default return literalValues->GetItem(1); }
XmlInputStream* MgXmlSchemaResolver::resolveSchema( XmlTransaction *txn, XmlManager &mgr, const std::string &schemaLocation, const std::string &nameSpace) const { // Verify the existance of the schema file if XML validation is enabled. XmlInputStream* xmlInputStream = NULL; if (m_validationEnabled) { if (schemaLocation.empty()) { // TODO: Add MgResources::GetMessage. STRING message = MgUtil::GetResourceMessage( MgResources::ResourceService, L"MgSchemaFileNotSpecified"); throw XmlException(XmlException::INDEXER_PARSER_ERROR, MgUtil::WideCharToMultiByte(message), __FILE__, __LINE__); } else { STRING schemaPathname = m_schemaFilePath; schemaPathname += MgUtil::MultiByteToWideChar(schemaLocation); if (MgFileUtil::PathnameExists(schemaPathname)) { xmlInputStream = mgr.createLocalFileInputStream( MgUtil::WideCharToMultiByte(schemaPathname)); } else { MgResources* resources = MgResources::GetInstance(); assert(NULL != resources); // TODO: Add MgResources::GetMessage. STRING message = MgUtil::GetResourceMessage( MgResources::ResourceService, L"MgSchemaFileNotFound"); MgStringCollection arguments; arguments.Add(schemaPathname); message = resources->FormatMessage(message, &arguments); throw XmlException(XmlException::INDEXER_PARSER_ERROR, MgUtil::WideCharToMultiByte(message), __FILE__, __LINE__); } } } return xmlInputStream; }
FdoLiteralValue* ExpressionFunctionLayerId::Evaluate(FdoLiteralValueCollection* literalValues) { // make sure we have zero arguments if (literalValues->GetCount() != 0) { MgResources* resources = MgResources::GetInstance(); assert(NULL != resources); STRING message = MgUtil::GetResourceMessage(MgResources::Stylization, L"MgIncorrectNumberOfArguments"); MgStringCollection arguments; arguments.Add(L"LAYERID"); // NOXLATE message = resources->FormatMessage(message, &arguments); throw FdoExpressionException::Create(message.c_str()); } return FDO_SAFE_ADDREF(m_layerIdValue); }
FdoLiteralValue* ExpressionFunctionHtmlColor::Evaluate(FdoLiteralValueCollection* literalValues) { // make sure we have three arguments if (literalValues->GetCount() != 3) { MgResources* resources = MgResources::GetInstance(); assert(NULL != resources); STRING message = MgUtil::GetResourceMessage(MgResources::Stylization, L"MgIncorrectNumberOfArguments"); MgStringCollection arguments; arguments.Add(L"HTMLCOLOR"); // NOXLATE message = resources->FormatMessage(message, &arguments); throw FdoExpressionException::Create(message.c_str()); } FdoPtr<FdoLiteralValue> arg1 = literalValues->GetItem(0); FdoPtr<FdoLiteralValue> arg2 = literalValues->GetItem(1); FdoPtr<FdoLiteralValue> arg3 = literalValues->GetItem(2); FdoInt32 red = ExpressionHelper::GetAsInt32(arg1); FdoInt32 green = ExpressionHelper::GetAsInt32(arg2); FdoInt32 blue = ExpressionHelper::GetAsInt32(arg3); // clean up red &= 0xFF; green &= 0xFF; blue &= 0xFF; wchar_t tmp[32] = { 0 }; std::wstring str; swprintf(tmp, 32, L"%0.2x", red); str.append(&tmp[0]); swprintf(tmp, 32, L"%0.2x", green); str.append(&tmp[0]); swprintf(tmp, 32, L"%0.2x", blue); str.append(&tmp[0]); m_htmlColorValue->SetString(str.c_str()); return FDO_SAFE_ADDREF(m_htmlColorValue); }
FdoLiteralValue* ExpressionFunctionArgb::Evaluate(FdoLiteralValueCollection* literalValues) { // make sure we have four arguments if (literalValues->GetCount() != 4) { MgResources* resources = MgResources::GetInstance(); assert(NULL != resources); STRING message = MgUtil::GetResourceMessage(MgResources::Stylization, L"MgIncorrectNumberOfArguments"); MgStringCollection arguments; arguments.Add(L"ARGB"); // NOXLATE message = resources->FormatMessage(message, &arguments); throw FdoExpressionException::Create(message.c_str()); } FdoPtr<FdoLiteralValue> arg1 = literalValues->GetItem(0); FdoPtr<FdoLiteralValue> arg2 = literalValues->GetItem(1); FdoPtr<FdoLiteralValue> arg3 = literalValues->GetItem(2); FdoPtr<FdoLiteralValue> arg4 = literalValues->GetItem(3); FdoInt32 alpha = ExpressionHelper::GetAsInt32(arg1); FdoInt32 red = ExpressionHelper::GetAsInt32(arg2); FdoInt32 green = ExpressionHelper::GetAsInt32(arg3); FdoInt32 blue = ExpressionHelper::GetAsInt32(arg4); // clean up red &= 0xFF; green &= 0xFF; blue &= 0xFF; alpha &= 0xFF; FdoInt32 color = (alpha << 24) | (red << 16) | (green << 8) | blue; m_argbValue->SetInt32(color); return FDO_SAFE_ADDREF(m_argbValue); }