Skip to content

Commit

Permalink
HPCC-30369 Various improments to IProperties iterators
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday committed Sep 29, 2023
1 parent e057926 commit fec7774
Show file tree
Hide file tree
Showing 24 changed files with 57 additions and 53 deletions.
5 changes: 3 additions & 2 deletions common/fileview2/fvresultset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2342,11 +2342,12 @@ extern FILEVIEW_API unsigned writeResultCursorXml(IXmlWriterExt & writer, IResul
writer.outputCString(schemaName, "@xmlSchema");
if (xmlns)
{
Owned<IPropertyIterator> it = const_cast<IProperties*>(xmlns)->getIterator();
Owned<IPropertyIterator> it = xmlns->getIterator();
ForEach(*it)
{
const char *name = it->getPropKey();
writer.outputXmlns(name,const_cast<IProperties*>(xmlns)->queryProp(name));
const char *value = it->queryPropValue();
writer.outputXmlns(name,value);
}
}
cursor->beginWriteXmlRows(writer);
Expand Down
2 changes: 1 addition & 1 deletion common/pkgfiles/package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void CPackageNode::mergeEnvironment(const CPackageNode *base)
ForEach(*envIterator)
{
const char *id = envIterator->getPropKey();
const char *val = base->mergedEnvironment->queryProp(id);
const char *val = envIterator->queryPropValue();
if (id && val && !mergedEnvironment->hasProp(id))
mergedEnvironment->setProp(id, val);
}
Expand Down
4 changes: 2 additions & 2 deletions common/thorhelper/roxiedebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ void DebugActivityRecord::outputProperties(IXmlWriter *output)
while (iterator->isValid())
{
const char *propName = iterator->getPropKey();
const char *propValue = properties->queryProp(propName);
const char *propValue = iterator->queryPropValue();
output->outputBeginNested("att", false); output->outputCString(propName, "@name"); output->outputCString(propValue, "@value"); output->outputEndNested("att");
iterator->next();
}
Expand Down Expand Up @@ -1900,7 +1900,7 @@ void CBaseServerDebugContext::getCurrentGraphXGMML(IXmlWriter *output, bool orig
while (iterator->isValid())
{
const char *graphName = iterator->getPropKey();
const char *graphXML = completedGraphs->queryProp(graphName);
const char *graphXML = iterator->queryPropValue();
output->outputString(0, 0, NULL);
output->outputQuoted(graphXML);
iterator->next();
Expand Down
5 changes: 3 additions & 2 deletions common/thorhelper/roxiehelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2253,15 +2253,16 @@ void FlushingStringBuffer::startDataset(const char *elementName, const char *res
s.append("result_").append(sequence+1).append('\'');
if (xmlns)
{
Owned<IPropertyIterator> it = const_cast<IProperties*>(xmlns)->getIterator(); //should fix IProperties to be const friendly
Owned<IPropertyIterator> it = xmlns->getIterator();
ForEach(*it)
{
const char *name = it->getPropKey();
const char *value = it->queryPropValue();
s.append(' ');
if (!streq(name, "xmlns"))
s.append("xmlns:");
s.append(name).append("='");
encodeUtf8XML(const_cast<IProperties*>(xmlns)->queryProp(name), s);
encodeUtf8XML(value, s);
s.append("'");
}
}
Expand Down
2 changes: 1 addition & 1 deletion common/thorhelper/thorsoapcall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1920,7 +1920,7 @@ class CWSCAsyncFor : implements IWSCAsyncFor, public CInterface, public CAsyncFo
const char * key = iter->getPropKey();
if (!httpHeaderBlockContainsHeader(httpheaders, key))
{
const char * value = traceHeaders->queryProp(key);
const char * value = iter->queryPropValue();
if (!isEmptyString(value))
request.append(key).append(": ").append(value).append("\r\n");
}
Expand Down
2 changes: 1 addition & 1 deletion ecl/eclagent/eclagent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3613,7 +3613,7 @@ extern int HTHOR_API eclagent_main(int argc, const char *argv[], Owned<ILocalWor
{
if (!query)
query.setown(createPTree("Query"));
const char *val = cmdLineArgs->queryProp(key);
const char *val = it->queryPropValue();
if (val[0]=='<')
{
Owned<IPropertyTree> valtree = createPTreeFromXMLString(val);
Expand Down
12 changes: 7 additions & 5 deletions esp/bindings/SOAP/Platform/soapmessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static void serializeAttributes(StringBuffer& outbuf, IProperties* attrs)
for (it->first(); it->isValid(); it->next())
{
const char* k = it->getPropKey();
const char* v = attrs->queryProp(k);
const char* v = it->queryPropValue();
outbuf.append(' ').append(k).append("=\"");
encodeUtf8XML(v,outbuf);
outbuf.append('"');
Expand Down Expand Up @@ -171,7 +171,8 @@ void CRpcMessage::add_attr(const char * path, const char * name, const char * va
for (piter->first(); piter->isValid(); piter->next())
{
const char *propkey = piter->getPropKey();
par->add_attribute(propkey, attrs.queryProp(propkey));
const char *value = piter->queryPropValue();
par->add_attribute(propkey, value);
}
}
}
Expand All @@ -181,7 +182,8 @@ void CRpcMessage::add_attr(const char * path, const char * name, const char * va
for (piter->first(); piter->isValid(); piter->next())
{
const char *propkey = piter->getPropKey();
add_attribute(propkey, attrs.queryProp(propkey));
const char *value = piter->queryPropValue();
add_attribute(propkey, value);
}
}
}
Expand Down Expand Up @@ -579,7 +581,7 @@ CSoapValue::CSoapValue(CSoapValue* soapvalue)
m_attributes.setown(createProperties());
Owned<IPropertyIterator> it = attrs->getIterator();
for (it->first(); it->isValid(); it->next())
m_attributes->setProp(it->getPropKey(), attrs->queryProp(it->getPropKey()));
m_attributes->setProp(it->getPropKey(), it->queryPropValue());
}
m_is_array_element = soapvalue->m_is_array_element;
}
Expand Down Expand Up @@ -1171,7 +1173,7 @@ void CSoapValue::add_value(const char* path, const char* ns, const char* name, c
for (piter->first(); piter->isValid(); piter->next())
{
const char *propkey = piter->getPropKey();
sv->add_attribute(propkey, attrs.queryProp(propkey));
sv->add_attribute(propkey, piter->queryPropValue());
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions esp/bindings/SOAP/Platform/soapparam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ bool EspBaseArrayParam::unmarshall(IEspContext* ctx, IProperties &params, MapStr
{
if (strlen(keyname)==taglen || !strncmp(keyname+taglen, "_rd_", 4))
{
const char *finger = params.queryProp(iter->getPropKey());
const char *finger = iter->queryPropValue();
StringBuffer itemval;
while (*finger)
{
Expand Down Expand Up @@ -610,7 +610,7 @@ bool EspBaseArrayParam::unmarshall(IEspContext* ctx, IProperties &params, MapStr
}
else if (strncmp(keyname+taglen, "_i", 2)==0)
{
append(params.queryProp(iter->getPropKey()));
append(iter->queryPropValue());
hasValue = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion esp/bindings/SOAP/ws_ecl_client/ws_ecl_client_bind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ class CClientRequestNode : implements IClientRequestNode, public CInterface
ForEach(*piter)
{
const char *propkey = piter->getPropKey();
rpcMsg.add_value(path, "", propkey, "", m_params->queryProp(propkey), false);
rpcMsg.add_value(path, "", propkey, "", piter->queryPropValue(), false);
}
}

Expand Down
2 changes: 1 addition & 1 deletion esp/bindings/http/client/httpclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ IHttpMessage *CHttpClient::sendRequestEx(const char* method, const char* content
{
if (strieq(key, HTTP_HEADER_CONTENT_ENCODING) || strieq(key, HTTP_HEADER_TRANSFER_ENCODING))
alreadyEncoded = true;
const char *value = headers->queryProp(key);
const char *value = iter->queryPropValue();
if (value && *value)
httprequest->addHeader(key, value);
}
Expand Down
2 changes: 1 addition & 1 deletion esp/esdllib/esdl_def.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class EsdlDefObject : public CInterface
ForEach(*it)
{
const char *name = it->getPropKey();
const char *val = props->queryProp(name);
const char *val = it->queryPropValue();
xml.appendf(" %s=\"", name);
encodeUtf8XML(val, xml);
xml.append('\"');
Expand Down
4 changes: 2 additions & 2 deletions esp/esdllib/esdl_def_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ void EsdlDefinitionHelper::loadTransformParams( EsdlXslTypeId xslId, IProperties
const char *key = it->getPropKey();
//set parameter in the XSL transform skipping over the @ prefix, if any
const char* paramName = *key == '@' ? key+1 : key;
trans->setParameter(paramName, params->queryProp(key));
trans->setParameter(paramName, it->queryPropValue());
}
}

Expand All @@ -360,7 +360,7 @@ void EsdlDefinitionHelper::loadTransformParams( EsdlXslTypeId xslId, IProperties
const char *key = it->getPropKey();
//set parameter in the XSL transform skipping over the @ prefix, if any
const char* paramName = *key == '@' ? key+1 : key;
trans->setParameter(paramName, overrideParams->queryProp(key));
trans->setParameter(paramName, it->queryPropValue());
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions esp/esdllib/esdl_transformer2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void Esdl2Base::serialize_attributes(StringBuffer &out)
{
if (stricmp(key, "base_type") != 0)
{
const char *value = m_def->queryProp(key);
const char *value = piter->queryPropValue();
if (value && *value)
out.appendf(" %s=\"%s\"", key, value);
}
Expand Down Expand Up @@ -1311,7 +1311,7 @@ void Esdl2Request::addDefaults(IPropertyTree *req)
const char *path = iter->getPropKey();
if (!req->hasProp(path))
{
const char *value = defvals->queryProp(path);
const char *value = iter->queryPropValue();
ensurePTree(req, path);
req->setProp(path, value);
}
Expand Down
6 changes: 3 additions & 3 deletions esp/esdlscriptlib/esdl_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3479,8 +3479,8 @@ class CEsdlCustomTransform : public CInterfaceOf<IEsdlCustomTransform>
const char *prefix = ns->getPropKey();
const char *existing = sourceContext->queryNamespace(prefix);
savedNamespaces->setProp(prefix, isEmptyString(existing) ? "" : existing);
sourceContext->registerNamespace(prefix, namespaces->queryProp(prefix));
targetXpath->registerNamespace(prefix, namespaces->queryProp(prefix));
sourceContext->registerNamespace(prefix, ns->queryPropValue());
targetXpath->registerNamespace(prefix, ns->queryPropValue());
}
CXpathContextScope scope(sourceContext, "transform", XpathVariableScopeType::simple, savedNamespaces);
if (!isEmptyString(target) && !streq(target, "."))
Expand Down Expand Up @@ -3607,7 +3607,7 @@ void processServiceAndMethodTransforms(IEsdlScriptContext * scriptCtx, std::init
{
const char *name = userPropIt->getPropKey();
if (name && *name)
sourceContext->addInputValue(name, user->getProperty(name));
sourceContext->addInputValue(name, userPropIt->queryPropValue());
}

auto it = statusLabels.find(user->getStatus());
Expand Down
2 changes: 1 addition & 1 deletion esp/platform/espcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ bool getUrlParams(IProperties *props, StringBuffer& params)
params.append(key);
if (stricmp(key,"ver_")==0)
hasVersion = true;
const char* v = props->queryProp(key);
const char* v = it->queryPropValue();
if (v && *v)
params.appendf("=%s",v);
}
Expand Down
2 changes: 1 addition & 1 deletion esp/services/WsDeploy/WsDeployService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6405,7 +6405,7 @@ void CWsDeployFileInfo::initFileInfo(bool createOrOverwrite, bool bClearEnv)
{
StringBuffer prop;
pParams->getProp(iter->getPropKey(), prop);
const char* val = pSettings->queryProp(iter->getPropKey());
const char* val = iter->queryPropValue();

if (!val || strcmp(val, prop.str()))
{
Expand Down
2 changes: 1 addition & 1 deletion esp/services/ws_ecl/ws_ecl_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ void CWsEclBinding::xsltTransform(const char* xml, unsigned int len, const char*
const char *key = it->getPropKey();
//set parameter in the XSL transform skipping over the @ prefix, if any
const char* paramName = *key == '@' ? key+1 : key;
trans->setParameter(paramName, StringBuffer().append('\'').append(params->queryProp(key)).append('\'').str());
trans->setParameter(paramName, StringBuffer().append('\'').append(it->queryPropValue()).append('\'').str());
}
}

Expand Down
2 changes: 1 addition & 1 deletion esp/services/ws_esdlconfig/ws_esdlconfigservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void CWsESDLConfigEx::wrapWithDefinitionElement(IEsdlDefinitionInfo* defInfo, St
ForEach(*iter)
{
const char* name = iter->getPropKey();
const char* val = metadata.queryProp(name);
const char* val = iter->queryPropValue();
// skip the leading @ in the property name
definitionElement.appendf(" %s=\"%s\"", &name[1], val);
}
Expand Down
2 changes: 1 addition & 1 deletion esp/services/ws_fs/ws_fsBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void CFileSpraySoapBindingEx::xsltTransform(const char* xml, const char* sheet,
const char *key = it->getPropKey();
//set parameter in the XSL transform skipping over the @ prefix, if any
const char* paramName = *key == '@' ? key+1 : key;
trans->setParameter(paramName, StringBuffer().append('\'').append(params->queryProp(key)).append('\'').str());
trans->setParameter(paramName, StringBuffer().append('\'').append(it->queryPropValue()).append('\'').str());
}
}

Expand Down
2 changes: 1 addition & 1 deletion esp/services/ws_workunits/ws_wuresult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void CWsWuResultOutHelper::readFilterByReq()
ForEach(*iter)
{
const char* keyname = iter->getPropKey();
const char* keyValue = reqParams->queryProp(iter->getPropKey());
const char* keyValue = iter->queryPropValue();
if (isEmptyString(keyname) || isEmptyString(keyValue) || strncmp(keyname, "FilterBys", 9))
continue;

Expand Down
28 changes: 15 additions & 13 deletions system/jlib/jprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,48 +35,50 @@ template <class PTYPE, class PITER>
class PropertyIteratorOf : implements PITER, public CInterface
{
protected:
HashIterator *piter;
const HashTable &properties;
HashIterator piter;

public:
IMPLEMENT_IINTERFACE;

PropertyIteratorOf(const HashTable &_properties) : properties(_properties)
PropertyIteratorOf(const HashTable &_properties) : properties(_properties), piter(properties)
{
properties.Link();
piter = new HashIterator(properties);
}
~PropertyIteratorOf()
{
properties.Release();
piter->Release();
}
virtual bool first()
virtual bool first() override
{
return piter->first();
return piter.first();
}
virtual bool next()
virtual bool next() override
{
return piter->next();
return piter.next();
}
virtual bool isValid()
virtual bool isValid() override
{
return piter->isValid();
return piter.isValid();
}
virtual PTYPE getPropKey() = 0;
};

typedef IPropertyIterator char_ptrIPropertyIterator;
class char_ptrPropertyIterator : public PropertyIteratorOf<const char *, char_ptrIPropertyIterator>
{
public:
char_ptrPropertyIterator(const HashTable &_properties) : PropertyIteratorOf<const char *, char_ptrIPropertyIterator>(_properties) { }
virtual const char *getPropKey()
virtual const char *getPropKey() override
{
IMapping &cur = piter->query();
IMapping &cur = piter.query();
const char *key = (const char *) (cur.getKey());
return key;
}
virtual const char *queryPropValue() override
{
IMapping &cur = piter.query();
return StringAttrMapping::mapToValue(&cur)->str();
}
};

template <class PTYPE, class MAPPING, class IPROP, class IPROPITER, class PROPITER>
Expand Down
2 changes: 1 addition & 1 deletion system/jlib/jprop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface jlib_decl IPropertyIteratorOf : extends IInterface
virtual bool next() = 0;
virtual bool isValid() = 0;
virtual PTYPE getPropKey() = 0;
virtual const char * queryPropValue() = 0;
};

template <class PTYPE, class PITER>
Expand Down Expand Up @@ -64,7 +65,6 @@ interface jlib_decl IPropertiesOf : extends serializable
#endif

interface IPropertyIterator : public IPropertyIteratorOf<char_ptr> { };
interface IAtomPropertyIterator : public IPropertyIteratorOf<IAtom *> { };
interface IProperties : public IPropertiesOf<char_ptr, IPropertyIterator> { };

#ifdef _MSC_VER
Expand Down
7 changes: 3 additions & 4 deletions system/jlib/jptree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8302,7 +8302,7 @@ IPropertyTree *createPTreeFromHttpParameters(const char *nameWithAttrs, IPropert
continue;
if (skipLeadingDotParameters && key.charAt(0)=='.')
continue;
const char *value = parameters->queryProp(key);
const char *value = iter->queryPropValue();
if (!value || !*value)
continue;
ensureHttpParameter(content, key, value);
Expand Down Expand Up @@ -8525,10 +8525,9 @@ void applyProperties(IPropertyTree * target, const IProperties * source)
Owned<IPropertyIterator> iter = source->getIterator();
ForEach(*iter)
{
StringBuffer value;
const char * name = iter->getPropKey();
source->getProp(name, value);
target->setProp(name, value.str());
const char * value = iter->queryPropValue();
target->setProp(name, value);
}
}

Expand Down
Loading

0 comments on commit fec7774

Please sign in to comment.