3#include "Components/Core/DynamicComponent.h"
5#include "Resources/Resources.h"
7namespace Cogs::RationalReducerExtension
16 std::vector<std::string> annotations;
18 static void registerType();
22 static constexpr auto npos {
static_cast<size_t>(-1) };
32 for (
size_t i = 0; i < annotations.size(); ++i)
34 const auto & annot = annotations[i];
35 if (annot.find(key.
data(), 0) == 0 && annot.size() > key.
size() && annot[key.
size()] ==
':') {
66 return annotations[index].substr(key.
size() + 1);
81 annotations[index] = annotations[index].substr(0, key.
size() + 1) + value.
to_string();
86template<>
inline Cogs::StringView getName<Cogs::RationalReducerExtension::AnnotationComponent>() {
return "AnnotationComponent"; }
Base class for components implementing dynamic behavior.
Provides a weakly referenced view over the contents of a string.
constexpr const char * data() const noexcept
Get the sequence of characters referenced by the string view.
constexpr size_t size() const noexcept
Get the size of the string.
std::string to_string() const
String conversion method.
A component that serves as storage for a vector of text annotations.
bool containsKey(const Cogs::StringView key)
Check if the annotations vector contains the key using ':' for key/value separator.
size_t indexOfKey(const Cogs::StringView key)
Get index of the key in the annotations vector using ':' for key/value separator.
void setValue(const Cogs::StringView key, const Cogs::StringView value)
Add or replace key value using ':' for key/value separator.
std::string getValue(const Cogs::StringView key)
Get key value using ':' for key/value separator.
static constexpr auto npos
Undefined index.