Merge branch 'master' into jgrpp
# Conflicts: # src/company_cmd.cpp # src/company_func.h # src/core/overflowsafe_type.hpp # src/engine.cpp # src/music/midifile.cpp # src/network/network_command.cpp # src/newgrf_debug_gui.cpp # src/newgrf_roadstop.h # src/newgrf_spritegroup.cpp # src/os/macosx/crashlog_osx.cpp # src/os/unix/crashlog_unix.cpp # src/pathfinder/yapf/yapf_common.hpp # src/road_gui.cpp # src/saveload/engine_sl.cpp # src/script/api/script_depotlist.cpp # src/script/api/script_roadtypelist.cpp # src/settings_gui.cpp # src/settings_type.h # src/strings.cpp # src/table/settings/game_settings.ini
This commit is contained in:
@@ -42,20 +42,13 @@ protected:
|
||||
public:
|
||||
/**
|
||||
* Create a new StringParameters instance that can reference part of the data of
|
||||
* the given partent instance.
|
||||
* the given parent instance.
|
||||
*/
|
||||
StringParameters(StringParameters &parent, size_t size) :
|
||||
parent(&parent),
|
||||
parameters(parent.parameters.subspan(parent.offset, size))
|
||||
{}
|
||||
|
||||
~StringParameters()
|
||||
{
|
||||
if (this->parent != nullptr) {
|
||||
this->parent->offset += this->parameters.size();
|
||||
}
|
||||
}
|
||||
|
||||
void PrepareForNextRun();
|
||||
void SetTypeOfNextParameter(char32_t type) { this->next_type = type; }
|
||||
|
||||
@@ -84,6 +77,17 @@ public:
|
||||
this->offset = offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Advance the offset within the string from where to return the next result of
|
||||
* \c GetInt64 or \c GetInt32.
|
||||
* @param advance The amount to advance the offset by.
|
||||
*/
|
||||
void AdvanceOffset(size_t advance)
|
||||
{
|
||||
this->offset += advance;
|
||||
assert(this->offset <= this->parameters.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next parameter from our parameters.
|
||||
* This updates the offset, so the next time this is called the next parameter
|
||||
@@ -94,7 +98,7 @@ public:
|
||||
T GetNextParameter()
|
||||
{
|
||||
auto ptr = GetNextParameterPointer();
|
||||
return static_cast<T>(ptr == nullptr ? 0 : ptr->data);
|
||||
return static_cast<T>(ptr->data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +110,6 @@ public:
|
||||
const char *GetNextParameterString()
|
||||
{
|
||||
auto ptr = GetNextParameterPointer();
|
||||
if (ptr == nullptr) return nullptr;
|
||||
return ptr->string != nullptr ? ptr->string->c_str() : ptr->string_view;
|
||||
}
|
||||
|
||||
@@ -226,7 +229,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
ArrayStringParameters(const ArrayStringParameters& other) = delete;
|
||||
ArrayStringParameters(const ArrayStringParameters &other) = delete;
|
||||
ArrayStringParameters& operator=(const ArrayStringParameters &other) = delete;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user