Changeset View
Changeset View
Standalone View
Standalone View
source/ps/XMB/XMBStorage.cpp
Show All 22 Lines | |||||
#include "lib/file/vfs/vfs.h" | #include "lib/file/vfs/vfs.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "scriptinterface/Object.h" | #include "scriptinterface/Object.h" | ||||
#include "scriptinterface/ScriptConversions.h" | #include "scriptinterface/ScriptConversions.h" | ||||
#include "scriptinterface/ScriptExtraHeaders.h" | #include "scriptinterface/ScriptExtraHeaders.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
#include <libxml/parser.h> | #include <libxml/parser.h> | ||||
#include <string_view> | |||||
#include <unordered_map> | #include <unordered_map> | ||||
const char* XMBStorage::HeaderMagicStr = "XMB0"; | const char* XMBStorage::HeaderMagicStr = "XMB0"; | ||||
const char* XMBStorage::UnfinishedHeaderMagicStr = "XMBu"; | const char* XMBStorage::UnfinishedHeaderMagicStr = "XMBu"; | ||||
// Arbitrary version number - change this if we update the code and | // Arbitrary version number - change this if we update the code and | ||||
// need to invalidate old users' caches | // need to invalidate old users' caches | ||||
const u32 XMBStorage::XMBVersion = 4; | const u32 XMBStorage::XMBVersion = 4; | ||||
▲ Show 20 Lines • Show All 191 Lines • ▼ Show 20 Lines | for (const std::string& prop : props) | ||||
if (prop == "_string") | if (prop == "_string") | ||||
continue; | continue; | ||||
bool attrib = !prop.empty() && prop.front() == '@'; | bool attrib = !prop.empty() && prop.front() == '@'; | ||||
std::string_view name = prop; | std::string_view name = prop; | ||||
if (!attrib && !prop.empty() && prop.back() == '@') | if (!attrib && !prop.empty() && prop.back() == '@') | ||||
{ | { | ||||
size_t idx = prop.substr(0, prop.size()-1).find_last_of('@'); | const size_t idx = std::string_view{prop}.substr(0, prop.size() - 1) | ||||
.find_last_of('@'); | |||||
if (idx == std::string::npos) | if (idx == std::string::npos) | ||||
vladislavbelov: Do we have that practice in the repo? When the last symbol is a `.` and the next line begins… | |||||
Done Inline ActionsIDK, i think of . as an operator just like && or ,. phosit: IDK, i think of `.` as an operator just like `&&` or `,`. | |||||
Done Inline ActionsTrue, but we handle . and -> differently at least by avoiding spaces around them. Another different approach is assignment operators. We use them on the same line but with spaces. vladislavbelov: True, but we handle `.` and `->` differently at least by avoiding spaces around them. Another… | |||||
Done Inline ActionsI'll move the dot down phosit: I'll move the dot down | |||||
{ | { | ||||
LOGERROR("Object key name cannot end with an '@' unless it is an index specifier."); | LOGERROR("Object key name cannot end with an '@' unless it is an index specifier."); | ||||
return false; | return false; | ||||
} | } | ||||
name = std::string_view(prop.c_str(), idx); | name = std::string_view(prop.c_str(), idx); | ||||
} | } | ||||
else if (attrib) | else if (attrib) | ||||
name = std::string_view(prop.c_str()+1, prop.length()-1); | name = std::string_view(prop.c_str()+1, prop.length()-1); | ||||
▲ Show 20 Lines • Show All 227 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Do we have that practice in the repo? When the last symbol is a . and the next line begins with a method name? Or we use . plus a method name on the next line?
Also spaces around -.