1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Replace custom class with string_view

This commit is contained in:
Ivan Savenko
2024-02-12 01:00:54 +02:00
parent ca9a16e30e
commit 25146bfa93

View File

@@ -13,37 +13,11 @@
VCMI_LIB_NAMESPACE_BEGIN VCMI_LIB_NAMESPACE_BEGIN
//Tiny string class that uses const char* as data for speed, members are private
//for ease of debugging and some compatibility with std::string
class constString
{
const char *data;
const size_t datasize;
public:
constString(const char * inputString, size_t stringSize):
data(inputString),
datasize(stringSize)
{
}
inline size_t size() const
{
return datasize;
};
inline const char& operator[] (size_t position)
{
assert (position < datasize);
return data[position];
}
};
//Internal class for string -> JsonNode conversion //Internal class for string -> JsonNode conversion
class JsonParser class JsonParser
{ {
std::string errors; // Contains description of all encountered errors std::string errors; // Contains description of all encountered errors
constString input; // Input data std::string_view input; // Input data
ui32 lineCount; // Currently parsed line, starting from 1 ui32 lineCount; // Currently parsed line, starting from 1
size_t lineStart; // Position of current line start size_t lineStart; // Position of current line start
size_t pos; // Current position of parser size_t pos; // Current position of parser