本文整理汇总了C++中MojObject::stringValue方法的典型用法代码示例。如果您正苦于以下问题:C++ MojObject::stringValue方法的具体用法?C++ MojObject::stringValue怎么用?C++ MojObject::stringValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MojObject
的用法示例。
在下文中一共展示了MojObject::stringValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Match
bool MojoCompareMatcher::Match(const MojObject& response)
{
LOG_AM_TRACE("Entering function %s", __FUNCTION__);
if (response.contains(m_key)) {
MojObject value;
MojString valueString;
response.get(m_key, value);
value.stringValue(valueString);
if (value != m_value) {
MojString oldValueString;
m_value.stringValue(oldValueString);
LOG_AM_DEBUG("Compare Matcher: Comparison key \"%s\" value changed from \"%s\" to \"%s\". Firing.",
m_key.data(),
oldValueString.data(), valueString.data());
return true;
} else {
LOG_AM_DEBUG("Compare Matcher: Comparison key \"%s\" value \"%s\" unchanged.",
m_key.data(), valueString.data());
}
} else {
LOG_AM_DEBUG("Compare Matcher: Comparison key (%s) not present.",
m_key.data());
}
return false;
}
示例2: ValidateOp
void MojoNewWhereMatcher::ValidateOp(const MojObject& op,
const MojObject& val) const
{
if (op.type() != MojObject::TypeString) {
throw std::runtime_error("Operation must be specified as a string "
"property");
}
MojString opStr;
MojErr err = op.stringValue(opStr);
if (err) {
throw std::runtime_error("Failed to convert operation to "
"string value");
}
if ((opStr != "<") && (opStr != "<=") && (opStr != "=") &&
(opStr != ">=") && (opStr != ">") && (opStr != "!=") &&
(opStr != "where")) {
throw std::runtime_error("Operation must be one of '<', '<=', "
"'=', '>=', '>', '!=', and 'where'");
}
if (opStr == "where") {
ValidateClauses(val);
}
}
示例3: CheckProperty
MojoNewWhereMatcher::MatchResult MojoNewWhereMatcher::CheckProperty(
const MojObject& key, const MojObject& response, const MojObject& op,
const MojObject& val, MatchMode mode) const
{
if (key.type() == MojObject::TypeString) {
MojString keyStr;
MojErr err = key.stringValue(keyStr);
if (err) {
throw std::runtime_error("Failed to convert property lookup key "
"to string");
}
MojObject propVal;
bool found = response.get(keyStr.data(), propVal);
if (!found) {
return NoProperty;
}
return CheckMatch(propVal, op, val);
} else if (key.type() == MojObject::TypeArray) {
return CheckProperty(key, key.arrayBegin(), response, op, val, mode);
} else {
throw std::runtime_error("Key specified was neither a string or "
"array of strings");
}
}
示例4: Match
bool MojoCompareMatcher::Match(const MojObject& response)
{
MojLogTrace(s_log);
if (response.contains(m_key)) {
MojObject value;
MojString valueString;
response.get(m_key, value);
value.stringValue(valueString);
if (value != m_value) {
MojString oldValueString;
m_value.stringValue(oldValueString);
MojLogInfo(s_log, _T("Compare Matcher: Comparison key \"%s\" "
"value changed from \"%s\" to \"%s\". Firing."), m_key.data(),
oldValueString.data(), valueString.data());
return true;
} else {
MojLogInfo(s_log, _T("Compare Matcher: Comparison key \"%s\" "
"value \"%s\" unchanged."), m_key.data(), valueString.data());
}
} else {
MojLogInfo(s_log, _T("Compare Matcher: Comparison key (%s) not "
"present."), m_key.data());
}
return false;
}
示例5: emptyTest
MojErr MojObjectTest::emptyTest(MojObject& obj)
{
MojObject obj2;
MojString str1;
MojString str2;
bool found = false;
MojTestAssert(obj.size() == 0);
MojTestAssert(obj.empty());
MojTestAssert(obj.boolValue() == false);
MojTestAssert(obj.intValue() == 0);
MojTestAssert(obj.decimalValue() == MojDecimal());
MojTestAssert(obj.begin() == obj.end());
MojTestAssert(!obj.contains(_T("hello")));
MojTestAssert(!obj.get(_T("hi"), obj2));
MojErr err = obj.del(_T("hello"), found);
MojTestErrCheck(err);
obj2.assign(obj);
MojTestAssert(obj2.type() == obj.type());
MojTestAssert(obj2 == obj);
MojTestAssert(!(obj2 != obj));
err = obj.stringValue(str1);
MojTestErrCheck(err);
err = obj2.stringValue(str2);
MojTestErrCheck(err);
MojTestAssert(str1 == str2);
return MojErrNone;
}
示例6: handleVal
MojErr MojDbPropExtractor::handleVal(const MojObject& val, KeySet& valsOut, MojSize idx) const
{
LOG_TRACE("Entering function %s", __FUNCTION__);
MojAssert(idx < m_prop.size());
MojErr err = MojErrNone;
if (idx == m_prop.size() - 1) {
// if we're at the end of the prop path, use this object as the value
if (m_tokenizer.get() && val.type() == MojObject::TypeString) {
MojString text;
err = val.stringValue(text);
MojErrCheck(err);
if (m_tokenizer.get()) {
err = m_tokenizer->tokenize(text, m_collator.get(), valsOut);
MojErrCheck(err);
}
} else {
MojDbKey key;
err = key.assign(val, m_collator.get());
MojErrCheck(err);
err = valsOut.put(key);
MojErrCheck(err);
}
} else {
// otherwise, keep recursing
err = valsImpl(val, valsOut, idx + 1);
MojErrCheck(err);
}
return MojErrNone;
}
示例7:
MojoObjectString::MojoObjectString(const MojObject& obj)
{
MojErr err = obj.stringValue(m_str);
/* Intentially ignore err here. This is for debug output, let's not
* make the problem worse... */
(void)err;
}
示例8: getLocale
MojErr MojDb::getLocale(MojString& valOut, MojDbReq& req)
{
MojObject curLocale;
MojErr err = getState(LocaleKey, curLocale, req);
MojErrCheck(err);
err = curLocale.stringValue(valOut);
MojErrCheck(err);
return MojErrNone;
}
示例9:
MojErr MojDbQuery::Page::fromObject(const MojObject& obj)
{
MojString str;
MojErr err = obj.stringValue(str);
MojErrCheck(err);
err = str.base64Decode(m_key.byteVec());
MojErrCheck(err);
return MojErrNone;
}
示例10: GetObjectValue
bool MojoWhereMatcher::GetObjectValue(const MojObject& key,
const MojObject& response, MojObject& value) const
{
if (key.type() == MojObject::TypeString) {
MojString keyStr;
MojErr err = key.stringValue(keyStr);
if (err) {
throw std::runtime_error("Error attempting to retrieve key name "
"getting object value");
}
if (response.contains(keyStr)) {
return response.get(keyStr, value);
} else {
return false;
}
} else if (key.type() == MojObject::TypeArray) {
MojObject cur = response;
for (MojObject::ConstArrayIterator iter = key.arrayBegin();
iter != key.arrayEnd(); ++iter) {
const MojObject& keyObj = *iter;
if (keyObj.type() != MojObject::TypeString) {
throw std::runtime_error("Non-string found in property "
"specifiction array");
}
MojString keyStr;
MojErr err = keyObj.stringValue(keyStr);
if (err) {
throw std::runtime_error("Failed to access lookup key");
}
if (cur.contains(keyStr)) {
MojObject tmp;
if (!cur.get(keyStr, tmp)) {
return false;
} else {
cur = tmp;
}
} else {
return false;
}
}
value = cur;
return true;
} else {
throw std::runtime_error("Property specification must be the "
"property name or array of property names");
}
}
示例11: configure
MojErr MojDbLunaServiceApp::configure(const MojObject& conf)
{
LOG_TRACE("Entering function %s", __FUNCTION__);
MojErr err = Base::configure(conf);
MojErrCheck(err);
m_conf = conf;
conf.get(MojDbStorageEngine::engineFactory()->name(), m_engineConf);
err = m_env->configure(m_engineConf);
MojErrCheck(err);
err = m_mainService.db().configure(conf);
MojErrCheck(err);
MojObject dbConf;
err = conf.getRequired("db", dbConf);
MojErrCheck(err);
MojObject dbPath;
err = dbConf.getRequired("path", dbPath);
MojErrCheck(err);
err = dbPath.stringValue(m_dbDir);
MojErrCheck(err);
MojObject serviceName;
err = dbConf.getRequired("service_name", serviceName);
MojErrCheck(err);
err = serviceName.stringValue(m_serviceName);
MojErrCheck(err);
err = m_mainService.configure(dbConf);
MojErrCheck(err);
return MojErrNone;
}
示例12: pushSearch
MojErr MojDbQueryPlan::pushSearch(MojDbKeyBuilder& lowerBuilder, MojDbKeyBuilder& upperBuilder,
const MojObject& val, MojDbTextCollator* collator)
{
// get text
MojString text;
MojErr err = val.stringValue(text);
MojErrCheck(err);
MojDbKeyBuilder::KeySet toks;
// tokenize
MojRefCountedPtr<MojDbTextTokenizer> tokenizer(new MojDbTextTokenizer);
MojAllocCheck(tokenizer.get());
err = tokenizer->init(m_locale);
MojErrCheck(err);
err = tokenizer->tokenize(text, collator, toks);
MojErrCheck(err);
// remove prefixes
MojDbKeyBuilder::KeySet::Iterator i;
err = toks.begin(i);
MojErrCheck(err);
MojDbKeyBuilder::KeySet::ConstIterator prev = toks.end();
while (i != toks.end()) {
if (prev != toks.end() && prev->stringPrefixOf(*i)) {
bool found = false;
err = toks.del(*prev, found);
MojErrCheck(err);
MojAssert(found);
}
prev = i;
++i;
}
// push toks
err = lowerBuilder.push(toks);
MojErrCheck(err);
err = upperBuilder.push(toks);
MojErrCheck(err);
m_groupCount = (MojUInt32) toks.size();
return MojErrNone;
}
示例13: CheckMatch
MojoNewWhereMatcher::MatchResult MojoNewWhereMatcher::CheckMatch(
const MojObject& rhs, const MojObject& op, const MojObject& val) const
{
MojString opStr;
MojErr err = op.stringValue(opStr);
if (err) {
throw std::runtime_error("Failed to convert operation to string "
"value");
}
bool result;
if (opStr == "<") {
result = (rhs < val);
} else if (opStr == "<=") {
result = (rhs <= val);
} else if (opStr == "=") {
result = (rhs == val);
} else if (opStr == "!=") {
result = (rhs != val);
} else if (opStr == ">=") {
result = (rhs >= val);
} else if (opStr == ">") {
result = (rhs > val);
} else if (opStr == "where") {
result = CheckClause(val, rhs, AndMode);
} else {
throw std::runtime_error("Unknown comparison operator in where "
"clause");
}
if (result) {
return Matched;
} else {
return NotMatched;
}
}
示例14: ConfidenceToInt
int ConnectionManagerProxy::ConfidenceToInt(const MojObject& confidenceObj) const
{
if (confidenceObj.type() != MojObject::TypeString) {
LOG_WARNING(MSGID_NON_STRING_TYPE_NW_CONFIDENCE, 0, "Network confidence must be specified as a string");
return ConnectionConfidenceUnknown;
}
MojString confidenceStr;
MojErr err = confidenceObj.stringValue(confidenceStr);
if (err != MojErrNone) {
LOG_WARNING(MSGID_GET_NW_CONFIDENCE_LEVEL_FAIL, 0, "Failed to retreive network confidence level as string");
return ConnectionConfidenceUnknown;
}
for (int i = 0; i < ConnectionConfidenceMax; ++i) {
if (confidenceStr == ConnectionConfidenceNames[i]) {
return i;
}
}
LOG_DEBUG("Unknown connection confidence string: \"%s\"", confidenceStr.data() );
return ConnectionConfidenceUnknown;
}
示例15: updateObjsViaMerge
MojErr MojDbPerfUpdateTest::updateObjsViaMerge(MojDb& db, const MojChar* kindId, MojErr (MojDbPerfTest::*createFn) (MojObject&, MojUInt64))
{
// register all the kinds
MojTime time;
MojErr err = putKinds(db, time);
MojTestErrCheck(err);
// put objects using createFn
MojObject objs;
err = putObjs(db, kindId, numInsertForPut, createFn, objs);
MojTestErrCheck(err);
MojObject midObj;
bool found = objs.at(numInsertForPut/2, midObj);
MojTestAssert(found);
MojTime objTime;
err = mergeObj(db, midObj, objTime);
MojTestErrCheck(err);
MojUInt64 mergeTime = objTime.microsecs();
err = MojPrintF("\n -------------------- \n");
MojTestErrCheck(err);
err = MojPrintF(" merging single object - index %llu - of kind %s %llu times took: %llu microsecs\n", numInsertForPut/2, kindId, numMergeIterations, mergeTime);
MojTestErrCheck(err);
err = MojPrintF(" time per merge: %llu microsecs", (mergeTime) / (numMergeIterations));
MojTestErrCheck(err);
err = MojPrintF("\n\n");
MojTestErrCheck(err);
MojString buf;
err = buf.format("Merge single object - index %llu - %llu times,%s,%llu,%llu,%llu,\n", numInsertForPut/2, numMergeIterations, kindId, mergeTime, mergeTime/numMergeIterations, mergeTime/(1*numMergeIterations));
MojTestErrCheck(err);
err = fileWrite(file, buf);
MojTestErrCheck(err);
MojTime batchTime;
MojObject::ArrayIterator beginArr;
err = objs.arrayBegin(beginArr);
MojErrCheck(err);
err = batchMergeObj(db, beginArr, beginArr + (numInsertForPut / 10), batchTime);
MojTestErrCheck(err);
mergeTime = batchTime.microsecs();
err = MojPrintF(" merging batch - %llu objects - of kind %s %llu times took: %llu microsecs\n", numInsertForPut/10, kindId, numBatchMergeIterations, mergeTime);
MojTestErrCheck(err);
err = MojPrintF(" time per batch merge: %llu microsecs\n", (mergeTime) / (numBatchMergeIterations));
MojTestErrCheck(err);
err = MojPrintF(" time per object: %llu microsecs", (mergeTime) / (numInsertForPut/10 * numBatchMergeIterations));
MojTestErrCheck(err);
err = MojPrintF("\n\n");
MojTestErrCheck(err);
err = buf.format("Batch merge %llu objects %llu times,%s,%llu,%llu,%llu,\n", numInsertForPut/10, numBatchMergeIterations, kindId, mergeTime, mergeTime/numBatchMergeIterations, mergeTime/(numInsertForPut/10*numBatchMergeIterations));
MojTestErrCheck(err);
err = fileWrite(file, buf);
MojTestErrCheck(err);
MojTime mergeQueryTime;
MojTestErrCheck(err);
MojDbQuery query;
err = query.from(kindId);
MojTestErrCheck(err);
query.limit(numInsertForPut/5);
query.desc(true);
MojObject queryObj;
err = query.toObject(queryObj);
MojTestErrCheck(err);
MojString queryStr;
err = queryObj.stringValue(queryStr);
MojTestErrCheck(err);
MojObject props;
err = props.putString(_T("newKey"), _T("here's a new value"));
MojTestErrCheck(err);
MojUInt32 count;
err = queryMergeObj(db, query, props, count, mergeQueryTime);
MojTestErrCheck(err);
mergeTime = mergeQueryTime.microsecs();
err = MojPrintF(" merging with query - %d objects - of kind %s %llu times took: %llu microsecs\n", count, kindId, numBatchMergeIterations, mergeTime);
MojTestErrCheck(err);
err = MojPrintF(" time per merge: %llu microsecs\n", (mergeTime) / (numBatchMergeIterations));
MojTestErrCheck(err);
err = MojPrintF(" time per object: %llu microsecs", (mergeTime) / (count * numBatchMergeIterations));
MojTestErrCheck(err);
err = MojPrintF("\n\n");
MojTestErrCheck(err);
err = buf.format("Merge with query %s,,,,,\nMerge with query - %d objects - %llu times,%s,%llu,%llu,%llu,\n", queryStr.data(), count, numBatchMergeIterations, kindId, mergeTime, mergeTime/numBatchMergeIterations, mergeTime/(count*numBatchMergeIterations));
MojTestErrCheck(err);
err = fileWrite(file, buf);
MojTestErrCheck(err);
return MojErrNone;
}