MCPcopy Create free account
hub / github.com/dhbloo/rapfi / parse_table_array

Function parse_table_array

Rapfi/external/cpptoml/include/cpptoml.h:2035–2134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2033 }
2034
2035 void parse_table_array(std::string::iterator& it,
2036 const std::string::iterator& end, table*& curr_table)
2037 {
2038 ++it;
2039 if (it == end || *it == ']')
2040 throw_parse_exception("Table array name cannot be empty");
2041
2042 auto key_end = [](char c) { return c == ']'; };
2043
2044 std::string full_ta_name;
2045 auto key_part_handler = [&](const std::string& part) {
2046 if (part.empty())
2047 throw_parse_exception("Empty component of table array name");
2048
2049 if (!full_ta_name.empty())
2050 full_ta_name += '.';
2051 full_ta_name += part;
2052
2053 if (curr_table->contains(part))
2054 {
2055#if !defined(__PGI)
2056 auto b = curr_table->get(part);
2057#else
2058 // Workaround for PGI compiler
2059 std::shared_ptr<base> b = curr_table->get(part);
2060#endif
2061
2062 // if this is the end of the table array name, add an
2063 // element to the table array that we just looked up,
2064 // provided it was not declared inline
2065 if (it != end && *it == ']')
2066 {
2067 if (!b->is_table_array())
2068 {
2069 throw_parse_exception("Key " + full_ta_name
2070 + " is not a table array");
2071 }
2072
2073 auto v = b->as_table_array();
2074
2075 if (v->is_inline())
2076 {
2077 throw_parse_exception("Static array " + full_ta_name
2078 + " cannot be appended to");
2079 }
2080
2081 v->get().push_back(make_table());
2082 curr_table = v->get().back().get();
2083 }
2084 // otherwise, just keep traversing down the key name
2085 else
2086 {
2087 if (b->is_table())
2088 curr_table = static_cast<table*>(b.get());
2089 else if (b->is_table_array())
2090 curr_table = std::static_pointer_cast<table_array>(b)
2091 ->get()
2092 .back()

Callers 1

parse_tableFunction · 0.85

Calls 15

throw_parse_exceptionFunction · 0.85
make_tableFunction · 0.85
make_table_arrayFunction · 0.85
parse_keyFunction · 0.85
make_consumerFunction · 0.85
consume_whitespaceFunction · 0.85
eol_or_commentFunction · 0.85
as_table_arrayMethod · 0.80
is_inlineMethod · 0.80
emptyMethod · 0.45
containsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected