cpp-hocon  0.3.0
path.hpp
1 #pragma once
2 
3 #include <hocon/functional_list.hpp>
4 #include <hocon/types.hpp>
5 
6 #include <string>
7 #include <vector>
8 #include <memory>
9 #include "export.h"
10 
11 namespace hocon {
12 
13  class LIBCPP_HOCON_EXPORT path {
14  public:
15  path();
16  explicit path(std::string first, path const& remainder);
17  explicit path(std::vector<std::string> elements);
18  explicit path(std::vector<path> paths_to_concat);
19 
20  shared_string first() const;
21 
23  path remainder() const;
24 
26  path parent() const;
27 
28  bool has_remainder() const;
29  bool empty() const;
30  shared_string last() const;
31  path prepend(path prefix);
32  int length() const;
33  path sub_path(int remove_from_front);
34  path sub_path(int start_index, int end_index);
35  bool starts_with(path other) const;
36 
37  bool operator==(path const& other) const;
38  bool operator!=(path const& other) const;
39 
41  static bool has_funky_chars(std::string const& s);
42 
43  void append_to_string(std::string& base) const;
44 
46  std::string to_string() const;
47 
49  std::string render() const;
50 
51  static path new_key(std::string key);
52  static path new_path(std::string path);
53 
54  private:
55  path(List<shared_string> other_path);
56 
57  List<shared_string> _path;
58  };
59 
60 } // namespace hocon
path remainder() const
Returns the path minus the first element, or null if no more elements.
path parent() const
Returns the path minus the last element or null if we have just one element.
std::string to_string() const
For debugging.
static bool has_funky_chars(std::string const &s)
Signals whether quotes and other noise need to be removed/ignored.
std::string render() const
Human-readable error-message-oriented string representation of path.
Factory for creating config_document instances.
Definition: config.hpp:18
bool operator==(config_document const &lhs, config_document const &rhs)
Config documents compare via rendered strings.