mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Merged r295:305 from the tags branch to the trunk
This commit is contained in:
@@ -52,6 +52,7 @@ namespace YAML
|
||||
Emitter& Write(double d);
|
||||
Emitter& Write(const _Alias& alias);
|
||||
Emitter& Write(const _Anchor& anchor);
|
||||
Emitter& Write(const _Tag& tag);
|
||||
Emitter& Write(const _Comment& comment);
|
||||
Emitter& Write(const _Null& null);
|
||||
|
||||
|
@@ -80,6 +80,16 @@ namespace YAML
|
||||
inline _Anchor Anchor(const std::string content) {
|
||||
return _Anchor(content);
|
||||
}
|
||||
|
||||
struct _Tag {
|
||||
_Tag(const std::string& content_): content(content_), verbatim(true) {}
|
||||
std::string content;
|
||||
bool verbatim;
|
||||
};
|
||||
|
||||
inline _Tag VerbatimTag(const std::string& content) {
|
||||
return _Tag(content);
|
||||
}
|
||||
|
||||
struct _Comment {
|
||||
_Comment(const std::string& content_): content(content_) {}
|
||||
|
@@ -17,7 +17,12 @@ namespace YAML
|
||||
const std::string YAML_DIRECTIVE_ARGS = "YAML directives must have exactly one argument";
|
||||
const std::string YAML_VERSION = "bad YAML version: ";
|
||||
const std::string YAML_MAJOR_VERSION = "YAML major version too large";
|
||||
const std::string REPEATED_YAML_DIRECTIVE= "repeated YAML directive";
|
||||
const std::string TAG_DIRECTIVE_ARGS = "TAG directives must have exactly two arguments";
|
||||
const std::string REPEATED_TAG_DIRECTIVE = "repeated TAG directive";
|
||||
const std::string CHAR_IN_TAG_HANDLE = "illegal character found while scanning tag handle";
|
||||
const std::string TAG_WITH_NO_SUFFIX = "tag handle with no suffix";
|
||||
const std::string END_OF_VERBATIM_TAG = "end of verbatim tag not found";
|
||||
const std::string END_OF_MAP = "end of map not found";
|
||||
const std::string END_OF_MAP_FLOW = "end of map flow not found";
|
||||
const std::string END_OF_SEQ = "end of sequence not found";
|
||||
@@ -57,6 +62,7 @@ namespace YAML
|
||||
const std::string SINGLE_QUOTED_CHAR = "invalid character in single-quoted string";
|
||||
const std::string INVALID_ANCHOR = "invalid anchor";
|
||||
const std::string INVALID_ALIAS = "invalid alias";
|
||||
const std::string INVALID_TAG = "invalid tag";
|
||||
const std::string EXPECTED_KEY_TOKEN = "expected key token";
|
||||
const std::string EXPECTED_VALUE_TOKEN = "expected value token";
|
||||
const std::string UNEXPECTED_KEY_TOKEN = "unexpected key token";
|
||||
|
@@ -9,7 +9,6 @@
|
||||
#include "iterator.h"
|
||||
#include "mark.h"
|
||||
#include "noncopyable.h"
|
||||
#include "parserstate.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -21,6 +20,7 @@ namespace YAML
|
||||
class Content;
|
||||
class Scanner;
|
||||
class Emitter;
|
||||
class ParserState;
|
||||
|
||||
enum CONTENT_TYPE { CT_NONE, CT_SCALAR, CT_SEQUENCE, CT_MAP };
|
||||
|
||||
@@ -75,6 +75,9 @@ namespace YAML
|
||||
const Node *Identity() const { return m_pIdentity; }
|
||||
bool IsAlias() const { return m_alias; }
|
||||
bool IsReferenced() const { return m_referenced; }
|
||||
|
||||
// for tags
|
||||
const std::string GetTag() const { return m_tag; } // TODO: should an aliased node return its alias's tag?
|
||||
|
||||
// emitting
|
||||
friend Emitter& operator << (Emitter& out, const Node& node);
|
||||
|
@@ -5,7 +5,6 @@
|
||||
|
||||
|
||||
#include "node.h"
|
||||
#include "parserstate.h"
|
||||
#include "noncopyable.h"
|
||||
#include <ios>
|
||||
#include <string>
|
||||
@@ -16,6 +15,7 @@
|
||||
namespace YAML
|
||||
{
|
||||
class Scanner;
|
||||
class ParserState;
|
||||
struct Token;
|
||||
|
||||
class Parser: private noncopyable
|
||||
@@ -33,13 +33,13 @@ namespace YAML
|
||||
|
||||
private:
|
||||
void ParseDirectives();
|
||||
void HandleDirective(Token *pToken);
|
||||
void HandleYamlDirective(Token *pToken);
|
||||
void HandleTagDirective(Token *pToken);
|
||||
void HandleDirective(const Token& token);
|
||||
void HandleYamlDirective(const Token& token);
|
||||
void HandleTagDirective(const Token& token);
|
||||
|
||||
private:
|
||||
std::auto_ptr<Scanner> m_pScanner;
|
||||
ParserState m_state;
|
||||
std::auto_ptr<ParserState> m_pState;
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -1,26 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef PARSERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define PARSERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
struct Version {
|
||||
int major, minor;
|
||||
};
|
||||
|
||||
struct ParserState
|
||||
{
|
||||
Version version;
|
||||
std::map <std::string, std::string> tags;
|
||||
|
||||
void Reset();
|
||||
std::string TranslateTag(const std::string& handle) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // PARSERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
Reference in New Issue
Block a user