CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Core/ELF/ParamSFO.h
Views: 1401
// Copyright (c) 2012- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#pragma once1819#include <string>20#include <map>21#include <vector>2223#include "Common/CommonTypes.h"24#include "Common/Log.h"2526class Path;2728class ParamSFOData29{30public:31void SetValue(const std::string &key, unsigned int value, int max_size);32void SetValue(const std::string &key, const std::string &value, int max_size);33void SetValue(const std::string &key, const u8 *value, unsigned int size, int max_size);3435int GetValueInt(const std::string &key) const;36std::string GetValueString(const std::string &key) const;37bool HasKey(const std::string &key) const;38const u8 *GetValueData(const std::string &key, unsigned int *size) const;3940std::vector<std::string> GetKeys() const;41std::string GenerateFakeID(const Path &filename) const;4243std::string GetDiscID();4445// This allocates a buffer (*paramsfo) using new[], whose size is zero-filled up to a multiple of 16 bytes.46// This is required for SavedataParam::BuildHash.47void WriteSFO(u8 **paramsfo, size_t *size) const;4849bool ReadSFO(const u8 *paramsfo, size_t size);50bool ReadSFO(const std::vector<u8> ¶msfo) {51if (!paramsfo.empty()) {52return ReadSFO(¶msfo[0], paramsfo.size());53} else {54return false;55}56}5758// If not found, returns a negative value.59int GetDataOffset(const u8 *paramsfo, const char *dataName);6061void Clear();6263private:64enum ValueType65{66VT_INT,67VT_UTF8,68VT_UTF8_SPE // raw data in u869};7071class ValueData72{73public:74ValueType type = VT_INT;75int max_size = 0;76std::string s_value;77int i_value = 0;7879u8* u_value = nullptr;80unsigned int u_size = 0;8182void SetData(const u8* data, int size);8384~ValueData() {85delete[] u_value;86}87};8889std::map<std::string,ValueData> values;90};91929394