Compare commits

...

14 Commits

Author SHA1 Message Date
11d75e401e pmt: reformat code, etc. 2025-11-24 18:50:57 +03:00
579b2623a4 Revert "pmt: Set version as release candicate"
This reverts commit 9a1af981d9.
2025-11-02 23:07:35 +03:00
a140320f30 Reapply "README: Fix wrong URLs."
This reverts commit 7405083815.
2025-11-02 23:07:04 +03:00
7405083815 Revert "README: Fix wrong URLs."
This reverts commit eda1b3d50c.
2025-11-02 23:06:03 +03:00
9a1af981d9 pmt: Set version as release candicate 2025-11-02 22:54:27 +03:00
eda1b3d50c README: Fix wrong URLs. 2025-10-28 12:02:31 +03:00
0c48c13852 Cleanup idea files, etc. 2025-10-28 11:42:35 +03:00
7ab20f1c99 .github/workflows/build.yml Güncelle 2025-10-28 11:15:15 +03:00
a45b7332cc build.sh: Stop thread allocation on dual-threaded devices 2025-10-28 11:03:47 +03:00
caff1510f9 .github/workflows/build.yml Güncelle 2025-10-28 10:54:22 +03:00
876674726d revert 4b1c1607ed
revert build.yml: use local server for builds
2025-10-28 10:16:55 +03:00
4b1c1607ed build.yml: use local server for builds 2025-10-28 09:21:34 +03:00
6a25a663e7 revert 1545511859
revert build.yml: Adapt with local git server

Signed-off-by: YZBruh <yagizzengin73@gmail.com>
2025-10-28 09:20:47 +03:00
1545511859 build.yml: Adapt with local git server
Signed-off-by: YZBruh <yagizzengin73@gmail.com>
2025-10-28 08:43:05 +03:00
39 changed files with 769 additions and 1027 deletions

View File

@@ -1,6 +1,6 @@
--- ---
Language: Cpp Language: Cpp
AccessModifierOffset: -2 AccessModifierOffset: -1
AlignAfterOpenBracket: Align AlignAfterOpenBracket: Align
AlignArrayOfStructures: None AlignArrayOfStructures: None
AlignConsecutiveAssignments: AlignConsecutiveAssignments:
@@ -65,7 +65,7 @@ AlignConsecutiveTableGenDefinitionColons:
AlignFunctionDeclarations: false AlignFunctionDeclarations: false
AlignFunctionPointers: false AlignFunctionPointers: false
PadOperators: false PadOperators: false
AlignEscapedNewlines: Right AlignEscapedNewlines: Left
AlignOperands: Align AlignOperands: Align
AlignTrailingComments: AlignTrailingComments:
Kind: Always Kind: Always
@@ -79,17 +79,22 @@ AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: true AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: true AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: AllIfsAndElse AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLambdasOnASingleLine: All AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false AllowShortLoopsOnASingleLine: true
AllowShortNamespacesOnASingleLine: false AllowShortNamespacesOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: false AlwaysBreakBeforeMultilineStrings: true
AttributeMacros: AttributeMacros:
- __capability - __capability
- absl_nonnull
- absl_nullable
- absl_nullability_unknown
BinPackArguments: true BinPackArguments: true
BinPackLongBracedList: true
BinPackParameters: BinPack BinPackParameters: BinPack
BitFieldColonSpacing: Both BitFieldColonSpacing: Both
BracedInitializerIndentWidth: -1
BraceWrapping: BraceWrapping:
AfterCaseLabel: false AfterCaseLabel: false
AfterClass: false AfterClass: false
@@ -118,13 +123,14 @@ BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Attach BreakBeforeBraces: Attach
BreakBeforeInlineASMColon: OnlyMultiline BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTemplateCloser: false
BreakBeforeTernaryOperators: true BreakBeforeTernaryOperators: true
BreakBinaryOperations: Never BreakBinaryOperations: Never
BreakConstructorInitializers: BeforeColon BreakConstructorInitializers: BeforeColon
BreakFunctionDefinitionParameters: false BreakFunctionDefinitionParameters: false
BreakInheritanceList: BeforeColon BreakInheritanceList: BeforeColon
BreakStringLiterals: true BreakStringLiterals: true
BreakTemplateDeclarations: MultiLine BreakTemplateDeclarations: Yes
ColumnLimit: 80 ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:' CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false CompactNamespaces: false
@@ -135,6 +141,7 @@ DerivePointerAlignment: false
DisableFormat: false DisableFormat: false
EmptyLineAfterAccessModifier: Never EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock EmptyLineBeforeAccessModifier: LogicalBlock
EnumTrailingComma: Leave
ExperimentalAutoDetectBinPacking: false ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true FixNamespaceComments: true
ForEachMacros: ForEachMacros:
@@ -143,25 +150,29 @@ ForEachMacros:
- BOOST_FOREACH - BOOST_FOREACH
IfMacros: IfMacros:
- KJ_IF_MAYBE - KJ_IF_MAYBE
IncludeBlocks: Preserve IncludeBlocks: Regroup
IncludeCategories: IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' - Regex: '^<ext/.*\.h>'
Priority: 2 Priority: 2
SortPriority: 0 SortPriority: 0
CaseSensitive: false CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)' - Regex: '^<.*\.h>'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1 Priority: 1
SortPriority: 0 SortPriority: 0
CaseSensitive: false CaseSensitive: false
IncludeIsMainRegex: '(Test)?$' - Regex: '^<.*'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 3
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '([-_](test|unittest))?$'
IncludeIsMainSourceRegex: '' IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false IndentAccessModifiers: false
IndentCaseBlocks: false IndentCaseBlocks: false
IndentCaseLabels: false IndentCaseLabels: true
IndentExportBlock: true IndentExportBlock: true
IndentExternBlock: AfterExternBlock IndentExternBlock: AfterExternBlock
IndentGotoLabels: true IndentGotoLabels: true
@@ -183,7 +194,7 @@ JavaScriptQuotes: Leave
JavaScriptWrapImports: true JavaScriptWrapImports: true
KeepEmptyLines: KeepEmptyLines:
AtEndOfFile: false AtEndOfFile: false
AtStartOfBlock: true AtStartOfBlock: false
AtStartOfFile: true AtStartOfFile: true
KeepFormFeed: false KeepFormFeed: false
LambdaBodyIndentation: Signature LambdaBodyIndentation: Signature
@@ -193,14 +204,15 @@ MacroBlockEnd: ''
MainIncludeChar: Quote MainIncludeChar: Quote
MaxEmptyLinesToKeep: 1 MaxEmptyLinesToKeep: 1
NamespaceIndentation: None NamespaceIndentation: None
ObjCBinPackProtocolList: Auto ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2 ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: BinPack OneLineFormatOffRegex: ''
PackConstructorInitializers: NextLine
PenaltyBreakAssignment: 2 PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakBeforeMemberAccess: 150 PenaltyBreakBeforeMemberAccess: 150
PenaltyBreakComment: 300 PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120 PenaltyBreakFirstLessLess: 120
@@ -210,10 +222,40 @@ PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10 PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000 PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0 PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 60 PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Right PointerAlignment: Left
PPIndentWidth: -1 PPIndentWidth: -1
QualifierAlignment: Leave QualifierAlignment: Leave
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
- ParseTestProto
- ParsePartialTestProto
CanonicalDelimiter: pb
BasedOnStyle: google
ReferenceAlignment: Pointer ReferenceAlignment: Pointer
ReflowComments: Always ReflowComments: Always
RemoveBracesLLVM: false RemoveBracesLLVM: false
@@ -225,11 +267,14 @@ RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1 ShortNamespaceLines: 1
SkipMacroDefinitionBody: false SkipMacroDefinitionBody: false
SortIncludes: CaseSensitive SortIncludes:
Enabled: true
IgnoreCase: false
SortJavaStaticImport: Before SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false SpaceAfterLogicalNot: false
SpaceAfterOperatorKeyword: false
SpaceAfterTemplateKeyword: true SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true SpaceBeforeAssignmentOperators: true
@@ -245,6 +290,7 @@ SpaceBeforeParensOptions:
AfterFunctionDefinitionName: false AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false AfterFunctionDeclarationName: false
AfterIfMacros: true AfterIfMacros: true
AfterNot: false
AfterOverloadedOperator: false AfterOverloadedOperator: false
AfterPlacementOperator: true AfterPlacementOperator: true
AfterRequiresInClause: false AfterRequiresInClause: false
@@ -253,7 +299,7 @@ SpaceBeforeParensOptions:
SpaceBeforeRangeBasedForLoopColon: true SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false SpaceInEmptyBlock: false
SpacesBeforeTrailingComments: 1 SpacesBeforeTrailingComments: 2
SpacesInAngles: Never SpacesInAngles: Never
SpacesInContainerLiterals: true SpacesInContainerLiterals: true
SpacesInLineCommentPrefix: SpacesInLineCommentPrefix:
@@ -267,7 +313,7 @@ SpacesInParensOptions:
InEmptyParentheses: false InEmptyParentheses: false
Other: false Other: false
SpacesInSquareBrackets: false SpacesInSquareBrackets: false
Standard: Latest Standard: Auto
StatementAttributeLikeMacros: StatementAttributeLikeMacros:
- Q_EMIT - Q_EMIT
StatementMacros: StatementMacros:

View File

@@ -35,7 +35,7 @@ jobs:
- name: Build And Prepare For Release - name: Build And Prepare For Release
id: build id: build
run: | run: |
git clone https://github.com/ShawkTeam/pmt-renovated -b main ./pmt && cd pmt git clone https://git.yzbruh.space/${{ github.repository }} -b main ./pmt && cd pmt
export ANDROID_NDK="${{ github.workspace }}/android-ndk-r28c" export ANDROID_NDK="${{ github.workspace }}/android-ndk-r28c"
bash build.sh clean bash build.sh clean
bash build.sh build -DCMAKE_BUILD_TYPE=Release bash build.sh build -DCMAKE_BUILD_TYPE=Release
@@ -50,8 +50,8 @@ jobs:
echo "BUILD_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV echo "BUILD_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV
echo "BUILD=${{ github.workspace }}/pmt" >> $GITHUB_ENV echo "BUILD=${{ github.workspace }}/pmt" >> $GITHUB_ENV
cd .. cd ..
echo -e "Read [Wiki - About Release Types](https://github.com/ShawkTeam/pmt-renovated/wiki/About-Release-Types) for getting more information.\n\n### Changes\n" > release.txt echo -e "Read [Wiki - About Release Types](https://git.yzbruh.space/${{ github.repository }}/wiki/About-Release-Types) for getting more information.\n\n### Changes\n" > release.txt
git log --since="2025-08-21" --pretty=format:" * %ad | [%s](https://github.com/ShawkTeam/pmt-renovated/commit/%H)" --date=short | sed 's/ -.*//' | grep -v cleanup >> release.txt git log --since="2025-08-21" --pretty=format:" * %ad | [%s](https://git.yzbruh.space/${{ github.repository }}/commit/%H)" --date=short | sed 's/ -.*//' | grep -v cleanup >> release.txt
working-directory: ${{ github.workspace }} working-directory: ${{ github.workspace }}
- name: Upload To GitHub Releases - name: Upload To GitHub Releases

1
.idea/.name generated
View File

@@ -1 +0,0 @@
pmt

2
.idea/1.0.0.iml generated
View File

@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />

344
.idea/editor.xml generated
View File

@@ -1,344 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BackendCodeEditorSettings">
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CDeclarationWithImplicitIntType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CommentTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConstevalIfIsAlwaysConstant/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractClassWithoutSpecifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractFinalClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractVirtualFunctionCallInCtor/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAccessSpecifierWithNoDeclarations/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAwaiterTypeIsNotClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBooleanIncrementExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatBadCode/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatLegacyCode/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatMixedArgs/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatTooFewArgs/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatTooManyArgs/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCStyleCast/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCVQualifierCanNotBeAppliedToReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassCanBeFinal/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassIsIncomplete/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassNeedsConstructorBecauseOfUninitializedMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCompileTimeConstantCanBeReplacedWithBooleanConstant/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConceptNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConditionalExpressionCanBeSimplified/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConstParameterInDeclaration/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConstValueFunctionReturnType/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCoroutineCallResolveError/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAArrayIndexOutOfBounds/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantConditions/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantFunctionResult/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantParameter/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFADeletedPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAEndlessLoop/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAInfiniteRecursion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAInvalidatedMemory/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALocalValueEscapesFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALocalValueEscapesScope/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALoopConditionNotUpdated/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAMemoryLeak/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFANotInitializedField/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFANullDereference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFATimeOver/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreachableCode/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreachableFunctionCall/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreadVariable/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnusedValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationHidesLocal/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationHidesUncapturedLocal/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationSpecifierWithoutDeclarators/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorDisambiguatedAsFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorUsedBeforeInitialization/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultCaseNotHandledInSwitchStatement/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultInitializationWithNoUserConstructor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultIsUsedAsIdentifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultedSpecialMemberFunctionIsImplicitlyDeleted/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeletingVoidPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDependentTemplateWithoutTemplateKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDependentTypeWithoutTypenameKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedEntity/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedOverridenMethod/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedRegisterStorageClassSpecifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDereferenceOperatorLimitExceeded/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDiscardedPostfixOperatorResult/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenSyntaxError/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenUndocumentedParameter/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenUnresolvedReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEmptyDeclaration/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceCVQualifiersOrder/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceCVQualifiersPlacement/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceDoStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceForStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceFunctionDeclarationStyle/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceIfStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceNestedNamespacesStyle/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceOverridingDestructorStyle/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceOverridingFunctionStyle/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceTypeAliasCodeStyle/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceWhileStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEntityAssignedButNoRead/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEntityUsedOnlyInUnevaluatedContext/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnumeratorNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEqualOperandsInBinaryExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEvaluationFailure/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppExplicitSpecializationInNonNamespaceScope/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppExpressionWithoutSideEffects/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFinalFunctionInFinalClass/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFinalNonOverridingVirtualFunction/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppForLoopCanBeReplacedWithWhile/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppForwardEnumDeclarationWithoutUnderlyingType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionDoesntReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionIsNotImplemented/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionResultShouldBeUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionalStyleCast/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHeaderHasBeenAlreadyIncluded/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHiddenFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHidingFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIdenticalOperandsInBinaryExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIfCanBeReplacedByConstexprIf/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppImplicitDefaultConstructorNotAvailable/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIncompatiblePointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIncompleteSwitchStatement/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppInconsistentNaming/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIntegralToPointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppInvalidLineContinuation/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppJoinDeclarationAndAssignment/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLambdaCaptureNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableMayBeConst/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableWithNonTrivialDtorIsNeverUsed/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLongFloat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberFunctionMayBeConst/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberFunctionMayBeStatic/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberInitializersOrder/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMismatchedClassTags/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMissingIncludeGuard/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMissingKeywordThrow/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppModulePartitionWithSeveralPartitionUnits/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtAddressOfClassRValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtBindingRValueToLvalueReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtCopyElisionInCopyInitDeclarator/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtDoubleUserConversionInCopyInit/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtNotInitializedStaticConstLocalVar/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtReinterpretCastFromNullptr/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMultiCharacterLiteral/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMultiCharacterWideLiteral/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMustBePublicVirtualToImplementInterface/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMutableSpecifierOnReferenceMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNoDiscardExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNodiscardFunctionWithoutReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExceptionSafeResourceAcquisition/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConversionOperator/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConvertingConstructor/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineFunctionDefinitionInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineVariableDefinitionInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNotAllPathsReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppObjectMemberMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppOutParameterMustBeWritten/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterMayBeConst/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterMayBeConstPtrOrRef/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterNamesMismatch/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterNeverUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPassValueParameterByConstReference/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPointerConversionDropsQualifiers/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPointerToIntegralConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPolymorphicClassWithNonVirtualPublicDestructor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyErroneousEmptyStatements/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyUninitializedMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyUnintendedObjectSlicing/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrecompiledHeaderIsNotIncluded/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrecompiledHeaderNotFound/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfBadFormat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfExtraArg/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfMissedArg/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfRiskyFormat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrivateSpecialMemberFunctionIsNotImplemented/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRangeBasedForIncompatibleReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedefinitionOfDefaultArgumentInOverrideFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantAccessSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBaseClassAccessSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBaseClassInitializer/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBooleanExpressionArgument/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantCastExpression/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantComplexityInComparison/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantConditionalExpression/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantConstSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantControlFlowJump/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantDereferencingAndTakingAddress/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElaboratedTypeSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElseKeyword/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElseKeywordInsideCompoundStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantEmptyDeclaration/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantEmptyStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantExportKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantFwdClassOrEnumSpecifier/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantInlineSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantLambdaParameterList/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantMemberInitializer/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantNamespaceDefinition/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantParentheses/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantQualifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantQualifierADL/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantStaticSpecifierOnMemberAllocationFunction/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantStaticSpecifierOnThreadLocalLocalVariable/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTemplateArguments/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTemplateKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTypenameKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantVoidArgumentList/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantZeroInitializerInAggregateInitialization/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReinterpretCastFromVoidPtr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRemoveRedundantBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReplaceMemsetWithZeroInitialization/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReplaceTieWithStructuredBinding/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReturnNoValueInNonVoidFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSmartPointerVsMakeFunction/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSomeObjectMembersMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSpecialFunctionWithoutNoexceptSpecification/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticAssertFailure/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticDataMemberInUnnamedStruct/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticSpecifierOnAnonymousNamespaceMember/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStringLiteralToCharPointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTabsAreDisallowed/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateArgumentsCanBeDeduced/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateParameterNeverUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateParameterShadowing/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppThrowExpressionCanBeReplacedWithRethrow/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTooWideScope/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTooWideScopeInitStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTypeAliasNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUninitializedDependentBaseClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUninitializedNonStaticDataMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnionMemberOfReferenceType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnmatchedPragmaEndRegionDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnmatchedPragmaRegionDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnamedNamespaceInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnecessaryWhitespace/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnsignedZeroComparison/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnusedIncludeDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAlgorithmWithCount/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAssociativeContains/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAuto/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAutoForNumeric/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseElementsView/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseEraseAlgorithm/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseFamiliarTemplateSyntaxForGenericLambdas/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseRangeAlgorithm/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseStdSize/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseStructuredBinding/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseTypeTraitAlias/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUserDefinedLiteralSuffixDoesNotStartWithUnderscore/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUsingResultOfAssignmentAsCondition/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVariableCanBeMadeConstexpr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVirtualFunctionCallInsideCtor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVirtualFunctionInFinalClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVolatileParameterInDeclaration/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWarningDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWrongIncludesOrder/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWrongSlashesInIncludeDirective/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppZeroConstantCanBeReplacedWithNullptr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppZeroValuedExpressionUsedAsNullPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=IdentifierTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=IfStdIsConstantEvaluatedCanBeReplaced/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StdIsConstantEvaluatedWillAlwaysEvaluateToConstant/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StringLiteralTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXPRESSION/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXTENDS_LIST/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_FOR_STMT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_PARAMETER/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_ARGUMENT/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_PARAMETER/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTIPLE_DECLARATION/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_TERNARY/@EntryValue" value="ALIGN_ALL" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_CLASS_DEFINITION/@EntryValue" value="1" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_DECLARATIONS/@EntryValue" value="0" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DECLARATION/@EntryValue" value="1" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DEFINITION/@EntryValue" value="1" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BREAK_TEMPLATE_DECLARATION/@EntryValue" value="LINE_BREAK" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CONTINUOUS_LINE_INDENT/@EntryValue" value="Double" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_ACCESS_SPECIFIERS_FROM_CLASS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CLASS_MEMBERS_FROM_ACCESS_SPECIFIERS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_COMMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_SIZE/@EntryValue" value="4" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_STYLE/@EntryValue" value="Space" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INITIALIZER_BRACES/@EntryValue" value="END_OF_LINE_NO_SPACE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INT_ALIGN_EQ/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INVOCABLE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_CODE/@EntryValue" value="2" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue" value="2" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_USER_LINEBREAKS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_COLON_IN_MEMBER_INITIALIZER_LISTS/@EntryValue" value="ON_SINGLE_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/MEMBER_INITIALIZER_LIST_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_INDENTATION/@EntryValue" value="All" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/OTHER_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_CATCH_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_ELSE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_NAMESPACE_DEFINITIONS_ON_SAME_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_WHILE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_BLOCK_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_EXTENDS_COLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_COLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_SEMICOLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_METHOD/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_NESTED_DECLARATOR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_METHOD/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_UNARY_OPERATOR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_EXTENDS_COLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_COLON/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_SEMICOLON/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_METHOD/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_METHOD/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BETWEEN_CLOSING_ANGLE_BRACKETS_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_ARRAY_ACCESS_BRACKETS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_DECLARATION_PARENTHESES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_BLOCKS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_METHOD_PARENTHESES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPECIAL_ELSE_IF_TREATMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TAB_WIDTH/@EntryValue" value="4" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TYPE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_BINARY_OPSIGN/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_DECLARATION_LPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_INVOCATION_LPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_ARGUMENTS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_LPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_RPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_LPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_RPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_TERNARY_OPSIGNS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_PARAMETERS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
<option name="/Default/CodeStyle/EditorConfig/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
</component>
</project>

8
.idea/misc.xml generated
View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakePythonSetting">
<option name="pythonIntegrationState" value="YES" />
</component>
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
<component name="WestSettings"><![CDATA[{}]]></component>
</project>

8
.idea/modules.xml generated
View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/1.0.0.iml" filepath="$PROJECT_DIR$/.idea/1.0.0.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated
View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@@ -25,13 +25,13 @@ PMT is designed for developers, technicians, and Android enthusiasts who need fi
## Documentation ## Documentation
For all information about PMT, see the [wiki](https://github.com/ShawkTeam/pmt-renovated/wiki).\ For all information about PMT, see the [wiki](https://git.yzbruh.space/YZBruh/pmt-renovated/wiki).\
Read [Wiki - Using PMT via Termux or ADB](https://github.com/ShawkTeam/pmt-renovated/wiki/Using-PMT-via-Termux-or-ADB) for learn how to use PMT via Termux or ADB.\ Read [Wiki - Using PMT via Termux or ADB](https://git.yzbruh.space/YZBruh/pmt-renovated/wiki/Using-PMT-via-Termux-or-ADB) for learn how to use PMT via Termux or ADB.\
Detailed usage instructions and option references can be found in the [Wiki - Usage](https://github.com/ShawkTeam/pmt-renovated/wiki/Usage).\ Detailed usage instructions and option references can be found in the [Wiki - Usage](https://git.yzbruh.space/YZBruh/pmt-renovated/wiki/Usage).\
See [Wiki - How To Build](https://github.com/ShawkTeam/pmt-renovated/wiki/How-To-Build) to learn how to build. See [Wiki - How To Build](https://git.yzbruh.space/YZBruh/pmt-renovated/wiki/How-To-Build) to learn how to build.
## Bug Reporting ## Bug Reporting
Please submit bugs at [Issues](https://github.com/ShawkTeam/pmt-renovated/issues) page. Please submit bugs at [Issues](https://git.yzbruh.space/YZBruh/pmt-renovated/issues) page.
--- ---

View File

@@ -61,9 +61,12 @@ build() {
-DANDROID_STL=c++_static -DANDROID_STL=c++_static
done done
CORES=$(($(nproc --all) - 2))
[ $CORES -eq 0 ] && CORES=2
for a in ${TARGET_ABI_LIST[@]}; do for a in ${TARGET_ABI_LIST[@]}; do
echo "Building $a artifacts... Using $(($(nproc) - 2)) thread." echo "Building $a artifacts... Using $CORES thread."
cmake --build build_$a -j$(($(nproc) - 2)) cmake --build build_$a -j$CORES
echo "$a build complete, artifacts: $PWD/build_$a" echo "$a build complete, artifacts: $PWD/build_$a"
done done
} }

View File

@@ -34,26 +34,26 @@
#define PART_MAP (*VARS.PartMap) #define PART_MAP (*VARS.PartMap)
namespace PartitionManager { namespace PartitionManager {
int Main(int argc, char **argv); int Main(int argc, char** argv);
// Print messages if not using quiet mode // Print messages if not using quiet mode
__attribute__((format(printf, 1, 2))) void print(const char *format, ...); __attribute__((format(printf, 1, 2))) void print(const char* format, ...);
__attribute__((format(printf, 1, 2))) void println(const char *format, ...); __attribute__((format(printf, 1, 2))) void println(const char* format, ...);
// If there is a delimiter in the string, CLI::detail::split returns; if not, an // If there is a delimiter in the string, CLI::detail::split returns; if not, an
// empty vector is returned. And checks duplicate arguments. // empty vector is returned. And checks duplicate arguments.
std::vector<std::string> splitIfHasDelim(const std::string &s, char delim, std::vector<std::string> splitIfHasDelim(const std::string& s, char delim,
bool checkForBadUsage = false); bool checkForBadUsage = false);
// Process vectors with input strings. Use for [flag(s)]-[other flag(s)] // Process vectors with input strings. Use for [flag(s)]-[other flag(s)]
// situations // situations
void processCommandLine(std::vector<std::string> &vec1, void processCommandLine(std::vector<std::string>& vec1,
std::vector<std::string> &vec2, const std::string &s1, std::vector<std::string>& vec2, const std::string& s1,
const std::string &s2, char delim, const std::string& s2, char delim,
bool checkForBadUsage = false); bool checkForBadUsage = false);
// Setting ups buffer size // Setting ups buffer size
void setupBufferSize(uint64_t &size, const std::string &entry); void setupBufferSize(uint64_t& size, const std::string& entry);
std::string getLibVersion(); std::string getLibVersion();
@@ -68,28 +68,29 @@ enum basic_function_flags {
// All function classes must inherit from this class. // All function classes must inherit from this class.
class basic_function { class basic_function {
public: public:
CLI::App *cmd = nullptr; CLI::App* cmd = nullptr;
std::vector<int> flags = {}; std::vector<int> flags = {};
virtual bool init(CLI::App &_app) = 0; virtual bool init(CLI::App& _app) = 0;
virtual bool run() = 0; virtual bool run() = 0;
[[nodiscard]] virtual bool isUsed() const = 0; [[nodiscard]] virtual bool isUsed() const = 0;
[[nodiscard]] virtual const char *name() const = 0; [[nodiscard]] virtual const char* name() const = 0;
virtual ~basic_function() = default; virtual ~basic_function() = default;
}; };
// A class for function management. // A class for function management.
template <class _Type> class basic_manager { template <class _Type>
private: class basic_manager {
private:
std::vector<std::unique_ptr<_Type>> _functions; std::vector<std::unique_ptr<_Type>> _functions;
public: public:
void registerFunction(std::unique_ptr<_Type> _func, CLI::App &_app) { void registerFunction(std::unique_ptr<_Type> _func, CLI::App& _app) {
LOGN(PMTF, INFO) << "registering: " << _func->name() << std::endl; LOGN(PMTF, INFO) << "registering: " << _func->name() << std::endl;
for (const auto &f : _functions) { for (const auto& f : _functions) {
if (std::string(_func->name()) == std::string(f->name())) { if (std::string(_func->name()) == std::string(f->name())) {
LOGN(PMTF, INFO) << "Is already registered: " << _func->name() LOGN(PMTF, INFO) << "Is already registered: " << _func->name()
<< ". Skipping." << std::endl; << ". Skipping." << std::endl;
@@ -104,7 +105,7 @@ public:
} }
[[nodiscard]] bool hasFlagOnUsedFunction(int flag) const { [[nodiscard]] bool hasFlagOnUsedFunction(int flag) const {
for (const auto &func : _functions) { for (const auto& func : _functions) {
if (func->isUsed()) { if (func->isUsed()) {
std::for_each(func->flags.begin(), func->flags.end(), [&](const int x) { std::for_each(func->flags.begin(), func->flags.end(), [&](const int x) {
LOGN(PMTF, INFO) << "Used flag " << x << " on " << func->name() LOGN(PMTF, INFO) << "Used flag " << x << " on " << func->name()
@@ -117,9 +118,9 @@ public:
return false; return false;
} }
[[nodiscard]] bool isUsed(const std::string &name) const { [[nodiscard]] bool isUsed(const std::string& name) const {
if (_functions.empty()) return false; if (_functions.empty()) return false;
for (const auto &func : _functions) { for (const auto& func : _functions) {
if (func->name() == name) return func->isUsed(); if (func->name() == name) return func->isUsed();
} }
return false; return false;
@@ -127,7 +128,7 @@ public:
[[nodiscard]] bool handleAll() const { [[nodiscard]] bool handleAll() const {
LOGN(PMTF, INFO) << "running caught commands in command-line." << std::endl; LOGN(PMTF, INFO) << "running caught commands in command-line." << std::endl;
for (const auto &func : _functions) { for (const auto& func : _functions) {
if (func->isUsed()) { if (func->isUsed()) {
LOGN(PMTF, INFO) << func->name() LOGN(PMTF, INFO) << func->name()
<< " is calling because used in command-line." << " is calling because used in command-line."
@@ -144,7 +145,7 @@ public:
}; };
class basic_variables final { class basic_variables final {
public: public:
basic_variables(); basic_variables();
std::unique_ptr<PartitionMap::BuildMap> PartMap; std::unique_ptr<PartitionMap::BuildMap> PartMap;

View File

@@ -19,8 +19,7 @@ RELEASE="20250821"
echo() { command echo "[$THIS]: $@"; } echo() { command echo "[$THIS]: $@"; }
checks() checks() {
{
if ! curl "https://github.com" &>/dev/null; then if ! curl "https://github.com" &>/dev/null; then
echo "No internet connection!" echo "No internet connection!"
exit 1 exit 1
@@ -32,8 +31,7 @@ checks()
[ ! -f $PREFIX/bin/wget ] && pkg install -y wget [ ! -f $PREFIX/bin/wget ] && pkg install -y wget
} }
select_variant() select_variant() {
{
LINK=""; ARCH=""; VARIANT="" LINK=""; ARCH=""; VARIANT=""
if getprop ro.product.cpu.abi | grep "arm64-v8a" &>/dev/null; then ARCH="arm64-v8a" if getprop ro.product.cpu.abi | grep "arm64-v8a" &>/dev/null; then ARCH="arm64-v8a"
@@ -44,8 +42,7 @@ select_variant()
LINK="https://github.com/ShawkTeam/pmt-renovated/releases/download/${RELEASE}/pmt-${VARIANT}${ARCH}.zip" LINK="https://github.com/ShawkTeam/pmt-renovated/releases/download/${RELEASE}/pmt-${VARIANT}${ARCH}.zip"
} }
download() download() {
{
echo "Downloading pmt-${VARIANT}${ARCH}.zip (${RELEASE})" echo "Downloading pmt-${VARIANT}${ARCH}.zip (${RELEASE})"
if ! wget -O $PREFIX/tmp/pmt.zip "${LINK}" &>/dev/null; then if ! wget -O $PREFIX/tmp/pmt.zip "${LINK}" &>/dev/null; then
echo "Download failed! LINK=${LINK}" echo "Download failed! LINK=${LINK}"
@@ -60,8 +57,7 @@ download()
fi fi
} }
setup() setup() {
{
[ -f $PREFIX/tmp/pmt_static ] && mv $PREFIX/tmp/pmt_static $PREFIX/tmp/pmt [ -f $PREFIX/tmp/pmt_static ] && mv $PREFIX/tmp/pmt_static $PREFIX/tmp/pmt
set -e set -e
install -t $PREFIX/bin $PREFIX/tmp/pmt install -t $PREFIX/bin $PREFIX/tmp/pmt
@@ -72,21 +68,18 @@ setup()
echo "Installed successfully. Try running 'pmt' command." echo "Installed successfully. Try running 'pmt' command."
} }
uninstall() uninstall() {
{
rm -f $PREFIX/bin/pmt $PREFIX/lib/libhelper* $PREFIX/lib/libpartition_map* &>/dev/null rm -f $PREFIX/bin/pmt $PREFIX/lib/libhelper* $PREFIX/lib/libpartition_map* &>/dev/null
} }
is_installed() is_installed() {
{
if /system/bin/which pmt &>/dev/null; then if /system/bin/which pmt &>/dev/null; then
echo "PMT is already installed." echo "PMT is already installed."
exit 1 exit 1
fi fi
} }
cleanup() cleanup() {
{
rm -f $PREFIX/tmp/pmt* $PREFIX/tmp/lib* $PREFIX/tmp/*.zip &>/dev/null rm -f $PREFIX/tmp/pmt* $PREFIX/tmp/lib* $PREFIX/tmp/*.zip &>/dev/null
} }
@@ -95,7 +88,7 @@ if [ $# -eq 0 ]; then
exit 1 exit 1
fi fi
if ! basename -a ${PREFIX}/bin/* | grep "termux" &>/dev/null; then if ! echo ${HOME} | grep "com.termux" &>/dev/null; then
echo "This script only for termux!" echo "This script only for termux!"
exit 1 exit 1
fi fi

View File

@@ -14,23 +14,24 @@
limitations under the License. limitations under the License.
*/ */
#include <fcntl.h>
#include <PartitionManager/PartitionManager.hpp> #include <PartitionManager/PartitionManager.hpp>
#include <algorithm> #include <algorithm>
#include <fcntl.h>
#include <memory> #include <memory>
#include <string> #include <string>
#include <unordered_set> #include <unordered_set>
#include <vector> #include <vector>
namespace PartitionManager { namespace PartitionManager {
std::vector<std::string> splitIfHasDelim(const std::string &s, const char delim, std::vector<std::string> splitIfHasDelim(const std::string& s, const char delim,
const bool checkForBadUsage) { const bool checkForBadUsage) {
if (s.find(delim) == std::string::npos) return {}; if (s.find(delim) == std::string::npos) return {};
auto vec = CLI::detail::split(s, delim); auto vec = CLI::detail::split(s, delim);
if (checkForBadUsage) { if (checkForBadUsage) {
std::unordered_set<std::string> set; std::unordered_set<std::string> set;
for (const auto &str : vec) { for (const auto& str : vec) {
if (set.find(str) != set.end()) if (set.find(str) != set.end())
throw CLI::ValidationError("Duplicate element in your inputs!"); throw CLI::ValidationError("Duplicate element in your inputs!");
set.insert(str); set.insert(str);
@@ -40,15 +41,17 @@ std::vector<std::string> splitIfHasDelim(const std::string &s, const char delim,
return vec; return vec;
} }
void setupBufferSize(uint64_t &size, const std::string &entry) { void setupBufferSize(uint64_t& size, const std::string& entry) {
if (PART_MAP.hasPartition(entry) && PART_MAP.sizeOf(entry) % size != 0) { if (PART_MAP.hasPartition(entry) && PART_MAP.sizeOf(entry) % size != 0) {
println("%sWARNING%s: Specified buffer size is invalid for %s! Using " println(
"%sWARNING%s: Specified buffer size is invalid for %s! Using "
"different buffer size for %s.", "different buffer size for %s.",
YELLOW, STYLE_RESET, entry.data(), entry.data()); YELLOW, STYLE_RESET, entry.data(), entry.data());
size = PART_MAP.sizeOf(entry) % 4096 == 0 ? 4096 : 1; size = PART_MAP.sizeOf(entry) % 4096 == 0 ? 4096 : 1;
} else if (Helper::fileIsExists(entry)) { } else if (Helper::fileIsExists(entry)) {
if (Helper::fileSize(entry) % size != 0) { if (Helper::fileSize(entry) % size != 0) {
println("%sWARNING%s: Specified buffer size is invalid for %s! using " println(
"%sWARNING%s: Specified buffer size is invalid for %s! using "
"different buffer size for %s.", "different buffer size for %s.",
YELLOW, STYLE_RESET, entry.data(), entry.data()); YELLOW, STYLE_RESET, entry.data(), entry.data());
size = Helper::fileSize(entry) % 4096 == 0 ? 4096 : 1; size = Helper::fileSize(entry) % 4096 == 0 ? 4096 : 1;
@@ -56,9 +59,9 @@ void setupBufferSize(uint64_t &size, const std::string &entry) {
} }
} }
void processCommandLine(std::vector<std::string> &vec1, void processCommandLine(std::vector<std::string>& vec1,
std::vector<std::string> &vec2, const std::string &s1, std::vector<std::string>& vec2, const std::string& s1,
const std::string &s2, const char delim, const std::string& s2, const char delim,
const bool checkForBadUsage) { const bool checkForBadUsage) {
vec1 = splitIfHasDelim(s1, delim, checkForBadUsage); vec1 = splitIfHasDelim(s1, delim, checkForBadUsage);
vec2 = splitIfHasDelim(s2, delim, checkForBadUsage); vec2 = splitIfHasDelim(s2, delim, checkForBadUsage);

View File

@@ -16,7 +16,7 @@
#include <PartitionManager/PartitionManager.hpp> #include <PartitionManager/PartitionManager.hpp>
int main(int argc, char **argv) { int main(int argc, char** argv) {
// Call integrated main function in library // Call integrated main function in library
return PartitionManager::Main(argc, argv); return PartitionManager::Main(argc, argv);
} }

View File

@@ -14,18 +14,20 @@
limitations under the License. limitations under the License.
*/ */
#include "functions/functions.hpp"
#include <PartitionManager/PartitionManager.hpp> #include <PartitionManager/PartitionManager.hpp>
#include <csignal> #include <csignal>
#include <cstdarg> #include <cstdarg>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include "functions/functions.hpp"
#ifndef ANDROID_BUILD #ifndef ANDROID_BUILD
#include <generated/buildInfo.hpp> #include <generated/buildInfo.hpp>
#endif #endif
#include <string>
#include <unistd.h> #include <unistd.h>
#include <string>
namespace PartitionManager { namespace PartitionManager {
/** /**
@@ -37,12 +39,15 @@ namespace PartitionManager {
FuncManager.registerFunction(std::make_unique<cls>(), AppMain) FuncManager.registerFunction(std::make_unique<cls>(), AppMain)
basic_variables::basic_variables() basic_variables::basic_variables()
: logFile(Helper::LoggingProperties::FILE), onLogical(false), : logFile(Helper::LoggingProperties::FILE),
quietProcess(false), verboseMode(false), viewVersion(false), onLogical(false),
quietProcess(false),
verboseMode(false),
viewVersion(false),
forceProcess(false) { forceProcess(false) {
try { try {
PartMap = std::make_unique<PartitionMap::BuildMap>(); PartMap = std::make_unique<PartitionMap::BuildMap>();
} catch (std::exception &) { } catch (std::exception&) {
} }
} }
@@ -57,26 +62,27 @@ static void sigHandler(const int sig) {
exit(sig); exit(sig);
} }
static int write(void *cookie, const char *buf, const int size) { static int write(void* cookie, const char* buf, const int size) {
auto *real = static_cast<FILE *>(cookie); auto* real = static_cast<FILE*>(cookie);
if (!VARS.quietProcess) { if (!VARS.quietProcess) {
const int ret = fwrite(buf, 1, static_cast<size_t>(size), real); const int ret = fwrite(buf, 1, static_cast<size_t>(size), real);
fflush(real); fflush(real);
return ret; return ret;
} else return size; } else
return size;
} }
static FILE *make_fp(FILE *real) { static FILE* make_fp(FILE* real) {
return funopen(real, nullptr, write, nullptr, nullptr); return funopen(real, nullptr, write, nullptr, nullptr);
} }
auto Variables = std::make_unique<VariableTable>(); auto Variables = std::make_unique<VariableTable>();
FILE *pstdout = make_fp(stdout); FILE* pstdout = make_fp(stdout);
FILE *pstderr = make_fp(stderr); FILE* pstderr = make_fp(stderr);
static Helper::garbageCollector collector; static Helper::garbageCollector collector;
int Main(int argc, char **argv) { int Main(int argc, char** argv) {
try { try {
// try-catch start // try-catch start
Helper::LoggingProperties::setProgramName(argv[0]); Helper::LoggingProperties::setProgramName(argv[0]);
@@ -90,7 +96,7 @@ int Main(int argc, char **argv) {
char buf[128]; char buf[128];
while (fgets(buf, sizeof(buf), stdin) != nullptr) { while (fgets(buf, sizeof(buf), stdin) != nullptr) {
buf[strcspn(buf, "\n")] = 0; buf[strcspn(buf, "\n")] = 0;
const char *token = strtok(buf, " \t"); const char* token = strtok(buf, " \t");
while (token != nullptr) { while (token != nullptr) {
argv[argc] = strdup(token); argv[argc] = strdup(token);
argc++; argc++;
@@ -111,14 +117,15 @@ int Main(int argc, char **argv) {
AppMain.fallthrough(true); AppMain.fallthrough(true);
AppMain.set_help_all_flag("--help-all", "Print full help message and exit"); AppMain.set_help_all_flag("--help-all", "Print full help message and exit");
AppMain.footer("Partition Manager Tool is written by YZBruh\n" AppMain.footer(
"Partition Manager Tool is written by YZBruh\n"
"This project licensed under " "This project licensed under "
"Apache 2.0 license\nReport " "Apache 2.0 license\nReport "
"bugs to https://github.com/ShawkTeam/pmt-renovated/issues"); "bugs to https://github.com/ShawkTeam/pmt-renovated/issues");
AppMain AppMain
.add_option("-S,--search-path", VARS.searchPath, .add_option("-S,--search-path", VARS.searchPath,
"Set partition search path") "Set partition search path")
->check([&](const std::string &val) { ->check([&](const std::string& val) {
if (val.find("/block") == std::string::npos) if (val.find("/block") == std::string::npos)
return std::string( return std::string(
"Partition search path is unexpected! Couldn't find " "Partition search path is unexpected! Couldn't find "
@@ -159,15 +166,18 @@ int Main(int argc, char **argv) {
if (FuncManager.hasFlagOnUsedFunction(NO_MAP_CHECK)) { if (FuncManager.hasFlagOnUsedFunction(NO_MAP_CHECK)) {
if (!VARS.searchPath.empty()) if (!VARS.searchPath.empty())
WARNING("-S (--search-path) flag is ignored. Because, don't needed " WARNING(
"-S (--search-path) flag is ignored. Because, don't needed "
"partition map by your used function.\n"); "partition map by your used function.\n");
if (VARS.onLogical) if (VARS.onLogical)
WARNING("-l (--logical) flag ignored. Because, partition type don't " WARNING(
"-l (--logical) flag ignored. Because, partition type don't "
"needed by your used function.\n"); "needed by your used function.\n");
} else { } else {
if (!VARS.searchPath.empty()) (PART_MAP)(VARS.searchPath); if (!VARS.searchPath.empty()) (PART_MAP)(VARS.searchPath);
if (!VARS.PartMap && VARS.searchPath.empty()) if (!VARS.PartMap && VARS.searchPath.empty())
throw Error("No default search entries were found. Specify a search " throw Error(
"No default search entries were found. Specify a search "
"directory with -S " "directory with -S "
"(--search-path)"); "(--search-path)");
@@ -187,13 +197,13 @@ int Main(int argc, char **argv) {
} }
return FuncManager.handleAll() == true ? EXIT_SUCCESS : EXIT_FAILURE; return FuncManager.handleAll() == true ? EXIT_SUCCESS : EXIT_FAILURE;
} catch (Helper::Error &error) { } catch (Helper::Error& error) {
// catch Helper::Error // catch Helper::Error
fprintf(pstderr, "%s%sERROR(S) OCCURRED:%s\n%s\n", RED, BOLD, STYLE_RESET, fprintf(pstderr, "%s%sERROR(S) OCCURRED:%s\n%s\n", RED, BOLD, STYLE_RESET,
error.what()); error.what());
return EXIT_FAILURE; return EXIT_FAILURE;
} catch (CLI::Error &error) { } catch (CLI::Error& error) {
// catch CLI::Error // catch CLI::Error
fprintf(stderr, "%s: %s%sFLAG PARSE ERROR:%s %s\n", argv[0], RED, BOLD, fprintf(stderr, "%s: %s%sFLAG PARSE ERROR:%s %s\n", argv[0], RED, BOLD,
@@ -202,14 +212,14 @@ int Main(int argc, char **argv) {
} // try-catch block end } // try-catch block end
} }
void print(const char *format, ...) { void print(const char* format, ...) {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
vfprintf(pstdout, format, args); vfprintf(pstdout, format, args);
va_end(args); va_end(args);
} }
void println(const char *format, ...) { void println(const char* format, ...) {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
vfprintf(pstdout, format, args); vfprintf(pstdout, format, args);

View File

@@ -14,21 +14,23 @@
limitations under the License. limitations under the License.
*/ */
#include "functions.hpp" #include <fcntl.h>
#include <private/android_filesystem_config.h>
#include <unistd.h>
#include <PartitionManager/PartitionManager.hpp> #include <PartitionManager/PartitionManager.hpp>
#include <cerrno> #include <cerrno>
#include <chrono> #include <chrono>
#include <cstdlib> #include <cstdlib>
#include <fcntl.h>
#include <future> #include <future>
#include <private/android_filesystem_config.h>
#include <unistd.h> #include "functions.hpp"
#define BFUN "backupFunction" #define BFUN "backupFunction"
#define FUNCTION_CLASS backupFunction #define FUNCTION_CLASS backupFunction
namespace PartitionManager { namespace PartitionManager {
RUN_ASYNC(const std::string &partitionName, const std::string &outputName, RUN_ASYNC(const std::string& partitionName, const std::string& outputName,
const uint64_t bufferSize) { const uint64_t bufferSize) {
if (!PART_MAP.hasPartition(partitionName)) if (!PART_MAP.hasPartition(partitionName))
return {Helper::format("Couldn't find partition: %s", partitionName.data()), return {Helper::format("Couldn't find partition: %s", partitionName.data()),
@@ -77,7 +79,7 @@ RUN_ASYNC(const std::string &partitionName, const std::string &outputName,
LOGN(BFUN, INFO) << "Writing partition " << partitionName LOGN(BFUN, INFO) << "Writing partition " << partitionName
<< " to file: " << outputName << std::endl; << " to file: " << outputName << std::endl;
auto *buffer = new (std::nothrow) char[bufferSize]; auto* buffer = new (std::nothrow) char[bufferSize];
collector.delAfterProgress(buffer); collector.delAfterProgress(buffer);
memset(buffer, 0x00, bufferSize); memset(buffer, 0x00, bufferSize);
@@ -148,12 +150,13 @@ RUN {
std::string end; std::string end;
bool endResult = true; bool endResult = true;
for (auto &future : futures) { for (auto& future : futures) {
auto [fst, snd] = future.get(); auto [fst, snd] = future.get();
if (!snd) { if (!snd) {
end += fst + '\n'; end += fst + '\n';
endResult = false; endResult = false;
} else println("%s", fst.c_str()); } else
println("%s", fst.c_str());
} }
if (!endResult) throw Error("%s", end.c_str()); if (!endResult) throw Error("%s", end.c_str());

View File

@@ -14,9 +14,10 @@ Copyright 2025 Yağız Zengin
limitations under the License. limitations under the License.
*/ */
#include "functions.hpp"
#include <PartitionManager/PartitionManager.hpp> #include <PartitionManager/PartitionManager.hpp>
#include "functions.hpp"
#define CFUN "cleanLogFunction" #define CFUN "cleanLogFunction"
#define FUNCTION_CLASS cleanLogFunction #define FUNCTION_CLASS cleanLogFunction

View File

@@ -14,18 +14,20 @@ Copyright 2025 Yağız Zengin
limitations under the License. limitations under the License.
*/ */
#include "functions.hpp" #include <fcntl.h>
#include <unistd.h>
#include <PartitionManager/PartitionManager.hpp> #include <PartitionManager/PartitionManager.hpp>
#include <cerrno> #include <cerrno>
#include <fcntl.h>
#include <future> #include <future>
#include <unistd.h>
#include "functions.hpp"
#define EFUN "eraseFunction" #define EFUN "eraseFunction"
#define FUNCTION_CLASS eraseFunction #define FUNCTION_CLASS eraseFunction
namespace PartitionManager { namespace PartitionManager {
RUN_ASYNC(const std::string &partitionName, const uint64_t bufferSize) { RUN_ASYNC(const std::string& partitionName, const uint64_t bufferSize) {
if (!PART_MAP.hasPartition(partitionName)) if (!PART_MAP.hasPartition(partitionName))
return {Helper::format("Couldn't find partition: %s", partitionName.data()), return {Helper::format("Couldn't find partition: %s", partitionName.data()),
false}; false};
@@ -65,7 +67,7 @@ RUN_ASYNC(const std::string &partitionName, const uint64_t bufferSize) {
LOGN(EFUN, INFO) << "Writing zero bytes to partition: " << partitionName LOGN(EFUN, INFO) << "Writing zero bytes to partition: " << partitionName
<< std::endl; << std::endl;
auto *buffer = new (std::nothrow) char[bufferSize]; auto* buffer = new (std::nothrow) char[bufferSize];
collector.delAfterProgress(buffer); collector.delAfterProgress(buffer);
memset(buffer, 0x00, bufferSize); memset(buffer, 0x00, bufferSize);
@@ -81,7 +83,8 @@ RUN_ASYNC(const std::string &partitionName, const uint64_t bufferSize) {
return {Helper::format("Can't write zero bytes to partition: %s: %s", return {Helper::format("Can't write zero bytes to partition: %s: %s",
partitionName.data(), strerror(errno)), partitionName.data(), strerror(errno)),
false}; false};
else bytesWritten += result; else
bytesWritten += result;
} }
return {Helper::format("Successfully wrote zero bytes to the %s partition", return {Helper::format("Successfully wrote zero bytes to the %s partition",
@@ -104,7 +107,7 @@ INIT {
RUN { RUN {
std::vector<std::future<pair>> futures; std::vector<std::future<pair>> futures;
for (const auto &partitionName : partitions) { for (const auto& partitionName : partitions) {
uint64_t buf = bufferSize; uint64_t buf = bufferSize;
setupBufferSize(buf, partitionName); setupBufferSize(buf, partitionName);
futures.push_back( futures.push_back(
@@ -115,12 +118,13 @@ RUN {
std::string end; std::string end;
bool endResult = true; bool endResult = true;
for (auto &future : futures) { for (auto& future : futures) {
auto [fst, snd] = future.get(); auto [fst, snd] = future.get();
if (!snd) { if (!snd) {
end += fst + '\n'; end += fst + '\n';
endResult = false; endResult = false;
} else println("%s", fst.c_str()); } else
println("%s", fst.c_str());
} }
if (!endResult) throw Error("%s", end.c_str()); if (!endResult) throw Error("%s", end.c_str());

View File

@@ -14,19 +14,21 @@ Copyright 2025 Yağız Zengin
limitations under the License. limitations under the License.
*/ */
#include "functions.hpp" #include <fcntl.h>
#include <unistd.h>
#include <PartitionManager/PartitionManager.hpp> #include <PartitionManager/PartitionManager.hpp>
#include <cerrno> #include <cerrno>
#include <cstdlib> #include <cstdlib>
#include <fcntl.h>
#include <future> #include <future>
#include <unistd.h>
#include "functions.hpp"
#define FFUN "flashFunction" #define FFUN "flashFunction"
#define FUNCTION_CLASS flashFunction #define FUNCTION_CLASS flashFunction
namespace PartitionManager { namespace PartitionManager {
RUN_ASYNC(const std::string &partitionName, const std::string &imageName, RUN_ASYNC(const std::string& partitionName, const std::string& imageName,
const uint64_t bufferSize, const bool deleteAfterProgress) { const uint64_t bufferSize, const bool deleteAfterProgress) {
if (!Helper::fileIsExists(imageName)) if (!Helper::fileIsExists(imageName))
return {Helper::format("Couldn't find image file: %s", imageName.data()), return {Helper::format("Couldn't find image file: %s", imageName.data()),
@@ -75,7 +77,7 @@ RUN_ASYNC(const std::string &partitionName, const std::string &imageName,
LOGN(FFUN, INFO) << "Writing image " << imageName LOGN(FFUN, INFO) << "Writing image " << imageName
<< " to partition: " << partitionName << std::endl; << " to partition: " << partitionName << std::endl;
auto *buffer = new (std::nothrow) char[bufferSize]; auto* buffer = new (std::nothrow) char[bufferSize];
collector.delAfterProgress(buffer); collector.delAfterProgress(buffer);
memset(buffer, 0x00, bufferSize); memset(buffer, 0x00, bufferSize);
@@ -146,12 +148,13 @@ RUN {
std::string end; std::string end;
bool endResult = true; bool endResult = true;
for (auto &future : futures) { for (auto& future : futures) {
auto [fst, snd] = future.get(); auto [fst, snd] = future.get();
if (!snd) { if (!snd) {
end += fst + '\n'; end += fst + '\n';
endResult = false; endResult = false;
} else println("%s", fst.c_str()); } else
println("%s", fst.c_str());
} }
if (!endResult) throw Error("%s", end.c_str()); if (!endResult) throw Error("%s", end.c_str());

View File

@@ -14,13 +14,15 @@ Copyright 2025 Yağız Zengin
limitations under the License. limitations under the License.
*/ */
#include "functions.hpp" #include <fcntl.h>
#include <PartitionManager/PartitionManager.hpp> #include <PartitionManager/PartitionManager.hpp>
#include <cerrno> #include <cerrno>
#include <cstdlib> #include <cstdlib>
#include <fcntl.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include "functions.hpp"
#define IFUN "infoFunction" #define IFUN "infoFunction"
#define FUNCTION_CLASS infoFunction #define FUNCTION_CLASS infoFunction
@@ -30,7 +32,8 @@ INIT {
LOGN(IFUN, INFO) << "Initializing variables of info printer function." LOGN(IFUN, INFO) << "Initializing variables of info printer function."
<< std::endl; << std::endl;
cmd = _app.add_subcommand("info", "Tell info(s) of input partition list") cmd = _app.add_subcommand("info", "Tell info(s) of input partition list")
->footer("Use get-all or getvar-all as partition name for getting " ->footer(
"Use get-all or getvar-all as partition name for getting "
"info's of all partitions.\nUse get-logicals as partition " "info's of all partitions.\nUse get-logicals as partition "
"name for getting info's of logical partitions.\n" "name for getting info's of logical partitions.\n"
"Use get-physical as partition name for getting info's of " "Use get-physical as partition name for getting info's of "
@@ -103,13 +106,14 @@ RUN {
PART_MAP.doForLogicalPartitions(func); PART_MAP.doForLogicalPartitions(func);
else if (partitions.back() == "get-physicals") else if (partitions.back() == "get-physicals")
PART_MAP.doForPhysicalPartitions(func); PART_MAP.doForPhysicalPartitions(func);
else PART_MAP.doForPartitionList(partitions, func); else
PART_MAP.doForPartitionList(partitions, func);
if (jsonFormat) { if (jsonFormat) {
nlohmann::json j; nlohmann::json j;
j["multipleType"] = Helper::multipleToString(multiple); j["multipleType"] = Helper::multipleToString(multiple);
j["partitions"] = nlohmann::json::array(); j["partitions"] = nlohmann::json::array();
for (const auto &[name, props] : jParts) { for (const auto& [name, props] : jParts) {
j["partitions"].push_back({{jNamePartition, name}, j["partitions"].push_back({{jNamePartition, name},
{jNameSize, props.size}, {jNameSize, props.size},
{jNameLogical, props.isLogical}}); {jNameLogical, props.isLogical}});

View File

@@ -14,14 +14,16 @@ Copyright 2025 Yağız Zengin
limitations under the License. limitations under the License.
*/ */
#include "functions.hpp" #include <fcntl.h>
#include <unistd.h>
#include <PartitionManager/PartitionManager.hpp> #include <PartitionManager/PartitionManager.hpp>
#include <chrono> #include <chrono>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <fcntl.h>
#include <random> #include <random>
#include <unistd.h>
#include "functions.hpp"
#define MTFUN "memoryTestFunction" #define MTFUN "memoryTestFunction"
#define FUNCTION_CLASS memoryTestFunction #define FUNCTION_CLASS memoryTestFunction
@@ -35,7 +37,7 @@ INIT {
cmd = _app.add_subcommand("memtest", "Test your write/read speed of device."); cmd = _app.add_subcommand("memtest", "Test your write/read speed of device.");
cmd->add_option("testDirectory", testPath, "Path to test directory") cmd->add_option("testDirectory", testPath, "Path to test directory")
->default_val("/data/local/tmp") ->default_val("/data/local/tmp")
->check([&](const std::string &val) { ->check([&](const std::string& val) {
if (val.find("/sdcard") != std::string::npos || if (val.find("/sdcard") != std::string::npos ||
val.find("/storage") != std::string::npos) val.find("/storage") != std::string::npos)
return std::string( return std::string(
@@ -69,7 +71,7 @@ RUN {
const std::string test = Helper::pathJoin(testPath, "test.bin"); const std::string test = Helper::pathJoin(testPath, "test.bin");
LOGN(MTFUN, INFO) << "Generating random data for testing" << std::endl; LOGN(MTFUN, INFO) << "Generating random data for testing" << std::endl;
auto *buffer = new (std::nothrow) char[bufferSize]; auto* buffer = new (std::nothrow) char[bufferSize];
collector.delAfterProgress(buffer); collector.delAfterProgress(buffer);
for (size_t i = 0; i < bufferSize; i++) for (size_t i = 0; i < bufferSize; i++)
@@ -99,9 +101,9 @@ RUN {
LOGN(MTFUN, INFO) << "Sequential write test done!" << std::endl; LOGN(MTFUN, INFO) << "Sequential write test done!" << std::endl;
if (!doNotReadTest) { if (!doNotReadTest) {
auto *rawBuffer = new char[bufferSize + 4096]; auto* rawBuffer = new char[bufferSize + 4096];
collector.delAfterProgress(rawBuffer); collector.delAfterProgress(rawBuffer);
auto *bufferRead = reinterpret_cast<char *>( auto* bufferRead = reinterpret_cast<char*>(
(reinterpret_cast<uintptr_t>(rawBuffer) + 4096 - 1) & ~(4096 - 1)); (reinterpret_cast<uintptr_t>(rawBuffer) + 4096 - 1) & ~(4096 - 1));
const int rfd = const int rfd =
Helper::openAndAddToCloseList(test, collector, O_RDONLY | O_DIRECT); Helper::openAndAddToCloseList(test, collector, O_RDONLY | O_DIRECT);

View File

@@ -14,9 +14,10 @@ Copyright 2025 Yağız Zengin
limitations under the License. limitations under the License.
*/ */
#include "functions.hpp"
#include <PartitionManager/PartitionManager.hpp> #include <PartitionManager/PartitionManager.hpp>
#include "functions.hpp"
#define SFUN "partitionSizeFunction" #define SFUN "partitionSizeFunction"
#define FUNCTION_CLASS partitionSizeFunction #define FUNCTION_CLASS partitionSizeFunction
@@ -26,7 +27,8 @@ INIT {
<< "Initializing variables of partition size getter function." << "Initializing variables of partition size getter function."
<< std::endl; << std::endl;
cmd = _app.add_subcommand("sizeof", "Tell size(s) of input partition list") cmd = _app.add_subcommand("sizeof", "Tell size(s) of input partition list")
->footer("Use get-all or getvar-all as partition name for getting " ->footer(
"Use get-all or getvar-all as partition name for getting "
"sizes of all partitions.\nUse get-logicals as partition " "sizes of all partitions.\nUse get-logicals as partition "
"name for getting sizes of logical partitions.\n" "name for getting sizes of logical partitions.\n"
"Use get-physical as partition name for getting sizes of " "Use get-physical as partition name for getting sizes of "
@@ -72,7 +74,8 @@ RUN {
partition.data()); partition.data());
} }
if (onlySize) println("%d", Helper::convertTo(props.size, multiple)); if (onlySize)
println("%d", Helper::convertTo(props.size, multiple));
else else
println("%s: %d%s", partition.data(), println("%s: %d%s", partition.data(),
Helper::convertTo(props.size, multiple), Helper::convertTo(props.size, multiple),
@@ -87,7 +90,8 @@ RUN {
PART_MAP.doForLogicalPartitions(func); PART_MAP.doForLogicalPartitions(func);
else if (partitions.back() == "get-physicals") else if (partitions.back() == "get-physicals")
PART_MAP.doForPhysicalPartitions(func); PART_MAP.doForPhysicalPartitions(func);
else PART_MAP.doForPartitionList(partitions, func); else
PART_MAP.doForPartitionList(partitions, func);
return true; return true;
} }

View File

@@ -14,9 +14,10 @@
limitations under the License. limitations under the License.
*/ */
#include "functions.hpp"
#include <PartitionManager/PartitionManager.hpp> #include <PartitionManager/PartitionManager.hpp>
#include "functions.hpp"
#define RPFUN "realPathFunction" #define RPFUN "realPathFunction"
#define FUNCTION_CLASS realPathFunction #define FUNCTION_CLASS realPathFunction
@@ -34,7 +35,7 @@ INIT {
} }
RUN { RUN {
for (const auto &partition : partitions) { for (const auto& partition : partitions) {
if (!PART_MAP.hasPartition(partition)) if (!PART_MAP.hasPartition(partition))
throw Error("Couldn't find partition: %s", partition.data()); throw Error("Couldn't find partition: %s", partition.data());
@@ -51,7 +52,8 @@ RUN {
if (realLinkPath) if (realLinkPath)
println("%s", PART_MAP.getRealLinkPathOf(partition).data()); println("%s", PART_MAP.getRealLinkPathOf(partition).data());
else println("%s", PART_MAP.getRealPathOf(partition).data()); else
println("%s", PART_MAP.getRealPathOf(partition).data());
} }
return true; return true;

View File

@@ -14,9 +14,10 @@ Copyright 2025 Yağız Zengin
limitations under the License. limitations under the License.
*/ */
#include "functions.hpp"
#include <PartitionManager/PartitionManager.hpp> #include <PartitionManager/PartitionManager.hpp>
#include "functions.hpp"
#define RFUN "rebootFunction" #define RFUN "rebootFunction"
#define FUNCTION_CLASS rebootFunction #define FUNCTION_CLASS rebootFunction
@@ -35,8 +36,10 @@ RUN {
<< (rebootTarget.empty() ? "none" : rebootTarget) << (rebootTarget.empty() ? "none" : rebootTarget)
<< std::endl; << std::endl;
if (Helper::androidReboot(rebootTarget)) println("Reboot command was sent"); if (Helper::androidReboot(rebootTarget))
else throw Error("Cannot reboot device"); println("Reboot command was sent");
else
throw Error("Cannot reboot device");
return true; return true;
} }

View File

@@ -14,10 +14,11 @@
limitations under the License. limitations under the License.
*/ */
#include "functions.hpp"
#include <PartitionManager/PartitionManager.hpp> #include <PartitionManager/PartitionManager.hpp>
#include <map> #include <map>
#include "functions.hpp"
#define TFUN "typeFunction" #define TFUN "typeFunction"
#define FUNCTION_CLASS typeFunction #define FUNCTION_CLASS typeFunction
@@ -47,14 +48,15 @@ RUN {
magics.merge(PartitionMap::Extras::AndroidMagicMap); magics.merge(PartitionMap::Extras::AndroidMagicMap);
else if (onlyCheckFileSystemMagics) else if (onlyCheckFileSystemMagics)
magics.merge(PartitionMap::Extras::FileSystemMagicMap); magics.merge(PartitionMap::Extras::FileSystemMagicMap);
else magics.merge(PartitionMap::Extras::MagicMap); else
magics.merge(PartitionMap::Extras::MagicMap);
for (const auto &content : contents) { for (const auto& content : contents) {
if (!PART_MAP.hasPartition(content) && !Helper::fileIsExists(content)) if (!PART_MAP.hasPartition(content) && !Helper::fileIsExists(content))
throw Error("Couldn't find partition or image file: %s", content.data()); throw Error("Couldn't find partition or image file: %s", content.data());
bool found = false; bool found = false;
for (const auto &[magic, name] : magics) { for (const auto& [magic, name] : magics) {
if (PartitionMap::Extras::hasMagic( if (PartitionMap::Extras::hasMagic(
magic, static_cast<ssize_t>(bufferSize), magic, static_cast<ssize_t>(bufferSize),
Helper::fileIsExists(content) Helper::fileIsExists(content)

View File

@@ -21,130 +21,130 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#define INIT bool FUNCTION_CLASS::init(CLI::App &_app) #define INIT bool FUNCTION_CLASS::init(CLI::App& _app)
#define RUN bool FUNCTION_CLASS::run() #define RUN bool FUNCTION_CLASS::run()
#define RUN_ASYNC pair FUNCTION_CLASS::runAsync #define RUN_ASYNC pair FUNCTION_CLASS::runAsync
#define IS_USED bool FUNCTION_CLASS::isUsed() const #define IS_USED bool FUNCTION_CLASS::isUsed() const
#define IS_USED_COMMON_BODY \ #define IS_USED_COMMON_BODY \
bool FUNCTION_CLASS::isUsed() const { return cmd->parsed(); } bool FUNCTION_CLASS::isUsed() const { return cmd->parsed(); }
#define NAME const char *FUNCTION_CLASS::name() const #define NAME const char* FUNCTION_CLASS::name() const
/** /**
* Please define FUNCTION_CLASS before using these macros!!! (INIT etc.) * Please define FUNCTION_CLASS before using these macros!!! (INIT etc.)
*/ */
#define COMMON_FUNCTION_BODY() \ #define COMMON_FUNCTION_BODY() \
CLI::App *cmd = nullptr; \ CLI::App* cmd = nullptr; \
bool init(CLI::App &_app) override; \ bool init(CLI::App& _app) override; \
bool run() override; \ bool run() override; \
[[nodiscard]] bool isUsed() const override; \ [[nodiscard]] bool isUsed() const override; \
[[nodiscard]] const char *name() const override [[nodiscard]] const char* name() const override
namespace PartitionManager { namespace PartitionManager {
using pair = std::pair<std::string, bool>; using pair = std::pair<std::string, bool>;
// Back-up function // Back-up function
class backupFunction final : public FunctionBase { class backupFunction final : public FunctionBase {
private: private:
std::vector<std::string> partitions, outputNames; std::vector<std::string> partitions, outputNames;
std::string rawPartitions, rawOutputNames, outputDirectory; std::string rawPartitions, rawOutputNames, outputDirectory;
uint64_t bufferSize = 0; uint64_t bufferSize = 0;
public: public:
COMMON_FUNCTION_BODY(); COMMON_FUNCTION_BODY();
static pair runAsync(const std::string &partitionName, static pair runAsync(const std::string& partitionName,
const std::string &outputName, uint64_t bufferSize); const std::string& outputName, uint64_t bufferSize);
}; };
// Image flasher function // Image flasher function
class flashFunction final : public FunctionBase { class flashFunction final : public FunctionBase {
private: private:
std::vector<std::string> partitions, imageNames; std::vector<std::string> partitions, imageNames;
std::string rawPartitions, rawImageNames, imageDirectory; std::string rawPartitions, rawImageNames, imageDirectory;
uint64_t bufferSize = 0; uint64_t bufferSize = 0;
bool deleteAfterProgress = false; bool deleteAfterProgress = false;
public: public:
COMMON_FUNCTION_BODY(); COMMON_FUNCTION_BODY();
static pair runAsync(const std::string &partitionName, static pair runAsync(const std::string& partitionName,
const std::string &imageName, uint64_t bufferSize, const std::string& imageName, uint64_t bufferSize,
bool deleteAfterProgress); bool deleteAfterProgress);
}; };
// Eraser function (writes zero bytes to partition) // Eraser function (writes zero bytes to partition)
class eraseFunction final : public FunctionBase { class eraseFunction final : public FunctionBase {
private: private:
std::vector<std::string> partitions; std::vector<std::string> partitions;
uint64_t bufferSize = 0; uint64_t bufferSize = 0;
public: public:
COMMON_FUNCTION_BODY(); COMMON_FUNCTION_BODY();
static pair runAsync(const std::string &partitionName, uint64_t bufferSize); static pair runAsync(const std::string& partitionName, uint64_t bufferSize);
}; };
// Partition size getter function // Partition size getter function
class partitionSizeFunction final : public FunctionBase { class partitionSizeFunction final : public FunctionBase {
private: private:
std::vector<std::string> partitions; std::vector<std::string> partitions;
bool onlySize = false, asByte = false, asKiloBytes = false, asMega = false, bool onlySize = false, asByte = false, asKiloBytes = false, asMega = false,
asGiga = false; asGiga = false;
public: public:
COMMON_FUNCTION_BODY(); COMMON_FUNCTION_BODY();
}; };
// Partition info getter function // Partition info getter function
class infoFunction final : public FunctionBase { class infoFunction final : public FunctionBase {
private: private:
std::vector<std::string> partitions; std::vector<std::string> partitions;
std::string jNamePartition, jNameSize, jNameLogical; std::string jNamePartition, jNameSize, jNameLogical;
int jIndentSize = 2; int jIndentSize = 2;
bool jsonFormat = false, asByte = true, asKiloBytes = false, asMega = false, bool jsonFormat = false, asByte = true, asKiloBytes = false, asMega = false,
asGiga = false; asGiga = false;
public: public:
COMMON_FUNCTION_BODY(); COMMON_FUNCTION_BODY();
}; };
class realPathFunction final : public FunctionBase { class realPathFunction final : public FunctionBase {
private: private:
std::vector<std::string> partitions; std::vector<std::string> partitions;
bool realLinkPath = false; bool realLinkPath = false;
public: public:
COMMON_FUNCTION_BODY(); COMMON_FUNCTION_BODY();
}; };
class typeFunction final : public FunctionBase { class typeFunction final : public FunctionBase {
private: private:
std::vector<std::string> contents; std::vector<std::string> contents;
bool onlyCheckAndroidMagics = false, onlyCheckFileSystemMagics = false; bool onlyCheckAndroidMagics = false, onlyCheckFileSystemMagics = false;
uint64_t bufferSize = 0; uint64_t bufferSize = 0;
public: public:
COMMON_FUNCTION_BODY(); COMMON_FUNCTION_BODY();
}; };
class rebootFunction final : public FunctionBase { class rebootFunction final : public FunctionBase {
private: private:
std::string rebootTarget; std::string rebootTarget;
public: public:
COMMON_FUNCTION_BODY(); COMMON_FUNCTION_BODY();
}; };
class memoryTestFunction final : public FunctionBase { class memoryTestFunction final : public FunctionBase {
private: private:
uint64_t bufferSize = MB(4), /* bufferSizeRandom = KB(4),*/ testFileSize = 0; uint64_t bufferSize = MB(4), /* bufferSizeRandom = KB(4),*/ testFileSize = 0;
std::string testPath; std::string testPath;
bool doNotReadTest = false; bool doNotReadTest = false;
public: public:
COMMON_FUNCTION_BODY(); COMMON_FUNCTION_BODY();
}; };
class cleanLogFunction final : public FunctionBase { class cleanLogFunction final : public FunctionBase {
public: public:
COMMON_FUNCTION_BODY(); COMMON_FUNCTION_BODY();
}; };

View File

@@ -17,8 +17,9 @@
#ifndef LIBHELPER_LIB_HPP #ifndef LIBHELPER_LIB_HPP
#define LIBHELPER_LIB_HPP #define LIBHELPER_LIB_HPP
#include <cstdint>
#include <dirent.h> #include <dirent.h>
#include <cstdint>
#include <exception> #include <exception>
#include <functional> #include <functional>
#include <optional> #include <optional>
@@ -62,57 +63,59 @@ constexpr int NO = 0;
namespace Helper { namespace Helper {
// Throwable error class // Throwable error class
class Error final : public std::exception { class Error final : public std::exception {
private: private:
std::string _message; std::string _message;
std::ostringstream _oss; std::ostringstream _oss;
public: public:
__attribute__((format(printf, 2, 3))) explicit Error(const char *format, ...); __attribute__((format(printf, 2, 3))) explicit Error(const char* format, ...);
[[nodiscard]] const char *what() const noexcept override; [[nodiscard]] const char* what() const noexcept override;
}; };
// Logging // Logging
class Logger final { class Logger final {
private: private:
LogLevels _level; LogLevels _level;
std::ostringstream _oss; std::ostringstream _oss;
const char *_function_name, *_logFile, *_program_name, *_file; const char *_function_name, *_logFile, *_program_name, *_file;
int _line; int _line;
public: public:
Logger(LogLevels level, const char *func, const char *file, const char *name, Logger(LogLevels level, const char* func, const char* file, const char* name,
const char *source_file, int line); const char* source_file, int line);
~Logger(); ~Logger();
template <typename T> Logger &operator<<(const T &msg) { template <typename T>
Logger& operator<<(const T& msg) {
_oss << msg; _oss << msg;
return *this; return *this;
} }
Logger &operator<<(std::ostream &(*msg)(std::ostream &)); Logger& operator<<(std::ostream& (*msg)(std::ostream&));
}; };
// Close file descriptors and delete allocated array memory // Close file descriptors and delete allocated array memory
class garbageCollector { class garbageCollector {
private: private:
std::vector<std::function<void()>> _cleaners; std::vector<std::function<void()>> _cleaners;
std::vector<FILE *> _fps; std::vector<FILE*> _fps;
std::vector<DIR *> _dps; std::vector<DIR*> _dps;
std::vector<int> _fds; std::vector<int> _fds;
std::vector<std::string> _files; std::vector<std::string> _files;
public: public:
~garbageCollector(); ~garbageCollector();
template <typename T> void delAfterProgress(T *_ptr) { template <typename T>
void delAfterProgress(T* _ptr) {
_cleaners.push_back([_ptr] { delete[] _ptr; }); _cleaners.push_back([_ptr] { delete[] _ptr; });
} }
void delFileAfterProgress(const std::string &_path); void delFileAfterProgress(const std::string& _path);
void closeAfterProgress(FILE *_fp); void closeAfterProgress(FILE* _fp);
void closeAfterProgress(DIR *_dp); void closeAfterProgress(DIR* _dp);
void closeAfterProgress(int _fd); void closeAfterProgress(int _fd);
}; };
@@ -122,7 +125,7 @@ class Random {
static_assert(count > 1, "count is larger than 1"); static_assert(count > 1, "count is larger than 1");
static_assert(count <= max - start, "count is greater than max-start"); static_assert(count <= max - start, "count is greater than max-start");
public: public:
static std::set<int> get() { static std::set<int> get() {
std::set<int> set; std::set<int> set;
std::random_device rd; std::random_device rd;
@@ -130,12 +133,10 @@ public:
if constexpr (d > 0) { if constexpr (d > 0) {
std::uniform_int_distribution<> dist(0, (max - start - 1) / d); std::uniform_int_distribution<> dist(0, (max - start - 1) / d);
while (set.size() < count) while (set.size() < count) set.insert(start + dist(gen) * d);
set.insert(start + dist(gen) * d);
} else { } else {
std::uniform_int_distribution<> dist(start, max - 1); std::uniform_int_distribution<> dist(start, max - 1);
while (set.size() < count) while (set.size() < count) set.insert(dist(gen));
set.insert(dist(gen));
} }
return set; return set;
@@ -158,39 +159,39 @@ public:
} }
}; };
template <typename _Type1, typename _Type2, typename _Type3> class PureTuple { template <typename _Type1, typename _Type2, typename _Type3>
private: class PureTuple {
private:
void expand_if_needed() { void expand_if_needed() {
if (count == capacity) { if (count == capacity) {
capacity *= 2; capacity *= 2;
Data *data = new Data[capacity]; Data* data = new Data[capacity];
for (size_t i = 0; i < count; i++) for (size_t i = 0; i < count; i++) data[i] = tuple_data[i];
data[i] = tuple_data[i];
delete[] tuple_data; delete[] tuple_data;
tuple_data = data; tuple_data = data;
} }
} }
public: public:
struct Data { struct Data {
_Type1 first; _Type1 first;
_Type2 second; _Type2 second;
_Type3 third; _Type3 third;
bool bool operator==(
operator==(const std::tuple<_Type1, _Type2, _Type3> &t) const noexcept { const std::tuple<_Type1, _Type2, _Type3>& t) const noexcept {
return first == std::get<0>(t) && second == std::get<1>(t) && return first == std::get<0>(t) && second == std::get<1>(t) &&
third == std::get<2>(t); third == std::get<2>(t);
} }
bool operator==(const Data &other) const noexcept { bool operator==(const Data& other) const noexcept {
return first == other.first && second == other.second && return first == other.first && second == other.second &&
third == other.third; third == other.third;
} }
bool operator!=(const Data &other) const noexcept { bool operator!=(const Data& other) const noexcept {
return !(*this == other); return !(*this == other);
} }
@@ -200,13 +201,13 @@ public:
bool operator!() const noexcept { return !bool{*this}; } bool operator!() const noexcept { return !bool{*this}; }
void operator()(const std::tuple<_Type1, _Type2, _Type3> &t) { void operator()(const std::tuple<_Type1, _Type2, _Type3>& t) {
first = std::get<0>(t); first = std::get<0>(t);
second = std::get<1>(t); second = std::get<1>(t);
third = std::get<2>(t); third = std::get<2>(t);
} }
Data &operator=(const std::tuple<_Type1, _Type2, _Type3> &t) { Data& operator=(const std::tuple<_Type1, _Type2, _Type3>& t) {
first = std::get<0>(t); first = std::get<0>(t);
second = std::get<1>(t); second = std::get<1>(t);
third = std::get<2>(t); third = std::get<2>(t);
@@ -214,7 +215,7 @@ public:
} }
}; };
Data *tuple_data = nullptr; Data* tuple_data = nullptr;
Data tuple_data_type = {_Type1{}, _Type2{}, _Type3{}}; Data tuple_data_type = {_Type1{}, _Type2{}, _Type3{}};
size_t capacity{}, count{}; size_t capacity{}, count{};
@@ -223,16 +224,17 @@ public:
PureTuple(std::initializer_list<Data> val) PureTuple(std::initializer_list<Data> val)
: tuple_data(new Data[20]), capacity(20), count(0) { : tuple_data(new Data[20]), capacity(20), count(0) {
for (const auto &v : val) for (const auto& v : val) insert(v);
insert(v);
} }
PureTuple(PureTuple &other) PureTuple(PureTuple& other)
: tuple_data(new Data[other.capacity]), capacity(other.capacity), : tuple_data(new Data[other.capacity]),
capacity(other.capacity),
count(other.count) { count(other.count) {
std::copy(other.tuple_data, other.tuple_data + count, tuple_data); std::copy(other.tuple_data, other.tuple_data + count, tuple_data);
} }
PureTuple(PureTuple &&other) noexcept PureTuple(PureTuple&& other) noexcept
: tuple_data(new Data[other.capacity]), capacity(other.capacity), : tuple_data(new Data[other.capacity]),
capacity(other.capacity),
count(other.count) { count(other.count) {
std::copy(other.tuple_data, other.tuple_data + count, tuple_data); std::copy(other.tuple_data, other.tuple_data + count, tuple_data);
other.clear(); other.clear();
@@ -240,21 +242,21 @@ public:
class iterator { class iterator {
private: private:
Data *it; Data* it;
public: public:
using iterator_category = std::random_access_iterator_tag; using iterator_category = std::random_access_iterator_tag;
using value_type = Data; using value_type = Data;
using difference_type = std::ptrdiff_t; using difference_type = std::ptrdiff_t;
using pointer = Data *; using pointer = Data*;
using reference = Data &; using reference = Data&;
explicit iterator(Data *ptr) : it(ptr) {} explicit iterator(Data* ptr) : it(ptr) {}
pointer operator->() const { return it; } pointer operator->() const { return it; }
reference operator*() { return *it; } reference operator*() { return *it; }
iterator &operator++() { iterator& operator++() {
++it; ++it;
return *this; return *this;
} }
@@ -263,7 +265,7 @@ public:
++(*this); ++(*this);
return tmp; return tmp;
} }
iterator &operator--() { iterator& operator--() {
--it; --it;
return *this; return *this;
} }
@@ -273,32 +275,32 @@ public:
return tmp; return tmp;
} }
iterator &operator+=(difference_type n) { iterator& operator+=(difference_type n) {
it += n; it += n;
return *this; return *this;
} }
iterator operator+(difference_type n) const { return iterator(it + n); } iterator operator+(difference_type n) const { return iterator(it + n); }
iterator &operator-=(difference_type n) { iterator& operator-=(difference_type n) {
it -= n; it -= n;
return *this; return *this;
} }
iterator operator-(difference_type n) const { return iterator(it - n); } iterator operator-(difference_type n) const { return iterator(it - n); }
difference_type operator-(const iterator &other) const { difference_type operator-(const iterator& other) const {
return it - other.it; return it - other.it;
} }
reference operator[](difference_type n) const { return it[n]; } reference operator[](difference_type n) const { return it[n]; }
bool operator<(const iterator &other) const { return it < other.it; } bool operator<(const iterator& other) const { return it < other.it; }
bool operator>(const iterator &other) const { return it > other.it; } bool operator>(const iterator& other) const { return it > other.it; }
bool operator<=(const iterator &other) const { return it <= other.it; } bool operator<=(const iterator& other) const { return it <= other.it; }
bool operator>=(const iterator &other) const { return it >= other.it; } bool operator>=(const iterator& other) const { return it >= other.it; }
bool operator!=(const iterator &other) const { return it != other.it; } bool operator!=(const iterator& other) const { return it != other.it; }
bool operator==(const iterator &other) const { return it == other.it; } bool operator==(const iterator& other) const { return it == other.it; }
}; };
bool find(const Data &data) const noexcept { bool find(const Data& data) const noexcept {
for (size_t i = 0; i < count; i++) for (size_t i = 0; i < count; i++)
if (data == tuple_data[i]) return true; if (data == tuple_data[i]) return true;
@@ -307,51 +309,50 @@ public:
template <typename T = std::tuple<_Type1, _Type2, _Type3>> template <typename T = std::tuple<_Type1, _Type2, _Type3>>
std::enable_if_t<std::is_same_v<T, std::tuple<_Type1, _Type2, _Type3>>, bool> std::enable_if_t<std::is_same_v<T, std::tuple<_Type1, _Type2, _Type3>>, bool>
find(const std::tuple<_Type1, _Type2, _Type3> &t) const noexcept { find(const std::tuple<_Type1, _Type2, _Type3>& t) const noexcept {
for (size_t i = 0; i < count; i++) for (size_t i = 0; i < count; i++)
if (tuple_data[i] == t) return true; if (tuple_data[i] == t) return true;
return false; return false;
} }
bool find(const _Type1 &val, const _Type2 &val2, bool find(const _Type1& val, const _Type2& val2,
const _Type3 &val3) const noexcept { const _Type3& val3) const noexcept {
for (size_t i = 0; i < count; i++) for (size_t i = 0; i < count; i++)
if (tuple_data[i] == std::make_tuple(val, val2, val3)) return true; if (tuple_data[i] == std::make_tuple(val, val2, val3)) return true;
return false; return false;
} }
void insert(const Data &val) noexcept { void insert(const Data& val) noexcept {
expand_if_needed(); expand_if_needed();
if (!find(val)) tuple_data[count++] = val; if (!find(val)) tuple_data[count++] = val;
} }
template <typename T = std::tuple<_Type1, _Type2, _Type3>> template <typename T = std::tuple<_Type1, _Type2, _Type3>>
std::enable_if_t<std::is_same_v<T, std::tuple<_Type1, _Type2, _Type3>>, void> std::enable_if_t<std::is_same_v<T, std::tuple<_Type1, _Type2, _Type3>>, void>
insert(const std::tuple<_Type1, _Type2, _Type3> &t) noexcept { insert(const std::tuple<_Type1, _Type2, _Type3>& t) noexcept {
expand_if_needed(); expand_if_needed();
if (!find(t)) if (!find(t))
tuple_data[count++] = tuple_data[count++] =
Data{std::get<0>(t), std::get<1>(t), std::get<2>(t)}; Data{std::get<0>(t), std::get<1>(t), std::get<2>(t)};
} }
void insert(const _Type1 &val, const _Type2 &val2, void insert(const _Type1& val, const _Type2& val2,
const _Type3 &val3) noexcept { const _Type3& val3) noexcept {
expand_if_needed(); expand_if_needed();
if (!find(val, val2, val3)) tuple_data[count++] = Data{val, val2, val3}; if (!find(val, val2, val3)) tuple_data[count++] = Data{val, val2, val3};
} }
void merge(const PureTuple &other) noexcept { void merge(const PureTuple& other) noexcept {
for (const auto &v : other) for (const auto& v : other) insert(v);
insert(v);
} }
void pop_back() noexcept { void pop_back() noexcept {
if (count > 0) --count; if (count > 0) --count;
} }
void pop(const Data &data) noexcept { void pop(const Data& data) noexcept {
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
if (tuple_data[i] == data) { if (tuple_data[i] == data) {
for (size_t j = i; j < count - 1; j++) for (size_t j = i; j < count - 1; j++)
@@ -374,7 +375,7 @@ public:
} }
} }
void pop(const _Type1 &val, const _Type2 &val2, const _Type3 &val3) noexcept { void pop(const _Type1& val, const _Type2& val2, const _Type3& val3) noexcept {
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
if (tuple_data[i] == std::make_tuple(val, val2, val3)) { if (tuple_data[i] == std::make_tuple(val, val2, val3)) {
for (size_t j = i; j < count - 1; j++) for (size_t j = i; j < count - 1; j++)
@@ -387,7 +388,7 @@ public:
template <typename T = std::tuple<_Type1, _Type2, _Type3>> template <typename T = std::tuple<_Type1, _Type2, _Type3>>
std::enable_if_t<std::is_same_v<T, std::tuple<_Type1, _Type2, _Type3>>, void> std::enable_if_t<std::is_same_v<T, std::tuple<_Type1, _Type2, _Type3>>, void>
pop(const std::tuple<_Type1, _Type2, _Type3> &t) noexcept { pop(const std::tuple<_Type1, _Type2, _Type3>& t) noexcept {
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
if (tuple_data[i] == t) { if (tuple_data[i] == t) {
for (size_t j = i; j < count - 1; j++) for (size_t j = i; j < count - 1; j++)
@@ -435,7 +436,7 @@ public:
explicit operator bool() const noexcept { return count > 0; } explicit operator bool() const noexcept { return count > 0; }
bool operator!() const noexcept { return count == 0; } bool operator!() const noexcept { return count == 0; }
bool operator==(const PureTuple &other) const noexcept { bool operator==(const PureTuple& other) const noexcept {
if (this->count != other.count || this->capacity != other.capacity) if (this->count != other.count || this->capacity != other.capacity)
return false; return false;
@@ -444,7 +445,7 @@ public:
return true; return true;
} }
bool operator!=(const PureTuple &other) const noexcept { bool operator!=(const PureTuple& other) const noexcept {
return !(*this == other); return !(*this == other);
} }
@@ -454,7 +455,7 @@ public:
} }
explicit operator int() const noexcept { return count; } explicit operator int() const noexcept { return count; }
PureTuple &operator=(const PureTuple &other) { PureTuple& operator=(const PureTuple& other) {
if (this != &other) { if (this != &other) {
delete[] tuple_data; delete[] tuple_data;
@@ -468,70 +469,71 @@ public:
return *this; return *this;
} }
PureTuple &operator<<(const std::tuple<_Type1, _Type2, _Type3> &t) noexcept { PureTuple& operator<<(const std::tuple<_Type1, _Type2, _Type3>& t) noexcept {
insert(t); insert(t);
return *this; return *this;
} }
friend PureTuple &operator>>(const std::tuple<_Type1, _Type2, _Type3> &t, friend PureTuple& operator>>(const std::tuple<_Type1, _Type2, _Type3>& t,
PureTuple &tuple) noexcept { PureTuple& tuple) noexcept {
tuple.insert(t); tuple.insert(t);
return tuple; return tuple;
} }
}; };
// Provides a capsule structure to store variable references and values. // Provides a capsule structure to store variable references and values.
template <typename _Type> class Capsule : public garbageCollector { template <typename _Type>
public: class Capsule : public garbageCollector {
_Type &value; public:
_Type& value;
// The value to be stored is taken as a reference as an argument // The value to be stored is taken as a reference as an argument
explicit Capsule(_Type &value) noexcept : value(value) {} explicit Capsule(_Type& value) noexcept : value(value) {}
// Set the value. // Set the value.
void set(const _Type &_value) noexcept { this->value = _value; } void set(const _Type& _value) noexcept { this->value = _value; }
void set(_Type &_value) noexcept { this->value = _value; } void set(_Type& _value) noexcept { this->value = _value; }
// Get reference of the value. // Get reference of the value.
_Type &get() noexcept { return this->value; } _Type& get() noexcept { return this->value; }
const _Type &get() const noexcept { return this->value; } const _Type& get() const noexcept { return this->value; }
// You can get the reference of the stored value in the input type (casting is // You can get the reference of the stored value in the input type (casting is
// required). // required).
operator _Type &() noexcept { return this->value; } operator _Type&() noexcept { return this->value; }
operator const _Type &() const noexcept { return this->value; } operator const _Type&() const noexcept { return this->value; }
explicit operator _Type *() noexcept { return &this->value; } explicit operator _Type*() noexcept { return &this->value; }
// The value of another capsule is taken. // The value of another capsule is taken.
Capsule &operator=(const Capsule &other) noexcept { Capsule& operator=(const Capsule& other) noexcept {
this->value = other.value; this->value = other.value;
return *this; return *this;
} }
// Assign another value. // Assign another value.
Capsule &operator=(const _Type &_value) noexcept { Capsule& operator=(const _Type& _value) noexcept {
this->value = _value; this->value = _value;
return *this; return *this;
} }
// Check if this capsule and another capsule hold the same data. // Check if this capsule and another capsule hold the same data.
bool operator==(const Capsule &other) const noexcept { bool operator==(const Capsule& other) const noexcept {
return this->value == other.value; return this->value == other.value;
} }
// Check if this capsule value and another capsule value hold the same data. // Check if this capsule value and another capsule value hold the same data.
bool operator==(const _Type &_value) const noexcept { bool operator==(const _Type& _value) const noexcept {
return this->value == _value; return this->value == _value;
} }
// Check that this capsule and another capsule do not hold the same data. // Check that this capsule and another capsule do not hold the same data.
bool operator!=(const Capsule &other) const noexcept { bool operator!=(const Capsule& other) const noexcept {
return !(*this == other); return !(*this == other);
} }
// Check that this capsule value and another capsule value do not hold the // Check that this capsule value and another capsule value do not hold the
// same data. // same data.
bool operator!=(const _Type &_value) const noexcept { bool operator!=(const _Type& _value) const noexcept {
return !(*this == _value); return !(*this == _value);
} }
@@ -542,17 +544,17 @@ public:
bool operator!() const noexcept { return this->value == _Type{}; } bool operator!() const noexcept { return this->value == _Type{}; }
// Change the value with the input operator. // Change the value with the input operator.
friend Capsule &operator>>(const _Type &_value, Capsule &_capsule) noexcept { friend Capsule& operator>>(const _Type& _value, Capsule& _capsule) noexcept {
_capsule.value = _value; _capsule.value = _value;
return _capsule; return _capsule;
} }
// Get the reference of the value held. // Get the reference of the value held.
_Type &operator()() noexcept { return value; } _Type& operator()() noexcept { return value; }
const _Type &operator()() const noexcept { return value; } const _Type& operator()() const noexcept { return value; }
// Set the value. // Set the value.
void operator()(const _Type &_value) noexcept { this->value = _value; } void operator()(const _Type& _value) noexcept { this->value = _value; }
}; };
namespace LoggingProperties { namespace LoggingProperties {
@@ -563,13 +565,19 @@ void set(std::string_view name, std::string_view file);
void setProgramName(std::string_view name); void setProgramName(std::string_view name);
void setLogFile(std::string_view file); void setLogFile(std::string_view file);
template <int state> void setPrinting() { template <int state>
if (state == 1 || state == 0) PRINT = state; void setPrinting() {
else PRINT = NO; if (state == 1 || state == 0)
PRINT = state;
else
PRINT = NO;
} }
template <int state> void setLoggingState() { template <int state>
if (state == 1 || state == 0) DISABLE = state; void setLoggingState() {
else DISABLE = NO; if (state == 1 || state == 0)
DISABLE = state;
else
DISABLE = NO;
} }
void reset(); void reset();
@@ -803,13 +811,14 @@ std::string multipleToString(sizeCastTypes type);
/** /**
* Format it input and return as std::string. * Format it input and return as std::string.
*/ */
__attribute__((format(printf, 1, 2))) std::string format(const char *format, __attribute__((format(printf, 1, 2))) std::string format(const char* format,
...); ...);
/** /**
* Convert input size to input multiple * Convert input size to input multiple
*/ */
template <uint64_t size> int convertTo(const sizeCastTypes type) { template <uint64_t size>
int convertTo(const sizeCastTypes type) {
if (type == KB) return TO_KB(size); if (type == KB) return TO_KB(size);
if (type == MB) return TO_MB(size); if (type == MB) return TO_MB(size);
if (type == GB) return TO_GB(size); if (type == GB) return TO_GB(size);
@@ -840,22 +849,22 @@ std::string getLibVersion();
* Open input path with flags and add to integrity list. * Open input path with flags and add to integrity list.
* And returns file descriptor. * And returns file descriptor.
*/ */
[[nodiscard]] int openAndAddToCloseList(const std::string_view &path, [[nodiscard]] int openAndAddToCloseList(const std::string_view& path,
garbageCollector &collector, int flags, garbageCollector& collector, int flags,
mode_t mode = 0000); mode_t mode = 0000);
/** /**
* Open input path with flags and add to integrity list. * Open input path with flags and add to integrity list.
* And returns file pointer. * And returns file pointer.
*/ */
[[nodiscard]] FILE *openAndAddToCloseList(const std::string_view &path, [[nodiscard]] FILE* openAndAddToCloseList(const std::string_view& path,
garbageCollector &collector, garbageCollector& collector,
const char *mode); const char* mode);
/** /**
* Open input directory and add to integrity list. * Open input directory and add to integrity list.
* And returns directory pointer. * And returns directory pointer.
*/ */
[[nodiscard]] DIR *openAndAddToCloseList(const std::string_view &path, [[nodiscard]] DIR* openAndAddToCloseList(const std::string_view& path,
garbageCollector &collector); garbageCollector& collector);
} // namespace Helper } // namespace Helper

View File

@@ -14,13 +14,14 @@
limitations under the License. limitations under the License.
*/ */
#include <cstdio>
#include <cstdlib>
#include <libhelper/lib.hpp>
#include <private/android_filesystem_config.h> #include <private/android_filesystem_config.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <cstdio>
#include <cstdlib>
#include <libhelper/lib.hpp>
namespace Helper { namespace Helper {
bool hasSuperUser() { return (getuid() == AID_ROOT); } bool hasSuperUser() { return (getuid() == AID_ROOT); }
bool hasAdbPermissions() { return (getuid() == AID_SHELL); } bool hasAdbPermissions() { return (getuid() == AID_SHELL); }

View File

@@ -14,22 +14,23 @@
limitations under the License. limitations under the License.
*/ */
#include <dirent.h>
#include <fcntl.h>
#include <libgen.h>
#include <unistd.h>
#include <cerrno> #include <cerrno>
#include <cstdarg> #include <cstdarg>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <dirent.h>
#include <exception> #include <exception>
#include <fcntl.h>
#include <functional> #include <functional>
#include <libgen.h>
#include <libhelper/lib.hpp> #include <libhelper/lib.hpp>
#include <sstream> #include <sstream>
#include <unistd.h>
namespace Helper { namespace Helper {
Error::Error(const char *format, ...) { Error::Error(const char* format, ...) {
char buf[1024]; char buf[1024];
va_list args; va_list args;
va_start(args, format); va_start(args, format);
@@ -39,19 +40,23 @@ Error::Error(const char *format, ...) {
LOGN(HELPER, ERROR) << _message << std::endl; LOGN(HELPER, ERROR) << _message << std::endl;
} }
const char *Error::what() const noexcept { return _message.data(); } const char* Error::what() const noexcept { return _message.data(); }
Logger::Logger(const LogLevels level, const char *func, const char *file, Logger::Logger(const LogLevels level, const char* func, const char* file,
const char *name, const char *source_file, const int line) const char* name, const char* source_file, const int line)
: _level(level), _function_name(func), _logFile(file), _program_name(name), : _level(level),
_file(source_file), _line(line) {} _function_name(func),
_logFile(file),
_program_name(name),
_file(source_file),
_line(line) {}
Logger::~Logger() { Logger::~Logger() {
if (LoggingProperties::DISABLE) return; if (LoggingProperties::DISABLE) return;
char str[1024]; char str[1024];
snprintf(str, sizeof(str), "<%c> [ <prog %s> <on %s:%d> %s %s] %s(): %s", snprintf(str, sizeof(str), "<%c> [ <prog %s> <on %s:%d> %s %s] %s(): %s",
static_cast<char>(_level), _program_name, static_cast<char>(_level), _program_name,
basename(const_cast<char *>(_file)), _line, currentDate().data(), basename(const_cast<char*>(_file)), _line, currentDate().data(),
currentTime().data(), _function_name, _oss.str().data()); currentTime().data(), _function_name, _oss.str().data());
if (!isExists(_logFile)) { if (!isExists(_logFile)) {
@@ -76,7 +81,7 @@ Logger::~Logger() {
} }
} }
if (FILE *fp = fopen(_logFile, "a"); fp != nullptr) { if (FILE* fp = fopen(_logFile, "a"); fp != nullptr) {
fprintf(fp, "%s", str); fprintf(fp, "%s", str);
fclose(fp); fclose(fp);
} else { } else {
@@ -91,30 +96,25 @@ Logger::~Logger() {
if (LoggingProperties::PRINT) printf("%s", str); if (LoggingProperties::PRINT) printf("%s", str);
} }
Logger &Logger::operator<<(std::ostream &(*msg)(std::ostream &)) { Logger& Logger::operator<<(std::ostream& (*msg)(std::ostream&)) {
_oss << msg; _oss << msg;
return *this; return *this;
} }
garbageCollector::~garbageCollector() { garbageCollector::~garbageCollector() {
for (auto &ptr_func : _cleaners) for (auto& ptr_func : _cleaners) ptr_func();
ptr_func(); for (const auto& fd : _fds) close(fd);
for (const auto &fd : _fds) for (const auto& fp : _fps) fclose(fp);
close(fd); for (const auto& dp : _dps) closedir(dp);
for (const auto &fp : _fps) for (const auto& file : _files) eraseEntry(file);
fclose(fp);
for (const auto &dp : _dps)
closedir(dp);
for (const auto &file : _files)
eraseEntry(file);
} }
void garbageCollector::delFileAfterProgress(const std::string &_path) { void garbageCollector::delFileAfterProgress(const std::string& _path) {
_files.push_back(_path); _files.push_back(_path);
} }
void garbageCollector::closeAfterProgress(const int _fd) { void garbageCollector::closeAfterProgress(const int _fd) {
_fds.push_back(_fd); _fds.push_back(_fd);
} }
void garbageCollector::closeAfterProgress(FILE *_fp) { _fps.push_back(_fp); } void garbageCollector::closeAfterProgress(FILE* _fp) { _fps.push_back(_fp); }
void garbageCollector::closeAfterProgress(DIR *_dp) { _dps.push_back(_dp); } void garbageCollector::closeAfterProgress(DIR* _dp) { _dps.push_back(_dp); }
} // namespace Helper } // namespace Helper

View File

@@ -14,16 +14,17 @@
limitations under the License. limitations under the License.
*/ */
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <cerrno> #include <cerrno>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <dirent.h>
#include <fcntl.h>
#include <libhelper/lib.hpp> #include <libhelper/lib.hpp>
#include <string> #include <string>
#include <sys/stat.h>
#include <unistd.h>
namespace Helper { namespace Helper {
bool writeFile(const std::string_view file, const std::string_view text) { bool writeFile(const std::string_view file, const std::string_view text) {
@@ -31,7 +32,7 @@ bool writeFile(const std::string_view file, const std::string_view text) {
<< std::endl; << std::endl;
garbageCollector collector; garbageCollector collector;
FILE *fp = openAndAddToCloseList(file, collector, "a"); FILE* fp = openAndAddToCloseList(file, collector, "a");
if (fp == nullptr) return false; if (fp == nullptr) return false;
fprintf(fp, "%s", text.data()); fprintf(fp, "%s", text.data());
@@ -43,13 +44,12 @@ std::optional<std::string> readFile(const std::string_view file) {
LOGN(HELPER, INFO) << "read " << file << " requested." << std::endl; LOGN(HELPER, INFO) << "read " << file << " requested." << std::endl;
garbageCollector collector; garbageCollector collector;
FILE *fp = openAndAddToCloseList(file, collector, "r"); FILE* fp = openAndAddToCloseList(file, collector, "r");
if (fp == nullptr) return std::nullopt; if (fp == nullptr) return std::nullopt;
char buffer[1024]; char buffer[1024];
std::string str; std::string str;
while (fgets(buffer, sizeof(buffer), fp)) while (fgets(buffer, sizeof(buffer), fp)) str += buffer;
str += buffer;
LOGN(HELPER, INFO) << "read " << file << " successfully, read text: \"" << str LOGN(HELPER, INFO) << "read " << file << " successfully, read text: \"" << str
<< "\"" << std::endl; << "\"" << std::endl;
@@ -95,7 +95,7 @@ bool makeRecursiveDirectory(const std::string_view paths) {
snprintf(tmp, sizeof(tmp), "%s", paths.data()); snprintf(tmp, sizeof(tmp), "%s", paths.data());
if (const size_t len = strlen(tmp); tmp[len - 1] == '/') tmp[len - 1] = '\0'; if (const size_t len = strlen(tmp); tmp[len - 1] == '/') tmp[len - 1] = '\0';
for (char *p = tmp + 1; *p; p++) { for (char* p = tmp + 1; *p; p++) {
if (*p == '/') { if (*p == '/') {
*p = '\0'; *p = '\0';
if (access(tmp, F_OK) != 0) { if (access(tmp, F_OK) != 0) {
@@ -150,10 +150,10 @@ bool eraseEntry(const std::string_view entry) {
bool eraseDirectoryRecursive(const std::string_view directory) { bool eraseDirectoryRecursive(const std::string_view directory) {
LOGN(HELPER, INFO) << "erase recursive requested: " << directory << std::endl; LOGN(HELPER, INFO) << "erase recursive requested: " << directory << std::endl;
struct stat buf{}; struct stat buf{};
dirent *entry; dirent* entry;
garbageCollector collector; garbageCollector collector;
DIR *dir = openAndAddToCloseList(directory.data(), collector); DIR* dir = openAndAddToCloseList(directory.data(), collector);
if (dir == nullptr) return false; if (dir == nullptr) return false;
while ((entry = readdir(dir)) != nullptr) { while ((entry = readdir(dir)) != nullptr) {

View File

@@ -14,13 +14,14 @@
limitations under the License. limitations under the License.
*/ */
#include <picosha2.h>
#include <sys/stat.h>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <libhelper/lib.hpp> #include <libhelper/lib.hpp>
#include <optional> #include <optional>
#include <picosha2.h>
#include <string> #include <string>
#include <sys/stat.h>
#include <vector> #include <vector>
namespace Helper { namespace Helper {

View File

@@ -14,35 +14,38 @@
limitations under the License. limitations under the License.
*/ */
#include <cutils/android_reboot.h>
#include <fcntl.h>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <ctime> #include <ctime>
#include <cutils/android_reboot.h>
#include <fcntl.h>
#ifndef ANDROID_BUILD #ifndef ANDROID_BUILD
#include <generated/buildInfo.hpp>
#include <sys/_system_properties.h> #include <sys/_system_properties.h>
#include <generated/buildInfo.hpp>
#else #else
#include <sys/system_properties.h> #include <sys/system_properties.h>
#endif #endif
#include <cstdarg>
#include <cutils/android_reboot.h> #include <cutils/android_reboot.h>
#include <iostream>
#include <libgen.h> #include <libgen.h>
#include <libhelper/lib.hpp>
#include <memory>
#include <string>
#include <string_view>
#include <sys/_system_properties.h> #include <sys/_system_properties.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <cstdarg>
#include <iostream>
#include <libhelper/lib.hpp>
#include <memory>
#include <string>
#include <string_view>
#ifdef __ANDROID__ #ifdef __ANDROID__
// From system/core/libcutils/android_reboot.cpp android16-s2-release // From system/core/libcutils/android_reboot.cpp android16-s2-release
int android_reboot(const unsigned cmd, int /*flags*/, const char *arg) { int android_reboot(const unsigned cmd, int /*flags*/, const char* arg) {
int ret; int ret;
const char *restart_cmd = nullptr; const char* restart_cmd = nullptr;
char *prop_value; char* prop_value;
switch (cmd) { switch (cmd) {
case ANDROID_RB_RESTART: // deprecated case ANDROID_RB_RESTART: // deprecated
@@ -58,8 +61,10 @@ int android_reboot(const unsigned cmd, int /*flags*/, const char *arg) {
} }
if (!restart_cmd) return -1; if (!restart_cmd) return -1;
if (arg && arg[0]) ret = asprintf(&prop_value, "%s,%s", restart_cmd, arg); if (arg && arg[0])
else ret = asprintf(&prop_value, "%s", restart_cmd); ret = asprintf(&prop_value, "%s,%s", restart_cmd, arg);
else
ret = asprintf(&prop_value, "%s", restart_cmd);
if (ret < 0) return -1; if (ret < 0) return -1;
ret = __system_property_set(ANDROID_RB_PROPERTY, prop_value); ret = __system_property_set(ANDROID_RB_PROPERTY, prop_value);
@@ -116,7 +121,7 @@ std::string currentWorkingDirectory() {
std::string currentDate() { std::string currentDate() {
const time_t t = time(nullptr); const time_t t = time(nullptr);
if (const tm *date = localtime(&t)) if (const tm* date = localtime(&t))
return std::string(std::to_string(date->tm_mday) + "/" + return std::string(std::to_string(date->tm_mday) + "/" +
std::to_string(date->tm_mon + 1) + "/" + std::to_string(date->tm_mon + 1) + "/" +
std::to_string(date->tm_year + 1900)); std::to_string(date->tm_year + 1900));
@@ -126,7 +131,7 @@ std::string currentDate() {
std::string currentTime() { std::string currentTime() {
const time_t t = time(nullptr); const time_t t = time(nullptr);
if (const tm *date = localtime(&t)) if (const tm* date = localtime(&t))
return std::string(std::to_string(date->tm_hour) + ":" + return std::string(std::to_string(date->tm_hour) + ":" +
std::to_string(date->tm_min) + ":" + std::to_string(date->tm_min) + ":" +
std::to_string(date->tm_sec)); std::to_string(date->tm_sec));
@@ -137,7 +142,7 @@ std::pair<std::string, int> runCommandWithOutput(const std::string_view cmd) {
LOGN(HELPER, INFO) << "run command and catch out request: " << cmd LOGN(HELPER, INFO) << "run command and catch out request: " << cmd
<< std::endl; << std::endl;
FILE *pipe = popen(cmd.data(), "r"); FILE* pipe = popen(cmd.data(), "r");
if (!pipe) return {}; if (!pipe) return {};
std::unique_ptr<FILE, decltype(&pclose)> pipe_holder(pipe, pclose); std::unique_ptr<FILE, decltype(&pclose)> pipe_holder(pipe, pclose);
@@ -148,7 +153,7 @@ std::pair<std::string, int> runCommandWithOutput(const std::string_view cmd) {
while (fgets(buffer, sizeof(buffer), pipe_holder.get()) != nullptr) while (fgets(buffer, sizeof(buffer), pipe_holder.get()) != nullptr)
output += buffer; output += buffer;
FILE *raw = pipe_holder.release(); FILE* raw = pipe_holder.release();
const int status = pclose(raw); const int status = pclose(raw);
return {output, (WIFEXITED(status) ? WEXITSTATUS(status) : -1)}; return {output, (WIFEXITED(status) ? WEXITSTATUS(status) : -1)};
} }
@@ -161,12 +166,12 @@ std::string pathJoin(std::string base, std::string relative) {
} }
std::string pathBasename(const std::string_view entry) { std::string pathBasename(const std::string_view entry) {
char *base = basename(const_cast<char *>(entry.data())); char* base = basename(const_cast<char*>(entry.data()));
return (base == nullptr) ? std::string() : std::string(base); return (base == nullptr) ? std::string() : std::string(base);
} }
std::string pathDirname(const std::string_view entry) { std::string pathDirname(const std::string_view entry) {
char *base = dirname(const_cast<char *>(entry.data())); char* base = dirname(const_cast<char*>(entry.data()));
return (base == nullptr) ? std::string() : std::string(base); return (base == nullptr) ? std::string() : std::string(base);
} }
@@ -183,8 +188,8 @@ bool changeOwner(const std::string_view file, const uid_t uid,
return chown(file.data(), uid, gid) == 0; return chown(file.data(), uid, gid) == 0;
} }
int openAndAddToCloseList(const std::string_view &path, int openAndAddToCloseList(const std::string_view& path,
garbageCollector &collector, const int flags, garbageCollector& collector, const int flags,
const mode_t mode) { const mode_t mode) {
const int fd = const int fd =
mode == 0 ? open(path.data(), flags) : open(path.data(), flags, mode); mode == 0 ? open(path.data(), flags) : open(path.data(), flags, mode);
@@ -192,16 +197,16 @@ int openAndAddToCloseList(const std::string_view &path,
return fd; return fd;
} }
FILE *openAndAddToCloseList(const std::string_view &path, FILE* openAndAddToCloseList(const std::string_view& path,
garbageCollector &collector, const char *mode) { garbageCollector& collector, const char* mode) {
FILE *fp = fopen(path.data(), mode); FILE* fp = fopen(path.data(), mode);
collector.closeAfterProgress(fp); collector.closeAfterProgress(fp);
return fp; return fp;
} }
DIR *openAndAddToCloseList(const std::string_view &path, DIR* openAndAddToCloseList(const std::string_view& path,
garbageCollector &collector) { garbageCollector& collector) {
DIR *dp = opendir(path.data()); DIR* dp = opendir(path.data());
collector.closeAfterProgress(dp); collector.closeAfterProgress(dp);
return dp; return dp;
} }
@@ -247,7 +252,7 @@ std::string multipleToString(const sizeCastTypes type) {
return "B"; return "B";
} }
std::string format(const char *format, ...) { std::string format(const char* format, ...) {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
char str[1024]; char str[1024];

View File

@@ -19,14 +19,14 @@
#include <iostream> #include <iostream>
#include <libhelper/lib.hpp> #include <libhelper/lib.hpp>
char *TEST_DIR = nullptr; char* TEST_DIR = nullptr;
std::string test_path(const char *file) { std::string test_path(const char* file) {
std::string end = std::string(TEST_DIR) + "/" + file; std::string end = std::string(TEST_DIR) + "/" + file;
return end; return end;
} }
int main(int argc, char **argv) { int main(int argc, char** argv) {
if (argc < 2) return 2; if (argc < 2) return 2;
TEST_DIR = argv[1]; TEST_DIR = argv[1];
@@ -51,11 +51,13 @@ int main(int argc, char **argv) {
if (!Helper::writeFile("file.txt", "hello world")) if (!Helper::writeFile("file.txt", "hello world"))
throw Helper::Error("Cannot write \"hello world\" in 'file.txt'"); throw Helper::Error("Cannot write \"hello world\" in 'file.txt'");
else std::cout << "file.txt writed." << std::endl; else
std::cout << "file.txt writed." << std::endl;
if (const auto content = Helper::readFile("file.txt"); !content) if (const auto content = Helper::readFile("file.txt"); !content)
throw Helper::Error("Cannot read 'file.txt'"); throw Helper::Error("Cannot read 'file.txt'");
else std::cout << "'file.txt': " << *content << std::endl; else
std::cout << "'file.txt': " << *content << std::endl;
std::cout << "Making directory 'dir2': " << std::boolalpha std::cout << "Making directory 'dir2': " << std::boolalpha
<< Helper::makeDirectory(test_path("dir2")) << std::endl; << Helper::makeDirectory(test_path("dir2")) << std::endl;
@@ -80,7 +82,8 @@ int main(int argc, char **argv) {
if (const auto sha256 = Helper::sha256Of(test_path("file2.txt")); !sha256) if (const auto sha256 = Helper::sha256Of(test_path("file2.txt")); !sha256)
throw Helper::Error("Cannot get sha256 of 'file2.txt'"); throw Helper::Error("Cannot get sha256 of 'file2.txt'");
else std::cout << "SHA256 of 'file2.txt': " << *sha256 << std::endl; else
std::cout << "SHA256 of 'file2.txt': " << *sha256 << std::endl;
std::cout << "'file2.txt' and 'file2lnk.txt' same? (SHA256): " std::cout << "'file2.txt' and 'file2lnk.txt' same? (SHA256): "
<< std::boolalpha << std::boolalpha
@@ -130,7 +133,7 @@ int main(int argc, char **argv) {
std::cout << "pure tuple test: " << std::boolalpha std::cout << "pure tuple test: " << std::boolalpha
<< static_cast<bool>(values.at(0)) << std::endl; << static_cast<bool>(values.at(0)) << std::endl;
for (const auto &[x, y, z] : values) { for (const auto& [x, y, z] : values) {
std::cout << std::boolalpha << "(" << x << ", " << y << ", " << z << ")" std::cout << std::boolalpha << "(" << x << ", " << y << ", " << z << ")"
<< std::endl; << std::endl;
} }
@@ -141,7 +144,7 @@ int main(int argc, char **argv) {
LOG(WARNING) << "Warning message" << std::endl; LOG(WARNING) << "Warning message" << std::endl;
LOG(ERROR) << "Error message" << std::endl; LOG(ERROR) << "Error message" << std::endl;
LOG(ABORT) << "Abort message" << std::endl; LOG(ABORT) << "Abort message" << std::endl;
} catch (std::exception &err) { } catch (std::exception& err) {
std::cout << err.what() << std::endl; std::cout << err.what() << std::endl;
return 1; return 1;
} }

View File

@@ -52,74 +52,73 @@ using Info = _entry;
* to be easily manipulated and modified only on this class. * to be easily manipulated and modified only on this class.
*/ */
class basic_partition_map { class basic_partition_map {
private: private:
void _resize_map(); void _resize_map();
[[nodiscard]] int _index_of(std::string_view name) const; [[nodiscard]] int _index_of(std::string_view name) const;
public: public:
_entry *_data; _entry* _data;
size_t _count{}, _capacity{}; size_t _count{}, _capacity{};
basic_partition_map(const std::string &name, uint64_t size, bool logical); basic_partition_map(const std::string& name, uint64_t size, bool logical);
basic_partition_map(const basic_partition_map &other); basic_partition_map(const basic_partition_map& other);
basic_partition_map(basic_partition_map &&other) noexcept; basic_partition_map(basic_partition_map&& other) noexcept;
basic_partition_map(); basic_partition_map();
~basic_partition_map(); ~basic_partition_map();
bool insert(const std::string &name, uint64_t size, bool logical); bool insert(const std::string& name, uint64_t size, bool logical);
void merge(const basic_partition_map &map); void merge(const basic_partition_map& map);
void clear(); void clear();
[[nodiscard]] uint64_t get_size(std::string_view name) const; [[nodiscard]] uint64_t get_size(std::string_view name) const;
[[nodiscard]] bool is_logical(std::string_view name) const; [[nodiscard]] bool is_logical(std::string_view name) const;
[[nodiscard]] _returnable_entry get_all(std::string_view name) const; [[nodiscard]] _returnable_entry get_all(std::string_view name) const;
[[nodiscard]] bool find(std::string_view name) const; [[nodiscard]] bool find(std::string_view name) const;
[[nodiscard]] std::string find_(const std::string &name) const; [[nodiscard]] std::string find_(const std::string& name) const;
[[nodiscard]] size_t size() const; [[nodiscard]] size_t size() const;
[[nodiscard]] bool empty() const; [[nodiscard]] bool empty() const;
basic_partition_map &operator=(const basic_partition_map &map); basic_partition_map& operator=(const basic_partition_map& map);
bool operator==(const basic_partition_map &other) const; bool operator==(const basic_partition_map& other) const;
bool operator!=(const basic_partition_map &other) const; bool operator!=(const basic_partition_map& other) const;
bool operator!() const; bool operator!() const;
explicit operator bool() const; explicit operator bool() const;
Info operator[](int index) const; Info operator[](int index) const;
BasicInf operator[](const std::string_view &name) const; BasicInf operator[](const std::string_view& name) const;
explicit operator std::vector<Info>() const; explicit operator std::vector<Info>() const;
explicit operator int() const; explicit operator int() const;
class iterator { class iterator {
public: public:
_entry *ptr; _entry* ptr;
explicit iterator(_entry *p); explicit iterator(_entry* p);
auto operator*() const auto operator*() const -> std::pair<std::string&, decltype(_entry::props)&>;
-> std::pair<std::string &, decltype(_entry::props) &>; _entry* operator->() const;
_entry *operator->() const; iterator& operator++();
iterator &operator++();
iterator operator++(int); iterator operator++(int);
bool operator!=(const iterator &other) const; bool operator!=(const iterator& other) const;
bool operator==(const iterator &other) const; bool operator==(const iterator& other) const;
}; };
class constant_iterator { class constant_iterator {
public: public:
const _entry *ptr; const _entry* ptr;
explicit constant_iterator(const _entry *p); explicit constant_iterator(const _entry* p);
auto operator*() const auto operator*() const
-> std::pair<const std::string &, const decltype(_entry::props) &>; -> std::pair<const std::string&, const decltype(_entry::props)&>;
const _entry *operator->() const; const _entry* operator->() const;
constant_iterator &operator++(); constant_iterator& operator++();
constant_iterator operator++(int); constant_iterator operator++(int);
bool operator!=(const constant_iterator &other) const; bool operator!=(const constant_iterator& other) const;
bool operator==(const constant_iterator &other) const; bool operator==(const constant_iterator& other) const;
}; };
/* for-each support */ /* for-each support */
@@ -133,20 +132,20 @@ using Partition_t = _entry;
using Map_t = basic_partition_map; using Map_t = basic_partition_map;
class basic_partition_map_builder final { class basic_partition_map_builder final {
private: private:
Map_t _current_map; Map_t _current_map;
std::string _workdir; std::string _workdir;
bool _any_generating_error, _map_builded; bool _any_generating_error, _map_builded;
Map_t _build_map(std::string_view path, bool logical = false); Map_t _build_map(std::string_view path, bool logical = false);
void _insert_logicals(Map_t &&logicals); void _insert_logicals(Map_t&& logicals);
void _map_build_check() const; void _map_build_check() const;
[[nodiscard]] static bool _is_real_block_dir(std::string_view path); [[nodiscard]] static bool _is_real_block_dir(std::string_view path);
[[nodiscard]] uint64_t _get_size(const std::string &path); [[nodiscard]] uint64_t _get_size(const std::string& path);
public: public:
/** /**
* By default, it searches the directories in the * By default, it searches the directories in the
* defaultEntryList in PartitionMap.cpp in order and * defaultEntryList in PartitionMap.cpp in order and
@@ -162,7 +161,7 @@ public:
/** /**
* Move constructor * Move constructor
*/ */
basic_partition_map_builder(basic_partition_map_builder &&other) noexcept; basic_partition_map_builder(basic_partition_map_builder&& other) noexcept;
/** /**
* Returns the current list content in Map_t type. * Returns the current list content in Map_t type.
@@ -174,8 +173,8 @@ public:
* Map_temp_t type. If the partition is not in the * Map_temp_t type. If the partition is not in the
* currently created list, returns std::nullopt. * currently created list, returns std::nullopt.
*/ */
[[nodiscard]] std::optional<std::pair<uint64_t, bool>> [[nodiscard]] std::optional<std::pair<uint64_t, bool>> get(
get(std::string_view name) const; std::string_view name) const;
/** /**
* If there is a logical partition(s) in the created * If there is a logical partition(s) in the created
@@ -183,16 +182,16 @@ public:
* data of type std::string). If there is no logical * data of type std::string). If there is no logical
* partition in the created list, it returns std::nullopt. * partition in the created list, it returns std::nullopt.
*/ */
[[nodiscard]] std::optional<std::list<std::string>> [[nodiscard]] std::optional<std::list<std::string>> getLogicalPartitionList()
getLogicalPartitionList() const; const;
/** /**
* The physical partitions in the created list are * The physical partitions in the created list are
* returned as std::list type. If there is no content * returned as std::list type. If there is no content
* due to any problem, returns std::nullopt. * due to any problem, returns std::nullopt.
*/ */
[[nodiscard]] std::optional<std::list<std::string>> [[nodiscard]] std::optional<std::list<std::string>> getPhysicalPartitionList()
getPhysicalPartitionList() const; const;
/** /**
* The partitions in the created list are returned as std::list * The partitions in the created list are returned as std::list
@@ -244,17 +243,17 @@ public:
/** /**
* Copy partition list to vec, current vec contents are cleaned * Copy partition list to vec, current vec contents are cleaned
*/ */
bool copyPartitionsToVector(std::vector<std::string> &vec) const; bool copyPartitionsToVector(std::vector<std::string>& vec) const;
/** /**
* Copy logical partition list to vec, current vec contents are cleaned * Copy logical partition list to vec, current vec contents are cleaned
*/ */
bool copyLogicalPartitionsToVector(std::vector<std::string> &vec) const; bool copyLogicalPartitionsToVector(std::vector<std::string>& vec) const;
/** /**
* Copy physical partition list to vec, current vec contents are cleaned * Copy physical partition list to vec, current vec contents are cleaned
*/ */
bool copyPhysicalPartitionsToVector(std::vector<std::string> &vec) const; bool copyPhysicalPartitionsToVector(std::vector<std::string>& vec) const;
/** /**
* The created list and the current search index name are cleared. * The created list and the current search index name are cleared.
@@ -265,26 +264,26 @@ public:
* Do input function (lambda) for all partitions. * Do input function (lambda) for all partitions.
*/ */
bool doForAllPartitions( bool doForAllPartitions(
const std::function<bool(std::string, BasicInf)> &func) const; const std::function<bool(std::string, BasicInf)>& func) const;
/** /**
* Do input function (lambda) for physical partitions. * Do input function (lambda) for physical partitions.
*/ */
bool doForPhysicalPartitions( bool doForPhysicalPartitions(
const std::function<bool(std::string, BasicInf)> &func) const; const std::function<bool(std::string, BasicInf)>& func) const;
/** /**
* Do input function (lambda) for logical partitions. * Do input function (lambda) for logical partitions.
*/ */
bool doForLogicalPartitions( bool doForLogicalPartitions(
const std::function<bool(std::string, BasicInf)> &func) const; const std::function<bool(std::string, BasicInf)>& func) const;
/** /**
* Do input function (lambda) for input partition list. * Do input function (lambda) for input partition list.
*/ */
bool doForPartitionList( bool doForPartitionList(
const std::vector<std::string> &partitions, const std::vector<std::string>& partitions,
const std::function<bool(std::string, BasicInf)> &func) const; const std::function<bool(std::string, BasicInf)>& func) const;
/** /**
* The entered path is defined as the new search * The entered path is defined as the new search
@@ -317,14 +316,14 @@ public:
* the same (checked only according to the partition * the same (checked only according to the partition
* names), true is returned, otherwise false is returned * names), true is returned, otherwise false is returned
*/ */
friend bool operator==(const basic_partition_map_builder &lhs, friend bool operator==(const basic_partition_map_builder& lhs,
const basic_partition_map_builder &rhs); const basic_partition_map_builder& rhs);
/** /**
* The opposite logic of the == operator. * The opposite logic of the == operator.
*/ */
friend bool operator!=(const basic_partition_map_builder &lhs, friend bool operator!=(const basic_partition_map_builder& lhs,
const basic_partition_map_builder &rhs); const basic_partition_map_builder& rhs);
/** /**
* You can check whether the object was created * You can check whether the object was created
@@ -347,12 +346,12 @@ public:
/** /**
* Get Map_t object reference * Get Map_t object reference
*/ */
Map_t &operator*(); Map_t& operator*();
/** /**
* Get constant Map_t object reference * Get constant Map_t object reference
*/ */
const Map_t &operator*() const; const Map_t& operator*() const;
/** /**
* Get Info structure with given index * Get Info structure with given index
@@ -362,7 +361,7 @@ public:
/** /**
* Get BasicInfo structure with given index * Get BasicInfo structure with given index
*/ */
BasicInf operator[](const std::string_view &name) const; BasicInf operator[](const std::string_view& name) const;
/** /**
* Get map contents as vector (PartitionManager::Info type). * Get map contents as vector (PartitionManager::Info type).
@@ -422,7 +421,7 @@ extern std::map<uint64_t, std::string> AndroidMagicMap;
extern std::map<uint64_t, std::string> MagicMap; extern std::map<uint64_t, std::string> MagicMap;
size_t getMagicLength(uint64_t magic); size_t getMagicLength(uint64_t magic);
bool hasMagic(uint64_t magic, ssize_t buf, const std::string &path); bool hasMagic(uint64_t magic, ssize_t buf, const std::string& path);
std::string formatMagic(uint64_t magic); std::string formatMagic(uint64_t magic);
} // namespace Extras } // namespace Extras
} // namespace PartitionMap } // namespace PartitionMap
@@ -430,6 +429,6 @@ std::string formatMagic(uint64_t magic);
#define MAP "libpartition_map" #define MAP "libpartition_map"
#define COMMON_LAMBDA_PARAMS \ #define COMMON_LAMBDA_PARAMS \
(const std::string &partition, const PartitionMap::BasicInf props) (const std::string& partition, const PartitionMap::BasicInf props)
#endif // #ifndef LIBPARTITION_MAP_LIB_HPP #endif // #ifndef LIBPARTITION_MAP_LIB_HPP

View File

@@ -25,8 +25,8 @@ Map_t basic_partition_map_builder::getAll() const {
return _current_map; return _current_map;
} }
std::optional<std::pair<uint64_t, bool>> std::optional<std::pair<uint64_t, bool>> basic_partition_map_builder::get(
basic_partition_map_builder::get(const std::string_view name) const { const std::string_view name) const {
_map_build_check(); _map_build_check();
if (!_current_map.find(name)) return std::nullopt; if (!_current_map.find(name)) return std::nullopt;
@@ -39,7 +39,7 @@ basic_partition_map_builder::getLogicalPartitionList() const {
_map_build_check(); _map_build_check();
std::list<std::string> logicals; std::list<std::string> logicals;
for (const auto &[name, props] : _current_map) for (const auto& [name, props] : _current_map)
if (props.isLogical) logicals.push_back(name); if (props.isLogical) logicals.push_back(name);
if (logicals.empty()) return std::nullopt; if (logicals.empty()) return std::nullopt;
@@ -51,7 +51,7 @@ basic_partition_map_builder::getPhysicalPartitionList() const {
_map_build_check(); _map_build_check();
std::list<std::string> physicals; std::list<std::string> physicals;
for (const auto &[name, props] : _current_map) for (const auto& [name, props] : _current_map)
if (!props.isLogical) physicals.push_back(name); if (!props.isLogical) physicals.push_back(name);
if (physicals.empty()) return std::nullopt; if (physicals.empty()) return std::nullopt;
@@ -63,8 +63,7 @@ basic_partition_map_builder::getPartitionList() const {
_map_build_check(); _map_build_check();
std::list<std::string> partitions; std::list<std::string> partitions;
for (const auto &[name, props] : _current_map) for (const auto& [name, props] : _current_map) partitions.push_back(name);
partitions.push_back(name);
if (partitions.empty()) return std::nullopt; if (partitions.empty()) return std::nullopt;
return partitions; return partitions;
@@ -78,8 +77,8 @@ std::string basic_partition_map_builder::getRealLinkPathOf(
return std::string(_workdir + "/" + name.data()); return std::string(_workdir + "/" + name.data());
} }
std::string std::string basic_partition_map_builder::getRealPathOf(
basic_partition_map_builder::getRealPathOf(const std::string_view name) const { const std::string_view name) const {
_map_build_check(); _map_build_check();
const std::string full = (isLogical(name)) const std::string full = (isLogical(name))

View File

@@ -15,12 +15,13 @@
*/ */
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h>
#include <libhelper/lib.hpp> #include <libhelper/lib.hpp>
#include <libpartition_map/lib.hpp> #include <libpartition_map/lib.hpp>
#include <map> #include <map>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <unistd.h>
#include "PartitionManager/PartitionManager.hpp" #include "PartitionManager/PartitionManager.hpp"
@@ -76,7 +77,7 @@ size_t getMagicLength(const uint64_t magic) {
} }
bool hasMagic(const uint64_t magic, const ssize_t buf, bool hasMagic(const uint64_t magic, const ssize_t buf,
const std::string &path) { const std::string& path) {
LOGN(MAP, INFO) << "Checking magic of " << path << " with using " << buf LOGN(MAP, INFO) << "Checking magic of " << path << " with using " << buf
<< " byte buffer size (has magic 0x" << std::hex << magic << " byte buffer size (has magic 0x" << std::hex << magic
<< "?)" << std::endl; << "?)" << std::endl;
@@ -89,7 +90,7 @@ bool hasMagic(const uint64_t magic, const ssize_t buf,
return false; return false;
} }
auto *buffer = new (std::nothrow) uint8_t[buf]; auto* buffer = new (std::nothrow) uint8_t[buf];
collector.delAfterProgress(buffer); collector.delAfterProgress(buffer);
const ssize_t bytesRead = read(fd, buffer, buf); const ssize_t bytesRead = read(fd, buffer, buf);

View File

@@ -14,24 +14,26 @@
limitations under the License. limitations under the License.
*/ */
#include <fcntl.h>
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <cerrno> #include <cerrno>
#include <cstring> #include <cstring>
#include <fcntl.h>
#include <filesystem> #include <filesystem>
#ifndef ANDROID_BUILD #ifndef ANDROID_BUILD
#include <generated/buildInfo.hpp> #include <generated/buildInfo.hpp>
#endif #endif
#include <iostream>
#include <libpartition_map/lib.hpp>
#include <linux/fs.h> #include <linux/fs.h>
#include <memory>
#include <string>
#include <string_view>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <iostream>
#include <libpartition_map/lib.hpp>
#include <memory>
#include <string>
#include <string_view>
#include <vector> #include <vector>
static constexpr std::array<std::string_view, 3> defaultEntryList = { static constexpr std::array<std::string_view, 3> defaultEntryList = {
@@ -60,7 +62,7 @@ Map_t basic_partition_map_builder::_build_map(std::string_view path,
std::vector<std::filesystem::directory_entry> entries{ std::vector<std::filesystem::directory_entry> entries{
std::filesystem::directory_iterator(path), std::filesystem::directory_iterator(path),
std::filesystem::directory_iterator()}; std::filesystem::directory_iterator()};
std::sort(entries.begin(), entries.end(), [](const auto &a, const auto &b) { std::sort(entries.begin(), entries.end(), [](const auto& a, const auto& b) {
return a.path().filename() < b.path().filename(); return a.path().filename() < b.path().filename();
}); });
@@ -69,7 +71,7 @@ Map_t basic_partition_map_builder::_build_map(std::string_view path,
<< " is exists but generated vector is empty " << " is exists but generated vector is empty "
"(std::vector<std::filesystem::directory_entry>)." "(std::vector<std::filesystem::directory_entry>)."
<< std::endl; << std::endl;
for (const auto &entry : entries) { for (const auto& entry : entries) {
if (entry.path().filename() != "by-uuid" && if (entry.path().filename() != "by-uuid" &&
std::string(entry.path()).find("com.") == std::string::npos) std::string(entry.path()).find("com.") == std::string::npos)
map.insert(entry.path().filename().string(), _get_size(entry.path()), map.insert(entry.path().filename().string(), _get_size(entry.path()),
@@ -82,7 +84,7 @@ Map_t basic_partition_map_builder::_build_map(std::string_view path,
return map; return map;
} }
void basic_partition_map_builder::_insert_logicals(Map_t &&logicals) { void basic_partition_map_builder::_insert_logicals(Map_t&& logicals) {
LOGN(MAP, INFO) LOGN(MAP, INFO)
<< "merging created logical partition list to this object's variable." << "merging created logical partition list to this object's variable."
<< std::endl; << std::endl;
@@ -96,7 +98,7 @@ void basic_partition_map_builder::_map_build_check() const {
if (!_map_builded) throw Error("Please build partition map before!"); if (!_map_builded) throw Error("Please build partition map before!");
} }
uint64_t basic_partition_map_builder::_get_size(const std::string &path) { uint64_t basic_partition_map_builder::_get_size(const std::string& path) {
const std::string real = std::filesystem::read_symlink(path); const std::string real = std::filesystem::read_symlink(path);
Helper::garbageCollector collector; Helper::garbageCollector collector;
@@ -120,7 +122,7 @@ uint64_t basic_partition_map_builder::_get_size(const std::string &path) {
basic_partition_map_builder::basic_partition_map_builder() { basic_partition_map_builder::basic_partition_map_builder() {
LOGN(MAP, INFO) << "default constructor called. Starting build." << std::endl; LOGN(MAP, INFO) << "default constructor called. Starting build." << std::endl;
for (const auto &path : defaultEntryList) { for (const auto& path : defaultEntryList) {
if (std::filesystem::exists(path)) { if (std::filesystem::exists(path)) {
_current_map = _build_map(path); _current_map = _build_map(path);
if (_current_map.empty()) { if (_current_map.empty()) {
@@ -149,8 +151,10 @@ basic_partition_map_builder::basic_partition_map_builder(
if (std::filesystem::exists(path)) { if (std::filesystem::exists(path)) {
if (!_is_real_block_dir(path)) return; if (!_is_real_block_dir(path)) return;
_current_map = _build_map(path); _current_map = _build_map(path);
if (_current_map.empty()) _any_generating_error = true; if (_current_map.empty())
else _workdir = path; _any_generating_error = true;
else
_workdir = path;
} else } else
throw Error("Cannot find directory: %s. Cannot build partition map!", throw Error("Cannot find directory: %s. Cannot build partition map!",
path.data()); path.data());
@@ -162,7 +166,7 @@ basic_partition_map_builder::basic_partition_map_builder(
} }
basic_partition_map_builder::basic_partition_map_builder( basic_partition_map_builder::basic_partition_map_builder(
basic_partition_map_builder &&other) noexcept { basic_partition_map_builder&& other) noexcept {
_current_map = Map_t(std::move(other._current_map)); _current_map = Map_t(std::move(other._current_map));
_workdir = std::move(other._workdir); _workdir = std::move(other._workdir);
_any_generating_error = other._any_generating_error; _any_generating_error = other._any_generating_error;
@@ -178,7 +182,7 @@ bool basic_partition_map_builder::hasPartition(
bool basic_partition_map_builder::hasLogicalPartitions() const { bool basic_partition_map_builder::hasLogicalPartitions() const {
_map_build_check(); _map_build_check();
for (const auto &[name, props] : _current_map) for (const auto& [name, props] : _current_map)
if (props.isLogical) return true; if (props.isLogical) return true;
return false; return false;
@@ -205,7 +209,8 @@ bool basic_partition_map_builder::readDirectory(const std::string_view path) {
if (_current_map.empty()) { if (_current_map.empty()) {
_any_generating_error = true; _any_generating_error = true;
return false; return false;
} else _workdir = path; } else
_workdir = path;
} else } else
throw Error("Cannot find directory: %s. Cannot build partition map!", throw Error("Cannot find directory: %s. Cannot build partition map!",
path.data()); path.data());
@@ -220,7 +225,7 @@ bool basic_partition_map_builder::readDefaultDirectories() {
_map_builded = false; _map_builded = false;
LOGN(MAP, INFO) << "read default directories request." << std::endl; LOGN(MAP, INFO) << "read default directories request." << std::endl;
for (const auto &path : defaultEntryList) { for (const auto& path : defaultEntryList) {
if (std::filesystem::exists(path)) { if (std::filesystem::exists(path)) {
_current_map = _build_map(path); _current_map = _build_map(path);
if (_current_map.empty()) { if (_current_map.empty()) {
@@ -244,48 +249,49 @@ bool basic_partition_map_builder::readDefaultDirectories() {
} }
bool basic_partition_map_builder::copyPartitionsToVector( bool basic_partition_map_builder::copyPartitionsToVector(
std::vector<std::string> &vec) const { std::vector<std::string>& vec) const {
if (_current_map.empty()) { if (_current_map.empty()) {
LOGN(MAP, ERROR) << "Current map is empty."; LOGN(MAP, ERROR) << "Current map is empty.";
return false; return false;
} }
vec.clear(); vec.clear();
for (const auto &[name, props] : _current_map) for (const auto& [name, props] : _current_map) vec.push_back(name);
vec.push_back(name);
return true; return true;
} }
bool basic_partition_map_builder::copyLogicalPartitionsToVector( bool basic_partition_map_builder::copyLogicalPartitionsToVector(
std::vector<std::string> &vec) const { std::vector<std::string>& vec) const {
if (_current_map.empty()) { if (_current_map.empty()) {
LOGN(MAP, ERROR) << "Current map is empty."; LOGN(MAP, ERROR) << "Current map is empty.";
return false; return false;
} }
std::vector<std::string> vec2; std::vector<std::string> vec2;
for (const auto &[name, props] : _current_map) for (const auto& [name, props] : _current_map)
if (props.isLogical) vec2.push_back(name); if (props.isLogical) vec2.push_back(name);
if (vec2.empty()) { if (vec2.empty()) {
LOGN(MAP, ERROR) << "Cannot find logical partitions in current map."; LOGN(MAP, ERROR) << "Cannot find logical partitions in current map.";
return false; return false;
} else vec = vec2; } else
vec = vec2;
return true; return true;
} }
bool basic_partition_map_builder::copyPhysicalPartitionsToVector( bool basic_partition_map_builder::copyPhysicalPartitionsToVector(
std::vector<std::string> &vec) const { std::vector<std::string>& vec) const {
if (_current_map.empty()) { if (_current_map.empty()) {
LOGN(MAP, ERROR) << "Current map is empty."; LOGN(MAP, ERROR) << "Current map is empty.";
return false; return false;
} }
std::vector<std::string> vec2; std::vector<std::string> vec2;
for (const auto &[name, props] : _current_map) for (const auto& [name, props] : _current_map)
if (!props.isLogical) vec2.push_back(name); if (!props.isLogical) vec2.push_back(name);
if (vec2.empty()) { if (vec2.empty()) {
LOGN(MAP, ERROR) << "Cannot find physical partitions in current map."; LOGN(MAP, ERROR) << "Cannot find physical partitions in current map.";
return false; return false;
} else vec = vec2; } else
vec = vec2;
return true; return true;
} }
@@ -295,12 +301,12 @@ bool basic_partition_map_builder::empty() const {
} }
bool basic_partition_map_builder::doForAllPartitions( bool basic_partition_map_builder::doForAllPartitions(
const std::function<bool(std::string, BasicInf)> &func) const { const std::function<bool(std::string, BasicInf)>& func) const {
_map_build_check(); _map_build_check();
bool err = false; bool err = false;
LOGN(MAP, INFO) << "Doing input function for all partitions." << std::endl; LOGN(MAP, INFO) << "Doing input function for all partitions." << std::endl;
for (const auto &[name, props] : _current_map) { for (const auto& [name, props] : _current_map) {
if (func(name, {props.size, props.isLogical})) if (func(name, {props.size, props.isLogical}))
LOGN(MAP, INFO) << "Done progress for " << name << " partition." LOGN(MAP, INFO) << "Done progress for " << name << " partition."
<< std::endl; << std::endl;
@@ -315,13 +321,13 @@ bool basic_partition_map_builder::doForAllPartitions(
} }
bool basic_partition_map_builder::doForPhysicalPartitions( bool basic_partition_map_builder::doForPhysicalPartitions(
const std::function<bool(std::string, BasicInf)> &func) const { const std::function<bool(std::string, BasicInf)>& func) const {
_map_build_check(); _map_build_check();
bool err = false; bool err = false;
LOGN(MAP, INFO) << "Doing input function for physical partitions." LOGN(MAP, INFO) << "Doing input function for physical partitions."
<< std::endl; << std::endl;
for (const auto &[name, props] : _current_map) { for (const auto& [name, props] : _current_map) {
if (props.isLogical) continue; if (props.isLogical) continue;
if (func(name, {props.size, props.isLogical})) if (func(name, {props.size, props.isLogical}))
LOGN(MAP, INFO) << "Done progress for " << name << " partition." LOGN(MAP, INFO) << "Done progress for " << name << " partition."
@@ -337,13 +343,13 @@ bool basic_partition_map_builder::doForPhysicalPartitions(
} }
bool basic_partition_map_builder::doForLogicalPartitions( bool basic_partition_map_builder::doForLogicalPartitions(
const std::function<bool(std::string, BasicInf)> &func) const { const std::function<bool(std::string, BasicInf)>& func) const {
_map_build_check(); _map_build_check();
bool err = false; bool err = false;
LOGN(MAP, INFO) << "Doing input function for logical partitions." LOGN(MAP, INFO) << "Doing input function for logical partitions."
<< std::endl; << std::endl;
for (const auto &[name, props] : _current_map) { for (const auto& [name, props] : _current_map) {
if (!props.isLogical) continue; if (!props.isLogical) continue;
if (func(name, {props.size, props.isLogical})) if (func(name, {props.size, props.isLogical}))
LOGN(MAP, INFO) << "Done progress for " << name << " partition." LOGN(MAP, INFO) << "Done progress for " << name << " partition."
@@ -359,14 +365,14 @@ bool basic_partition_map_builder::doForLogicalPartitions(
} }
bool basic_partition_map_builder::doForPartitionList( bool basic_partition_map_builder::doForPartitionList(
const std::vector<std::string> &partitions, const std::vector<std::string>& partitions,
const std::function<bool(std::string, BasicInf)> &func) const { const std::function<bool(std::string, BasicInf)>& func) const {
_map_build_check(); _map_build_check();
bool err = false; bool err = false;
LOGN(MAP, INFO) << "Doing input function for input partition list." LOGN(MAP, INFO) << "Doing input function for input partition list."
<< std::endl; << std::endl;
for (const auto &partition : partitions) { for (const auto& partition : partitions) {
if (!hasPartition(partition)) if (!hasPartition(partition))
throw Error("Couldn't find partition: %s", partition.data()); throw Error("Couldn't find partition: %s", partition.data());
if (!func(partition, _current_map[partition])) { if (!func(partition, _current_map[partition])) {
@@ -379,19 +385,19 @@ bool basic_partition_map_builder::doForPartitionList(
return err; return err;
} }
uint64_t uint64_t basic_partition_map_builder::sizeOf(
basic_partition_map_builder::sizeOf(const std::string_view name) const { const std::string_view name) const {
_map_build_check(); _map_build_check();
return _current_map.get_size(name); return _current_map.get_size(name);
} }
bool operator==(const basic_partition_map_builder &lhs, bool operator==(const basic_partition_map_builder& lhs,
const basic_partition_map_builder &rhs) { const basic_partition_map_builder& rhs) {
return lhs._current_map == rhs._current_map; return lhs._current_map == rhs._current_map;
} }
bool operator!=(const basic_partition_map_builder &lhs, bool operator!=(const basic_partition_map_builder& lhs,
const basic_partition_map_builder &rhs) { const basic_partition_map_builder& rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }
@@ -409,9 +415,9 @@ bool basic_partition_map_builder::operator()(const std::string_view path) {
return readDirectory(path); return readDirectory(path);
} }
Map_t &basic_partition_map_builder::operator*() { return _current_map; } Map_t& basic_partition_map_builder::operator*() { return _current_map; }
const Map_t &basic_partition_map_builder::operator*() const { const Map_t& basic_partition_map_builder::operator*() const {
return _current_map; return _current_map;
} }
@@ -419,8 +425,8 @@ Info basic_partition_map_builder::operator[](const int index) const {
return _current_map[index]; return _current_map[index];
} }
BasicInf BasicInf basic_partition_map_builder::operator[](
basic_partition_map_builder::operator[](const std::string_view &name) const { const std::string_view& name) const {
return _current_map[name]; return _current_map[name];
} }

View File

@@ -20,16 +20,16 @@
#include <utility> #include <utility>
namespace PartitionMap { namespace PartitionMap {
basic_partition_map::iterator::iterator(_entry *p) : ptr(p) {} basic_partition_map::iterator::iterator(_entry* p) : ptr(p) {}
auto basic_partition_map::iterator::operator*() const auto basic_partition_map::iterator::operator*() const
-> std::pair<std::string &, decltype(_entry::props) &> { -> std::pair<std::string&, decltype(_entry::props)&> {
return {ptr->name, ptr->props}; return {ptr->name, ptr->props};
} }
_entry *basic_partition_map::iterator::operator->() const { return ptr; } _entry* basic_partition_map::iterator::operator->() const { return ptr; }
basic_partition_map::iterator &basic_partition_map::iterator::operator++() { basic_partition_map::iterator& basic_partition_map::iterator::operator++() {
++ptr; ++ptr;
return *this; return *this;
} }
@@ -40,27 +40,27 @@ basic_partition_map::iterator basic_partition_map::iterator::operator++(int) {
return tmp; return tmp;
} }
bool basic_partition_map::iterator::operator==(const iterator &other) const { bool basic_partition_map::iterator::operator==(const iterator& other) const {
return ptr == other.ptr; return ptr == other.ptr;
} }
bool basic_partition_map::iterator::operator!=(const iterator &other) const { bool basic_partition_map::iterator::operator!=(const iterator& other) const {
return ptr != other.ptr; return ptr != other.ptr;
} }
basic_partition_map::constant_iterator::constant_iterator(const _entry *p) basic_partition_map::constant_iterator::constant_iterator(const _entry* p)
: ptr(p) {} : ptr(p) {}
auto basic_partition_map::constant_iterator::operator*() const auto basic_partition_map::constant_iterator::operator*() const
-> std::pair<const std::string &, const decltype(_entry::props) &> { -> std::pair<const std::string&, const decltype(_entry::props)&> {
return {ptr->name, ptr->props}; return {ptr->name, ptr->props};
} }
const _entry *basic_partition_map::constant_iterator::operator->() const { const _entry* basic_partition_map::constant_iterator::operator->() const {
return ptr; return ptr;
} }
basic_partition_map::constant_iterator & basic_partition_map::constant_iterator&
basic_partition_map::constant_iterator::operator++() { basic_partition_map::constant_iterator::operator++() {
++ptr; ++ptr;
return *this; return *this;
@@ -74,21 +74,20 @@ basic_partition_map::constant_iterator::operator++(int) {
} }
bool basic_partition_map::constant_iterator::operator==( bool basic_partition_map::constant_iterator::operator==(
const constant_iterator &other) const { const constant_iterator& other) const {
return ptr == other.ptr; return ptr == other.ptr;
} }
bool basic_partition_map::constant_iterator::operator!=( bool basic_partition_map::constant_iterator::operator!=(
const constant_iterator &other) const { const constant_iterator& other) const {
return ptr != other.ptr; return ptr != other.ptr;
} }
void basic_partition_map::_resize_map() { void basic_partition_map::_resize_map() {
const size_t new_capacity = _capacity * 2; const size_t new_capacity = _capacity * 2;
auto *new_data = new _entry[new_capacity]; auto* new_data = new _entry[new_capacity];
for (size_t i = 0; i < _count; i++) for (size_t i = 0; i < _count; i++) new_data[i] = _data[i];
new_data[i] = _data[i];
delete[] _data; delete[] _data;
_data = new_data; _data = new_data;
@@ -103,21 +102,23 @@ int basic_partition_map::_index_of(const std::string_view name) const {
return 0; return 0;
} }
basic_partition_map::basic_partition_map(const std::string &name, basic_partition_map::basic_partition_map(const std::string& name,
const uint64_t size, const uint64_t size,
const bool logical) { const bool logical) {
_data = new _entry[_capacity]; _data = new _entry[_capacity];
insert(name, size, logical); insert(name, size, logical);
} }
basic_partition_map::basic_partition_map(const basic_partition_map &other) basic_partition_map::basic_partition_map(const basic_partition_map& other)
: _data(new _entry[other._capacity]), _count(other._count), : _data(new _entry[other._capacity]),
_count(other._count),
_capacity(other._capacity) { _capacity(other._capacity) {
std::copy(other._data, other._data + _count, _data); std::copy(other._data, other._data + _count, _data);
} }
basic_partition_map::basic_partition_map(basic_partition_map &&other) noexcept basic_partition_map::basic_partition_map(basic_partition_map&& other) noexcept
: _data(new _entry[other._capacity]), _count(other._count), : _data(new _entry[other._capacity]),
_count(other._count),
_capacity(other._capacity) { _capacity(other._capacity) {
std::copy(other._data, other._data + _count, _data); std::copy(other._data, other._data + _count, _data);
other.clear(); other.clear();
@@ -129,7 +130,7 @@ basic_partition_map::basic_partition_map() : _capacity(6) {
basic_partition_map::~basic_partition_map() { delete[] _data; } basic_partition_map::~basic_partition_map() { delete[] _data; }
bool basic_partition_map::insert(const std::string &name, const uint64_t size, bool basic_partition_map::insert(const std::string& name, const uint64_t size,
const bool logical) { const bool logical) {
if (name == _data[_index_of(name)].name) return false; if (name == _data[_index_of(name)].name) return false;
if (_count == _capacity) _resize_map(); if (_count == _capacity) _resize_map();
@@ -141,9 +142,9 @@ bool basic_partition_map::insert(const std::string &name, const uint64_t size,
return true; return true;
} }
void basic_partition_map::merge(const basic_partition_map &map) { void basic_partition_map::merge(const basic_partition_map& map) {
LOGN(MAP, INFO) << "map merge request." << std::endl; LOGN(MAP, INFO) << "map merge request." << std::endl;
for (const auto &[name, props] : map) for (const auto& [name, props] : map)
insert(name, props.size, props.isLogical); insert(name, props.size, props.isLogical);
LOGN(MAP, INFO) << "map merged successfully." << std::endl; LOGN(MAP, INFO) << "map merged successfully." << std::endl;
} }
@@ -162,8 +163,8 @@ bool basic_partition_map::is_logical(const std::string_view name) const {
return false; return false;
} }
_returnable_entry _returnable_entry basic_partition_map::get_all(
basic_partition_map::get_all(const std::string_view name) const { const std::string_view name) const {
if (const int pos = _index_of(name); name == _data[pos].name) if (const int pos = _index_of(name); name == _data[pos].name)
return _returnable_entry{_data[pos].props.size, _data[pos].props.isLogical}; return _returnable_entry{_data[pos].props.size, _data[pos].props.isLogical};
@@ -176,7 +177,7 @@ bool basic_partition_map::find(const std::string_view name) const {
return false; return false;
} }
std::string basic_partition_map::find_(const std::string &name) const { std::string basic_partition_map::find_(const std::string& name) const {
if (name == _data[_index_of(name)].name) return name; if (name == _data[_index_of(name)].name) return name;
return {}; return {};
@@ -194,8 +195,8 @@ void basic_partition_map::clear() {
_data = new _entry[_capacity]; _data = new _entry[_capacity];
} }
basic_partition_map & basic_partition_map& basic_partition_map::operator=(
basic_partition_map::operator=(const basic_partition_map &map) { const basic_partition_map& map) {
if (this != &map) { if (this != &map) {
delete[] _data; delete[] _data;
@@ -208,7 +209,7 @@ basic_partition_map::operator=(const basic_partition_map &map) {
return *this; return *this;
} }
bool basic_partition_map::operator==(const basic_partition_map &other) const { bool basic_partition_map::operator==(const basic_partition_map& other) const {
if (this->_capacity != other._capacity || this->_count != other._count) if (this->_capacity != other._capacity || this->_count != other._count)
return false; return false;
@@ -217,12 +218,13 @@ bool basic_partition_map::operator==(const basic_partition_map &other) const {
_data[i].props.size == other._data[i].props.size && _data[i].props.size == other._data[i].props.size &&
_data[i].props.isLogical == other._data[i].props.isLogical) _data[i].props.isLogical == other._data[i].props.isLogical)
continue; continue;
else return false; else
return false;
return true; return true;
} }
bool basic_partition_map::operator!=(const basic_partition_map &other) const { bool basic_partition_map::operator!=(const basic_partition_map& other) const {
return !(*this == other); return !(*this == other);
} }
@@ -235,7 +237,7 @@ Info basic_partition_map::operator[](const int index) const {
return _data[index]; return _data[index];
} }
BasicInf basic_partition_map::operator[](const std::string_view &name) const { BasicInf basic_partition_map::operator[](const std::string_view& name) const {
if (_count == 0) return {}; if (_count == 0) return {};
if (const int i = _index_of(name); name == _data[i].name) if (const int i = _index_of(name); name == _data[i].name)

View File

@@ -14,10 +14,11 @@
limitations under the License. limitations under the License.
*/ */
#include <unistd.h>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <libpartition_map/lib.hpp> #include <libpartition_map/lib.hpp>
#include <unistd.h>
int main() { int main() {
if (getuid() != 0) return 2; if (getuid() != 0) return 2;
@@ -31,7 +32,7 @@ int main() {
const auto map = MyMap.getAll(); const auto map = MyMap.getAll();
if (map.empty()) throw PartitionMap::Error("getAll() empty"); if (map.empty()) throw PartitionMap::Error("getAll() empty");
for (const auto &[name, props] : map) { for (const auto& [name, props] : map) {
std::cout << "Partition: " << name << ", size: " << props.size std::cout << "Partition: " << name << ", size: " << props.size
<< ", logical: " << props.isLogical << std::endl; << ", logical: " << props.isLogical << std::endl;
} }
@@ -45,14 +46,14 @@ int main() {
if (!logicals) if (!logicals)
throw PartitionMap::Error("getLogicalPartitionList() returned nullopt"); throw PartitionMap::Error("getLogicalPartitionList() returned nullopt");
std::cout << "Logical partitions: " << std::endl; std::cout << "Logical partitions: " << std::endl;
for (const auto &name : *logicals) for (const auto& name : *logicals)
std::cout << " - " << name << std::endl; std::cout << " - " << name << std::endl;
const auto physicals = MyMap.getPhysicalPartitionList(); const auto physicals = MyMap.getPhysicalPartitionList();
if (!physicals) if (!physicals)
throw PartitionMap::Error("getPhysicalPartitionList() returned nullopt"); throw PartitionMap::Error("getPhysicalPartitionList() returned nullopt");
std::cout << "Physical partitions: " << std::endl; std::cout << "Physical partitions: " << std::endl;
for (const auto &name : *physicals) for (const auto& name : *physicals)
std::cout << " - " << name << std::endl; std::cout << " - " << name << std::endl;
if (const std::vector<PartitionMap::Info> parts = if (const std::vector<PartitionMap::Info> parts =
@@ -61,7 +62,7 @@ int main() {
throw PartitionMap::Error( throw PartitionMap::Error(
"operator std::vector<PartitionMap::Info>() returned empty vector"); "operator std::vector<PartitionMap::Info>() returned empty vector");
auto func = [](const std::string &partition, auto func = [](const std::string& partition,
const PartitionMap::BasicInf props) -> bool { const PartitionMap::BasicInf props) -> bool {
std::ofstream f("parts.txt"); std::ofstream f("parts.txt");
f << "Partition: " << partition << ", size: " << props.size f << "Partition: " << partition << ", size: " << props.size
@@ -96,10 +97,10 @@ int main() {
if (MyMap != MyMap2) std::cout << "map1 != map2" << std::endl; if (MyMap != MyMap2) std::cout << "map1 != map2" << std::endl;
std::cout << PartitionMap::getLibVersion() << std::endl; std::cout << PartitionMap::getLibVersion() << std::endl;
} catch (PartitionMap::Error &error) { } catch (PartitionMap::Error& error) {
std::cerr << error.what() << std::endl; std::cerr << error.what() << std::endl;
return 1; return 1;
} catch (std::ios_base::failure &error) { } catch (std::ios_base::failure& error) {
std::cerr << "fstream error: " << error.what() << std::endl; std::cerr << "fstream error: " << error.what() << std::endl;
return 1; return 1;
} }