22 return makeItemImpl(std::move(key));
29 Item* item = findItem(key);
30 return item? *item: makeItemImpl(key);
37 (std::string
const& key)
const noexcept ->
Item const*
39 for (
auto const& item: fItems)
if (key == item.key())
return &item;
46 (std::string
const& key) noexcept ->
Item*
50 return const_cast<Item*
>(std::as_const(*this).findItem(key));
58 if (
auto item = findItem(key); item)
return *item;
65 (std::string
const& key)
const noexcept
78 {
return fItems.size(); }
83 fItems.emplace_back(std::move(key));
89 std::ostream& icarus::operator<<
92 out <<
"'" << item.key() <<
"' (" << item.
nValues() <<
")";
93 if (!item.values().empty()) {
95 for (
auto const&
value: item.values()) out <<
" '" <<
value <<
'\'';
104 out << data.
size() <<
" items";
107 for (
auto const& item: data.
items()) out <<
"\n " << item;
bool hasItem(std::string const &key) const noexcept
Returns whether an item with the specified key is present.
Item * findItem(std::string const &key) noexcept
Returns the item with specified key, nullptr if none.
decltype(auto) items() const noexcept
Returns a forward-iterable list of references to items.
Item const & getItem(std::string const &key) const
Returns the item with specified key, throws std::out_of_range if none.
Item & makeItemImpl(std::string key)
Creates, registers and return a new item (assumed not to exist yet).
Representation of a single item of data: a key and several values.
std::ostream & operator<<(std::ostream &out, IntegerRanges< T, CheckGrowing > const &ranges)
Simple parsed data format.
Collection of items with key/values structure.
std::size_t nValues() const noexcept
Returns the number of values currently present.
std::vector< Item > fItems
Collection of data items.
std::size_t size() const noexcept
Returns the number of items in the data.
Item & makeItem(std::string key)
Creates and registers a new item with the specified key.
Item & makeOrFetchItem(std::string const &key)
Creates or retrieves an item with the specified key.
bool empty() const noexcept
Returns whether there is no item in data.