本文整理汇总了C++中DynamicObject::getIterator方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicObject::getIterator方法的具体用法?C++ DynamicObject::getIterator怎么用?C++ DynamicObject::getIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicObject
的用法示例。
在下文中一共展示了DynamicObject::getIterator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _applyContext
/**
* Recursively applies context to the given input object.
*
* @param ctx the context to use.
* @param usedCtx the used context values.
* @param predicate the related predicate or NULL if none.
* @param in the input object.
* @param out the contextualized output object.
*/
static void _applyContext(
DynamicObject& ctx, DynamicObject& usedCtx,
const char* predicate, DynamicObject& in, DynamicObject& out)
{
if(in.isNull())
{
out.setNull();
}
else
{
// initialize output
DynamicObjectType inType = in->getType();
out->setType(inType);
if(inType == Map)
{
// add context to each property in the map
char* tmp = NULL;
DynamicObjectIterator i = in.getIterator();
while(i->hasNext())
{
// compact predicate
DynamicObject& next = i->next();
DynamicObject cp(NULL);
const char* p;
if(strcmp(i->getName(), "@") == 0)
{
p = "@";
}
else
{
cp = _compactString(ctx, usedCtx, NULL, i->getName(), &tmp);
p = cp;
}
// recurse
_applyContext(ctx, usedCtx, p, next, out[p]);
}
free(tmp);
}
else if(inType == Array)
{
// apply context to each object in the array
DynamicObjectIterator i = in.getIterator();
while(i->hasNext())
{
DynamicObject& next = i->next();
_applyContext(ctx, usedCtx, predicate, next, out->append());
}
}
// only strings need context applied, numbers & booleans don't
else if(inType == String)
{
// compact string
char* tmp = NULL;
out = _compactString(ctx, usedCtx, predicate, in->getString(), &tmp);
free(tmp);
}
}
}
示例2: appendValuesSql
void DatabaseClient::appendValuesSql(string& sql, DynamicObject& params)
{
string values;
bool first = true;
DynamicObjectIterator i = params.getIterator();
while(i->hasNext())
{
DynamicObject& name = i->next()["name"];
if(first)
{
first = false;
sql.append(" (");
values.append(" VALUES (?");
}
else
{
sql.append(",");
values.append(",?");
}
// append unaliased name
sql.push_back('`');
sql.append(name->getString());
sql.push_back('`');
}
if(!first)
{
sql.append(")");
values.append(")");
}
sql.append(values);
}
示例3: appendSetSql
void DatabaseClient::appendSetSql(string& sql, DynamicObject& params)
{
bool first = true;
DynamicObjectIterator i = params.getIterator();
while(i->hasNext())
{
DynamicObject& param = i->next();
if(first)
{
first = false;
sql.append(" ");
}
else
{
sql.append(",");
}
// append name
if(param->hasMember("tableAlias"))
{
sql.append(param["tableAlias"]->getString());
sql.push_back('.');
}
sql.append(param["name"]->getString());
sql.append("=?");
}
}
示例4: _filter
/**
* Recursively filter input to output.
*
* @param filter the fitler to use.
* @param in the input object.
* @param out the filtered output object.
*/
static void _filter(
DynamicObject& filter, DynamicObject& in, DynamicObject& out)
{
if(!in.isNull())
{
DynamicObjectType inType = in->getType();
if(inType == Map)
{
// check if this object matches filter
if(_filterOne(filter, in))
{
out["@"]->append(in);
}
}
if(inType == Map || inType == Array)
{
// filter each object
DynamicObjectIterator i = in.getIterator();
while(i->hasNext())
{
_filter(filter, i->next(), out);
}
}
}
}
示例5: appendColumnNames
void DatabaseClient::appendColumnNames(
string& sql, DynamicObject& columnSchemas)
{
bool first = true;
DynamicObjectIterator i = columnSchemas.getIterator();
while(i->hasNext())
{
DynamicObject& next = i->next();
if(first)
{
first = false;
sql.append(" ");
}
else
{
sql.append(",");
}
if(next->hasMember("tableAlias"))
{
sql.append(next["tableAlias"]->getString());
sql.append(".");
}
sql.append(next["column"]["name"]->getString());
}
}
示例6: unregisterObserver
void EventController::unregisterObserver(
Observer* observer, DynamicObject& eventTypes)
{
DynamicObjectIterator i = eventTypes.getIterator();
while(i->hasNext())
{
DynamicObject& type = i->next();
unregisterObserver(observer, type->getString());
}
}
示例7: while
string X509Certificate::getField(DynamicObject& subjectOrIssuer, const char* sn)
{
string rval;
DynamicObjectIterator i = subjectOrIssuer.getIterator();
while(i->hasNext())
{
DynamicObject& entry = i->next();
if(strcmp(entry["type"]->getString(), sn) == 0)
{
rval = entry["value"]->getString();
break;
}
}
return rval;
}
示例8: _setDecodedParam
static bool _setDecodedParam(
Statement* s, unsigned int index,
DynamicObject& param, DynamicObject& value)
{
bool rval = true;
if(param->hasMember("encode"))
{
// FIXME: could use streams here and handle types other than string,
// but the DatabaseClient API might be abandoned before this actually
// ever really gets used to that extent
// fill byte buffer with initial data
ByteBuffer b;
b.put(value->getString(), value->length(), true);
// apply each decoding
// FIXME: optimize this by doing it once and storing it when
// defining the schema
DynamicObject decode = param["encode"].clone();
decode->reverse();
DynamicObjectIterator i = decode.getIterator();
while(rval && i->hasNext())
{
const char* type = i->next()->getString();
// convert hex to binary
if(strcmp(type, "hex") == 0)
{
const char* hex = b.bytes();
unsigned int len = b.length();
unsigned int binLen = (len >> 1) + 1;
char bin[binLen];
rval = Convert::hexToBytes(hex, len, bin, binLen);
if(rval)
{
b.clear();
b.put(bin, binLen, true);
}
}
}
// only blobs are supported at the moment
rval = rval && s->setBlob(index, b.bytes(), b.length());
}
示例9: registerObserver
void EventController::registerObserver(
Observer* observer, DynamicObject& eventTypes)
{
DynamicObjectIterator i = eventTypes.getIterator();
while(i->hasNext())
{
// register all types
DynamicObject& next = i->next();
if(next->getType() == String)
{
registerObserver(observer, next->getString());
}
else if(next->getType() == Map)
{
registerObserver(
observer, next["type"]->getString(),
next->hasMember("filter") ? &next["filter"] : NULL);
}
}
}
示例10: _removeContext
/**
* Recursively removes context from the given input object.
*
* @param ctx the context to use (changes during recursion as necessary).
* @param in the input object.
* @param out the normalized output object.
* @param bnodeId the last blank node ID used.
*
* @return true on success, false on failure with exception set.
*/
static bool _removeContext(
DynamicObject& ctx, DynamicObject& in, DynamicObject& out, int& bnodeId)
{
bool rval = true;
if(in.isNull())
{
out.setNull();
}
else
{
// initialize output
DynamicObjectType inType = in->getType();
out->setType(inType);
// update context
if(inType == Map && in->hasMember("#"))
{
ctx = in["#"];
}
if(inType == Map)
{
rval = _normalize(ctx, in, NULL, &out, bnodeId);
}
else if(inType == Array)
{
// strip context from each object in the array
DynamicObjectIterator i = in.getIterator();
while(i->hasNext())
{
DynamicObject& next = i->next();
rval = _removeContext(ctx, next, out->append(), bnodeId);
}
}
}
return rval;
}
示例11: isValid
bool Contains::isValid(
DynamicObject& obj,
ValidatorContext* context)
{
bool rval = false;
// check if objects are equal
rval = (obj == mObject);
// if not equal, check if target contains the validation object
if(!rval && !obj.isNull() &&
(obj->getType() == Array || obj->getType() == Map))
{
DynamicObjectIterator i = obj.getIterator();
while(!rval && i->hasNext())
{
DynamicObject& next = i->next();
rval = (next == mObject);
}
}
if(!rval)
{
DynamicObject detail =
context->addError("monarch.validation.NotFound", &obj);
detail["validator"] = "monarch.validator.Contains";
detail["expectedValue"] = mObject;
detail["message"] = mErrorMessage ? mErrorMessage :
"The input object was not equal to or found in the validator.";
}
if(rval)
{
context->addSuccess();
}
return rval;
}
示例12: appendOrderSql
void DatabaseClient::appendOrderSql(
string& sql, DynamicObject& params, bool useTableAlias)
{
bool first = true;
DynamicObjectIterator i = params.getIterator();
while(i->hasNext())
{
DynamicObject& param = i->next();
if(first)
{
first = false;
sql.append(" ORDER BY ");
}
else
{
sql.append(", ");
}
// append aliased name
if(useTableAlias)
{
sql.append(param["tableAlias"]->getString());
sql.append(".");
}
sql.append(param["name"]->getString());
// direction
if(param["direction"]->getInt32() == ASC)
{
sql.append(" ASC");
}
else
{
sql.append(" DESC");
}
}
}
示例13: paramsToElement
// a helper function that converts message parameters into a dom element
static void paramsToElement(SoapMessage& msg, DynamicObject& params, Element& e)
{
if(params->getType() == Map)
{
DynamicObjectIterator pi = params.getIterator();
while(pi->hasNext())
{
DynamicObject& p = pi->next();
// add param element
Element param;
param["name"] = pi->getName();
param["namespace"] = msg["namespace"]->getString();
e["children"][pi->getName()]->append(param);
paramsToElement(msg, p, param);
}
}
else
{
// use 0/1 for booleans
e["data"] = (params->getType() == Boolean) ?
(params->getBoolean() ? "1" : "0") : params->getString();
}
}
示例14: _filterOne
static bool _filterOne(DynamicObject& filter, DynamicObject& object)
{
bool rval = true;
// loop over all filter properties
DynamicObjectIterator i;
i = filter.getIterator();
while(rval && i->hasNext())
{
DynamicObject& next = i->next();
const char* name = i->getName();
// check if object has property
rval = object->hasMember(name);
if(rval)
{
// loop over all filter values
DynamicObjectIterator fpi;
fpi = next.getIterator();
while(rval && fpi->hasNext())
{
DynamicObject& fpnext = fpi->next();
// make sure value appears in object property
DynamicObjectIterator opi;
opi = object[name].getIterator();
rval = false;
while(!rval && opi->hasNext())
{
DynamicObject& opnext = opi->next();
rval = (fpnext == opnext);
}
}
}
}
return rval;
}
示例15: addService
bool WebServiceContainer::addService(
WebServiceRef& service,
WebService::SecurityType st,
bool initialize,
const char* domain)
{
bool rval = true;
if(initialize)
{
rval = service->initialize();
}
if(rval)
{
// build list of domains to add service to
DynamicObject domains(NULL);
DynamicObject added;
added->setType(Array);
if(domain != NULL)
{
domains = DynamicObject();
domains->append(domain);
}
else
{
domains = mDefaultDomains;
}
HttpRequestServicer* hrs = &(*service);
const char* path = hrs->getPath();
// prevent other container access
mContainerLock.lockExclusive();
DynamicObjectIterator di = domains.getIterator();
while(rval && di->hasNext())
{
const char* dom = di->next()->getString();
rval = internalAddService(service, st, dom);
if(rval)
{
added->append(dom);
}
}
di = rval ? domains.getIterator() : added.getIterator();
while(di->hasNext())
{
const char* dom = di->next()->getString();
// success, add domain to http servicer
if(rval)
{
if(st == WebService::Secure || st == WebService::Both)
{
mHttpConnectionServicer.addRequestServicer(hrs, true, dom);
MO_CAT_DEBUG(MO_WS_CAT,
"Added secure web service: %s%s", dom, path);
}
if(st != WebService::Secure)
{
mHttpConnectionServicer.addRequestServicer(hrs, false, dom);
MO_CAT_DEBUG(MO_WS_CAT,
"Added non-secure web service: %s%s", dom, path);
}
}
// could not add service to all domains, so remove it
else
{
internalRemoveService(path, st, dom, NULL);
}
}
// permit access again
mContainerLock.unlockExclusive();
}
// failed to add service
if(!rval)
{
// service was initialized, so clean it up
if(initialize)
{
service->cleanup();
}
// set exception
ExceptionRef e = new Exception(
"Could not add web service.",
"monarch.ws.AddWebServiceFailure");
Exception::push(e);
}
return rval;
}