Do bulk replace of stl types.
This commit is contained in:
parent
521486be62
commit
c25a56ee19
531 changed files with 2274 additions and 2181 deletions
|
@ -1,28 +1,28 @@
|
|||
#include "XmlAttribute.h"
|
||||
|
||||
XmlAttribute::XmlAttribute(const std::string& name)
|
||||
XmlAttribute::XmlAttribute(const String& name)
|
||||
: mName(name),
|
||||
mValue()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
XmlAttributePtr XmlAttribute::Create(const std::string& name)
|
||||
XmlAttributePtr XmlAttribute::Create(const String& name)
|
||||
{
|
||||
return std::make_unique<XmlAttribute>(name);
|
||||
}
|
||||
|
||||
const std::string& XmlAttribute::getName() const
|
||||
const String& XmlAttribute::getName() const
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
const std::string& XmlAttribute::getValue() const
|
||||
const String& XmlAttribute::getValue() const
|
||||
{
|
||||
return mValue;
|
||||
}
|
||||
|
||||
void XmlAttribute::setValue(const std::string& value)
|
||||
void XmlAttribute::setValue(const String& value)
|
||||
{
|
||||
mValue = value;
|
||||
}
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "Memory.h"
|
||||
#include "String.h"
|
||||
|
||||
class XmlAttribute
|
||||
{
|
||||
public:
|
||||
XmlAttribute(const std::string& name);
|
||||
XmlAttribute(const String& name);
|
||||
|
||||
static std::unique_ptr<XmlAttribute> Create(const std::string& name);
|
||||
static Ptr<XmlAttribute> Create(const String& name);
|
||||
|
||||
const std::string& getName() const;
|
||||
const String& getName() const;
|
||||
|
||||
const std::string& getValue() const;
|
||||
const String& getValue() const;
|
||||
|
||||
void setValue(const std::string& value);
|
||||
void setValue(const String& value);
|
||||
private:
|
||||
std::string mName;
|
||||
std::string mValue;
|
||||
String mName;
|
||||
String mValue;
|
||||
};
|
||||
|
||||
using XmlAttributePtr = std::unique_ptr<XmlAttribute>;
|
||||
using XmlAttributePtr = Ptr<XmlAttribute>;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "XmlAttribute.h"
|
||||
|
||||
XmlElement::XmlElement(const std::string& tagName)
|
||||
XmlElement::XmlElement(const String& tagName)
|
||||
: mTagName(tagName),
|
||||
mChildren()
|
||||
{
|
||||
|
@ -14,12 +14,12 @@ XmlElement::~XmlElement()
|
|||
|
||||
}
|
||||
|
||||
XmlElementPtr XmlElement::Create(const std::string& tagName)
|
||||
XmlElementPtr XmlElement::Create(const String& tagName)
|
||||
{
|
||||
return std::make_unique<XmlElement>(tagName);
|
||||
}
|
||||
|
||||
void XmlElement::setTagName(const std::string& tagName)
|
||||
void XmlElement::setTagName(const String& tagName)
|
||||
{
|
||||
mTagName = tagName;
|
||||
}
|
||||
|
@ -34,29 +34,29 @@ void XmlElement::addAttribute(XmlAttributePtr attribute)
|
|||
mAttributes[attribute->getName()] = std::move(attribute);
|
||||
}
|
||||
|
||||
void XmlElement::addAttribute(const std::string& name, const std::string& value)
|
||||
void XmlElement::addAttribute(const String& name, const String& value)
|
||||
{
|
||||
auto attr = std::make_unique<XmlAttribute>(name);
|
||||
attr->setValue(value);
|
||||
addAttribute(std::move(attr));
|
||||
}
|
||||
|
||||
const std::string& XmlElement::getTagName() const
|
||||
const String& XmlElement::getTagName() const
|
||||
{
|
||||
return mTagName;
|
||||
}
|
||||
|
||||
const std::string& XmlElement::getText() const
|
||||
const String& XmlElement::getText() const
|
||||
{
|
||||
return mText;
|
||||
}
|
||||
|
||||
void XmlElement::setText(const std::string& text)
|
||||
void XmlElement::setText(const String& text)
|
||||
{
|
||||
mText = text;
|
||||
}
|
||||
|
||||
XmlElement* XmlElement::getFirstChildWithTagName(const std::string& tag)
|
||||
XmlElement* XmlElement::getFirstChildWithTagName(const String& tag)
|
||||
{
|
||||
for(auto& child : mChildren)
|
||||
{
|
||||
|
@ -69,12 +69,12 @@ XmlElement* XmlElement::getFirstChildWithTagName(const std::string& tag)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool XmlElement::hasAttribute(const std::string& attribute) const
|
||||
bool XmlElement::hasAttribute(const String& attribute) const
|
||||
{
|
||||
return (bool)(getAttribute(attribute));
|
||||
}
|
||||
|
||||
XmlAttribute* XmlElement::getAttribute(const std::string& attributeName) const
|
||||
XmlAttribute* XmlElement::getAttribute(const String& attributeName) const
|
||||
{
|
||||
if (auto iter = mAttributes.find(attributeName); iter != mAttributes.end())
|
||||
{
|
||||
|
@ -83,21 +83,21 @@ XmlAttribute* XmlElement::getAttribute(const std::string& attributeName) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const std::unordered_map<std::string, XmlAttributePtr>& XmlElement::getAttributes() const
|
||||
const std::unordered_map<String, XmlAttributePtr>& XmlElement::getAttributes() const
|
||||
{
|
||||
return mAttributes;
|
||||
}
|
||||
|
||||
const std::vector<std::unique_ptr<XmlElement> >& XmlElement::getChildren() const
|
||||
const Vector<Ptr<XmlElement> >& XmlElement::getChildren() const
|
||||
{
|
||||
return mChildren;
|
||||
}
|
||||
|
||||
std::string XmlElement::toString(unsigned depth, bool keepInline) const
|
||||
String XmlElement::toString(unsigned depth, bool keepInline) const
|
||||
{
|
||||
const auto prefix = std::string(2*depth, ' ');
|
||||
const auto prefix = String(2*depth, ' ');
|
||||
|
||||
std::string line_ending = keepInline ? "" : "\n";
|
||||
String line_ending = keepInline ? "" : "\n";
|
||||
|
||||
auto content = prefix + "<" + getTagName();
|
||||
for (const auto& [key, attribute] : getAttributes())
|
||||
|
|
|
@ -1,47 +1,44 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "Pointer.h"
|
||||
#include "String.h"
|
||||
#include "Map.h"
|
||||
|
||||
class XmlAttribute;
|
||||
using XmlAttributePtr = std::unique_ptr<XmlAttribute>;
|
||||
|
||||
class XmlElement
|
||||
{
|
||||
public:
|
||||
XmlElement(const std::string& tagName);
|
||||
XmlElement(const String& tagName);
|
||||
virtual ~XmlElement();
|
||||
|
||||
static std::unique_ptr<XmlElement> Create(const std::string& tagName);
|
||||
static Ptr<XmlElement> Create(const String& tagName);
|
||||
|
||||
void addAttribute(XmlAttributePtr attribute);
|
||||
void addAttribute(const std::string& name, const std::string& value);
|
||||
void addChild(std::unique_ptr<XmlElement> child);
|
||||
void addAttribute(const String& name, const String& value);
|
||||
void addChild(Ptr<XmlElement> child);
|
||||
|
||||
const std::string& getTagName() const;
|
||||
const std::string& getText() const;
|
||||
const String& getTagName() const;
|
||||
const String& getText() const;
|
||||
|
||||
bool hasAttribute(const std::string& attribute) const;
|
||||
XmlAttribute* getAttribute(const std::string& attribute) const;
|
||||
const std::unordered_map<std::string, XmlAttributePtr>& getAttributes() const;
|
||||
XmlAttribute* getAttribute(const String& attribute) const;
|
||||
const Map<Ptr<XmlAttribute> >& getAttributes() const;
|
||||
|
||||
const std::vector<std::unique_ptr<XmlElement> >& getChildren() const;
|
||||
const Vector<Ptr<XmlElement> >& getChildren() const;
|
||||
|
||||
XmlElement* getFirstChildWithTagName(const std::string& tag);
|
||||
XmlElement* getFirstChildWithTagName(const String& tag);
|
||||
|
||||
void setText(const std::string& text);
|
||||
void setTagName(const std::string& tagName);
|
||||
bool hasAttribute(const String& attribute) const;
|
||||
|
||||
virtual std::string toString(unsigned depth = 0, bool keepInline = false) const;
|
||||
void setText(const String& text);
|
||||
void setTagName(const String& tagName);
|
||||
|
||||
virtual String toString(unsigned depth = 0, bool keepInline = false) const;
|
||||
|
||||
protected:
|
||||
std::string mTagName;
|
||||
std::string mText;
|
||||
String mTagName;
|
||||
String mText;
|
||||
|
||||
std::unordered_map<std::string, XmlAttributePtr> mAttributes;
|
||||
std::vector<std::unique_ptr<XmlElement> > mChildren;
|
||||
Map<Ptr<XmlAttributePtr> > mAttributes;
|
||||
Vector<Ptr<XmlElement> > mChildren;
|
||||
};
|
||||
|
||||
using XmlElementPtr = std::unique_ptr<XmlElement>;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "XmlAttribute.h"
|
||||
|
||||
XmlProlog::XmlProlog(const std::string& tagName)
|
||||
XmlProlog::XmlProlog(const String& tagName)
|
||||
: XmlElement(tagName),
|
||||
mVersion(XmlProlog::Version::V1_0),
|
||||
mEncoding(XmlProlog::Encoding::UTF8)
|
||||
|
@ -10,7 +10,7 @@ XmlProlog::XmlProlog(const std::string& tagName)
|
|||
|
||||
}
|
||||
|
||||
XmlPrologPtr XmlProlog::Create(const std::string& tagName)
|
||||
XmlPrologPtr XmlProlog::Create(const String& tagName)
|
||||
{
|
||||
return std::make_unique<XmlProlog>(tagName);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ XmlProlog::Version XmlProlog::getVersion() const
|
|||
return mVersion;
|
||||
}
|
||||
|
||||
void XmlProlog::setEncoding(const std::string& encoding)
|
||||
void XmlProlog::setEncoding(const String& encoding)
|
||||
{
|
||||
if(encoding == "UTF-8")
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ void XmlProlog::setEncoding(const std::string& encoding)
|
|||
}
|
||||
}
|
||||
|
||||
void XmlProlog::setVersion(const std::string& version)
|
||||
void XmlProlog::setVersion(const String& version)
|
||||
{
|
||||
if(version == "1.0")
|
||||
{
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#include "XmlElement.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "Memory.h"
|
||||
#include "Vector.h"
|
||||
|
||||
class XmlProlog : public XmlElement
|
||||
{
|
||||
|
@ -17,15 +17,15 @@ public:
|
|||
};
|
||||
|
||||
public:
|
||||
XmlProlog(const std::string& tagName);
|
||||
XmlProlog(const String& tagName);
|
||||
|
||||
static std::unique_ptr<XmlProlog> Create(const std::string& tagName);
|
||||
static Ptr<XmlProlog> Create(const String& tagName);
|
||||
|
||||
Encoding getEncoding() const;
|
||||
Version getVersion() const;
|
||||
|
||||
void setEncoding(const std::string& encoding);
|
||||
void setVersion(const std::string& version);
|
||||
void setEncoding(const String& encoding);
|
||||
void setVersion(const String& version);
|
||||
void update();
|
||||
|
||||
private:
|
||||
|
@ -33,4 +33,4 @@ private:
|
|||
Encoding mEncoding;
|
||||
};
|
||||
|
||||
using XmlPrologPtr = std::unique_ptr<XmlProlog>;
|
||||
using XmlPrologPtr = Ptr<XmlProlog>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue