Move to object_ptr

This commit is contained in:
Jiga228
2025-10-17 21:39:30 +07:00
parent 136235749a
commit 137522cefa
8 changed files with 58 additions and 48 deletions
+13 -13
View File
@@ -95,7 +95,7 @@ SaveMap::SaveMap(const std::string& json_data)
end = object_json.find('\"', begin);
std::string object_name = object_json.substr(begin, end - begin);
ISave* object_ptr = MakeObjectByName(object_name);
UType::object_ptr<ISave> object_ptr(MakeObjectByName(object_name));
object_ptr->load(std::make_shared<SaveMap>(object_json));
save_objects[name.c_str() + 1] = object_ptr;
@@ -169,10 +169,10 @@ SaveMap::SaveMap(const std::string& json_data)
}
} else if (name[1] == 'o')
{
save_vector_objects[key] = std::vector<ISave*>();
save_vector_objects[key] = std::vector<UType::object_ptr<ISave>>();
if (arr_data.length() == 2)
continue;
std::vector<ISave*>& vector_object = save_vector_objects[key];
std::vector<UType::object_ptr<ISave>>& vector_object = save_vector_objects[key];
size_t j = 1;
while (j < arr_data.length())
@@ -196,7 +196,7 @@ SaveMap::SaveMap(const std::string& json_data)
size_t end_name = object_json.find('\"', begin_name);
std::string object_name = object_json.substr(begin_name, end_name - begin_name);
ISave* object_ptr = MakeObjectByName(object_name);
UType::object_ptr<ISave> object_ptr(MakeObjectByName(object_name));
object_ptr->load(std::make_shared<SaveMap>(object_json));
vector_object.push_back(object_ptr);
@@ -270,10 +270,10 @@ SaveMap::SaveMap(const std::string& json_data)
}
} else if (name[1] == 'o')
{
save_list_objects[key] = std::list<ISave*>();
save_list_objects[key] = std::list<UType::object_ptr<ISave>>();
if (arr_data.length() == 2)
continue;
std::list<ISave*>& list_object = save_list_objects[key];
std::list<UType::object_ptr<ISave>>& list_object = save_list_objects[key];
size_t j = 1;
while (j < arr_data.length())
@@ -297,7 +297,7 @@ SaveMap::SaveMap(const std::string& json_data)
size_t end_name = object_json.find('\"', begin_name);
std::string object_name = object_json.substr(begin_name, end_name - begin_name);
ISave* object_ptr = MakeObjectByName(object_name);
UType::object_ptr<ISave> object_ptr(MakeObjectByName(object_name));
object_ptr->load(std::make_shared<SaveMap>(object_json));
list_object.push_back(object_ptr);
@@ -387,7 +387,7 @@ std::shared_ptr<SaveMap> SaveMap::SaveString(const char* name, const std::string
return std::shared_ptr<SaveMap>(this);
}
std::shared_ptr<SaveMap> SaveMap::SaveObject(const char* name, ISave* object) noexcept
std::shared_ptr<SaveMap> SaveMap::SaveObject(const char* name, UType::object_ptr<ISave> object) noexcept
{
save_objects[name] = object;
return std::shared_ptr<SaveMap>(this);
@@ -411,7 +411,7 @@ std::shared_ptr<SaveMap> SaveMap::SaveVectorStrings(const char* name, std::vecto
return std::shared_ptr<SaveMap>(this);
}
std::shared_ptr<SaveMap> SaveMap::SaveVectorObject(const char* name, std::vector<ISave*>&& value) noexcept
std::shared_ptr<SaveMap> SaveMap::SaveVectorObject(const char* name, std::vector<UType::object_ptr<ISave>>&& value) noexcept
{
save_vector_objects[name] = std::move(value);
return std::shared_ptr<SaveMap>(this);
@@ -435,7 +435,7 @@ std::shared_ptr<SaveMap> SaveMap::SaveListStrings(const char* name, std::list<st
return std::shared_ptr<SaveMap>(this);
}
std::shared_ptr<SaveMap> SaveMap::SaveListObject(const char* name, std::list<ISave*>&& value) noexcept
std::shared_ptr<SaveMap> SaveMap::SaveListObject(const char* name, std::list<UType::object_ptr<ISave>>&& value) noexcept
{
save_list_objects[name] = std::move(value);
return std::shared_ptr<SaveMap>(this);
@@ -456,7 +456,7 @@ std::string SaveMap::GetString(const char* name)
return save_string[name];
}
ISave* SaveMap::GetObject(const char* name)
UType::object_ptr<ISave> SaveMap::GetObject(const char* name)
{
return save_objects[name];
}
@@ -476,7 +476,7 @@ std::vector<std::string> SaveMap::GetVectorString(const char* name)
return save_vector_strings[name];
}
std::vector<ISave*>& SaveMap::GetVectorObject(const char* name)
std::vector<UType::object_ptr<ISave>>& SaveMap::GetVectorObject(const char* name)
{
return save_vector_objects[name];
}
@@ -496,7 +496,7 @@ std::list<std::string>& SaveMap::GetListString(const char* name)
return save_list_strings[name];
}
std::list<ISave*>& SaveMap::GetListObject(const char* name)
std::list<UType::object_ptr<ISave>>& SaveMap::GetListObject(const char* name)
{
return save_list_objects[name];
}