MCPcopy Create free account
hub / github.com/Tencent/libpag / ReadCommonConfig

Function ReadCommonConfig

exporter/src/config/ConfigFile.cpp:32–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30using namespace tinyxml2;
31namespace exporter {
32static void ReadCommonConfig(XMLElement* commonElement, ConfigParam* configParam) {
33 if (!commonElement) {
34 return;
35 }
36
37 if (XMLElement* tagLevelElement = commonElement->FirstChildElement("tag-level")) {
38 if (const auto tagModeText = GetChildElementText(tagLevelElement, "mode")) {
39 if (SafeStringEqual(tagModeText, "beta")) {
40 configParam->tagMode = TagMode::Beta;
41 } else if (SafeStringEqual(tagModeText, "custom")) {
42 configParam->tagMode = TagMode::Custom;
43 } else {
44 configParam->tagMode = TagMode::Stable;
45 }
46 }
47
48 if (const auto customLevelText = GetChildElementText(tagLevelElement, "custom-level")) {
49 configParam->exportTagLevel = SafeStringToInt<uint16_t>(customLevelText, 1023);
50 }
51 }
52
53 if (const auto imageQualityText = GetChildElementText(commonElement, "image-quality")) {
54 configParam->imageQuality = SafeStringToInt(imageQualityText, 80);
55 }
56
57 if (const auto imagePixelRatioText = GetChildElementText(commonElement, "image-pixel-ratio")) {
58 configParam->imagePixelRatio = SafeStringToFloat(imagePixelRatioText, 2.0f);
59 }
60
61 if (const auto enableLayerNameText = GetChildElementText(commonElement, "enable-layer-name")) {
62 configParam->exportLayerName = SafeStringToInt(enableLayerNameText, 1) != 0;
63 }
64
65 if (const auto enableFontFileText = GetChildElementText(commonElement, "enable-font-file")) {
66 configParam->exportFontFile = SafeStringToInt(enableFontFileText, 0) != 0;
67 }
68
69 if (const auto exportScenseText = GetChildElementText(commonElement, "export-scense")) {
70 configParam->scenes = static_cast<ExportScenes>(SafeStringToInt(exportScenseText, 0));
71 }
72
73 if (const auto exportLanguageText = GetChildElementText(commonElement, "export-language")) {
74 configParam->language = static_cast<Language>(SafeStringToInt(exportLanguageText, 0));
75 }
76}
77
78static void ReadBitmapConfig(XMLElement* bitmapElement, ConfigParam* configParam) {
79 if (!bitmapElement) {

Callers 1

ReadConfigFileFunction · 0.85

Calls 4

GetChildElementTextFunction · 0.85
SafeStringEqualFunction · 0.85
SafeStringToIntFunction · 0.85
SafeStringToFloatFunction · 0.85

Tested by

no test coverage detected