1 #include <internal/values/config_string.hpp>
2 
3 using namespace std;
4 
5 namespace hocon {
6 
config_string(shared_origin origin,string text,config_string_type quoted)7     config_string::config_string(shared_origin origin, string text, config_string_type quoted) :
8         config_value(move(origin)), _text(move(text)), _quoted(quoted) { }
9 
value_type() const10     config_value::type config_string::value_type() const {
11         return config_value::type::STRING;
12     }
13 
transform_to_string() const14     string config_string::transform_to_string() const {
15         return _text;
16     }
17 
new_copy(shared_origin origin) const18     shared_value config_string::new_copy(shared_origin origin) const {
19         return make_shared<config_string>(move(origin), _text, _quoted);
20     }
21 
unwrapped() const22     unwrapped_value config_string::unwrapped() const {
23         return _text;
24     }
25 
was_quoted() const26     bool config_string::was_quoted() const {
27         return _quoted == config_string_type::QUOTED;
28     }
29 
operator ==(config_value const & other) const30     bool config_string::operator==(config_value const& other) const {
31         return equals<config_string>(other, [&](config_string const& o) { return _text == o._text; });
32     }
33 
render(std::string & s,int indent,bool at_root,config_render_options options) const34     void config_string::render(std::string& s, int indent, bool at_root, config_render_options options) const {
35         string rendered;
36 
37         if (options.get_json()) {
38             rendered = hocon::render_json_string(_text);
39         } else  {
40             rendered = hocon::render_string_unquoted_if_possible(_text);
41         }
42 
43         s += rendered;
44     }
45 
46 
47 }  // namespace hocon
48