mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
This commit is contained in:
@@ -16,6 +16,8 @@ namespace YAML
|
||||
class Sequence;
|
||||
class Map;
|
||||
|
||||
enum CONTENT_TYPE;
|
||||
|
||||
class Content
|
||||
{
|
||||
public:
|
||||
@@ -31,6 +33,7 @@ namespace YAML
|
||||
virtual bool GetEnd(std::map <Node *, Node *, ltnode>::const_iterator& it) const { return false; }
|
||||
virtual Node *GetNode(unsigned i) const { return 0; }
|
||||
virtual unsigned GetSize() const { return 0; }
|
||||
virtual CONTENT_TYPE GetType() const = 0;
|
||||
|
||||
// extraction
|
||||
virtual void Read(std::string& s) { throw InvalidScalar(); }
|
||||
|
@@ -163,6 +163,11 @@ namespace YAML
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
CONTENT_TYPE Map::GetType() const
|
||||
{
|
||||
return CT_MAP;
|
||||
}
|
||||
|
||||
int Map::Compare(Content *pContent)
|
||||
{
|
||||
return -pContent->Compare(this);
|
||||
|
@@ -19,6 +19,8 @@ namespace YAML
|
||||
virtual void Parse(Scanner *pScanner, const ParserState& state);
|
||||
virtual void Write(std::ostream& out, int indent, bool startedLine, bool onlyOneCharOnLine);
|
||||
|
||||
virtual CONTENT_TYPE GetType() const;
|
||||
|
||||
// ordering
|
||||
virtual int Compare(Content *pContent);
|
||||
virtual int Compare(Scalar *pScalar) { return 1; }
|
||||
|
@@ -144,6 +144,14 @@ namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
CONTENT_TYPE Node::GetType() const
|
||||
{
|
||||
if(!m_pContent)
|
||||
return CT_NONE;
|
||||
|
||||
return m_pContent->GetType();
|
||||
}
|
||||
|
||||
// begin
|
||||
// Returns an iterator to the beginning of this (sequence or map).
|
||||
Iterator Node::begin() const
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include "scanner.h"
|
||||
#include "token.h"
|
||||
#include "exceptions.h"
|
||||
#include "node.h"
|
||||
#include <sstream>
|
||||
|
||||
namespace YAML
|
||||
@@ -37,6 +38,11 @@ namespace YAML
|
||||
out << "\"\n";
|
||||
}
|
||||
|
||||
CONTENT_TYPE Scalar::GetType() const
|
||||
{
|
||||
return CT_SCALAR;
|
||||
}
|
||||
|
||||
void Scalar::Read(std::string& s)
|
||||
{
|
||||
s = m_data;
|
||||
|
@@ -14,6 +14,8 @@ namespace YAML
|
||||
virtual void Parse(Scanner *pScanner, const ParserState& state);
|
||||
virtual void Write(std::ostream& out, int indent, bool startedLine, bool onlyOneCharOnLine);
|
||||
|
||||
virtual CONTENT_TYPE GetType() const;
|
||||
|
||||
// extraction
|
||||
virtual void Read(std::string& s);
|
||||
virtual void Read(int& i);
|
||||
|
@@ -150,6 +150,11 @@ namespace YAML
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
CONTENT_TYPE Sequence::GetType() const
|
||||
{
|
||||
return CT_SEQUENCE;
|
||||
}
|
||||
|
||||
int Sequence::Compare(Content *pContent)
|
||||
{
|
||||
return -pContent->Compare(this);
|
||||
|
@@ -22,6 +22,8 @@ namespace YAML
|
||||
virtual void Parse(Scanner *pScanner, const ParserState& state);
|
||||
virtual void Write(std::ostream& out, int indent, bool startedLine, bool onlyOneCharOnLine);
|
||||
|
||||
virtual CONTENT_TYPE GetType() const;
|
||||
|
||||
// ordering
|
||||
virtual int Compare(Content *pContent);
|
||||
virtual int Compare(Scalar *pScalar) { return 1; }
|
||||
|
Reference in New Issue
Block a user