nginxconfig
C++libraryforparsingandprintingnginx.conf
nginxconfig/ast.hpp
Go to the documentation of this file.
00001 
00012 #ifndef __NGINXCONFIG_AST_HPP_INCLUDED__
00013 #define __NGINXCONFIG_AST_HPP_INCLUDED__
00014 
00015 #include <nginxconfig/config.hpp>
00016 
00017 #include <deque>
00018 #include <iosfwd>
00019 #include <stdexcept>
00020 #include <string>
00021 
00022 namespace nginxconfig
00023 {
00024 
00025 enum class ast_entry_kind : unsigned int
00026 {
00028     simple,
00030     complex,
00032     document,
00034     comment,
00035 };
00036 
00037 NGINXCONFIG_PUBLIC std::ostream& operator<<(std::ostream& os, const ast_entry_kind& kind);
00038 
00040 class NGINXCONFIG_PUBLIC kind_error :
00041         public std::logic_error
00042 {
00043 public:
00044     explicit kind_error(const std::string& description);
00045     
00046     virtual ~kind_error() noexcept;
00047 };
00048 
00050 class NGINXCONFIG_PUBLIC ast_entry
00051 {
00052 public:
00053     using attribute_list = std::deque<std::string>;
00054     using child_list     = std::deque<ast_entry>;
00055 
00056 public:
00058     static ast_entry make_simple(std::string    name,
00059                                  attribute_list attributes   = attribute_list(),
00060                                  std::string    comment_text = std::string()
00061                                 );
00062     
00064     static ast_entry make_complex(std::string    name,
00065                                   attribute_list attributes = attribute_list(),
00066                                   child_list     children   = child_list()
00067                                  );
00068     
00070     static ast_entry make_document(child_list children   = child_list());
00071     
00073     static ast_entry make_comment(std::string comment_text);
00074     
00075     ast_entry(const ast_entry&);
00076     ast_entry& operator=(const ast_entry&);
00077     
00078     ast_entry(ast_entry&&) noexcept;
00079     ast_entry& operator=(ast_entry&&) noexcept;
00080     
00081     ~ast_entry() noexcept;
00082     
00084     friend void swap(ast_entry& a, ast_entry& b) noexcept;
00085     
00090     ast_entry_kind kind() const;
00091     
00098     const std::string& name() const;
00099     std::string&       name();
00100     
00106     const attribute_list& attributes() const;
00107     attribute_list&       attributes();
00108     
00113     const child_list& children() const;
00114     child_list&       children();
00115     
00121     const std::string& comment() const;
00122     std::string&       comment();
00123     
00125     bool operator==(const ast_entry& other) const;
00126     bool operator!=(const ast_entry& other) const;
00127     
00128 private:
00129     explicit ast_entry(ast_entry_kind kind);
00130     
00131 private:
00132     ast_entry_kind _kind;
00133     std::string    _name;
00134     attribute_list _attributes;
00135     child_list     _children;
00136     std::string    _comment;
00137 };
00138 
00139 NGINXCONFIG_PUBLIC std::ostream& operator<<(std::ostream&, const ast_entry&);
00140 
00141 }
00142 
00143 #endif/*__NGINXCONFIG_AST_HPP_INCLUDED__*/
 All Classes Files Functions Variables Friends Defines