5#include "Utilities/Strings.h"
6#include "ValueVariant.h"
8#include "Rendering/DataFormat.h"
10#include "Foundation/StringView.h"
11#include "Foundation/Reflection/TypeDatabase.h"
20 extern const size_t ParsedDataTypeSizes[];
21 extern const char * ParsedDataTypeNames[];
23 enum struct ParsedValueTextureFlags
28 ENABLE_ENUM_FLAGS(ParsedValueTextureFlags);
45 ParsedDataType type = ParsedDataType::Unknown;
50 size_t dimension =
static_cast<size_t>(-1);
56 glm::vec2 float2Value;
57 glm::vec3 float3Value;
58 glm::vec4 float4Value;
59 glm::mat4 float4x4Value;
65 glm::uvec2 uint2Value;
66 glm::uvec3 uint3Value;
67 glm::uvec4 uint4Value;
71 ParsedValueTextureFlags flags;
73 float _fill[16] = { 0.f };
75 std::vector<std::pair<size_t, std::string>> expressions;
77 std::vector<ParsedValue> values;
80 bool asBool(
bool& rv,
bool complain =
true)
const;
81 bool asFloat(
float& rv,
bool complain =
true)
const;
82 bool asInt(
int& rv,
bool complain =
true)
const;
85 using TokenStream = std::vector<StringView>;
87 bool matchChars(
const char c,
const StringView & chars);
89 void COGSCORE_DLL_API split(
const StringView & str,
const StringView & splits, TokenStream & tokens);
90 void COGSCORE_DLL_API split(
const StringView & str,
const StringView & splits,
const int grouper, TokenStream & tokens);
93 TokenStream tokenize(
const StringView & valueStr);
94 void tokenize(
const StringView & valueStr, TokenStream & tokens);
96 void COGSCORE_DLL_API parseStringValue(
const StringView & value, ParsedValue & v);
98 Cogs::TextureFormat COGSCORE_DLL_API parseTextureFormat(
const StringView & str, Cogs::TextureFormat defaultFormat = TextureFormat::R8G8B8A8_UNORM_SRGB);
100 double parseDouble(
const StringView & token,
double defaultValue = 0);
101 float parseFloat(
const StringView & token,
float defaultValue = 0);
102 int32_t parseInt(
const StringView & token, int32_t defaultValue = 0);
103 uint32_t parseUInt(
const StringView & token, uint32_t defaultValue = 0);
104 bool parseBool(
const StringView & token,
bool defaultValue =
false);
125 T parseEnum(
const StringView & token, T defaultValue = T())
127 return static_cast<T
>(parseEnum(token, Reflection::TypeDatabase::getType<T>(),
static_cast<int>(defaultValue)));
131 T parseEnumFlags(
const StringView & token, T defaultValue = T())
133 return static_cast<T
>(parseEnumFlags(token, Reflection::TypeDatabase::getType<T>(),
static_cast<int>(defaultValue)));
136 void parseQueryString(std::vector<ParsedValue>& attributes, StringView query);
138 void parseValues(
float * values,
const TokenStream & tokens,
size_t expected);
139 void parseValues(
double * values,
const TokenStream & tokens,
size_t expected);
140 void parseValues(
int * values,
const TokenStream & tokens,
size_t expected);
141 void parseValues(uint32_t * values,
const TokenStream & tokens,
size_t expected);
142 void parseValues(
bool* values,
const TokenStream & tokens,
size_t expected);
144 void parseValues(std::vector<std::pair<size_t, std::string>>& expressions,
float * values,
const TokenStream & tokens,
size_t expected);
145 void parseValues(std::vector<std::pair<size_t, std::string>>& expressions,
double * values,
const TokenStream & tokens,
size_t expected);
146 void parseValues(std::vector<std::pair<size_t, std::string>>& expressions,
int * values,
const TokenStream & tokens,
size_t expected);
147 void parseValues(std::vector<std::pair<size_t, std::string>>& expressions, uint32_t * values,
const TokenStream & tokens,
size_t expected);
148 void parseValues(std::vector<std::pair<size_t, std::string>>& expressions,
bool* values,
const TokenStream & tokens,
size_t expected);
Represents a discrete type definition, describing a native type class.
Provides a weakly referenced view over the contents of a string.
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
bool parseBool_(bool &rv, const StringView &token)
Parse a bool putting return value in rv and returning whether or not parsing was successful.
uint64_t COGSCORE_DLL_API parseISO8601(const StringView &iso8601)
Parse ISO 8601 timestamps.
bool parseInt_(int32_t &rv, const StringView &token)
Parse an int putting return value in rv and returning whether or not parsing was successful.
Stores the parsed output of a key/value pair.
std::string key
The input key.
std::string value
The value is available for all non vector types.