本文整理汇总了C++中KValueRef::SetString方法的典型用法代码示例。如果您正苦于以下问题:C++ KValueRef::SetString方法的具体用法?C++ KValueRef::SetString怎么用?C++ KValueRef::SetString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KValueRef
的用法示例。
在下文中一共展示了KValueRef::SetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _EncodeURIComponent
void Network::_EncodeURIComponent(const ValueList &args, KValueRef result)
{
if (args.at(0)->IsNull() || args.at(0)->IsUndefined())
{
result->SetString("");
}
else if (args.at(0)->IsString())
{
std::string src = args.at(0)->ToString();
std::string sResult = URLUtils::EncodeURIComponent(src);
result->SetString(sResult);
}
else if (args.at(0)->IsDouble())
{
std::stringstream str;
str << args.at(0)->ToDouble();
result->SetString(str.str().c_str());
}
else if (args.at(0)->IsBool())
{
std::stringstream str;
str << args.at(0)->ToBool();
result->SetString(str.str().c_str());
}
else if (args.at(0)->IsInt())
{
std::stringstream str;
str << args.at(0)->ToInt();
result->SetString(str.str().c_str());
}
else
{
throw ValueException::FromString("Could not encodeURIComponent with type passed");
}
}
示例2: _GetData
void Clipboard::_GetData(const ValueList& args, KValueRef result)
{
args.VerifyException("getData", "s");
std::string mimeType(args.GetString(0));
DataType type = MimeTypeToDataType(mimeType);
if (type == URI_LIST)
{
std::vector<std::string>& list = this->GetURIList();
if (mimeType == "url")
{
std::string url;
if (list.size() > 0)
url = list.at(0);
result->SetString(url.c_str());
}
else
{
result->SetList(StaticBoundList::FromStringVector(list));
}
}
else if (type == IMAGE)
{
result->SetObject(this->GetImage(mimeType));
}
else
{
result->SetString(this->GetText());
}
}
示例3: Getter
void PropertiesBinding::Getter(const ValueList& args, KValueRef result, Type type)
{
if (args.size() > 0 && args.at(0)->IsString())
{
std::string eprefix = "PropertiesBinding::Get: ";
try
{
std::string property = args.at(0)->ToString();
if (args.size() == 1)
{
switch (type)
{
case Bool:
result->SetBool(config->getBool(property));
break;
case Double:
result->SetDouble(config->getDouble(property));
break;
case Int:
result->SetInt(config->getInt(property));
break;
case String:
result->SetString(config->getString(property).c_str());
break;
default:
break;
}
return;
}
else if (args.size() >= 2)
{
switch (type)
{
case Bool:
result->SetBool(config->getBool(property, args.at(1)->ToBool()));
break;
case Double:
result->SetDouble(config->getDouble(property, args.at(1)->ToDouble()));
break;
case Int:
result->SetInt(config->getInt(property, args.at(1)->ToInt()));
break;
case String:
result->SetString(config->getString(property, args.at(1)->ToString()).c_str());
break;
default: break;
}
return;
}
}
catch(Poco::Exception &e)
{
throw ValueException::FromString(eprefix + e.displayText());
}
}
}
示例4: _ToUpperCase
void Bytes::_ToUpperCase(const ValueList& args, KValueRef result)
{
if (this->size > 0)
{
std::string target(this->buffer, this->size);
std::string r = Poco::toUpper(target);
result->SetString(r);
}
else
{
result->SetString("");
}
}
示例5: DigestHMACToHex
void Codec::DigestHMACToHex(const ValueList& args, KValueRef result)
{
args.VerifyException("digestHMACToHex", "i s s");
int type = args.at(0)->ToInt();
std::string encoded = args.at(1)->ToString();
std::string key = args.at(2)->ToString();
switch(type)
{
case CODEC_MD2:
{
Poco::HMACEngine<Poco::MD2Engine> engine(key);
engine.update(encoded);
std::string data = Poco::DigestEngine::digestToHex(engine.digest());
result->SetString(data);
break;
}
case CODEC_MD4:
{
Poco::HMACEngine<Poco::MD4Engine> engine(key);
engine.update(encoded);
std::string data = Poco::DigestEngine::digestToHex(engine.digest());
result->SetString(data);
break;
}
case CODEC_MD5:
{
Poco::HMACEngine<Poco::MD5Engine> engine(key);
engine.update(encoded);
std::string data = Poco::DigestEngine::digestToHex(engine.digest());
result->SetString(data);
break;
}
case CODEC_SHA1:
{
Poco::HMACEngine<Poco::SHA1Engine> engine(key);
engine.update(encoded);
std::string data = Poco::DigestEngine::digestToHex(engine.digest());
result->SetString(data);
break;
}
default:
{
std::ostringstream msg("Unsupported encoding type: ");
msg << type;
throw ValueException::FromString(msg.str());
}
}
}
示例6: TransformValue
void ResultSetBinding::TransformValue(size_t index, KValueRef result)
{
MetaColumn::ColumnDataType type = rs->columnType(index);
Poco::DynamicAny value = rs->value(index);
if (value.isEmpty())
{
result->SetNull();
}
else if (type == MetaColumn::FDT_STRING)
{
std::string str;
value.convert(str);
result->SetString(str);
}
else if (type == MetaColumn::FDT_BOOL)
{
bool v = false;
value.convert(v);
result->SetBool(v);
}
else if (type == MetaColumn::FDT_FLOAT || type == MetaColumn::FDT_DOUBLE)
{
float f = 0;
value.convert(f);
result->SetDouble(f);
}
else if (type == MetaColumn::FDT_BLOB || type == MetaColumn::FDT_UNKNOWN)
{
std::string str;
value.convert(str);
result->SetString(str);
}
else
{
// the rest of these are ints:
// FDT_INT8,
// FDT_UINT8,
// FDT_INT16,
// FDT_UINT16,
// FDT_INT32,
// FDT_UINT32,
// FDT_INT64,
// FDT_UINT64,
int i;
value.convert(i);
result->SetInt(i);
}
}
示例7: _GetArgumentValue
void ApplicationBinding::_GetArgumentValue(const ValueList& args, KValueRef result)
{
args.VerifyException("getArgumentValue", "s");
string arg = args.at(0)->ToString();
string argValue = this->application->GetArgumentValue(arg);
result->SetString(argValue);
}
示例8: ToString
void HostBinding::ToString(const ValueList& args, KValueRef result)
{
std::string s("[IPAddress ");
s+=name;
s+="]";
result->SetString(s.c_str());
}
示例9: _DecodeURIComponent
void Network::_DecodeURIComponent(const ValueList &args, KValueRef result)
{
if (args.at(0)->IsNull() || args.at(0)->IsUndefined())
{
result->SetString("");
}
else if (args.at(0)->IsString())
{
std::string src = args.at(0)->ToString();
std::string sResult = URLUtils::DecodeURIComponent(src);
result->SetString(sResult);
}
else
{
throw ValueException::FromString("Could not decodeURIComponent with type passed");
}
}
示例10: _GetVersion
void Platform::_GetVersion(const ValueList& args, KValueRef result)
{
static std::string osVersion;
if (osVersion.empty())
osVersion = GetVersionImpl();
result->SetString(osVersion.c_str());
}
示例11: _Substring
void Bytes::_Substring(const ValueList& args, KValueRef result)
{
// This method now follows the spec located at:
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String/substring
args.VerifyException("Bytes.substring", "i,?i");
std::string target = "";
if (this->size > 0)
{
target = this->buffer;
}
long indexA = args.GetInt(0);
if (indexA < 0)
indexA = 0;
if (indexA > (long) target.size())
indexA = target.size();
if (args.size() < 2)
{
std::string r = target.substr(indexA);
result->SetString(r);
}
else
{
long indexB = args.GetInt(1);
if (indexB < 0)
indexB = 0;
if (indexB > (long) target.size())
indexB = target.size();
if (indexA == indexB)
{
result->SetString("");
return;
}
if (indexA > indexB)
{
long temp = indexA;
indexA = indexB;
indexB = temp;
}
std::string r = target.substr(indexA, indexB - indexA);
result->SetString(r);
}
}
示例12: _GetHTTPSProxy
void Network::_GetHTTPSProxy(const ValueList& args, KValueRef result)
{
SharedProxy proxy = ProxyConfig::GetHTTPSProxyOverride();
if (proxy.isNull())
result->SetNull();
else
result->SetString(proxy->ToString().c_str());
}
示例13: GetIcon
void AppBinding::GetIcon(const ValueList& args, KValueRef result)
{
SharedApplication app = this->host->GetApplication();
result->SetNull();
if (app && !app->image.empty())
{
result->SetString(app->image);
}
}
示例14: DigestToHex
void Codec::DigestToHex(const ValueList& args, KValueRef result)
{
args.VerifyException("digestToHex", "i s|o");
int type = args.at(0)->ToInt();
Poco::DigestEngine *engine = NULL;
switch(type)
{
case CODEC_MD2:
{
engine = new Poco::MD2Engine();
break;
}
case CODEC_MD4:
{
engine = new Poco::MD4Engine();
break;
}
case CODEC_MD5:
{
engine = new Poco::MD5Engine();
break;
}
case CODEC_SHA1:
{
engine = new Poco::SHA1Engine();
break;
}
default:
{
std::ostringstream msg("Unsupported encoding type: ");
msg << type;
throw ValueException::FromString(msg.str());
}
}
if (args.at(1)->IsString())
{
engine->update(args.GetString(1));
}
else
{
AutoPtr<Bytes> bytes(args.GetObject(1).cast<Bytes>());
if (!bytes.isNull())
{
engine->update(bytes->Pointer(), bytes->Length());
}
}
std::string data = Poco::DigestEngine::digestToHex(engine->digest());
result->SetString(data);
delete engine;
}
示例15: GetLineEnding
void FilesystemBinding::GetLineEnding(const ValueList& args, KValueRef result)
{
try
{
result->SetString(Poco::LineEnding::NEWLINE_LF.c_str());
}
catch (Poco::Exception& exc)
{
throw ValueException::FromString(exc.displayText());
}
}