diff --git a/include/config_parser.h b/include/config_parser.h index 7a5bdcf..f10d4a1 100644 --- a/include/config_parser.h +++ b/include/config_parser.h @@ -40,8 +40,12 @@ public: ModuleType GetModuleType() const; uint32_t ParseRefence(); uint32_t Save(const std::string &filePath) const; - static void SetUseModule() { useModule_ = true; }; - static std::string GetConfigName() { return useModule_ ? MODULE_JSON : CONFIG_JSON; }; + static void SetUseModule() { + useModule_ = true; + }; + static std::string GetConfigName() { + return useModule_ ? MODULE_JSON : CONFIG_JSON; + }; private: bool ParseModule(Json::Value &moduleNode); bool ParseDistro(Json::Value &distroNode); diff --git a/include/file_manager.h b/include/file_manager.h index 747cad3..9b30368 100644 --- a/include/file_manager.h +++ b/include/file_manager.h @@ -28,8 +28,12 @@ namespace Restool { class FileManager : public Singleton { public: uint32_t ScanModules(const std::vector &inputs, const std::string &output); - const std::map> &GetResources() const { return items_; }; - void SetModuleName(const std::string &moduleName) { moduleName_ = moduleName; }; + const std::map> &GetResources() const { + return items_; + }; + void SetModuleName(const std::string &moduleName) { + moduleName_ = moduleName; + }; uint32_t ScanIncrement(const std::string &output); private: diff --git a/include/i_resource_compiler.h b/include/i_resource_compiler.h index cb5df84..6667c5e 100644 --- a/include/i_resource_compiler.h +++ b/include/i_resource_compiler.h @@ -32,7 +32,9 @@ public: const std::map> &GetResult() const; uint32_t Compile(const FileInfo &fileInfo); void SetModuleName(const std::string &moduleName); - void SetPreviewMode(bool enable) { previewMode_ = enable; }; + void SetPreviewMode(bool enable) { + previewMode_ = enable; + }; uint32_t CompileForAppend(const FileInfo &fileInfo); const std::map, std::vector> &GetResourceItems() const; diff --git a/include/increment_manager.h b/include/increment_manager.h index de60447..6e39114 100644 --- a/include/increment_manager.h +++ b/include/increment_manager.h @@ -44,10 +44,18 @@ public: virtual ~IncrementManager(); uint32_t Init(const std::string &cachePath, const std::vector &folder, const std::string &outputPath, const std::string &moduleName); - const std::map> &GetResourceItems() const { return items_; }; - const std::map> &GetScanDirs() const { return scanDirs_; }; - bool FirstIncrement() const { return firstIncrement_; }; - bool Enable() const { return enalbe_; }; + const std::map> &GetResourceItems() const { + return items_; + }; + const std::map> &GetScanDirs() const { + return scanDirs_; + }; + bool FirstIncrement() const { + return firstIncrement_; + }; + bool Enable() const { + return enalbe_; + }; static const std::string ID_JSON_FILE; private: diff --git a/include/key_manager.h b/include/key_manager.h index 5c5d001..aa69260 100644 --- a/include/key_manager.h +++ b/include/key_manager.h @@ -28,7 +28,9 @@ public: virtual ~KeyManager() {}; bool LoadKey(const std::string &keysPath); bool SaveKey(const std::string &keysPath); - std::map> &GetKeys() { return keys_; }; + std::map> &GetKeys() { + return keys_; + }; private: std::map> keys_; }; diff --git a/include/preview_manager.h b/include/preview_manager.h index 92d8e5a..9c49456 100644 --- a/include/preview_manager.h +++ b/include/preview_manager.h @@ -28,7 +28,9 @@ public: PreviewManager() {}; virtual ~PreviewManager(); uint32_t ScanModules(const std::vector &modulePaths, const std::string &output); - void SetPriority(int32_t priority) { priority_ = priority; }; + void SetPriority(int32_t priority) { + priority_ = priority; + }; private: bool ScanFile(const std::string &filePath, int32_t priority); int32_t priority_ = -1; diff --git a/include/resource_append.h b/include/resource_append.h index 7a6f2de..593d291 100644 --- a/include/resource_append.h +++ b/include/resource_append.h @@ -35,8 +35,10 @@ private: bool Combine(const std::string &folderPath); bool ScanResources(const std::string &resourcePath, const std::string &outputPath); bool ScanIegalResources(const std::string &resourcePath, const std::string &outputPath); - bool ScanLimitKey(const std::unique_ptr &entry, const std::string &limitKey, const std::string outputPath); - bool ScanFiles(const std::unique_ptr &entry, const DirectoryInfo &directoryInfo, const std::string &outputPath); + bool ScanLimitKey(const std::unique_ptr &entry, const std::string &limitKey, + const std::string outputPath); + bool ScanFiles(const std::unique_ptr &entry, const DirectoryInfo &directoryInfo, + const std::string &outputPath); bool ScanFile(const FileInfo &fileInfo, const std::string &outputPath); bool ScanSingleFile(const std::string &filePath, const std::string &outputPath); bool WriteFileInner(std::ostringstream &outStream, const std::string &outputPath) const; diff --git a/include/resource_module.h b/include/resource_module.h index 61bdda1..24a4974 100644 --- a/include/resource_module.h +++ b/include/resource_module.h @@ -31,7 +31,9 @@ public: const std::map> &GetScanDirectorys() const; static uint32_t MergeResourceItem(std::map> &alls, const std::map> &other, bool tipError = false); - void SetPreviewMode(bool enable) { previewMode_ = enable; }; + void SetPreviewMode(bool enable) { + previewMode_ = enable; + }; protected: const std::string &modulePath_; diff --git a/include/solid_xml.h b/include/solid_xml.h index b7365ed..76583e4 100644 --- a/include/solid_xml.h +++ b/include/solid_xml.h @@ -42,9 +42,15 @@ private: virtual bool LoadFrom(std::ifstream &in); virtual bool FlushIndex(const std::map> &oldKeys, std::map> &newKeys); - void SetName(int32_t index) { name_ = index; }; - void SetValue(int32_t index) { value_ = index; }; - void SetNameSpace(int32_t index) { nameSpace_ = index; }; + void SetName(int32_t index) { + name_ = index; + }; + void SetValue(int32_t index) { + value_ = index; + }; + void SetNameSpace(int32_t index) { + nameSpace_ = index; + }; protected: int32_t name_; int32_t value_; @@ -59,9 +65,15 @@ private: bool LoadFrom(std::ifstream &in) override; bool FlushIndex(const std::map> &oldKeys, std::map> &newKeys) override; - void SetChild(int32_t index) { child_ = index; }; - void SetBrother(int32_t index) { brother_ = index; }; - void AddAttribute(int32_t index) { attributes_.push_back(index); }; + void SetChild(int32_t index) { + child_ = index; + }; + void SetBrother(int32_t index) { + brother_ = index; + }; + void AddAttribute(int32_t index) { + attributes_.push_back(index); + }; private: int32_t child_; int32_t brother_; diff --git a/include/sqlite_database.h b/include/sqlite_database.h index 508b8be..17baba7 100644 --- a/include/sqlite_database.h +++ b/include/sqlite_database.h @@ -30,7 +30,9 @@ public: bool OpenDatabase(); void CloseDatabase(); bool Insert(const ResourceItem &resourceItem); - void SetPriority(int32_t priority) { priority_ = priority; }; + void SetPriority(int32_t priority) { + priority_ = priority; + }; private: bool Query(const ResourceItem &resourceItem, int32_t &id); bool FindMaxId(); diff --git a/src/cmd_parser.cpp b/src/cmd_parser.cpp index 471bd36..75dc55c 100644 --- a/src/cmd_parser.cpp +++ b/src/cmd_parser.cpp @@ -205,7 +205,7 @@ uint32_t PackageParser::AddConfig(const string& argValue) uint32_t PackageParser::AddStartId(const string& argValue) { - startId_ = strtol(argValue.c_str(), nullptr, 16); + startId_ = strtol(argValue.c_str(), nullptr, 16); // 16 is hexadecimal number if ((startId_ >= 0x01000000 && startId_ < 0x06ffffff) || (startId_ >= 0x08000000 && startId_ < 0x41ffffff)) { return RESTOOL_SUCCESS; } @@ -317,7 +317,6 @@ bool PackageParser::IsAscii(const string& argValue) const } return false; }); - if (result != argValue.end()) { cerr << "Error: '" << argValue << "' must be ASCII" << endl; return false; diff --git a/src/resource_append.cpp b/src/resource_append.cpp index f0adb63..88f3771 100644 --- a/src/resource_append.cpp +++ b/src/resource_append.cpp @@ -70,14 +70,14 @@ uint32_t ResourceAppend::Combine() } // private - bool ResourceAppend::Combine(const string &folderPath) - { +bool ResourceAppend::Combine(const string &folderPath) +{ FileEntry entry(folderPath); if (!entry.Init()) { return false; } - itemsForModule_.clear(); + itemsForModule_.clear(); for (const auto &child : entry.GetChilds()) { if (!child->IsFile()) { cerr << "Error:" << child->GetFilePath().GetPath() << " not file" << endl; @@ -89,7 +89,7 @@ uint32_t ResourceAppend::Combine() } } return true; - } +} bool ResourceAppend::ParseRef() { @@ -138,17 +138,17 @@ bool ResourceAppend::ScanResources(const string &resourcePath, const string &out vector keyParams; if (KeyParser::Parse(entry.GetFilePath().GetFilename(), keyParams)) { for (const auto &child : entry.GetChilds()) { - if(!ResourceUtil::IslegalPath(child->GetFilePath().GetFilename())){ + if (!ResourceUtil::IslegalPath(child->GetFilePath().GetFilename())) { continue; } - if(!ScanIegalResources(child->GetFilePath().GetPath(), outputPath)){ + if (!ScanIegalResources(child->GetFilePath().GetPath(), outputPath)) { return false; } } return true; } - if (ResourceUtil::IslegalPath(entry.GetFilePath().GetFilename())){ + if (ResourceUtil::IslegalPath(entry.GetFilePath().GetFilename())) { return ScanIegalResources(resourcePath, outputPath); } @@ -184,7 +184,7 @@ bool ResourceAppend::ScanIegalResources(const string &resourcePath, const string return false; } for (const auto &child : entry.GetChilds()) { - if(!ScanSingleFile(child->GetFilePath().GetPath(), outputPath)){ + if (!ScanSingleFile(child->GetFilePath().GetPath(), outputPath)) { return false; } } @@ -202,7 +202,7 @@ bool ResourceAppend::ScanLimitKey(const unique_ptr &entry, for (const auto &child : entry->GetChilds()) { string fileCuster = child->GetFilePath().GetFilename(); if (ResourceUtil::IsIgnoreFile(fileCuster, child->IsFile())) { - continue; + continue; } if (child->IsFile()) { @@ -277,8 +277,8 @@ bool ResourceAppend::ScanFile(const FileInfo &fileInfo, const string &outputPath return true; } - bool ResourceAppend::ScanSingleFile(const string &filePath, const string &outputPath) - { +bool ResourceAppend::ScanSingleFile(const string &filePath, const string &outputPath) +{ if (filePath.find(RAW_FILE_DIR) != string::npos) { return WriteRawFile(filePath, outputPath); } @@ -304,7 +304,7 @@ bool ResourceAppend::ScanFile(const FileInfo &fileInfo, const string &outputPath return false; } return true; - } +} bool ResourceAppend::WriteFileInner(ostringstream &outStream, const string &outputPath) const { @@ -341,11 +341,11 @@ bool ResourceAppend::WriteResourceItem(const ResourceItem &resourceItem, ostring out.write(reinterpret_cast(resourceItem.GetName().c_str()), size); size = resourceItem.GetLimitKey().length(); - out.write(reinterpret_cast(&size), sizeof(int32_t)); - out.write(reinterpret_cast(resourceItem.GetLimitKey().c_str()),size); + out.write(reinterpret_cast(&size), sizeof(int32_t)); + out.write(reinterpret_cast(resourceItem.GetLimitKey().c_str()), size); size = resourceItem.GetFilePath().length(); - out.write(reinterpret_cast(&size), sizeof(int32_t)); + out.write(reinterpret_cast(&size), sizeof(int32_t)); out.write(reinterpret_cast(resourceItem.GetFilePath().c_str()), size); int32_t type = static_cast(resourceItem.GetResType()); @@ -505,7 +505,7 @@ bool ResourceAppend::LoadResourceItemFromMem(const char buffer[], int32_t length // limit key string limitKeyStr = ParseString(buffer, length, offset); // file path - string filePathStr = ParseString(buffer, length, offset);; + string filePathStr = ParseString(buffer, length, offset); // ResType int32_t type = ParseInt32(buffer, length, offset); ResType resType = static_cast(type); @@ -535,7 +535,7 @@ bool ResourceAppend::LoadResourceItemFromMem(const char buffer[], int32_t length shared_ptr resourceItem = make_shared(nameStr, keyParams, resType); resourceItem->SetData(reinterpret_cast(data.c_str()), data.length()); resourceItem->SetLimitKey(limitKeyStr); - resourceItem->SetFilePath(filePathStr); + resourceItem->SetFilePath(filePathStr); if (!Push(resourceItem)) { return false; } @@ -618,14 +618,14 @@ bool ResourceAppend::LoadResourceItemWin(const string &filePath) return result; } - void * pBuffer = MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 0); + void* pBuffer = MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 0); if (pBuffer == nullptr) { cerr << "Error: map view of file " << GetLastError() << endl; CloseHandle(hReadFile); return result; } - char * buffer = reinterpret_cast(pBuffer); + char* buffer = reinterpret_cast(pBuffer); result = LoadResourceItemFromMem(buffer, fileSize); UnmapViewOfFile(hFileMap); CloseHandle(hReadFile); diff --git a/src/resource_util.cpp b/src/resource_util.cpp index 761aa44..4f05176 100644 --- a/src/resource_util.cpp +++ b/src/resource_util.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include "file_entry.h" namespace OHOS {