Skip to content

Commit e5465cf

Browse files
authored
Merge pull request #76 from MikaelSmith/update-pot
(maint) Fix include file from file
2 parents d612e36 + e9a1ef4 commit e5465cf

File tree

7 files changed

+56
-24
lines changed

7 files changed

+56
-24
lines changed

lib/inc/internal/parseable.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@
99
namespace hocon {
1010

1111
class config_document;
12-
class parseable_file;
13-
class parseable_string;
14-
class parseable_not_found;
1512

1613
class parseable : public config_parseable, public std::enable_shared_from_this<parseable> {
1714
public:
18-
static parseable_file new_file(std::string input_file_path, config_parse_options options);
19-
static parseable_string new_string(std::string s, config_parse_options options);
20-
static parseable_not_found new_not_found(std::string what_not_found, std::string message,
21-
config_parse_options options);
15+
static std::shared_ptr<parseable> new_file(std::string input_file_path, config_parse_options options);
16+
static std::shared_ptr<parseable> new_string(std::string s, config_parse_options options);
17+
static std::shared_ptr<parseable> new_not_found(std::string what_not_found, std::string message,
18+
config_parse_options options);
2219

2320
static config_syntax syntax_from_extension(std::string name);
2421

@@ -43,6 +40,11 @@ namespace hocon {
4340

4441
std::string to_string() const;
4542

43+
// Disable copy constructors, as include_context assumes it can hold a reference to parseable.
44+
parseable() = default;
45+
parseable(parseable const&) = delete;
46+
parseable& operator=(parseable const&) = delete;
47+
4648
private:
4749
std::shared_ptr<config_document> parse_document(config_parse_options const& base_options) const;
4850
std::shared_ptr<config_document> parse_document(shared_origin origin,

lib/src/config.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace hocon {
4040

4141
shared_config config::parse_string(string s, config_parse_options options)
4242
{
43-
return parseable::new_string(move(s), move(options)).parse()->to_config();
43+
return parseable::new_string(move(s), move(options))->parse()->to_config();
4444
}
4545

4646
shared_config config::parse_string(string s)

lib/src/config_document_factory.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ using namespace std;
66
namespace hocon { namespace config_document_factory {
77

88
shared_ptr<config_document> parse_file(string input_file_path, config_parse_options options) {
9-
return parseable::new_file(move(input_file_path), move(options)).parse_config_document();
9+
return parseable::new_file(move(input_file_path), move(options))->parse_config_document();
1010
}
1111

1212
shared_ptr<config_document> parse_file(string input_file_path) {
1313
return parse_file(move(input_file_path), config_parse_options());
1414
}
1515

1616
shared_ptr<config_document> parse_string(string s, config_parse_options options) {
17-
return parseable::new_string(move(s), move(options)).parse_config_document();
17+
return parseable::new_string(move(s), move(options))->parse_config_document();
1818
}
1919

2020
shared_ptr<config_document> parse_string(string s) {

lib/src/parseable.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ namespace hocon {
2727

2828
const int parseable::MAX_INCLUDE_DEPTH = 50;
2929

30-
parseable_file parseable::new_file(std::string input_file_path, config_parse_options options) {
31-
return parseable_file(move(input_file_path), move(options));
30+
shared_ptr<parseable> parseable::new_file(std::string input_file_path, config_parse_options options) {
31+
return make_shared<parseable_file>(move(input_file_path), move(options));
3232
}
3333

34-
parseable_string parseable::new_string(std::string s, config_parse_options options) {
35-
return parseable_string(move(s), move(options));
34+
shared_ptr<parseable> parseable::new_string(std::string s, config_parse_options options) {
35+
return make_shared<parseable_string>(move(s), move(options));
3636
}
3737

38-
parseable_not_found parseable::new_not_found(std::string what_not_found, std::string message,
38+
shared_ptr<parseable> parseable::new_not_found(std::string what_not_found, std::string message,
3939
config_parse_options options) {
40-
return parseable_not_found(move(what_not_found), move(message), move(options));
40+
return make_shared<parseable_not_found>(move(what_not_found), move(message), move(options));
4141
}
4242

4343
void parseable::post_construct(config_parse_options const& base_options) {

lib/src/simple_includer.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,15 @@ namespace hocon {
144144
auto p = _context->relative_to(name);
145145
if (p == nullptr) {
146146
// avoid returning null
147-
return make_shared<parseable_not_found>(
148-
parseable::new_not_found(name, _("include was not found: '{1}'", name), move(parse_options)));
147+
return parseable::new_not_found(name, _("include was not found: '{1}'", name), move(parse_options));
149148
} else {
150149
return p;
151150
}
152151
}
153152

154153
/** File name source */
155154
shared_parseable file_name_source::name_to_parseable(std::string name, config_parse_options parse_options) const {
156-
return make_shared<parseable_file>(
157-
parseable::new_file(move(name), move(parse_options)));
155+
return parseable::new_file(move(name), move(parse_options));
158156
}
159157

160158
/** Proxy */

lib/tests/conf_parser_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static shared_value parse_without_resolving(string s) {
2323
auto options = config_parse_options()
2424
.set_origin_description(make_shared<string>("test conf string"))
2525
.set_syntax(config_syntax::CONF);
26-
return parseable::new_string(move(s), move(options)).parse_value();
26+
return parseable::new_string(move(s), move(options))->parse_value();
2727
}
2828

2929
static shared_value parse(string s) {
@@ -221,7 +221,7 @@ TEST_CASE("implied comma handling") {
221221
[&](string const &s) { return drop_curlies(s); }
222222
};
223223

224-
auto tested = 0;
224+
auto tested = 0u;
225225
for (auto v : valids) {
226226
for (auto change : changes) {
227227
++tested;
@@ -306,7 +306,7 @@ TEST_CASE("line numbers in errors (pending)", "[!shouldfail]") {
306306
TEST_CASE("to string for parseables") {
307307
// just be sure the to_string don't throw, to get test coverage
308308
auto options = config_parse_options();
309-
parseable::new_file("foo", options).to_string();
309+
parseable::new_file("foo", options)->to_string();
310310
// TODO: are other APIs needed?
311311
}
312312

locales/cpp-hocon.pot

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#, fuzzy
77
msgid ""
88
msgstr ""
9-
"Project-Id-Version: cpp-hocon 0.1.0\n"
9+
"Project-Id-Version: cpp-hocon 0.1.2\n"
1010
"Report-Msgid-Bugs-To: [email protected]\n"
1111
"POT-Creation-Date: \n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
@@ -88,6 +88,38 @@ msgstr ""
8888
msgid "List does not contain only configs."
8989
msgstr ""
9090

91+
#: lib/src/config.cc
92+
msgid "Value at '{1}' was not a number or string."
93+
msgstr ""
94+
95+
#: lib/src/config.cc
96+
msgid "Not a valid time_unit"
97+
msgstr ""
98+
99+
#: lib/src/config.cc
100+
msgid "as_long: Overflow occurred during time conversion"
101+
msgstr ""
102+
103+
#: lib/src/config.cc
104+
msgid "convert_long: Overflow occurred during time conversion"
105+
msgstr ""
106+
107+
#: lib/src/config.cc
108+
msgid "convert_double: Overflow occurred during time conversion"
109+
msgstr ""
110+
111+
#: lib/src/config.cc
112+
msgid "Could not parse time unit '{1}' (try ns, us, ms, s, m, h, or d)"
113+
msgstr ""
114+
115+
#: lib/src/config.cc
116+
msgid "No number in duration value '{1}'"
117+
msgstr ""
118+
119+
#: lib/src/config.cc
120+
msgid "Value '{1}' could not be converted to a number."
121+
msgstr ""
122+
91123
#: lib/src/config.cc
92124
msgid "Creating new object from config_object did not return a config_object"
93125
msgstr ""

0 commit comments

Comments
 (0)