mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 10:32:57 +01:00
Add elements(), make toString virtual and _elements protected
This commit is contained in:
parent
9a5b149a01
commit
2475bebb30
@ -82,13 +82,13 @@ public:
|
||||
|
||||
virtual ~Document();
|
||||
|
||||
|
||||
|
||||
void read(BinaryReader& reader);
|
||||
|
||||
|
||||
|
||||
void write(BinaryWriter& writer);
|
||||
|
||||
|
||||
|
||||
template<typename T>
|
||||
T get(const std::string& name)
|
||||
{
|
||||
@ -124,6 +124,10 @@ public:
|
||||
return element;
|
||||
}
|
||||
|
||||
|
||||
void elements(std::vector<std::string>& keys) const;
|
||||
|
||||
|
||||
bool exists(const std::string& name)
|
||||
{
|
||||
return std::find_if(_elements.begin(), _elements.end(), ElementFindByName(name)) != _elements.end();
|
||||
@ -159,10 +163,10 @@ public:
|
||||
void clear();
|
||||
|
||||
|
||||
std::string toString() const;
|
||||
virtual std::string toString() const;
|
||||
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
ElementSet _elements;
|
||||
};
|
||||
@ -179,6 +183,15 @@ inline void Document::clear()
|
||||
_elements.clear();
|
||||
}
|
||||
|
||||
|
||||
inline void Document::elements(std::vector<std::string>& keys) const
|
||||
{
|
||||
for(ElementSet::const_iterator it = _elements.begin(); it != _elements.end(); ++it)
|
||||
{
|
||||
keys.push_back((*it)->name());
|
||||
}
|
||||
}
|
||||
|
||||
// BSON Embedded Document
|
||||
// spec: document
|
||||
template<>
|
||||
@ -188,8 +201,7 @@ struct ElementTraits<Document::Ptr>
|
||||
|
||||
static std::string toString(const Document::Ptr& value)
|
||||
{
|
||||
//TODO
|
||||
return value.isNull() ? "null" : "{}";
|
||||
return value.isNull() ? "null" : value->toString();
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user