Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/yaml-cpp/parser.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #ifndef PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
0002 #define PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
0003 
0004 #if defined(_MSC_VER) ||                                            \
0005     (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
0006      (__GNUC__ >= 4))  // GCC supports "pragma once" correctly since 3.4
0007 #pragma once
0008 #endif
0009 
0010 #include <ios>
0011 #include <memory>
0012 
0013 #include "yaml-cpp/dll.h"
0014 
0015 namespace YAML {
0016 class EventHandler;
0017 class Node;
0018 class Scanner;
0019 struct Directives;
0020 struct Token;
0021 
0022 /**
0023  * A parser turns a stream of bytes into one stream of "events" per YAML
0024  * document in the input stream.
0025  */
0026 class YAML_CPP_API Parser {
0027  public:
0028   /** Constructs an empty parser (with no input. */
0029   Parser();
0030 
0031   Parser(const Parser&) = delete;
0032   Parser(Parser&&) = delete;
0033   Parser& operator=(const Parser&) = delete;
0034   Parser& operator=(Parser&&) = delete;
0035 
0036   /**
0037    * Constructs a parser from the given input stream. The input stream must
0038    * live as long as the parser.
0039    */
0040   explicit Parser(std::istream& in);
0041 
0042   ~Parser();
0043 
0044   /** Evaluates to true if the parser has some valid input to be read. */
0045   explicit operator bool() const;
0046 
0047   /**
0048    * Resets the parser with the given input stream. Any existing state is
0049    * erased.
0050    */
0051   void Load(std::istream& in);
0052 
0053   /**
0054    * Handles the next document by calling events on the {@code eventHandler}.
0055    *
0056    * @throw a ParserException on error.
0057    * @return false if there are no more documents
0058    */
0059   bool HandleNextDocument(EventHandler& eventHandler);
0060 
0061   void PrintTokens(std::ostream& out);
0062 
0063  private:
0064   /**
0065    * Reads any directives that are next in the queue, setting the internal
0066    * {@code m_pDirectives} state.
0067    */
0068   void ParseDirectives();
0069 
0070   void HandleDirective(const Token& token);
0071 
0072   /**
0073    * Handles a "YAML" directive, which should be of the form 'major.minor' (like
0074    * a version number).
0075    */
0076   void HandleYamlDirective(const Token& token);
0077 
0078   /**
0079    * Handles a "TAG" directive, which should be of the form 'handle prefix',
0080    * where 'handle' is converted to 'prefix' in the file.
0081    */
0082   void HandleTagDirective(const Token& token);
0083 
0084  private:
0085   std::unique_ptr<Scanner> m_pScanner;
0086   std::unique_ptr<Directives> m_pDirectives;
0087 };
0088 }  // namespace YAML
0089 
0090 #endif  // PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66