编码规范修改

Signed-off-by: fangyunzhong <fangyunzhong2@huawei.com>
This commit is contained in:
fangyunzhong
2022-09-12 14:34:41 +08:00
parent f1c13eb31f
commit b6e02db9e5
13 changed files with 82 additions and 43 deletions
+6 -2
View File
@@ -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);
+6 -2
View File
@@ -28,8 +28,12 @@ namespace Restool {
class FileManager : public Singleton<FileManager> {
public:
uint32_t ScanModules(const std::vector<std::string> &inputs, const std::string &output);
const std::map<int32_t, std::vector<ResourceItem>> &GetResources() const { return items_; };
void SetModuleName(const std::string &moduleName) { moduleName_ = moduleName; };
const std::map<int32_t, std::vector<ResourceItem>> &GetResources() const {
return items_;
};
void SetModuleName(const std::string &moduleName) {
moduleName_ = moduleName;
};
uint32_t ScanIncrement(const std::string &output);
private:
+3 -1
View File
@@ -32,7 +32,9 @@ public:
const std::map<int32_t, std::vector<ResourceItem>> &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::pair<ResType, std::string>, std::vector<ResourceItem>> &GetResourceItems() const;
+12 -4
View File
@@ -44,10 +44,18 @@ public:
virtual ~IncrementManager();
uint32_t Init(const std::string &cachePath, const std::vector<std::string> &folder,
const std::string &outputPath, const std::string &moduleName);
const std::map<int32_t, std::vector<ResourceItem>> &GetResourceItems() const { return items_; };
const std::map<ResType, std::vector<DirectoryInfo>> &GetScanDirs() const { return scanDirs_; };
bool FirstIncrement() const { return firstIncrement_; };
bool Enable() const { return enalbe_; };
const std::map<int32_t, std::vector<ResourceItem>> &GetResourceItems() const {
return items_;
};
const std::map<ResType, std::vector<DirectoryInfo>> &GetScanDirs() const {
return scanDirs_;
};
bool FirstIncrement() const {
return firstIncrement_;
};
bool Enable() const {
return enalbe_;
};
static const std::string ID_JSON_FILE;
private:
+3 -1
View File
@@ -28,7 +28,9 @@ public:
virtual ~KeyManager() {};
bool LoadKey(const std::string &keysPath);
bool SaveKey(const std::string &keysPath);
std::map<XmlKeyNode::KeyType, std::shared_ptr<XmlKeyNode>> &GetKeys() { return keys_; };
std::map<XmlKeyNode::KeyType, std::shared_ptr<XmlKeyNode>> &GetKeys() {
return keys_;
};
private:
std::map<XmlKeyNode::KeyType, std::shared_ptr<XmlKeyNode>> keys_;
};
+3 -1
View File
@@ -28,7 +28,9 @@ public:
PreviewManager() {};
virtual ~PreviewManager();
uint32_t ScanModules(const std::vector<std::string> &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;
+4 -2
View File
@@ -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<FileEntry> &entry, const std::string &limitKey, const std::string outputPath);
bool ScanFiles(const std::unique_ptr<FileEntry> &entry, const DirectoryInfo &directoryInfo, const std::string &outputPath);
bool ScanLimitKey(const std::unique_ptr<FileEntry> &entry, const std::string &limitKey,
const std::string outputPath);
bool ScanFiles(const std::unique_ptr<FileEntry> &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;
+3 -1
View File
@@ -31,7 +31,9 @@ public:
const std::map<ResType, std::vector<DirectoryInfo>> &GetScanDirectorys() const;
static uint32_t MergeResourceItem(std::map<int32_t, std::vector<ResourceItem>> &alls,
const std::map<int32_t, std::vector<ResourceItem>> &other, bool tipError = false);
void SetPreviewMode(bool enable) { previewMode_ = enable; };
void SetPreviewMode(bool enable) {
previewMode_ = enable;
};
protected:
const std::string &modulePath_;
+18 -6
View File
@@ -42,9 +42,15 @@ private:
virtual bool LoadFrom(std::ifstream &in);
virtual bool FlushIndex(const std::map<XmlKeyNode::KeyType, std::shared_ptr<XmlKeyNode>> &oldKeys,
std::map<XmlKeyNode::KeyType, std::shared_ptr<XmlKeyNode>> &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<XmlKeyNode::KeyType, std::shared_ptr<XmlKeyNode>> &oldKeys,
std::map<XmlKeyNode::KeyType, std::shared_ptr<XmlKeyNode>> &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_;
+3 -1
View File
@@ -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();
+1 -2
View File
@@ -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;
+19 -19
View File
@@ -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<KeyParam> 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<FileEntry> &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<const char *>(resourceItem.GetName().c_str()), size);
size = resourceItem.GetLimitKey().length();
out.write(reinterpret_cast<const char *>(&size), sizeof(int32_t));
out.write(reinterpret_cast<const char *>(resourceItem.GetLimitKey().c_str()),size);
out.write(reinterpret_cast<const char *>(&size), sizeof(int32_t));
out.write(reinterpret_cast<const char *>(resourceItem.GetLimitKey().c_str()), size);
size = resourceItem.GetFilePath().length();
out.write(reinterpret_cast<const char *>(&size), sizeof(int32_t));
out.write(reinterpret_cast<const char *>(&size), sizeof(int32_t));
out.write(reinterpret_cast<const char *>(resourceItem.GetFilePath().c_str()), size);
int32_t type = static_cast<int32_t>(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<ResType>(type);
@@ -535,7 +535,7 @@ bool ResourceAppend::LoadResourceItemFromMem(const char buffer[], int32_t length
shared_ptr<ResourceItem> resourceItem = make_shared<ResourceItem>(nameStr, keyParams, resType);
resourceItem->SetData(reinterpret_cast<const int8_t *>(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<char *>(pBuffer);
char* buffer = reinterpret_cast<char *>(pBuffer);
result = LoadResourceItemFromMem(buffer, fileSize);
UnmapViewOfFile(hFileMap);
CloseHandle(hReadFile);
+1 -1
View File
@@ -18,7 +18,7 @@
#include<fstream>
#include<iostream>
#include<regex>
#include<stdlib.h>
#include<cstdlib>
#include "file_entry.h"
namespace OHOS {