From a5cba68982b3313ad78f937d6e14f6883cd81552 Mon Sep 17 00:00:00 2001 From: Brad Aagaard Date: Sat, 14 Nov 2026 17:01:34 -0700 Subject: [PATCH 01/10] cxx: Switch from uncrustify to clang-format for formatting C/C++ code. --- .clang-format | 320 ++ .vscode/settings.json | 36 +- libsrc/spatialdata/geocoords/CSCart.cc | 11 +- libsrc/spatialdata/geocoords/CSCart.hh | 9 +- libsrc/spatialdata/geocoords/CSGeo.cc | 57 +- libsrc/spatialdata/geocoords/CSGeo.hh | 31 +- libsrc/spatialdata/geocoords/CSGeoLocal.cc | 43 +- libsrc/spatialdata/geocoords/CSGeoLocal.hh | 9 +- .../spatialdata/geocoords/CSPicklerAscii.cc | 8 +- .../spatialdata/geocoords/CSPicklerAscii.hh | 13 +- libsrc/spatialdata/geocoords/Converter.cc | 82 +- libsrc/spatialdata/geocoords/Converter.hh | 15 +- libsrc/spatialdata/geocoords/CoordSys.cc | 12 +- libsrc/spatialdata/geocoords/CoordSys.hh | 12 +- libsrc/spatialdata/geocoords/geocoordsfwd.hh | 4 +- libsrc/spatialdata/muparser/muParser.cpp | 435 +- libsrc/spatialdata/muparser/muParser.h | 107 +- libsrc/spatialdata/muparser/muParserBase.cpp | 3980 +++++++++-------- libsrc/spatialdata/muparser/muParserBase.h | 611 +-- .../spatialdata/muparser/muParserBytecode.cpp | 1361 +++--- .../spatialdata/muparser/muParserBytecode.h | 261 +- .../spatialdata/muparser/muParserCallback.cpp | 1867 ++++---- .../spatialdata/muparser/muParserCallback.h | 382 +- libsrc/spatialdata/muparser/muParserDef.h | 1199 +++-- libsrc/spatialdata/muparser/muParserError.cpp | 639 ++- libsrc/spatialdata/muparser/muParserError.h | 189 +- libsrc/spatialdata/muparser/muParserFixes.h | 108 +- libsrc/spatialdata/muparser/muParserInt.cpp | 571 ++- libsrc/spatialdata/muparser/muParserInt.h | 279 +- .../muparser/muParserTemplateMagic.h | 457 +- libsrc/spatialdata/muparser/muParserToken.h | 1068 ++--- .../muparser/muParserTokenReader.cpp | 1931 ++++---- .../muparser/muParserTokenReader.h | 271 +- libsrc/spatialdata/muparser/muparserfwd.hh | 2 +- libsrc/spatialdata/spatialdb/AnalyticDB.cc | 60 +- libsrc/spatialdata/spatialdb/AnalyticDB.hh | 9 +- libsrc/spatialdata/spatialdb/AnalyticDB.icc | 6 +- libsrc/spatialdata/spatialdb/CompositeDB.cc | 55 +- libsrc/spatialdata/spatialdb/CompositeDB.hh | 24 +- libsrc/spatialdata/spatialdb/Exception.hh | 3 +- libsrc/spatialdata/spatialdb/Exception.icc | 5 +- libsrc/spatialdata/spatialdb/GocadVoxet.cc | 115 +- libsrc/spatialdata/spatialdb/GocadVoxet.hh | 15 +- libsrc/spatialdata/spatialdb/GravityField.cc | 29 +- libsrc/spatialdata/spatialdb/GravityField.hh | 9 +- libsrc/spatialdata/spatialdb/SCECCVMH.cc | 103 +- libsrc/spatialdata/spatialdb/SCECCVMH.hh | 31 +- libsrc/spatialdata/spatialdb/SCECCVMH.icc | 9 +- libsrc/spatialdata/spatialdb/SimpleDB.cc | 37 +- libsrc/spatialdata/spatialdb/SimpleDB.hh | 24 +- libsrc/spatialdata/spatialdb/SimpleDBData.cc | 39 +- libsrc/spatialdata/spatialdb/SimpleDBData.hh | 6 +- libsrc/spatialdata/spatialdb/SimpleDBData.icc | 38 +- libsrc/spatialdata/spatialdb/SimpleDBQuery.cc | 134 +- libsrc/spatialdata/spatialdb/SimpleDBQuery.hh | 21 +- .../spatialdata/spatialdb/SimpleGridAscii.cc | 129 +- .../spatialdata/spatialdb/SimpleGridAscii.hh | 35 +- libsrc/spatialdata/spatialdb/SimpleGridDB.cc | 227 +- libsrc/spatialdata/spatialdb/SimpleGridDB.hh | 19 +- libsrc/spatialdata/spatialdb/SimpleGridDB.icc | 7 +- libsrc/spatialdata/spatialdb/SimpleIO.cc | 33 +- libsrc/spatialdata/spatialdb/SimpleIO.hh | 14 +- libsrc/spatialdata/spatialdb/SimpleIO.icc | 6 +- libsrc/spatialdata/spatialdb/SimpleIOAscii.cc | 115 +- libsrc/spatialdata/spatialdb/SimpleIOAscii.hh | 9 +- .../spatialdata/spatialdb/SimpleIOAscii.icc | 3 +- libsrc/spatialdata/spatialdb/SpatialDB.cc | 49 +- libsrc/spatialdata/spatialdb/SpatialDB.hh | 50 +- libsrc/spatialdata/spatialdb/SpatialDB.icc | 6 +- libsrc/spatialdata/spatialdb/TimeHistory.cc | 32 +- libsrc/spatialdata/spatialdb/TimeHistory.hh | 9 +- libsrc/spatialdata/spatialdb/TimeHistory.icc | 12 +- libsrc/spatialdata/spatialdb/TimeHistoryIO.cc | 54 +- libsrc/spatialdata/spatialdb/TimeHistoryIO.hh | 30 +- libsrc/spatialdata/spatialdb/UniformDB.cc | 52 +- libsrc/spatialdata/spatialdb/UniformDB.hh | 9 +- libsrc/spatialdata/spatialdb/UniformDB.icc | 6 +- .../spatialdata/spatialdb/UserFunctionDB.cc | 122 +- .../spatialdata/spatialdb/UserFunctionDB.hh | 33 +- libsrc/spatialdata/spatialdb/cspatialdb.cc | 9 +- libsrc/spatialdata/spatialdb/f77spatialdb.cc | 11 +- libsrc/spatialdata/spatialdb/f77spatialdb.h | 18 +- libsrc/spatialdata/spatialdb/spatialdbfwd.hh | 4 +- libsrc/spatialdata/units/Parser.cc | 2 +- libsrc/spatialdata/units/Parser.hh | 6 +- libsrc/spatialdata/units/unitsfwd.hh | 4 +- libsrc/spatialdata/utils/LineParser.cc | 5 +- libsrc/spatialdata/utils/LineParser.hh | 15 +- libsrc/spatialdata/utils/PointsStream.cc | 22 +- libsrc/spatialdata/utils/PointsStream.hh | 9 +- libsrc/spatialdata/utils/PointsStream.icc | 24 +- .../spatialdata/utils/SpatialdataVersion.cc | 8 +- .../spatialdata/utils/SpatialdataVersion.hh | 30 +- libsrc/spatialdata/utils/utilsfwd.hh | 4 +- templates/spatialdb/UniformVelModel.cc | 42 +- templates/spatialdb/UniformVelModel.hh | 31 +- tests/libtests/geocoords/TestCSCart.cc | 31 +- tests/libtests/geocoords/TestCSGeo.cc | 141 +- tests/libtests/geocoords/TestCSGeoLocal.cc | 122 +- .../libtests/geocoords/TestCSPicklerAscii.cc | 34 +- tests/libtests/geocoords/TestConverter.cc | 16 +- tests/libtests/geocoords/TestConverter.hh | 19 +- .../libtests/geocoords/TestConverter_Cases.cc | 353 +- tests/libtests/spatialdb/TestAnalyticDB.cc | 116 +- tests/libtests/spatialdb/TestCompositeDB.cc | 133 +- tests/libtests/spatialdb/TestGravityField.cc | 29 +- tests/libtests/spatialdb/TestGravityField.hh | 28 +- .../spatialdb/TestGravityField_Cases.cc | 145 +- tests/libtests/spatialdb/TestSCECCVMH.cc | 578 ++- tests/libtests/spatialdb/TestSimpleDB.cc | 26 +- tests/libtests/spatialdb/TestSimpleDB.hh | 29 +- tests/libtests/spatialdb/TestSimpleDBData.cc | 81 +- tests/libtests/spatialdb/TestSimpleDBQuery.cc | 66 +- tests/libtests/spatialdb/TestSimpleDBQuery.hh | 19 +- .../spatialdb/TestSimpleDBQuery_Cases.cc | 109 +- .../libtests/spatialdb/TestSimpleDB_Cases.cc | 331 +- .../libtests/spatialdb/TestSimpleGridAscii.cc | 227 +- tests/libtests/spatialdb/TestSimpleGridDB.cc | 73 +- tests/libtests/spatialdb/TestSimpleGridDB.hh | 34 +- .../spatialdb/TestSimpleGridDB_Cases.cc | 706 ++- tests/libtests/spatialdb/TestSimpleIOAscii.cc | 113 +- tests/libtests/spatialdb/TestSpatialDB.cc | 82 +- tests/libtests/spatialdb/TestTimeHistory.cc | 43 +- tests/libtests/spatialdb/TestTimeHistoryIO.cc | 41 +- tests/libtests/spatialdb/TestUniformDB.cc | 82 +- .../libtests/spatialdb/TestUserFunctionDB.cc | 32 +- .../libtests/spatialdb/TestUserFunctionDB.hh | 28 +- .../spatialdb/TestUserFunctionDB_Cases.cc | 350 +- tests/libtests/spatialdb/testf77query.h | 3 +- tests/libtests/units/TestParser.cc | 54 +- tests/libtests/utils/TestPointsStream.cc | 33 +- .../libtests/utils/TestSpatialdataVersion.cc | 29 +- tests/src/driver_catch2.cc | 12 +- 133 files changed, 12560 insertions(+), 10245 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..f10f0a3d --- /dev/null +++ b/.clang-format @@ -0,0 +1,320 @@ +--- +Language: Cpp +AlignAfterOpenBracket: true +AccessModifierOffset: -2 +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: true + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseArrows: false + AlignCaseColons: false +AlignConsecutiveTableGenBreakingDAGArgColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenCondOperatorColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenDefinitionColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignEscapedNewlines: Right +AlignOperands: Align +AlignTrailingComments: + AlignPPAndNotPP: true + Kind: Never + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowBreakBeforeNoexceptSpecifier: Never +AllowBreakBeforeQtProperty: false +AllowShortBlocksOnASingleLine: Never +AllowShortCaseExpressionOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: true +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AllowShortNamespacesOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: All +AlwaysBreakBeforeMultilineStrings: true +AttributeMacros: + - __capability +BinPackArguments: false +BinPackLongBracedList: true +BinPackParameters: AlwaysOnePerLine +BitFieldColonSpacing: Both +BracedInitializerIndentWidth: -1 +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterExternBlock: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAdjacentStringLiterals: true +BreakAfterAttributes: Leave +BreakAfterJavaFieldAnnotations: false +BreakAfterOpenBracketBracedList: false +BreakAfterOpenBracketFunction: false +BreakAfterOpenBracketIf: false +BreakAfterOpenBracketLoop: false +BreakAfterOpenBracketSwitch: false +BreakAfterReturnType: None +BreakArrays: true +BreakBeforeBinaryOperators: None +BreakBeforeCloseBracketBracedList: false +BreakBeforeCloseBracketFunction: false +BreakBeforeCloseBracketIf: false +BreakBeforeCloseBracketLoop: false +BreakBeforeCloseBracketSwitch: false +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Attach +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTemplateCloser: false +BreakBeforeTernaryOperators: true +BreakBinaryOperations: Never +BreakConstructorInitializers: AfterColon +BreakFunctionDefinitionParameters: false +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +BreakTemplateDeclarations: MultiLine +ColumnLimit: 120 +CommentPragmas: "^ IWYU pragma:" +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: AlignFirstComment +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +EnumTrailingComma: Leave +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: "^\"(llvm|llvm-c|clang|clang-c)/" + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: "^(<|\"(gtest|gmock|isl|json)/)" + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: ".*" + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: "(Test)?$" +IncludeIsMainSourceRegex: "" +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: false +IndentExportBlock: true +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentPPDirectives: None +IndentRequiresClause: true +IndentWidth: 4 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: false +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigitsInsert: 0 + BinaryMaxDigitsRemove: 0 + Decimal: 0 + DecimalMinDigitsInsert: 0 + DecimalMaxDigitsRemove: 0 + Hex: 0 + HexMinDigitsInsert: 0 + HexMaxDigitsRemove: 0 + BinaryMinDigits: 0 + DecimalMinDigits: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLines: + AtEndOfFile: false + AtStartOfBlock: true + AtStartOfFile: true +KeepFormFeed: false +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: "" +MacroBlockEnd: "" +MainIncludeChar: Quote +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: All +NumericLiteralCase: + ExponentLetter: Leave + HexDigit: Leave + Prefix: Leave + Suffix: Leave +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +OneLineFormatOffRegex: "" +PackConstructorInitializers: BinPack +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakBeforeMemberAccess: 150 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakScopeResolution: 500 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +PPIndentWidth: -1 +QualifierAlignment: Leave +ReferenceAlignment: Pointer +ReflowComments: Always +RemoveBracesLLVM: false +RemoveEmptyLinesInUnwrappedLines: false +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SkipMacroDefinitionBody: false +SortIncludes: + Enabled: true + IgnoreCase: false + IgnoreExtension: false +SortJavaStaticImport: Before +SortUsingDeclarations: LexicographicNumeric +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterOperatorKeyword: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterNot: false + AfterOverloadedOperator: false + AfterPlacementOperator: true + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBraces: Never +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInContainerLiterals: true +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + ExceptDoubleParentheses: false + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false +SpacesInSquareBrackets: false +Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TableGenBreakInsideDAGArg: DontBreak +TabWidth: 8 +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: + - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE +WrapNamespaceBodyWithEmptyLines: Leave +... diff --git a/.vscode/settings.json b/.vscode/settings.json index 411a5dd6..a33d24b1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,19 +2,9 @@ "editor.formatOnSave": true, "telemetry.enableTelemetry": false, "telemetry.enableCrashReporter": false, - "uncrustify.configPath.linux": "developer/uncrustify.cfg", - "uncrustify.configPath.osx": "developer/uncrustify.cfg", - "[markdown]": { - "editor.wordWrap": "wordWrapColumn", - "editor.wordWrapColumn": 100, - }, "files.associations": { "*.icc": "cpp", }, - "python.formatting.autopep8Args": [ - "-max-line-length", - "120" - ], "testMate.cpp.test.advancedExecutables": [ { "name": "${filename}", @@ -49,5 +39,29 @@ "trelis", "viscoelastic", "xdmf" - ] + ], + "C_Cpp.default.cppStandard": "c++14", + "C_Cpp.default.cStandard": "c11", + "[markdown]": { + "editor.wordWrap": "wordWrapColumn", + "editor.wordWrapColumn": 100, + }, + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter", + "editor.formatOnSave": true + }, + "black-formatter.args": [ + "--line-length", + "120" + ], + "[cpp]": { + "editor.defaultFormatter": "ms-vscode.cpptools", + "editor.formatOnSave": true + }, + "[c]": { + "editor.defaultFormatter": "ms-vscode.cpptools", + "editor.formatOnSave": true + }, + "C_Cpp.formatting": "clangFormat", + "C_Cpp.clang_format_style": "file" } \ No newline at end of file diff --git a/libsrc/spatialdata/geocoords/CSCart.cc b/libsrc/spatialdata/geocoords/CSCart.cc index 14a272a6..ad523c5f 100644 --- a/libsrc/spatialdata/geocoords/CSCart.cc +++ b/libsrc/spatialdata/geocoords/CSCart.cc @@ -16,28 +16,29 @@ #include // USES std::istream, std::ostream -#include // USES strcasecmp #include // USES std::ostringstream #include // USES std::runtime_error +#include // USES strcasecmp // ---------------------------------------------------------------------- // Default constructor -spatialdata::geocoords::CSCart::CSCart(void) : - _toMeters(1.0) { +spatialdata::geocoords::CSCart::CSCart(void) : _toMeters(1.0) { setCSType(CARTESIAN); } // constructor // ---------------------------------------------------------------------- // Default destructor -spatialdata::geocoords::CSCart::~CSCart(void) {} // destructor +spatialdata::geocoords::CSCart::~CSCart(void) { +} // destructor // ---------------------------------------------------------------------- // Copy constructor spatialdata::geocoords::CSCart::CSCart(const CSCart& cs) : CoordSys(cs), - _toMeters(cs._toMeters) {} + _toMeters(cs._toMeters) { +} // ---------------------------------------------------------------------- diff --git a/libsrc/spatialdata/geocoords/CSCart.hh b/libsrc/spatialdata/geocoords/CSCart.hh index a8de7996..10472435 100644 --- a/libsrc/spatialdata/geocoords/CSCart.hh +++ b/libsrc/spatialdata/geocoords/CSCart.hh @@ -15,8 +15,7 @@ class spatialdata::geocoords::CSCart : public CoordSys { friend class TestCSCart; -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /// Default constructor @@ -55,8 +54,7 @@ public: */ virtual void unpickle(std::istream& s); -protected: - + protected: // PROTECTED METHODS ////////////////////////////////////////////////// /** Copy constructor @@ -65,8 +63,7 @@ protected: */ CSCart(const CSCart& cs); -private: - + private: // PRIVATE MEMBERS //////////////////////////////////////////////////// double _toMeters; ///< Scale factor to convert coordinates to meters diff --git a/libsrc/spatialdata/geocoords/CSGeo.cc b/libsrc/spatialdata/geocoords/CSGeo.cc index bb8647af..e61dfbe4 100644 --- a/libsrc/spatialdata/geocoords/CSGeo.cc +++ b/libsrc/spatialdata/geocoords/CSGeo.cc @@ -21,12 +21,12 @@ extern "C" { #include // USES M_PI, cos(), sin() #include // USES memcpy() -#include // USES std::ostringsgream #include // USES std::istream, std::ostream +#include // USES std::ostringsgream -#include // USES strcasecmp() -#include // USES std::runtime_error, std::exception #include // USES assert() +#include // USES std::runtime_error, std::exception +#include // USES strcasecmp() // ---------------------------------------------------------------------- // Default constructor @@ -41,7 +41,8 @@ spatialdata::geocoords::CSGeo::CSGeo(void) : // ---------------------------------------------------------------------- // Default destructor spatialdata::geocoords::CSGeo::~CSGeo(void) { - delete _converter;_converter = NULL; + delete _converter; + _converter = NULL; } @@ -58,7 +59,8 @@ spatialdata::geocoords::CSGeo::clone(void) const { spatialdata::geocoords::CSGeo::CSGeo(const CSGeo& cs) : CoordSys(cs), _string(cs._string), - _converter(new spatialdata::geocoords::Converter) {} + _converter(new spatialdata::geocoords::Converter) { +} // ---------------------------------------------------------------------- @@ -81,11 +83,9 @@ spatialdata::geocoords::CSGeo::getString(void) const { // Set number of spatial dimensions in coordinate system. void spatialdata::geocoords::CSGeo::setSpaceDim(const int ndims) { - if (( ndims < 2) || ( ndims > 3) ) { + if ((ndims < 2) || (ndims > 3)) { std::ostringstream msg; - msg - << "Number of spatial dimensions (" << ndims - << ") must be >= 2 and <= 3."; + msg << "Number of spatial dimensions (" << ndims << ") must be >= 2 and <= 3."; throw std::runtime_error(msg.str()); } // if CoordSys::setSpaceDim(ndims); @@ -100,15 +100,13 @@ spatialdata::geocoords::CSGeo::computeSurfaceNormal(double* dir, const size_t numLocs, const size_t numDims, const double dx) const { - assert( (0 < numLocs && dir) || (0 == numLocs && !dir) ); - assert( (0 < numLocs && coords) || (0 == numLocs && !coords) ); + assert((0 < numLocs && dir) || (0 == numLocs && !dir)); + assert((0 < numLocs && coords) || (0 == numLocs && !coords)); if (numDims != getSpaceDim()) { std::ostringstream msg; - msg - << "Number of spatial dimensions of coordinates (" - << numDims << ") does not match number of spatial dimensions (" - << getSpaceDim() << ") of coordinate system."; + msg << "Number of spatial dimensions of coordinates (" << numDims + << ") does not match number of spatial dimensions (" << getSpaceDim() << ") of coordinate system."; throw std::runtime_error(msg.str()); } // if @@ -123,27 +121,28 @@ spatialdata::geocoords::CSGeo::computeSurfaceNormal(double* dir, case PJ_TYPE_PROJECTED_CRS: case PJ_TYPE_OTHER_COORDINATE_OPERATION: for (size_t i = 0; i < numLocs; ++i) { - dir[i*numDims+0] = +0.0; - dir[i*numDims+1] = +0.0; - dir[i*numDims+2] = +1.0; + dir[i * numDims + 0] = +0.0; + dir[i * numDims + 1] = +0.0; + dir[i * numDims + 2] = +1.0; } // for break; case PJ_TYPE_GEOCENTRIC_CRS: { // Surface normal is associated with geodetic lon/lat CSGeo csLL; csLL.setString("EPSG:4326"); // WGS84 - double* coordsLL = (numLocs*numDims > 0) ? new double[numLocs*numDims] : NULL; - memcpy(coordsLL, coords, numLocs*numDims*sizeof(double)); + double* coordsLL = (numLocs * numDims > 0) ? new double[numLocs * numDims] : NULL; + memcpy(coordsLL, coords, numLocs * numDims * sizeof(double)); assert(_converter); _converter->convert(coordsLL, numLocs, numDims, &csLL, this); for (size_t i = 0; i < numLocs; ++i) { - const double latRad = coordsLL[i*numDims+0] * M_PI/180.0; - const double lonRad = coordsLL[i*numDims+1] * M_PI/180.0; - dir[i*numDims+0] = cos(latRad) * cos(lonRad); - dir[i*numDims+1] = cos(latRad) * sin(lonRad); - dir[i*numDims+2] = sin(latRad); + const double latRad = coordsLL[i * numDims + 0] * M_PI / 180.0; + const double lonRad = coordsLL[i * numDims + 1] * M_PI / 180.0; + dir[i * numDims + 0] = cos(latRad) * cos(lonRad); + dir[i * numDims + 1] = cos(latRad) * sin(lonRad); + dir[i * numDims + 2] = sin(latRad); } // for - delete[] coordsLL;coordsLL = NULL; + delete[] coordsLL; + coordsLL = NULL; break; } // PJ_TYPE_GEOCENTRIC_CRS default: { @@ -151,9 +150,9 @@ spatialdata::geocoords::CSGeo::computeSurfaceNormal(double* dir, << ") not recognized for coordinate system '" << _string << "' " << "when computing normal of ground surface. Using default value of (0, 0, +1)."; for (size_t i = 0; i < numLocs; ++i) { - dir[i*numDims+0] = +0.0; - dir[i*numDims+1] = +0.0; - dir[i*numDims+2] = +1.0; + dir[i * numDims + 0] = +0.0; + dir[i * numDims + 1] = +0.0; + dir[i * numDims + 2] = +1.0; } // for } // default diff --git a/libsrc/spatialdata/geocoords/CSGeo.hh b/libsrc/spatialdata/geocoords/CSGeo.hh index 7ebdae0c..d0ba51b0 100644 --- a/libsrc/spatialdata/geocoords/CSGeo.hh +++ b/libsrc/spatialdata/geocoords/CSGeo.hh @@ -19,8 +19,7 @@ class spatialdata::geocoords::CSGeo : public CoordSys { friend class TestCSGeo; -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /// Default constructor @@ -69,7 +68,7 @@ public: const double* coords, const size_t numLocs, const size_t numDims, - const double dx=1000.0) const; + const double dx = 1000.0) const; /** Convert coordinates from local coordinate system to geographic coordinate system. * @@ -77,10 +76,9 @@ public: * @param[in] numLocs Number of location * @param[in] numDims Number of spatial dimensions in coordinates */ - virtual - void localToGeographic(double* coords, - const size_t numLocs, - const size_t numDims) const; + virtual void localToGeographic(double* coords, + const size_t numLocs, + const size_t numDims) const; /** Convert coordinates from geographic coordinate system to local coordinate system. * @@ -88,27 +86,23 @@ public: * @param[in] numLocs Number of location * @param[in] numDims Number of spatial dimensions in coordinates */ - virtual - void geographicToLocal(double* coords, - const size_t numLocs, - const size_t numDims) const; + virtual void geographicToLocal(double* coords, + const size_t numLocs, + const size_t numDims) const; /** Pickle coordinate system to ascii stream. * * @param s Output stream */ - virtual - void pickle(std::ostream& s) const override; + virtual void pickle(std::ostream& s) const override; /** Unpickle coordinate system from ascii stream. * * @param s Input stream */ - virtual - void unpickle(std::istream& s) override; - -protected: + virtual void unpickle(std::istream& s) override; + protected: // PROTECTED METHODS ////////////////////////////////////////////////// /** Copy constructor @@ -117,8 +111,7 @@ protected: */ CSGeo(const CSGeo& cs); -private: - + private: // PRIVATE MEMBERS //////////////////////////////////////////////////// std::string _string; ///< String specifying coordinate system. diff --git a/libsrc/spatialdata/geocoords/CSGeoLocal.cc b/libsrc/spatialdata/geocoords/CSGeoLocal.cc index 0a81a559..4aa33930 100644 --- a/libsrc/spatialdata/geocoords/CSGeoLocal.cc +++ b/libsrc/spatialdata/geocoords/CSGeoLocal.cc @@ -15,24 +15,26 @@ #include "spatialdata/utils/LineParser.hh" // USES LineParser #include // USES M_PI, cos(), sin() -#include // USES std::ostringsgream #include // USES std::istream, std::ostream +#include // USES std::ostringsgream -#include // USES strcasecmp() -#include // USES std::runtime_error, std::exception #include // USES assert() +#include // USES std::runtime_error, std::exception +#include // USES strcasecmp() // ---------------------------------------------------------------------- // Default constructor spatialdata::geocoords::CSGeoLocal::CSGeoLocal(void) : _originX(0.0), _originY(0.0), - _yAzimuth(0.0) {} + _yAzimuth(0.0) { +} // ---------------------------------------------------------------------- // Default destructor -spatialdata::geocoords::CSGeoLocal::~CSGeoLocal(void) {} +spatialdata::geocoords::CSGeoLocal::~CSGeoLocal(void) { +} // ---------------------------------------------------------------------- @@ -49,7 +51,8 @@ spatialdata::geocoords::CSGeoLocal::CSGeoLocal(const CSGeoLocal& cs) : CSGeo(cs), _originX(cs._originX), _originY(cs._originY), - _yAzimuth(cs._yAzimuth) {} + _yAzimuth(cs._yAzimuth) { +} // ---------------------------------------------------------------------- @@ -70,9 +73,15 @@ void spatialdata::geocoords::CSGeoLocal::getLocal(double* originX, double* originY, double* yAzimuth) const { - if (originX) { *originX = _originX; } - if (originY) { *originY = _originY; } - if (yAzimuth) { *yAzimuth = _yAzimuth; } + if (originX) { + *originX = _originX; + } + if (originY) { + *originY = _originY; + } + if (yAzimuth) { + *yAzimuth = _yAzimuth; + } } @@ -86,12 +95,12 @@ spatialdata::geocoords::CSGeoLocal::localToGeographic(double* coords, const double cosTheta = cos(yAzimuthR); const double sinTheta = sin(yAzimuthR); for (size_t iLoc = 0; iLoc < numLocs; ++iLoc) { - const double localX = coords[iLoc*numDims+0]; - const double localY = coords[iLoc*numDims+1]; + const double localX = coords[iLoc * numDims + 0]; + const double localY = coords[iLoc * numDims + 1]; const double unrotX = cosTheta * localX + sinTheta * localY; const double unrotY = -sinTheta * localX + cosTheta * localY; - coords[iLoc*numDims + 0] = _originX + unrotX; - coords[iLoc*numDims + 1] = _originY + unrotY; + coords[iLoc * numDims + 0] = _originX + unrotX; + coords[iLoc * numDims + 1] = _originY + unrotY; } // for } @@ -106,10 +115,10 @@ spatialdata::geocoords::CSGeoLocal::geographicToLocal(double* coords, const double cosTheta = cos(yAzimuthR); const double sinTheta = sin(yAzimuthR); for (size_t iLoc = 0; iLoc < numLocs; ++iLoc) { - const double unrotX = coords[iLoc*numDims + 0] - _originX; - const double unrotY = coords[iLoc*numDims + 1] - _originY; - coords[iLoc*numDims + 0] = cosTheta * unrotX - sinTheta * unrotY; - coords[iLoc*numDims + 1] = sinTheta * unrotX + cosTheta * unrotY; + const double unrotX = coords[iLoc * numDims + 0] - _originX; + const double unrotY = coords[iLoc * numDims + 1] - _originY; + coords[iLoc * numDims + 0] = cosTheta * unrotX - sinTheta * unrotY; + coords[iLoc * numDims + 1] = sinTheta * unrotX + cosTheta * unrotY; } // for } diff --git a/libsrc/spatialdata/geocoords/CSGeoLocal.hh b/libsrc/spatialdata/geocoords/CSGeoLocal.hh index 8581ac48..a044986f 100644 --- a/libsrc/spatialdata/geocoords/CSGeoLocal.hh +++ b/libsrc/spatialdata/geocoords/CSGeoLocal.hh @@ -19,8 +19,7 @@ class spatialdata::geocoords::CSGeoLocal : public CSGeo { friend class TestCSGeoLocal; -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// /// Default constructor @@ -87,8 +86,7 @@ public: */ void unpickle(std::istream& s) override; -protected: - + protected: // PROTECTED METHODS ////////////////////////////////////////////////// /** Copy constructor @@ -97,8 +95,7 @@ protected: */ CSGeoLocal(const CSGeoLocal& cs); -private: - + private: // PRIVATE MEMBERS //////////////////////////////////////////////////// double _originX; ///< X coordinate of local origin. diff --git a/libsrc/spatialdata/geocoords/CSPicklerAscii.cc b/libsrc/spatialdata/geocoords/CSPicklerAscii.cc index c986738b..69fc295f 100644 --- a/libsrc/spatialdata/geocoords/CSPicklerAscii.cc +++ b/libsrc/spatialdata/geocoords/CSPicklerAscii.cc @@ -17,10 +17,10 @@ #include "CSGeo.hh" // USES CSGeo #include "CSGeoLocal.hh" // USES CSGeoLocal +#include // USES assert() #include // USES std::ostringstream #include // USES std::runtime_error #include // USES strcasecmp() -#include // USES assert() // ---------------------------------------------------------------------- // Pickle coordinate system. @@ -40,7 +40,8 @@ spatialdata::geocoords::CSPicklerAscii::unpickle(std::istream& s, CoordSys** cs) { assert(cs); - delete *cs;*cs = 0; + delete *cs; + *cs = 0; const int maxIgnore = 128; std::string objname; @@ -54,8 +55,7 @@ spatialdata::geocoords::CSPicklerAscii::unpickle(std::istream& s, *cs = new CSGeoLocal; } else { std::ostringstream msg; - msg << "Could not parse coordinate system object name '" - << objname << "'\n" + msg << "Could not parse coordinate system object name '" << objname << "'\n" << "into a known type of coordinate system object.\n" << "Known types of coordinate systems:\n" << " 'cartesian' and 'geographic'"; diff --git a/libsrc/spatialdata/geocoords/CSPicklerAscii.hh b/libsrc/spatialdata/geocoords/CSPicklerAscii.hh index 71c5cc93..15f79f86 100644 --- a/libsrc/spatialdata/geocoords/CSPicklerAscii.hh +++ b/libsrc/spatialdata/geocoords/CSPicklerAscii.hh @@ -14,8 +14,7 @@ #include // USES std::istream, std::ostream class spatialdata::geocoords::CSPicklerAscii { -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /** Pickle coordinate system. @@ -23,18 +22,16 @@ public: * @param s Ouput stream * @param cs Pointer to coordinate system */ - static - void pickle(std::ostream& s, - const CoordSys* cs); + static void pickle(std::ostream& s, + const CoordSys* cs); /** Unpickle coordinate system. * * @param s Input stream * @param cs Pointer to pointer to coordinate system */ - static - void unpickle(std::istream& s, - CoordSys** cs); + static void unpickle(std::istream& s, + CoordSys** cs); }; // class CSPicklerAscii diff --git a/libsrc/spatialdata/geocoords/Converter.cc b/libsrc/spatialdata/geocoords/Converter.cc index bb464eb2..362b6c26 100644 --- a/libsrc/spatialdata/geocoords/Converter.cc +++ b/libsrc/spatialdata/geocoords/Converter.cc @@ -12,26 +12,25 @@ #include "Converter.hh" // implementation of class methods -#include "CoordSys.hh" // USES CoordSys -#include "CSGeo.hh" // USES CSGeo #include "CSCart.hh" // USES CSCart +#include "CSGeo.hh" // USES CSGeo +#include "CoordSys.hh" // USES CoordSys extern "C" { #include "proj.h" // USES PROJ } +#include // USES assert() #include // USES HUGE_VAL -#include // USES strcasecmp() -#include // USES std::runtime_error, std::exception #include // USES std::ostringsgream -#include // USES assert() +#include // USES std::runtime_error, std::exception +#include // USES strcasecmp() namespace spatialdata { namespace geocoords { namespace _converter { class Cache { -public: - + public: std::string csDest; std::string csSrc; PJ* proj; @@ -39,30 +38,33 @@ namespace spatialdata { Cache(void) : csDest(""), csSrc(""), - proj(NULL) {} + proj(NULL) { + } ~Cache(void) { csDest = ""; csSrc = ""; - proj_destroy(proj);proj = NULL; + proj_destroy(proj); + proj = NULL; } }; // Cache - } // _converter - } // geocoords -} // spatialdata + } // namespace _converter + } // namespace geocoords +} // namespace spatialdata // ---------------------------------------------------------------------- // Default constructor -spatialdata::geocoords::Converter::Converter(void) : - _cache(new _converter::Cache) {} +spatialdata::geocoords::Converter::Converter(void) : _cache(new _converter::Cache) { +} // ---------------------------------------------------------------------- // Default destructor spatialdata::geocoords::Converter::~Converter(void) { - delete _cache;_cache = NULL; + delete _cache; + _cache = NULL; } // destructor @@ -75,8 +77,7 @@ spatialdata::geocoords::Converter::convert(double* coords, const size_t numDims, const CoordSys* csDest, const CoordSys* csSrc) { - assert( (0 < numLocs && 0 != coords) || - (0 == numLocs && 0 == coords)); + assert((0 < numLocs && 0 != coords) || (0 == numLocs && 0 == coords)); assert(csDest); assert(csSrc); @@ -86,22 +87,19 @@ spatialdata::geocoords::Converter::convert(double* coords, if (csSrc->getSpaceDim() != csDest->getSpaceDim()) { std::ostringstream msg; msg << "Cannot convert between coordinate systems with different spatial dimensions.\n" - << "Source and destination coordinate systems have " - << csSrc->getSpaceDim() << " and " << csDest->getSpaceDim() - << " dimensions, respectively."; + << "Source and destination coordinate systems have " << csSrc->getSpaceDim() << " and " + << csDest->getSpaceDim() << " dimensions, respectively."; throw std::invalid_argument(msg.str()); } // if switch (csSrc->getCSType()) { - case spatialdata::geocoords::CoordSys::GEOGRAPHIC: - { // GEOGRAPHIC + case spatialdata::geocoords::CoordSys::GEOGRAPHIC: { // GEOGRAPHIC const CSGeo* csGeoDest = dynamic_cast(csDest); const CSGeo* csGeoSrc = dynamic_cast(csSrc); _convert(coords, numLocs, numDims, csGeoDest, csGeoSrc); break; } // GEOGRAPHIC - case spatialdata::geocoords::CoordSys::CARTESIAN: - { // CARTESIAN + case spatialdata::geocoords::CoordSys::CARTESIAN: { // CARTESIAN const CSCart* csCartDest = dynamic_cast(csDest); const CSCart* csCartSrc = dynamic_cast(csSrc); _convert(coords, numLocs, numDims, csCartDest, csCartSrc); @@ -124,8 +122,7 @@ spatialdata::geocoords::Converter::_convert(double* coords, const CSGeo* csSrc) { assert(csDest); assert(csSrc); - assert( (0 < numLocs && 0 != coords) || - (0 == numLocs && 0 == coords)); + assert((0 < numLocs && 0 != coords) || (0 == numLocs && 0 == coords)); double* const x = (numDims >= 2) ? coords + 0 : NULL; double* const y = (numDims >= 2) ? coords + 1 : NULL; @@ -134,8 +131,12 @@ spatialdata::geocoords::Converter::_convert(double* coords, bool needsNewProj = false; assert(_cache); - if ((0 == _cache->csSrc.length()) || (0 != strcasecmp(_cache->csSrc.c_str(), csSrc->getString()))) { needsNewProj = true; } - if ((0 == _cache->csDest.length()) || (0 != strcasecmp(_cache->csDest.c_str(), csDest->getString()))) { needsNewProj = true; } + if ((0 == _cache->csSrc.length()) || (0 != strcasecmp(_cache->csSrc.c_str(), csSrc->getString()))) { + needsNewProj = true; + } + if ((0 == _cache->csDest.length()) || (0 != strcasecmp(_cache->csDest.c_str(), csDest->getString()))) { + needsNewProj = true; + } if (needsNewProj) { proj_destroy(_cache->proj); _cache->proj = proj_create_crs_to_crs(PJ_DEFAULT_CTX, csSrc->getString(), csDest->getString(), NULL); @@ -152,12 +153,20 @@ spatialdata::geocoords::Converter::_convert(double* coords, csSrc->localToGeographic(coords, numLocs, numDims); double t = HUGE_VAL; - const size_t numSuccessful = - proj_trans_generic(_cache->proj, PJ_FWD, - x, stride, numLocs, - y, stride, numLocs, - z, stride, numLocs, - &t, 0, numLocs); + const size_t numSuccessful = proj_trans_generic(_cache->proj, + PJ_FWD, + x, + stride, + numLocs, + y, + stride, + numLocs, + z, + stride, + numLocs, + &t, + 0, + numLocs); if (numSuccessful < numLocs) { std::ostringstream msg; msg << "Error while converting coordinates:\n" @@ -181,10 +190,9 @@ spatialdata::geocoords::Converter::_convert(double* coords, const CSCart* csSrc) { assert(csDest); assert(csSrc); - assert( (0 < numLocs && 0 != coords) || - (0 == numLocs && 0 == coords)); + assert((0 < numLocs && 0 != coords) || (0 == numLocs && 0 == coords)); - const int size = numLocs*numDims; + const int size = numLocs * numDims; const double scale = csSrc->getToMeters() / csDest->getToMeters(); for (int i = 0; i < size; ++i) { coords[i] *= scale; diff --git a/libsrc/spatialdata/geocoords/Converter.hh b/libsrc/spatialdata/geocoords/Converter.hh index ea256c19..0674b9f3 100644 --- a/libsrc/spatialdata/geocoords/Converter.hh +++ b/libsrc/spatialdata/geocoords/Converter.hh @@ -17,15 +17,14 @@ namespace spatialdata { namespace geocoords { namespace _converter { class Cache; - } // _Converter - } // geocoords -} // spatialdata + } // namespace _converter + } // namespace geocoords +} // namespace spatialdata class spatialdata::geocoords::Converter { friend class TestConverter; // unit testing -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /// Default constructor @@ -49,8 +48,7 @@ public: const CoordSys* csDest, const CoordSys* csSrc); -private: - + private: // PRIVATE METHODS //////////////////////////////////////////////////// /** Convert coordinates from source geographic coordinate system to @@ -83,8 +81,7 @@ private: const CSCart* csDest, const CSCart* csSrc); -private: - + private: // PRIVATE MEMBERS //////////////////////////////////////////////////// _converter::Cache* _cache; diff --git a/libsrc/spatialdata/geocoords/CoordSys.cc b/libsrc/spatialdata/geocoords/CoordSys.cc index a8592554..8b56f081 100644 --- a/libsrc/spatialdata/geocoords/CoordSys.cc +++ b/libsrc/spatialdata/geocoords/CoordSys.cc @@ -19,19 +19,22 @@ // Default constructor spatialdata::geocoords::CoordSys::CoordSys(void) : _spaceDim(3), - _csType(CARTESIAN) {} + _csType(CARTESIAN) { +} // ---------------------------------------------------------------------- // Copy destructor spatialdata::geocoords::CoordSys::CoordSys(const CoordSys& cs) : _spaceDim(cs._spaceDim), - _csType(cs._csType) {} + _csType(cs._csType) { +} // ---------------------------------------------------------------------- // Default destructor -spatialdata::geocoords::CoordSys::~CoordSys(void) {} +spatialdata::geocoords::CoordSys::~CoordSys(void) { +} // ---------------------------------------------------------------------- @@ -40,8 +43,7 @@ void spatialdata::geocoords::CoordSys::setSpaceDim(const int ndims) { if (ndims < 1) { std::ostringstream msg; - msg - << "Number of spatial dimensions (" << ndims << ") must be >= 1."; + msg << "Number of spatial dimensions (" << ndims << ") must be >= 1."; throw std::invalid_argument(msg.str()); } // if _spaceDim = ndims; diff --git a/libsrc/spatialdata/geocoords/CoordSys.hh b/libsrc/spatialdata/geocoords/CoordSys.hh index b97c6906..207bd891 100644 --- a/libsrc/spatialdata/geocoords/CoordSys.hh +++ b/libsrc/spatialdata/geocoords/CoordSys.hh @@ -13,8 +13,7 @@ #include // USES std::istream, std::ostream class spatialdata::geocoords::CoordSys { -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /// Type of coordinate system @@ -24,8 +23,7 @@ public: LOCAL_GEOGRAPHIC, ///< Local geographic coordinate system }; -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /// Default constructor @@ -67,8 +65,7 @@ public: */ virtual void unpickle(std::istream& s) = 0; -protected: - + protected: // PROTECTED METHODS ////////////////////////////////////////////////// /** Copy destructor. @@ -83,8 +80,7 @@ protected: */ void setCSType(const CSTypeEnum cs); -private: - + private: // PRIVATE MEMBERS //////////////////////////////////////////////////// int _spaceDim; ///< Number of spatial dimensions in coordinate system diff --git a/libsrc/spatialdata/geocoords/geocoordsfwd.hh b/libsrc/spatialdata/geocoords/geocoordsfwd.hh index b5f77f3f..f3d84e1a 100644 --- a/libsrc/spatialdata/geocoords/geocoordsfwd.hh +++ b/libsrc/spatialdata/geocoords/geocoordsfwd.hh @@ -17,7 +17,7 @@ namespace spatialdata { class CSGeoLocal; class Converter; class CSPicklerAscii; - } // geocoords -} // spatialdata + } // namespace geocoords +} // namespace spatialdata // End of file diff --git a/libsrc/spatialdata/muparser/muParser.cpp b/libsrc/spatialdata/muparser/muParser.cpp index 0ebef2a8..7e328719 100644 --- a/libsrc/spatialdata/muparser/muParser.cpp +++ b/libsrc/spatialdata/muparser/muParser.cpp @@ -1,233 +1,236 @@ /* - - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2004 - 2021 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include "muParser.h" #include "muParserTemplateMagic.h" //--- Standard includes ------------------------------------------------------------------------ -#include #include +#include #include using namespace std; /** \file - \brief Implementation of the standard floating point parser. + \brief Implementation of the standard floating point parser. */ - /** \brief Namespace for mathematical applications. */ -namespace mu -{ - //--------------------------------------------------------------------------- - /** \brief Default value recognition callback. - \param [in] a_szExpr Pointer to the expression - \param [in, out] a_iPos Pointer to an index storing the current position within the expression - \param [out] a_fVal Pointer where the value should be stored in case one is found. - \return 1 if a value was found 0 otherwise. - */ - int Parser::IsVal(const char_type* a_szExpr, int* a_iPos, value_type* a_fVal) - { - value_type fVal(0); - - stringstream_type stream(a_szExpr); - stream.seekg(0); // todo: check if this really is necessary - stream.imbue(Parser::s_locale); - stream >> fVal; - stringstream_type::pos_type iEnd = stream.tellg(); // Position after reading - - if (iEnd == (stringstream_type::pos_type) - 1) - return 0; - - *a_iPos += (int)iEnd; - *a_fVal = fVal; - return 1; - } - - - //--------------------------------------------------------------------------- - /** \brief Constructor. - - Call ParserBase class constructor and trigger Function, Operator and Constant initialization. - */ - Parser::Parser() - :ParserBase() - { - AddValIdent(IsVal); - - InitCharSets(); - InitFun(); - InitConst(); - InitOprt(); - } - - //--------------------------------------------------------------------------- - /** \brief Define the character sets. - \sa DefineNameChars, DefineOprtChars, DefineInfixOprtChars - - This function is used for initializing the default character sets that define - the characters to be useable in function and variable names and operators. - */ - void Parser::InitCharSets() - { - DefineNameChars(_T("0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")); - DefineOprtChars(_T("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-*^/?<>=#!$%&|~'_{}")); - DefineInfixOprtChars(_T("/+-*^?<>=#!$%&|~'_")); - } - - //--------------------------------------------------------------------------- - /** \brief Initialize the default functions. */ - void Parser::InitFun() - { - if (mu::TypeInfo::IsInteger()) - { - // When setting MUP_BASETYPE to an integer type - // Place functions for dealing with integer values here - // ... - // ... - // ... - } - else - { - // trigonometric functions - DefineFun(_T("sin"), MathImpl::Sin); - DefineFun(_T("cos"), MathImpl::Cos); - DefineFun(_T("tan"), MathImpl::Tan); - // arcus functions - DefineFun(_T("asin"), MathImpl::ASin); - DefineFun(_T("acos"), MathImpl::ACos); - DefineFun(_T("atan"), MathImpl::ATan); - DefineFun(_T("atan2"), MathImpl::ATan2); - // hyperbolic functions - DefineFun(_T("sinh"), MathImpl::Sinh); - DefineFun(_T("cosh"), MathImpl::Cosh); - DefineFun(_T("tanh"), MathImpl::Tanh); - // arcus hyperbolic functions - DefineFun(_T("asinh"), MathImpl::ASinh); - DefineFun(_T("acosh"), MathImpl::ACosh); - DefineFun(_T("atanh"), MathImpl::ATanh); - // Logarithm functions - DefineFun(_T("log2"), MathImpl::Log2); - DefineFun(_T("log10"), MathImpl::Log10); - DefineFun(_T("log"), MathImpl::Log); - DefineFun(_T("ln"), MathImpl::Log); - // misc - DefineFun(_T("exp"), MathImpl::Exp); - DefineFun(_T("sqrt"), MathImpl::Sqrt); - DefineFun(_T("sign"), MathImpl::Sign); - DefineFun(_T("rint"), MathImpl::Rint); - DefineFun(_T("abs"), MathImpl::Abs); - // Functions with variable number of arguments - DefineFun(_T("sum"), MathImpl::Sum); - DefineFun(_T("avg"), MathImpl::Avg); - DefineFun(_T("min"), MathImpl::Min); - DefineFun(_T("max"), MathImpl::Max); - } - } - - //--------------------------------------------------------------------------- - /** \brief Initialize constants. - - By default the parser recognizes two constants. Pi ("pi") and the Eulerian - number ("_e"). - */ - void Parser::InitConst() - { - DefineConst(_T("_pi"), MathImpl::CONST_PI); - DefineConst(_T("_e"), MathImpl::CONST_E); - } - - //--------------------------------------------------------------------------- - /** \brief Initialize operators. - - By default only the unary minus operator is added. - */ - void Parser::InitOprt() - { - DefineInfixOprt(_T("-"), MathImpl::UnaryMinus); - DefineInfixOprt(_T("+"), MathImpl::UnaryPlus); - } - - //--------------------------------------------------------------------------- - void Parser::OnDetectVar(string_type* /*pExpr*/, int& /*nStart*/, int& /*nEnd*/) - { - // this is just sample code to illustrate modifying variable names on the fly. - // I'm not sure anyone really needs such a feature... - /* - - - string sVar(pExpr->begin()+nStart, pExpr->begin()+nEnd); - string sRepl = std::string("_") + sVar + "_"; - - int nOrigVarEnd = nEnd; - cout << "variable detected!\n"; - cout << " Expr: " << *pExpr << "\n"; - cout << " Start: " << nStart << "\n"; - cout << " End: " << nEnd << "\n"; - cout << " Var: \"" << sVar << "\"\n"; - cout << " Repl: \"" << sRepl << "\"\n"; - nEnd = nStart + sRepl.length(); - cout << " End: " << nEnd << "\n"; - pExpr->replace(pExpr->begin()+nStart, pExpr->begin()+nOrigVarEnd, sRepl); - cout << " New expr: " << *pExpr << "\n"; - */ - } - - //--------------------------------------------------------------------------- - /** \brief Numerically differentiate with regard to a variable. - \param [in] a_Var Pointer to the differentiation variable. - \param [in] a_fPos Position at which the differentiation should take place. - \param [in] a_fEpsilon Epsilon used for the numerical differentiation. - - Numerical differentiation uses a 5 point operator yielding a 4th order - formula. The default value for epsilon is 0.00074 which is - numeric_limits::epsilon() ^ (1/5). - */ - value_type Parser::Diff(value_type* a_Var, value_type a_fPos, value_type a_fEpsilon) const - { - value_type fRes(0); - value_type fBuf(*a_Var); - value_type f[4] = { 0,0,0,0 }; - value_type fEpsilon(a_fEpsilon); - - // Backwards compatible calculation of epsilon inc case the user doesn't provide - // his own epsilon - if (fEpsilon == 0) - fEpsilon = (a_fPos == 0) ? (value_type)1e-10 : (value_type)1e-7 * a_fPos; - - *a_Var = a_fPos + 2 * fEpsilon; f[0] = Eval(); - *a_Var = a_fPos + 1 * fEpsilon; f[1] = Eval(); - *a_Var = a_fPos - 1 * fEpsilon; f[2] = Eval(); - *a_Var = a_fPos - 2 * fEpsilon; f[3] = Eval(); - *a_Var = fBuf; // restore variable - - fRes = (-f[0] + 8 * f[1] - 8 * f[2] + f[3]) / (12 * fEpsilon); - return fRes; - } +namespace mu { + //--------------------------------------------------------------------------- + /** \brief Default value recognition callback. + \param [in] a_szExpr Pointer to the expression + \param [in, out] a_iPos Pointer to an index storing the current position within the expression + \param [out] a_fVal Pointer where the value should be stored in case one is found. + \return 1 if a value was found 0 otherwise. + */ + int + Parser::IsVal(const char_type* a_szExpr, + int* a_iPos, + value_type* a_fVal) { + value_type fVal(0); + + stringstream_type stream(a_szExpr); + stream.seekg(0); // todo: check if this really is necessary + stream.imbue(Parser::s_locale); + stream >> fVal; + stringstream_type::pos_type iEnd = stream.tellg(); // Position after reading + + if (iEnd == (stringstream_type::pos_type)-1) + return 0; + + *a_iPos += (int)iEnd; + *a_fVal = fVal; + return 1; + } + + + //--------------------------------------------------------------------------- + /** \brief Constructor. + + Call ParserBase class constructor and trigger Function, Operator and Constant initialization. + */ + Parser::Parser() : ParserBase() { + AddValIdent(IsVal); + + InitCharSets(); + InitFun(); + InitConst(); + InitOprt(); + } + + //--------------------------------------------------------------------------- + /** \brief Define the character sets. + \sa DefineNameChars, DefineOprtChars, DefineInfixOprtChars + + This function is used for initializing the default character sets that define + the characters to be useable in function and variable names and operators. + */ + void + Parser::InitCharSets() { + DefineNameChars(_T("0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")); + DefineOprtChars(_T("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-*^/?<>=#!$%&|~'_{}")); + DefineInfixOprtChars(_T("/+-*^?<>=#!$%&|~'_")); + } + + //--------------------------------------------------------------------------- + /** \brief Initialize the default functions. */ + void + Parser::InitFun() { + if (mu::TypeInfo::IsInteger()) { + // When setting MUP_BASETYPE to an integer type + // Place functions for dealing with integer values here + // ... + // ... + // ... + } else { + // trigonometric functions + DefineFun(_T("sin"), MathImpl::Sin); + DefineFun(_T("cos"), MathImpl::Cos); + DefineFun(_T("tan"), MathImpl::Tan); + // arcus functions + DefineFun(_T("asin"), MathImpl::ASin); + DefineFun(_T("acos"), MathImpl::ACos); + DefineFun(_T("atan"), MathImpl::ATan); + DefineFun(_T("atan2"), MathImpl::ATan2); + // hyperbolic functions + DefineFun(_T("sinh"), MathImpl::Sinh); + DefineFun(_T("cosh"), MathImpl::Cosh); + DefineFun(_T("tanh"), MathImpl::Tanh); + // arcus hyperbolic functions + DefineFun(_T("asinh"), MathImpl::ASinh); + DefineFun(_T("acosh"), MathImpl::ACosh); + DefineFun(_T("atanh"), MathImpl::ATanh); + // Logarithm functions + DefineFun(_T("log2"), MathImpl::Log2); + DefineFun(_T("log10"), MathImpl::Log10); + DefineFun(_T("log"), MathImpl::Log); + DefineFun(_T("ln"), MathImpl::Log); + // misc + DefineFun(_T("exp"), MathImpl::Exp); + DefineFun(_T("sqrt"), MathImpl::Sqrt); + DefineFun(_T("sign"), MathImpl::Sign); + DefineFun(_T("rint"), MathImpl::Rint); + DefineFun(_T("abs"), MathImpl::Abs); + // Functions with variable number of arguments + DefineFun(_T("sum"), MathImpl::Sum); + DefineFun(_T("avg"), MathImpl::Avg); + DefineFun(_T("min"), MathImpl::Min); + DefineFun(_T("max"), MathImpl::Max); + } + } + + //--------------------------------------------------------------------------- + /** \brief Initialize constants. + + By default the parser recognizes two constants. Pi ("pi") and the Eulerian + number ("_e"). + */ + void + Parser::InitConst() { + DefineConst(_T("_pi"), MathImpl::CONST_PI); + DefineConst(_T("_e"), MathImpl::CONST_E); + } + + //--------------------------------------------------------------------------- + /** \brief Initialize operators. + + By default only the unary minus operator is added. + */ + void + Parser::InitOprt() { + DefineInfixOprt(_T("-"), MathImpl::UnaryMinus); + DefineInfixOprt(_T("+"), MathImpl::UnaryPlus); + } + + //--------------------------------------------------------------------------- + void + Parser::OnDetectVar(string_type* /*pExpr*/, + int& /*nStart*/, + int& /*nEnd*/) { + // this is just sample code to illustrate modifying variable names on the fly. + // I'm not sure anyone really needs such a feature... + /* + + + string sVar(pExpr->begin()+nStart, pExpr->begin()+nEnd); + string sRepl = std::string("_") + sVar + "_"; + + int nOrigVarEnd = nEnd; + cout << "variable detected!\n"; + cout << " Expr: " << *pExpr << "\n"; + cout << " Start: " << nStart << "\n"; + cout << " End: " << nEnd << "\n"; + cout << " Var: \"" << sVar << "\"\n"; + cout << " Repl: \"" << sRepl << "\"\n"; + nEnd = nStart + sRepl.length(); + cout << " End: " << nEnd << "\n"; + pExpr->replace(pExpr->begin()+nStart, pExpr->begin()+nOrigVarEnd, sRepl); + cout << " New expr: " << *pExpr << "\n"; + */ + } + + //--------------------------------------------------------------------------- + /** \brief Numerically differentiate with regard to a variable. + \param [in] a_Var Pointer to the differentiation variable. + \param [in] a_fPos Position at which the differentiation should take place. + \param [in] a_fEpsilon Epsilon used for the numerical differentiation. + + Numerical differentiation uses a 5 point operator yielding a 4th order + formula. The default value for epsilon is 0.00074 which is + numeric_limits::epsilon() ^ (1/5). + */ + value_type + Parser::Diff(value_type* a_Var, + value_type a_fPos, + value_type a_fEpsilon) const { + value_type fRes(0); + value_type fBuf(*a_Var); + value_type f[4] = {0, 0, 0, 0}; + value_type fEpsilon(a_fEpsilon); + + // Backwards compatible calculation of epsilon inc case the user doesn't provide + // his own epsilon + if (fEpsilon == 0) + fEpsilon = (a_fPos == 0) ? (value_type)1e-10 : (value_type)1e-7 * a_fPos; + + *a_Var = a_fPos + 2 * fEpsilon; + f[0] = Eval(); + *a_Var = a_fPos + 1 * fEpsilon; + f[1] = Eval(); + *a_Var = a_fPos - 1 * fEpsilon; + f[2] = Eval(); + *a_Var = a_fPos - 2 * fEpsilon; + f[3] = Eval(); + *a_Var = fBuf; // restore variable + + fRes = (-f[0] + 8 * f[1] - 8 * f[2] + f[3]) / (12 * fEpsilon); + return fRes; + } } // namespace mu diff --git a/libsrc/spatialdata/muparser/muParser.h b/libsrc/spatialdata/muparser/muParser.h index 62032aa1..aece777f 100644 --- a/libsrc/spatialdata/muparser/muParser.h +++ b/libsrc/spatialdata/muparser/muParser.h @@ -1,30 +1,30 @@ /* - - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2004 - 2021 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #ifndef MU_PARSER_H #define MU_PARSER_H @@ -37,35 +37,36 @@ #include "muParserTemplateMagic.h" /** \file - \brief Definition of the standard floating point parser. + \brief Definition of the standard floating point parser. */ -namespace mu -{ - /** \brief Mathematical expressions parser. - - Standard implementation of the mathematical expressions parser. - Can be used as a reference implementation for subclassing the parser. - */ - class API_EXPORT_CXX Parser : public ParserBase - { - public: - - Parser(); - - void InitCharSets() override; - void InitFun() override; - void InitConst() override; - void InitOprt() override; - void OnDetectVar(string_type* pExpr, int& nStart, int& nEnd) override; - - value_type Diff(value_type* a_Var, value_type a_fPos, value_type a_fEpsilon = 0) const; - - protected: - - static int IsVal(const char_type* a_szExpr, int* a_iPos, value_type* a_fVal); - }; +namespace mu { + /** \brief Mathematical expressions parser. + + Standard implementation of the mathematical expressions parser. + Can be used as a reference implementation for subclassing the parser. + */ + class API_EXPORT_CXX Parser : public ParserBase { + public: + Parser(); + + void InitCharSets() override; + void InitFun() override; + void InitConst() override; + void InitOprt() override; + void OnDetectVar(string_type* pExpr, + int& nStart, + int& nEnd) override; + + value_type Diff(value_type* a_Var, + value_type a_fPos, + value_type a_fEpsilon = 0) const; + + protected: + static int IsVal(const char_type* a_szExpr, + int* a_iPos, + value_type* a_fVal); + }; } // namespace mu #endif - diff --git a/libsrc/spatialdata/muparser/muParserBase.cpp b/libsrc/spatialdata/muparser/muParserBase.cpp index a28a7fc1..c8e27ed8 100644 --- a/libsrc/spatialdata/muparser/muParserBase.cpp +++ b/libsrc/spatialdata/muparser/muParserBase.cpp @@ -1,44 +1,44 @@ /* - - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2022 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include "muParserBase.h" #include "muParserTemplateMagic.h" //--- Standard includes ------------------------------------------------------------------------ #include +#include +#include #include -#include -#include #include -#include #include -#include -#include +#include +#include +#include #ifdef MUP_USE_OPENMP @@ -47,1876 +47,2140 @@ #endif #if defined(_MSC_VER) - #pragma warning(push) - #pragma warning(disable : 26812) +#pragma warning(push) +#pragma warning(disable : 26812) #endif using namespace std; /** \file - \brief This file contains the basic implementation of the muparser engine. + \brief This file contains the basic implementation of the muparser engine. */ -namespace mu -{ - std::locale ParserBase::s_locale = std::locale(std::locale::classic(), new change_dec_sep('.')); - - bool ParserBase::g_DbgDumpCmdCode = false; - bool ParserBase::g_DbgDumpStack = false; - - //------------------------------------------------------------------------------ - /** \brief Identifiers for built in binary operators. - - When defining custom binary operators with #AddOprt(...) make sure not to choose - names conflicting with these definitions. - */ - const char_type* ParserBase::c_DefaultOprt[] = - { - _T("<="), _T(">="), _T("!="), - _T("=="), _T("<"), _T(">"), - _T("+"), _T("-"), _T("*"), - _T("/"), _T("^"), _T("&&"), - _T("||"), _T("="), _T("("), - _T(")"), _T("?"), _T(":"), 0 - }; - - const int ParserBase::s_MaxNumOpenMPThreads = 16; - - //------------------------------------------------------------------------------ - /** \brief Constructor. - \param a_szFormula the formula to interpret. - \throw ParserException if a_szFormula is nullptr. - */ - ParserBase::ParserBase() - : m_pParseFormula(&ParserBase::ParseString) - , m_vRPN() - , m_vStringBuf() - , m_pTokenReader() - , m_FunDef() - , m_PostOprtDef() - , m_InfixOprtDef() - , m_OprtDef() - , m_ConstDef() - , m_StrVarDef() - , m_VarDef() - , m_bBuiltInOp(true) - , m_sNameChars() - , m_sOprtChars() - , m_sInfixOprtChars() - , m_vStackBuffer() - , m_nFinalResultIdx(0) - { - InitTokenReader(); - } - - //--------------------------------------------------------------------------- - /** \brief Copy constructor. - - The parser can be safely copy constructed but the bytecode is reset during - copy construction. - */ - ParserBase::ParserBase(const ParserBase& a_Parser) - : m_pParseFormula(&ParserBase::ParseString) - , m_vRPN() - , m_vStringBuf() - , m_pTokenReader() - , m_FunDef() - , m_PostOprtDef() - , m_InfixOprtDef() - , m_OprtDef() - , m_ConstDef() - , m_StrVarDef() - , m_VarDef() - , m_bBuiltInOp(true) - , m_sNameChars() - , m_sOprtChars() - , m_sInfixOprtChars() - { - m_pTokenReader.reset(new token_reader_type(this)); - Assign(a_Parser); - } - - //--------------------------------------------------------------------------- - ParserBase::~ParserBase() - {} - - //--------------------------------------------------------------------------- - /** \brief Assignment operator. - - Implemented by calling Assign(a_Parser). Self assignment is suppressed. - \param a_Parser Object to copy to this. - \return *this - \throw nothrow - */ - ParserBase& ParserBase::operator=(const ParserBase& a_Parser) - { - Assign(a_Parser); - return *this; - } - - //--------------------------------------------------------------------------- - /** \brief Copy state of a parser object to this. - - Clears Variables and Functions of this parser. - Copies the states of all internal variables. - Resets parse function to string parse mode. - - \param a_Parser the source object. - */ - void ParserBase::Assign(const ParserBase& a_Parser) - { - if (&a_Parser == this) - return; - - // Don't copy bytecode instead cause the parser to create new bytecode - // by resetting the parse function. - ReInit(); - - m_ConstDef = a_Parser.m_ConstDef; // Copy user define constants - m_VarDef = a_Parser.m_VarDef; // Copy user defined variables - m_bBuiltInOp = a_Parser.m_bBuiltInOp; - m_vStringBuf = a_Parser.m_vStringBuf; - m_vStackBuffer = a_Parser.m_vStackBuffer; - m_nFinalResultIdx = a_Parser.m_nFinalResultIdx; - m_StrVarDef = a_Parser.m_StrVarDef; - m_vStringVarBuf = a_Parser.m_vStringVarBuf; - m_pTokenReader.reset(a_Parser.m_pTokenReader->Clone(this)); - - // Copy function and operator callbacks - m_FunDef = a_Parser.m_FunDef; // Copy function definitions - m_PostOprtDef = a_Parser.m_PostOprtDef; // post value unary operators - m_InfixOprtDef = a_Parser.m_InfixOprtDef; // unary operators for infix notation - m_OprtDef = a_Parser.m_OprtDef; // binary operators - - m_sNameChars = a_Parser.m_sNameChars; - m_sOprtChars = a_Parser.m_sOprtChars; - m_sInfixOprtChars = a_Parser.m_sInfixOprtChars; - } - - //--------------------------------------------------------------------------- - /** \brief Set the decimal separator. - \param cDecSep Decimal separator as a character value. - \sa SetThousandsSep - - By default muparser uses the "C" locale. The decimal separator of this - locale is overwritten by the one provided here. - */ - void ParserBase::SetDecSep(char_type cDecSep) - { - char_type cThousandsSep = std::use_facet< change_dec_sep >(s_locale).thousands_sep(); - s_locale = std::locale(std::locale("C"), new change_dec_sep(cDecSep, cThousandsSep)); - } - - //--------------------------------------------------------------------------- - /** \brief Sets the thousands operator. - \param cThousandsSep The thousands separator as a character - \sa SetDecSep - - By default muparser uses the "C" locale. The thousands separator of this - locale is overwritten by the one provided here. - */ - void ParserBase::SetThousandsSep(char_type cThousandsSep) - { - char_type cDecSep = std::use_facet< change_dec_sep >(s_locale).decimal_point(); - s_locale = std::locale(std::locale("C"), new change_dec_sep(cDecSep, cThousandsSep)); - } - - //--------------------------------------------------------------------------- - /** \brief Resets the locale. - - The default locale used "." as decimal separator, no thousands separator and - "," as function argument separator. - */ - void ParserBase::ResetLocale() - { - s_locale = std::locale(std::locale("C"), new change_dec_sep('.')); - SetArgSep(','); - } - - //--------------------------------------------------------------------------- - /** \brief Initialize the token reader. - - Create new token reader object and submit pointers to function, operator, - constant and variable definitions. - - \post m_pTokenReader.get()!=0 - \throw nothrow - */ - void ParserBase::InitTokenReader() - { - m_pTokenReader.reset(new token_reader_type(this)); - } - - //--------------------------------------------------------------------------- - /** \brief Reset parser to string parsing mode and clear internal buffers. - - Clear bytecode, reset the token reader. - \throw nothrow - */ - void ParserBase::ReInit() const - { - m_pParseFormula = &ParserBase::ParseString; - m_vStringBuf.clear(); - m_vRPN.clear(); - m_pTokenReader->ReInit(); - } - - //--------------------------------------------------------------------------- - void ParserBase::OnDetectVar(string_type* /*pExpr*/, int& /*nStart*/, int& /*nEnd*/) - {} - - //--------------------------------------------------------------------------- - /** \brief Returns the bytecode of the current expression. - */ - const ParserByteCode& ParserBase::GetByteCode() const - { - return m_vRPN; - } - - //--------------------------------------------------------------------------- - /** \brief Returns the version of muparser. - \param eInfo A flag indicating whether the full version info should be - returned or not. - - Format is as follows: "MAJOR.MINOR (COMPILER_FLAGS)" The COMPILER_FLAGS - are returned only if eInfo==pviFULL. - */ - string_type ParserBase::GetVersion(EParserVersionInfo eInfo) const - { - stringstream_type ss; - - ss << ParserVersion; - - if (eInfo == pviFULL) - { - ss << _T(" (") << ParserVersionDate; - ss << std::dec << _T("; ") << sizeof(void*) * 8 << _T("BIT"); +namespace mu { + std::locale ParserBase::s_locale = std::locale(std::locale::classic(), new change_dec_sep('.')); + + bool ParserBase::g_DbgDumpCmdCode = false; + bool ParserBase::g_DbgDumpStack = false; + + //------------------------------------------------------------------------------ + /** \brief Identifiers for built in binary operators. + + When defining custom binary operators with #AddOprt(...) make sure not to choose + names conflicting with these definitions. + */ + const char_type* ParserBase::c_DefaultOprt[] = {_T("<="), + _T(">="), + _T("!="), + _T("=="), + _T("<"), + _T(">"), + _T("+"), + _T("-"), + _T("*"), + _T("/"), + _T("^"), + _T("&&"), + _T("||"), + _T("="), + _T("("), + _T(")"), + _T("?"), + _T(":"), + 0}; + + const int ParserBase::s_MaxNumOpenMPThreads = 16; + + //------------------------------------------------------------------------------ + /** \brief Constructor. + \param a_szFormula the formula to interpret. + \throw ParserException if a_szFormula is nullptr. + */ + ParserBase::ParserBase() : + m_pParseFormula(&ParserBase::ParseString), + m_vRPN(), + m_vStringBuf(), + m_pTokenReader(), + m_FunDef(), + m_PostOprtDef(), + m_InfixOprtDef(), + m_OprtDef(), + m_ConstDef(), + m_StrVarDef(), + m_VarDef(), + m_bBuiltInOp(true), + m_sNameChars(), + m_sOprtChars(), + m_sInfixOprtChars(), + m_vStackBuffer(), + m_nFinalResultIdx(0) { + InitTokenReader(); + } + + //--------------------------------------------------------------------------- + /** \brief Copy constructor. + + The parser can be safely copy constructed but the bytecode is reset during + copy construction. + */ + ParserBase::ParserBase(const ParserBase& a_Parser) : + m_pParseFormula(&ParserBase::ParseString), + m_vRPN(), + m_vStringBuf(), + m_pTokenReader(), + m_FunDef(), + m_PostOprtDef(), + m_InfixOprtDef(), + m_OprtDef(), + m_ConstDef(), + m_StrVarDef(), + m_VarDef(), + m_bBuiltInOp(true), + m_sNameChars(), + m_sOprtChars(), + m_sInfixOprtChars() { + m_pTokenReader.reset(new token_reader_type(this)); + Assign(a_Parser); + } + + //--------------------------------------------------------------------------- + ParserBase::~ParserBase() { + } + + //--------------------------------------------------------------------------- + /** \brief Assignment operator. + + Implemented by calling Assign(a_Parser). Self assignment is suppressed. + \param a_Parser Object to copy to this. + \return *this + \throw nothrow + */ + ParserBase& + ParserBase::operator=(const ParserBase& a_Parser) { + Assign(a_Parser); + return *this; + } + + //--------------------------------------------------------------------------- + /** \brief Copy state of a parser object to this. + + Clears Variables and Functions of this parser. + Copies the states of all internal variables. + Resets parse function to string parse mode. + + \param a_Parser the source object. + */ + void + ParserBase::Assign(const ParserBase& a_Parser) { + if (&a_Parser == this) + return; + + // Don't copy bytecode instead cause the parser to create new bytecode + // by resetting the parse function. + ReInit(); + + m_ConstDef = a_Parser.m_ConstDef; // Copy user define constants + m_VarDef = a_Parser.m_VarDef; // Copy user defined variables + m_bBuiltInOp = a_Parser.m_bBuiltInOp; + m_vStringBuf = a_Parser.m_vStringBuf; + m_vStackBuffer = a_Parser.m_vStackBuffer; + m_nFinalResultIdx = a_Parser.m_nFinalResultIdx; + m_StrVarDef = a_Parser.m_StrVarDef; + m_vStringVarBuf = a_Parser.m_vStringVarBuf; + m_pTokenReader.reset(a_Parser.m_pTokenReader->Clone(this)); + + // Copy function and operator callbacks + m_FunDef = a_Parser.m_FunDef; // Copy function definitions + m_PostOprtDef = a_Parser.m_PostOprtDef; // post value unary operators + m_InfixOprtDef = a_Parser.m_InfixOprtDef; // unary operators for infix notation + m_OprtDef = a_Parser.m_OprtDef; // binary operators + + m_sNameChars = a_Parser.m_sNameChars; + m_sOprtChars = a_Parser.m_sOprtChars; + m_sInfixOprtChars = a_Parser.m_sInfixOprtChars; + } + + //--------------------------------------------------------------------------- + /** \brief Set the decimal separator. + \param cDecSep Decimal separator as a character value. + \sa SetThousandsSep + + By default muparser uses the "C" locale. The decimal separator of this + locale is overwritten by the one provided here. + */ + void + ParserBase::SetDecSep(char_type cDecSep) { + char_type cThousandsSep = std::use_facet>(s_locale).thousands_sep(); + s_locale = std::locale(std::locale("C"), new change_dec_sep(cDecSep, cThousandsSep)); + } + + //--------------------------------------------------------------------------- + /** \brief Sets the thousands operator. + \param cThousandsSep The thousands separator as a character + \sa SetDecSep + + By default muparser uses the "C" locale. The thousands separator of this + locale is overwritten by the one provided here. + */ + void + ParserBase::SetThousandsSep(char_type cThousandsSep) { + char_type cDecSep = std::use_facet>(s_locale).decimal_point(); + s_locale = std::locale(std::locale("C"), new change_dec_sep(cDecSep, cThousandsSep)); + } + + //--------------------------------------------------------------------------- + /** \brief Resets the locale. + + The default locale used "." as decimal separator, no thousands separator and + "," as function argument separator. + */ + void + ParserBase::ResetLocale() { + s_locale = std::locale(std::locale("C"), new change_dec_sep('.')); + SetArgSep(','); + } + + //--------------------------------------------------------------------------- + /** \brief Initialize the token reader. + + Create new token reader object and submit pointers to function, operator, + constant and variable definitions. + + \post m_pTokenReader.get()!=0 + \throw nothrow + */ + void + ParserBase::InitTokenReader() { + m_pTokenReader.reset(new token_reader_type(this)); + } + + //--------------------------------------------------------------------------- + /** \brief Reset parser to string parsing mode and clear internal buffers. + + Clear bytecode, reset the token reader. + \throw nothrow + */ + void + ParserBase::ReInit() const { + m_pParseFormula = &ParserBase::ParseString; + m_vStringBuf.clear(); + m_vRPN.clear(); + m_pTokenReader->ReInit(); + } + + //--------------------------------------------------------------------------- + void + ParserBase::OnDetectVar(string_type* /*pExpr*/, + int& /*nStart*/, + int& /*nEnd*/) { + } + + //--------------------------------------------------------------------------- + /** \brief Returns the bytecode of the current expression. + */ + const ParserByteCode& + ParserBase::GetByteCode() const { + return m_vRPN; + } + + //--------------------------------------------------------------------------- + /** \brief Returns the version of muparser. + \param eInfo A flag indicating whether the full version info should be + returned or not. + + Format is as follows: "MAJOR.MINOR (COMPILER_FLAGS)" The COMPILER_FLAGS + are returned only if eInfo==pviFULL. + */ + string_type + ParserBase::GetVersion(EParserVersionInfo eInfo) const { + stringstream_type ss; + + ss << ParserVersion; + + if (eInfo == pviFULL) { + ss << _T(" (") << ParserVersionDate; + ss << std::dec << _T("; ") << sizeof(void*) * 8 << _T("BIT"); #ifdef _DEBUG - ss << _T("; DEBUG"); -#else - ss << _T("; RELEASE"); + ss << _T("; DEBUG"); +#else + ss << _T("; RELEASE"); #endif #ifdef _UNICODE - ss << _T("; UNICODE"); + ss << _T("; UNICODE"); #else #ifdef _MBCS - ss << _T("; MBCS"); + ss << _T("; MBCS"); #else - ss << _T("; ASCII"); + ss << _T("; ASCII"); #endif #endif #ifdef MUP_USE_OPENMP - ss << _T("; OPENMP"); + ss << _T("; OPENMP"); #endif - ss << _T(")"); - } - - return ss.str(); - } - - //--------------------------------------------------------------------------- - /** \brief Add a value parsing function. - - When parsing an expression muParser tries to detect values in the expression - string using different valident callbacks. Thus it's possible to parse - for hex values, binary values and floating point values. - */ - void ParserBase::AddValIdent(identfun_type a_pCallback) - { - m_pTokenReader->AddValIdent(a_pCallback); - } - - //--------------------------------------------------------------------------- - /** \brief Set a function that can create variable pointer for unknown expression variables. - \param a_pFactory A pointer to the variable factory. - \param pUserData A user defined context pointer. - */ - void ParserBase::SetVarFactory(facfun_type a_pFactory, void* pUserData) - { - m_pTokenReader->SetVarCreator(a_pFactory, pUserData); - } - - //--------------------------------------------------------------------------- - /** \brief Add a function or operator callback to the parser. */ - void ParserBase::AddCallback( - const string_type& a_strName, - const ParserCallback& a_Callback, - funmap_type& a_Storage, - const char_type* a_szCharSet) - { - if (!a_Callback.IsValid()) - Error(ecINVALID_FUN_PTR); - - const funmap_type* pFunMap = &a_Storage; - - // Check for conflicting operator or function names - if (pFunMap != &m_FunDef && m_FunDef.find(a_strName) != m_FunDef.end()) - Error(ecNAME_CONFLICT, -1, a_strName); - - if (pFunMap != &m_PostOprtDef && m_PostOprtDef.find(a_strName) != m_PostOprtDef.end()) - Error(ecNAME_CONFLICT, -1, a_strName); - - if (pFunMap != &m_InfixOprtDef && pFunMap != &m_OprtDef && m_InfixOprtDef.find(a_strName) != m_InfixOprtDef.end()) - Error(ecNAME_CONFLICT, -1, a_strName); - - if (pFunMap != &m_InfixOprtDef && pFunMap != &m_OprtDef && m_OprtDef.find(a_strName) != m_OprtDef.end()) - Error(ecNAME_CONFLICT, -1, a_strName); - - CheckOprt(a_strName, a_Callback, a_szCharSet); - a_Storage[a_strName] = a_Callback; - ReInit(); - } - - //--------------------------------------------------------------------------- - /** \brief Check if a name contains invalid characters. - - \throw ParserException if the name contains invalid characters. - */ - void ParserBase::CheckOprt(const string_type& a_sName, - const ParserCallback& a_Callback, - const string_type& a_szCharSet) const - { - if (!a_sName.length() || - (a_sName.find_first_not_of(a_szCharSet) != string_type::npos) || - (a_sName[0] >= '0' && a_sName[0] <= '9')) - { - switch (a_Callback.GetCode()) - { - case cmOPRT_POSTFIX: Error(ecINVALID_POSTFIX_IDENT, -1, a_sName); break; - case cmOPRT_INFIX: Error(ecINVALID_INFIX_IDENT, -1, a_sName); break; - default: Error(ecINVALID_NAME, -1, a_sName); - } - } - } - - - /** \brief Check if a name contains invalid characters. - \throw ParserException if the name contains invalid characters. - */ - void ParserBase::CheckName(const string_type& a_sName, const string_type& a_szCharSet) const - { - if (!a_sName.length() || - (a_sName.find_first_not_of(a_szCharSet) != string_type::npos) || - (a_sName[0] >= '0' && a_sName[0] <= '9')) - { - Error(ecINVALID_NAME); - } - } - - /** \brief Set the formula. - \param a_strFormula Formula as string_type - \throw ParserException in case of syntax errors. - - Triggers first time calculation thus the creation of the bytecode and - scanning of used variables. - */ - void ParserBase::SetExpr(const string_type& a_sExpr) - { - // Check locale compatibility - if (m_pTokenReader->GetArgSep() == std::use_facet >(s_locale).decimal_point()) - Error(ecLOCALE); - - // Check maximum allowed expression length. An arbitrary value small enough so i can debug expressions sent to me - if (a_sExpr.length() >= MaxLenExpression) - Error(ecEXPRESSION_TOO_LONG, 0, a_sExpr); - - m_pTokenReader->SetFormula(a_sExpr + _T(" ")); - ReInit(); - } - - //--------------------------------------------------------------------------- - /** \brief Get the default symbols used for the built in operators. - \sa c_DefaultOprt - */ - const char_type** ParserBase::GetOprtDef() const - { - return (const char_type**)(&c_DefaultOprt[0]); - } - - //--------------------------------------------------------------------------- - /** \brief Define the set of valid characters to be used in names of - functions, variables, constants. - */ - void ParserBase::DefineNameChars(const char_type* a_szCharset) - { - m_sNameChars = a_szCharset; - } - - //--------------------------------------------------------------------------- - /** \brief Define the set of valid characters to be used in names of - binary operators and postfix operators. - */ - void ParserBase::DefineOprtChars(const char_type* a_szCharset) - { - m_sOprtChars = a_szCharset; - } - - //--------------------------------------------------------------------------- - /** \brief Define the set of valid characters to be used in names of - infix operators. - */ - void ParserBase::DefineInfixOprtChars(const char_type* a_szCharset) - { - m_sInfixOprtChars = a_szCharset; - } - - //--------------------------------------------------------------------------- - /** \brief Virtual function that defines the characters allowed in name identifiers. - \sa #ValidOprtChars, #ValidPrefixOprtChars - */ - const char_type* ParserBase::ValidNameChars() const - { - MUP_ASSERT(m_sNameChars.size()); - return m_sNameChars.c_str(); - } - - //--------------------------------------------------------------------------- - /** \brief Virtual function that defines the characters allowed in operator definitions. - \sa #ValidNameChars, #ValidPrefixOprtChars - */ - const char_type* ParserBase::ValidOprtChars() const - { - MUP_ASSERT(m_sOprtChars.size()); - return m_sOprtChars.c_str(); - } - - //--------------------------------------------------------------------------- - /** \brief Virtual function that defines the characters allowed in infix operator definitions. - \sa #ValidNameChars, #ValidOprtChars - */ - const char_type* ParserBase::ValidInfixOprtChars() const - { - MUP_ASSERT(m_sInfixOprtChars.size()); - return m_sInfixOprtChars.c_str(); - } - - //--------------------------------------------------------------------------- - /** \brief Add a user defined operator. - \post Will reset the Parser to string parsing mode. - */ - void ParserBase::DefinePostfixOprt(const string_type& a_sName, fun_type1 a_pFun, bool a_bAllowOpt) - { - if (a_sName.length() > MaxLenIdentifier) - Error(ecIDENTIFIER_TOO_LONG); - - AddCallback(a_sName, ParserCallback(a_pFun, a_bAllowOpt, prPOSTFIX, cmOPRT_POSTFIX), m_PostOprtDef, ValidOprtChars()); - } - - //--------------------------------------------------------------------------- - /** \brief Initialize user defined functions. - - Calls the virtual functions InitFun(), InitConst() and InitOprt(). - */ - void ParserBase::Init() - { - InitCharSets(); - InitFun(); - InitConst(); - InitOprt(); - } - - //--------------------------------------------------------------------------- - /** \brief Add a user defined operator. - \post Will reset the Parser to string parsing mode. - \param [in] a_sName operator Identifier - \param [in] a_pFun Operator callback function - \param [in] a_iPrec Operator Precedence (default=prSIGN) - \param [in] a_bAllowOpt True if operator is volatile (default=false) - \sa EPrec - */ - void ParserBase::DefineInfixOprt(const string_type& a_sName, fun_type1 a_pFun, int a_iPrec, bool a_bAllowOpt) - { - if (a_sName.length() > MaxLenIdentifier) - Error(ecIDENTIFIER_TOO_LONG); - - AddCallback(a_sName, ParserCallback(a_pFun, a_bAllowOpt, a_iPrec, cmOPRT_INFIX), m_InfixOprtDef, ValidInfixOprtChars()); - } - - - //--------------------------------------------------------------------------- - /** \brief Define a binary operator. - \param [in] a_sName The identifier of the operator. - \param [in] a_pFun Pointer to the callback function. - \param [in] a_iPrec Precedence of the operator. - \param [in] a_eAssociativity The associativity of the operator. - \param [in] a_bAllowOpt If this is true the operator may be optimized away. - - Adds a new Binary operator the the parser instance. - */ - void ParserBase::DefineOprt(const string_type& a_sName, fun_type2 a_pFun, unsigned a_iPrec, EOprtAssociativity a_eAssociativity, bool a_bAllowOpt) - { - if (a_sName.length() > MaxLenIdentifier) - Error(ecIDENTIFIER_TOO_LONG); - - // Check for conflicts with built in operator names - for (int i = 0; m_bBuiltInOp && i < cmENDIF; ++i) - { - if (a_sName == string_type(c_DefaultOprt[i])) - { - Error(ecBUILTIN_OVERLOAD, -1, a_sName); - } - } - - AddCallback(a_sName, ParserCallback(a_pFun, a_bAllowOpt, a_iPrec, a_eAssociativity), m_OprtDef, ValidOprtChars()); - } - - //--------------------------------------------------------------------------- - /** \brief Define a new string constant. - \param [in] a_strName The name of the constant. - \param [in] a_strVal the value of the constant. - */ - void ParserBase::DefineStrConst(const string_type& a_strName, const string_type& a_strVal) - { - // Test if a constant with that names already exists - if (m_StrVarDef.find(a_strName) != m_StrVarDef.end()) - Error(ecNAME_CONFLICT); - - CheckName(a_strName, ValidNameChars()); - - m_vStringVarBuf.push_back(a_strVal); // Store variable string in internal buffer - m_StrVarDef[a_strName] = m_vStringVarBuf.size() - 1; // bind buffer index to variable name - - ReInit(); - } - - //--------------------------------------------------------------------------- - /** \brief Add a user defined variable. - \param [in] a_sName the variable name - \param [in] a_pVar A pointer to the variable value. - \post Will reset the Parser to string parsing mode. - \throw ParserException in case the name contains invalid signs or a_pVar is nullptr. - */ - void ParserBase::DefineVar(const string_type& a_sName, value_type* a_pVar) - { - if (a_pVar == 0) - Error(ecINVALID_VAR_PTR); - - if (a_sName.length() > MaxLenIdentifier) - Error(ecIDENTIFIER_TOO_LONG); - - // Test if a constant with that names already exists - if (m_ConstDef.find(a_sName) != m_ConstDef.end()) - Error(ecNAME_CONFLICT); - - CheckName(a_sName, ValidNameChars()); - m_VarDef[a_sName] = a_pVar; - ReInit(); - } - - //--------------------------------------------------------------------------- - /** \brief Add a user defined constant. - \param [in] a_sName The name of the constant. - \param [in] a_fVal the value of the constant. - \post Will reset the Parser to string parsing mode. - \throw ParserException in case the name contains invalid signs. - */ - void ParserBase::DefineConst(const string_type& a_sName, value_type a_fVal) - { - if (a_sName.length() > MaxLenIdentifier) - Error(ecIDENTIFIER_TOO_LONG); - - CheckName(a_sName, ValidNameChars()); - m_ConstDef[a_sName] = a_fVal; - ReInit(); - } - - //--------------------------------------------------------------------------- - /** \brief Get operator priority. - \throw ParserException if a_Oprt is no operator code - */ - int ParserBase::GetOprtPrecedence(const token_type& a_Tok) const - { - switch (a_Tok.GetCode()) - { - // built in operators - case cmEND: return -5; - case cmARG_SEP: return -4; - case cmASSIGN: return -1; - case cmELSE: - case cmIF: return 0; - case cmLAND: return prLAND; - case cmLOR: return prLOR; - case cmLT: - case cmGT: - case cmLE: - case cmGE: - case cmNEQ: - case cmEQ: return prCMP; - case cmADD: - case cmSUB: return prADD_SUB; - case cmMUL: - case cmDIV: return prMUL_DIV; - case cmPOW: return prPOW; - - // user defined binary operators - case cmOPRT_INFIX: - case cmOPRT_BIN: return a_Tok.GetPri(); - default: - throw exception_type(ecINTERNAL_ERROR, 5, _T("")); - } - } - - //--------------------------------------------------------------------------- - /** \brief Get operator priority. - \throw ParserException if a_Oprt is no operator code - */ - EOprtAssociativity ParserBase::GetOprtAssociativity(const token_type& a_Tok) const - { - switch (a_Tok.GetCode()) - { - case cmASSIGN: - case cmLAND: - case cmLOR: - case cmLT: - case cmGT: - case cmLE: - case cmGE: - case cmNEQ: - case cmEQ: - case cmADD: - case cmSUB: - case cmMUL: - case cmDIV: return oaLEFT; - case cmPOW: return oaRIGHT; - case cmOPRT_BIN: return a_Tok.GetAssociativity(); - default: return oaNONE; - } - } - - //--------------------------------------------------------------------------- - /** \brief Return a map containing the used variables only. */ - const varmap_type& ParserBase::GetUsedVar() const - { - try - { - m_pTokenReader->IgnoreUndefVar(true); - CreateRPN(); // try to create bytecode, but don't use it for any further calculations since it - // may contain references to nonexisting variables. - m_pParseFormula = &ParserBase::ParseString; - m_pTokenReader->IgnoreUndefVar(false); - } - catch (exception_type& /*e*/) - { - // Make sure to stay in string parse mode, don't call ReInit() - // because it deletes the array with the used variables - m_pParseFormula = &ParserBase::ParseString; - m_pTokenReader->IgnoreUndefVar(false); - throw; - } - - return m_pTokenReader->GetUsedVar(); - } - - //--------------------------------------------------------------------------- - /** \brief Return a map containing the used variables only. */ - const varmap_type& ParserBase::GetVar() const - { - return m_VarDef; - } - - //--------------------------------------------------------------------------- - /** \brief Return a map containing all parser constants. */ - const valmap_type& ParserBase::GetConst() const - { - return m_ConstDef; - } - - //--------------------------------------------------------------------------- - /** \brief Return prototypes of all parser functions. - \return #m_FunDef - \sa FunProt - \throw nothrow - - The return type is a map of the public type #funmap_type containing the prototype - definitions for all numerical parser functions. String functions are not part of - this map. The Prototype definition is encapsulated in objects of the class FunProt - one per parser function each associated with function names via a map construct. - */ - const funmap_type& ParserBase::GetFunDef() const - { - return m_FunDef; - } - - //--------------------------------------------------------------------------- - /** \brief Retrieve the formula. */ - const string_type& ParserBase::GetExpr() const - { - return m_pTokenReader->GetExpr(); - } - - //--------------------------------------------------------------------------- - /** \brief Execute a function that takes a single string argument. - \param a_FunTok Function token. - \throw exception_type If the function token is not a string function - */ - ParserBase::token_type ParserBase::ApplyStrFunc( - const token_type& a_FunTok, - const std::vector& a_vArg) const - { - if (a_vArg.back().GetCode() != cmSTRING) - Error(ecSTRING_EXPECTED, m_pTokenReader->GetPos(), a_FunTok.GetAsString()); - - token_type valTok; - generic_callable_type pFunc = a_FunTok.GetFuncAddr(); - MUP_ASSERT(pFunc); - - try - { - // Check function arguments; write dummy value into valtok to represent the result - switch (a_FunTok.GetArgCount()) - { - case 0: valTok.SetVal(1); a_vArg[0].GetAsString(); break; - case 1: valTok.SetVal(1); a_vArg[1].GetAsString(); a_vArg[0].GetVal(); break; - case 2: valTok.SetVal(1); a_vArg[2].GetAsString(); a_vArg[1].GetVal(); a_vArg[0].GetVal(); break; - case 3: valTok.SetVal(1); a_vArg[3].GetAsString(); a_vArg[2].GetVal(); a_vArg[1].GetVal(); a_vArg[0].GetVal(); break; - case 4: valTok.SetVal(1); a_vArg[4].GetAsString(); a_vArg[3].GetVal(); a_vArg[2].GetVal(); a_vArg[1].GetVal(); a_vArg[0].GetVal(); break; - case 5: valTok.SetVal(1); a_vArg[5].GetAsString(); a_vArg[4].GetVal(); a_vArg[3].GetVal(); a_vArg[2].GetVal(); a_vArg[1].GetVal(); a_vArg[0].GetVal(); break; - default: Error(ecINTERNAL_ERROR); - } - } - catch (ParserError&) - { - Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), a_FunTok.GetAsString()); - } - - // string functions won't be optimized - m_vRPN.AddStrFun(pFunc, a_FunTok.GetArgCount(), a_vArg.back().GetIdx()); - - // Push dummy value representing the function result to the stack - return valTok; - } - - //--------------------------------------------------------------------------- - /** \brief Apply a function token. - \param iArgCount Number of Arguments actually gathered used only for multiarg functions. - \post The result is pushed to the value stack - \post The function token is removed from the stack - \throw exception_type if Argument count does not match function requirements. - */ - void ParserBase::ApplyFunc(std::stack& a_stOpt, std::stack& a_stVal, int a_iArgCount) const - { - MUP_ASSERT(m_pTokenReader.get()); - - // Operator stack empty or does not contain tokens with callback functions - if (a_stOpt.empty() || a_stOpt.top().GetFuncAddr() == 0) - return; - - token_type funTok = a_stOpt.top(); - a_stOpt.pop(); - MUP_ASSERT(funTok.GetFuncAddr() != nullptr); - - // Binary operators must rely on their internal operator number - // since counting of operators relies on commas for function arguments - // binary operators do not have commas in their expression - int iArgCount = (funTok.GetCode() == cmOPRT_BIN) ? funTok.GetArgCount() : a_iArgCount; - - // determine how many parameters the function needs. To remember iArgCount includes the - // string parameter whilst GetArgCount() counts only numeric parameters. - int iArgRequired = funTok.GetArgCount() + ((funTok.GetType() == tpSTR) ? 1 : 0); - - // That's the number of numerical parameters - int iArgNumerical = iArgCount - ((funTok.GetType() == tpSTR) ? 1 : 0); - - if (funTok.GetCode() == cmFUNC_STR && iArgCount - iArgNumerical > 1) - Error(ecINTERNAL_ERROR); - - if (funTok.GetArgCount() >= 0 && iArgCount > iArgRequired) - Error(ecTOO_MANY_PARAMS, m_pTokenReader->GetPos() - 1, funTok.GetAsString()); - - if (funTok.GetCode() != cmOPRT_BIN && iArgCount < iArgRequired) - Error(ecTOO_FEW_PARAMS, m_pTokenReader->GetPos() - 1, funTok.GetAsString()); - - if (funTok.GetCode() == cmFUNC_STR && iArgCount > iArgRequired) - Error(ecTOO_MANY_PARAMS, m_pTokenReader->GetPos() - 1, funTok.GetAsString()); - - // Collect the numeric function arguments from the value stack and store them - // in a vector - std::vector stArg; - for (int i = 0; i < iArgNumerical; ++i) - { - if (a_stVal.empty()) - Error(ecINTERNAL_ERROR, m_pTokenReader->GetPos(), funTok.GetAsString()); - - stArg.push_back(a_stVal.top()); - a_stVal.pop(); - - if (stArg.back().GetType() == tpSTR && funTok.GetType() != tpSTR) - Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), funTok.GetAsString()); - } - - switch (funTok.GetCode()) - { - case cmFUNC_STR: - if (a_stVal.empty()) - Error(ecINTERNAL_ERROR, m_pTokenReader->GetPos(), funTok.GetAsString()); - - stArg.push_back(a_stVal.top()); - a_stVal.pop(); - - if (stArg.back().GetType() == tpSTR && funTok.GetType() != tpSTR) - Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), funTok.GetAsString()); - - ApplyStrFunc(funTok, stArg); - break; - - case cmFUNC_BULK: - m_vRPN.AddBulkFun(funTok.GetFuncAddr(), (int)stArg.size()); - break; - - case cmOPRT_BIN: - case cmOPRT_POSTFIX: - case cmOPRT_INFIX: - case cmFUNC: - if (funTok.GetArgCount() == -1 && iArgCount == 0) - Error(ecTOO_FEW_PARAMS, m_pTokenReader->GetPos(), funTok.GetAsString()); - - m_vRPN.AddFun(funTok.GetFuncAddr(), (funTok.GetArgCount() == -1) ? -iArgNumerical : iArgNumerical, funTok.IsOptimizable()); - break; - default: - break; - } - - // Push dummy value representing the function result to the stack - token_type token; - token.SetVal(1); - a_stVal.push(token); - } - - //--------------------------------------------------------------------------- - void ParserBase::ApplyIfElse(std::stack& a_stOpt, std::stack& a_stVal) const - { - // Check if there is an if Else clause to be calculated - while (a_stOpt.size() && a_stOpt.top().GetCode() == cmELSE) - { - MUP_ASSERT(!a_stOpt.empty()) - token_type opElse = a_stOpt.top(); - a_stOpt.pop(); - - // Take the value associated with the else branch from the value stack - MUP_ASSERT(!a_stVal.empty()); - token_type vVal2 = a_stVal.top(); - if (vVal2.GetType() != tpDBL) - Error(ecUNEXPECTED_STR, m_pTokenReader->GetPos()); - - a_stVal.pop(); - - // it then else is a ternary operator Pop all three values from the value s - // tack and just return the right value - MUP_ASSERT(!a_stVal.empty()); - token_type vVal1 = a_stVal.top(); - if (vVal1.GetType() != tpDBL) - Error(ecUNEXPECTED_STR, m_pTokenReader->GetPos()); - - a_stVal.pop(); - - MUP_ASSERT(!a_stVal.empty()); - token_type vExpr = a_stVal.top(); - a_stVal.pop(); - - a_stVal.push((vExpr.GetVal() != 0) ? vVal1 : vVal2); - - token_type opIf = a_stOpt.top(); - a_stOpt.pop(); - - MUP_ASSERT(opElse.GetCode() == cmELSE); - - if (opIf.GetCode() != cmIF) - Error(ecMISPLACED_COLON, m_pTokenReader->GetPos()); - - m_vRPN.AddIfElse(cmENDIF); - } // while pending if-else-clause found - } - - //--------------------------------------------------------------------------- - /** \brief Performs the necessary steps to write code for - the execution of binary operators into the bytecode. - */ - void ParserBase::ApplyBinOprt(std::stack& a_stOpt, std::stack& a_stVal) const - { - // is it a user defined binary operator? - if (a_stOpt.top().GetCode() == cmOPRT_BIN) - { - ApplyFunc(a_stOpt, a_stVal, 2); - } - else - { - if (a_stVal.size() < 2) - Error(ecINTERNAL_ERROR, m_pTokenReader->GetPos(), _T("ApplyBinOprt: not enough values in value stack!")); - - token_type valTok1 = a_stVal.top(); - a_stVal.pop(); - - token_type valTok2 = a_stVal.top(); - a_stVal.pop(); - - token_type optTok = a_stOpt.top(); - a_stOpt.pop(); - - token_type resTok; - - if (valTok1.GetType() != valTok2.GetType() || - (valTok1.GetType() == tpSTR && valTok2.GetType() == tpSTR)) - Error(ecOPRT_TYPE_CONFLICT, m_pTokenReader->GetPos(), optTok.GetAsString()); - - if (optTok.GetCode() == cmASSIGN) - { - if (valTok2.GetCode() != cmVAR) - Error(ecUNEXPECTED_OPERATOR, -1, _T("=")); - - m_vRPN.AddAssignOp(valTok2.GetVar()); - } - else - m_vRPN.AddOp(optTok.GetCode()); - - resTok.SetVal(1); - a_stVal.push(resTok); - } - } - - //--------------------------------------------------------------------------- - /** \brief Apply a binary operator. - \param a_stOpt The operator stack - \param a_stVal The value stack - */ - void ParserBase::ApplyRemainingOprt(std::stack& stOpt, std::stack& stVal) const - { - while (stOpt.size() && - stOpt.top().GetCode() != cmBO && - stOpt.top().GetCode() != cmIF) - { - token_type tok = stOpt.top(); - switch (tok.GetCode()) - { - case cmOPRT_INFIX: - case cmOPRT_BIN: - case cmLE: - case cmGE: - case cmNEQ: - case cmEQ: - case cmLT: - case cmGT: - case cmADD: - case cmSUB: - case cmMUL: - case cmDIV: - case cmPOW: - case cmLAND: - case cmLOR: - case cmASSIGN: - if (stOpt.top().GetCode() == cmOPRT_INFIX) - ApplyFunc(stOpt, stVal, 1); - else - ApplyBinOprt(stOpt, stVal); - break; - - case cmELSE: - ApplyIfElse(stOpt, stVal); - break; - - default: - Error(ecINTERNAL_ERROR); - } - } - } - - //--------------------------------------------------------------------------- - /** \brief Parse the command code. - \sa ParseString(...) - - Command code contains precalculated stack positions of the values and the - associated operators. The Stack is filled beginning from index one the - value at index zero is not used at all. - */ - value_type ParserBase::ParseCmdCode() const - { - return ParseCmdCodeBulk(0, 0); - } - - value_type ParserBase::ParseCmdCodeShort() const - { - const SToken *const tok = m_vRPN.GetBase(); - value_type buf; - - switch (tok->Cmd) - { - case cmVAL: - return tok->Val.data2; - - case cmVAR: - return *tok->Val.ptr; - - case cmVARMUL: - return *tok->Val.ptr * tok->Val.data + tok->Val.data2; - - case cmVARPOW2: - buf = *(tok->Val.ptr); - return buf * buf; - - case cmVARPOW3: - buf = *(tok->Val.ptr); - return buf * buf * buf; - - case cmVARPOW4: - buf = *(tok->Val.ptr); - return buf * buf * buf * buf; - - // numerical function without any argument - case cmFUNC: - return tok->Fun.cb.call_fun<0>(); - - // String function without a numerical argument - case cmFUNC_STR: - return tok->Fun.cb.call_strfun<1>(m_vStringBuf[0].c_str()); - - default: - throw ParserError(ecINTERNAL_ERROR); - } - } - - //--------------------------------------------------------------------------- - /** \brief Evaluate the RPN. - \param nOffset The offset added to variable addresses (for bulk mode) - \param nThreadID OpenMP Thread id of the calling thread - */ - value_type ParserBase::ParseCmdCodeBulk(int nOffset, int nThreadID) const - { - assert(nThreadID <= s_MaxNumOpenMPThreads); - - // Note: The check for nOffset==0 and nThreadID here is not necessary but - // brings a minor performance gain when not in bulk mode. - value_type *stack = ((nOffset == 0) && (nThreadID == 0)) ? &m_vStackBuffer[0] : &m_vStackBuffer[nThreadID * (m_vStackBuffer.size() / s_MaxNumOpenMPThreads)]; - value_type buf; - int sidx(0); - for (const SToken* pTok = m_vRPN.GetBase(); pTok->Cmd != cmEND; ++pTok) - { - switch (pTok->Cmd) - { - // built in binary operators - case cmLE: --sidx; stack[sidx] = stack[sidx] <= stack[sidx + 1]; continue; - case cmGE: --sidx; stack[sidx] = stack[sidx] >= stack[sidx + 1]; continue; - case cmNEQ: --sidx; stack[sidx] = stack[sidx] != stack[sidx + 1]; continue; - case cmEQ: --sidx; stack[sidx] = stack[sidx] == stack[sidx + 1]; continue; - case cmLT: --sidx; stack[sidx] = stack[sidx] < stack[sidx + 1]; continue; - case cmGT: --sidx; stack[sidx] = stack[sidx] > stack[sidx + 1]; continue; - case cmADD: --sidx; stack[sidx] += stack[1 + sidx]; continue; - case cmSUB: --sidx; stack[sidx] -= stack[1 + sidx]; continue; - case cmMUL: --sidx; stack[sidx] *= stack[1 + sidx]; continue; - case cmDIV: --sidx; - stack[sidx] /= stack[1 + sidx]; - continue; - - case cmPOW: - --sidx; stack[sidx] = MathImpl::Pow(stack[sidx], stack[1 + sidx]); - continue; - - case cmLAND: --sidx; stack[sidx] = stack[sidx] && stack[sidx + 1]; continue; - case cmLOR: --sidx; stack[sidx] = stack[sidx] || stack[sidx + 1]; continue; - - case cmASSIGN: - // Bugfix for Bulkmode: - // for details see: - // https://groups.google.com/forum/embed/?place=forum/muparser-dev&showsearch=true&showpopout=true&showtabs=false&parenturl=http://muparser.beltoforion.de/mup_forum.html&afterlogin&pli=1#!topic/muparser-dev/szgatgoHTws - --sidx; - stack[sidx] = *(pTok->Oprt.ptr + nOffset) = stack[sidx + 1]; - continue; - // original code: - //--sidx; Stack[sidx] = *pTok->Oprt.ptr = Stack[sidx+1]; continue; - - case cmIF: - if (stack[sidx--] == 0) - { - MUP_ASSERT(sidx >= 0); - pTok += pTok->Oprt.offset; - } - continue; - - case cmELSE: - pTok += pTok->Oprt.offset; - continue; - - case cmENDIF: - continue; - - // value and variable tokens - case cmVAR: stack[++sidx] = *(pTok->Val.ptr + nOffset); continue; - case cmVAL: stack[++sidx] = pTok->Val.data2; continue; - - case cmVARPOW2: buf = *(pTok->Val.ptr + nOffset); - stack[++sidx] = buf * buf; - continue; - - case cmVARPOW3: buf = *(pTok->Val.ptr + nOffset); - stack[++sidx] = buf * buf * buf; - continue; - - case cmVARPOW4: buf = *(pTok->Val.ptr + nOffset); - stack[++sidx] = buf * buf * buf * buf; - continue; - - case cmVARMUL: - stack[++sidx] = *(pTok->Val.ptr + nOffset) * pTok->Val.data + pTok->Val.data2; - continue; - - // Next is treatment of numeric functions - case cmFUNC: - { - int iArgCount = pTok->Fun.argc; - - // switch according to argument count - switch (iArgCount) - { - case 0: sidx += 1; stack[sidx] = pTok->Fun.cb.call_fun<0 >(); continue; - case 1: stack[sidx] = pTok->Fun.cb.call_fun<1 >(stack[sidx]); continue; - case 2: sidx -= 1; stack[sidx] = pTok->Fun.cb.call_fun<2 >(stack[sidx], stack[sidx + 1]); continue; - case 3: sidx -= 2; stack[sidx] = pTok->Fun.cb.call_fun<3 >(stack[sidx], stack[sidx + 1], stack[sidx + 2]); continue; - case 4: sidx -= 3; stack[sidx] = pTok->Fun.cb.call_fun<4 >(stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3]); continue; - case 5: sidx -= 4; stack[sidx] = pTok->Fun.cb.call_fun<5 >(stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3], stack[sidx + 4]); continue; - case 6: sidx -= 5; stack[sidx] = pTok->Fun.cb.call_fun<6 >(stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3], stack[sidx + 4], stack[sidx + 5]); continue; - case 7: sidx -= 6; stack[sidx] = pTok->Fun.cb.call_fun<7 >(stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3], stack[sidx + 4], stack[sidx + 5], stack[sidx + 6]); continue; - case 8: sidx -= 7; stack[sidx] = pTok->Fun.cb.call_fun<8 >(stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3], stack[sidx + 4], stack[sidx + 5], stack[sidx + 6], stack[sidx + 7]); continue; - case 9: sidx -= 8; stack[sidx] = pTok->Fun.cb.call_fun<9 >(stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3], stack[sidx + 4], stack[sidx + 5], stack[sidx + 6], stack[sidx + 7], stack[sidx + 8]); continue; - case 10:sidx -= 9; stack[sidx] = pTok->Fun.cb.call_fun<10>(stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3], stack[sidx + 4], stack[sidx + 5], stack[sidx + 6], stack[sidx + 7], stack[sidx + 8], stack[sidx + 9]); continue; - default: - // function with variable arguments store the number as a negative value - if (iArgCount > 0) - Error(ecINTERNAL_ERROR, -1); - - sidx -= -iArgCount - 1; - - // From oss-fuzz. Happend when Multiarg functions and if-then-else are used incorrectly. - // Expressions where this was observed: - // sum(0?1,2,3,4,5:6) -> fixed - // avg(0>3?4:(""),0^3?4:("")) - // - // The final result normally lieas at position 1. If sixd is smaller there is something wrong. - if (sidx <= 0) - Error(ecINTERNAL_ERROR, -1); - // - - stack[sidx] = pTok->Fun.cb.call_multfun(&stack[sidx], -iArgCount); - continue; - } - } - - // Next is treatment of string functions - case cmFUNC_STR: - { - sidx -= pTok->Fun.argc - 1; - - // The index of the string argument in the string table - int iIdxStack = pTok->Fun.idx; - if (iIdxStack < 0 || iIdxStack >= (int)m_vStringBuf.size()) - Error(ecINTERNAL_ERROR, m_pTokenReader->GetPos()); - - switch (pTok->Fun.argc) // switch according to argument count - { - case 0: stack[sidx] = pTok->Fun.cb.call_strfun<1>(m_vStringBuf[iIdxStack].c_str()); continue; - case 1: stack[sidx] = pTok->Fun.cb.call_strfun<2>(m_vStringBuf[iIdxStack].c_str(), stack[sidx]); continue; - case 2: stack[sidx] = pTok->Fun.cb.call_strfun<3>(m_vStringBuf[iIdxStack].c_str(), stack[sidx], stack[sidx + 1]); continue; - case 3: stack[sidx] = pTok->Fun.cb.call_strfun<4>(m_vStringBuf[iIdxStack].c_str(), stack[sidx], stack[sidx + 1], stack[sidx + 2]); continue; - case 4: stack[sidx] = pTok->Fun.cb.call_strfun<5>(m_vStringBuf[iIdxStack].c_str(), stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3]); continue; - case 5: stack[sidx] = pTok->Fun.cb.call_strfun<6>(m_vStringBuf[iIdxStack].c_str(), stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3], stack[sidx + 4]); continue; - } - - continue; - } - - case cmFUNC_BULK: - { - int iArgCount = pTok->Fun.argc; - - // switch according to argument count - switch (iArgCount) - { - case 0: sidx += 1; stack[sidx] = pTok->Fun.cb.call_bulkfun<0 >(nOffset, nThreadID); continue; - case 1: stack[sidx] = pTok->Fun.cb.call_bulkfun<1 >(nOffset, nThreadID, stack[sidx]); continue; - case 2: sidx -= 1; stack[sidx] = pTok->Fun.cb.call_bulkfun<2 >(nOffset, nThreadID, stack[sidx], stack[sidx + 1]); continue; - case 3: sidx -= 2; stack[sidx] = pTok->Fun.cb.call_bulkfun<3 >(nOffset, nThreadID, stack[sidx], stack[sidx + 1], stack[sidx + 2]); continue; - case 4: sidx -= 3; stack[sidx] = pTok->Fun.cb.call_bulkfun<4 >(nOffset, nThreadID, stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3]); continue; - case 5: sidx -= 4; stack[sidx] = pTok->Fun.cb.call_bulkfun<5 >(nOffset, nThreadID, stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3], stack[sidx + 4]); continue; - case 6: sidx -= 5; stack[sidx] = pTok->Fun.cb.call_bulkfun<6 >(nOffset, nThreadID, stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3], stack[sidx + 4], stack[sidx + 5]); continue; - case 7: sidx -= 6; stack[sidx] = pTok->Fun.cb.call_bulkfun<7 >(nOffset, nThreadID, stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3], stack[sidx + 4], stack[sidx + 5], stack[sidx + 6]); continue; - case 8: sidx -= 7; stack[sidx] = pTok->Fun.cb.call_bulkfun<8 >(nOffset, nThreadID, stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3], stack[sidx + 4], stack[sidx + 5], stack[sidx + 6], stack[sidx + 7]); continue; - case 9: sidx -= 8; stack[sidx] = pTok->Fun.cb.call_bulkfun<9 >(nOffset, nThreadID, stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3], stack[sidx + 4], stack[sidx + 5], stack[sidx + 6], stack[sidx + 7], stack[sidx + 8]); continue; - case 10:sidx -= 9; stack[sidx] = pTok->Fun.cb.call_bulkfun<10>(nOffset, nThreadID, stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3], stack[sidx + 4], stack[sidx + 5], stack[sidx + 6], stack[sidx + 7], stack[sidx + 8], stack[sidx + 9]); continue; - default: - throw exception_type(ecINTERNAL_ERROR, 2, _T("")); - } - } - - default: - throw exception_type(ecINTERNAL_ERROR, 3, _T("")); - } // switch CmdCode - } // for all bytecode tokens - - return stack[m_nFinalResultIdx]; - } - - //--------------------------------------------------------------------------- - void ParserBase::CreateRPN() const - { - if (!m_pTokenReader->GetExpr().length()) - Error(ecUNEXPECTED_EOF, 0); - - std::stack stOpt, stVal; - std::stack stArgCount; - token_type opta, opt; // for storing operators - token_type val, tval; // for storing value - int ifElseCounter = 0; - - ReInit(); - - // The outermost counter counts the number of separated items - // such as in "a=10,b=20,c=c+a" - stArgCount.push(1); - - for (;;) - { - opt = m_pTokenReader->ReadNextToken(); - - switch (opt.GetCode()) - { - // - // Next three are different kind of value entries - // - case cmSTRING: - if (stOpt.empty()) - Error(ecSTR_RESULT, m_pTokenReader->GetPos(), opt.GetAsString()); - - opt.SetIdx((int)m_vStringBuf.size()); // Assign buffer index to token - stVal.push(opt); - m_vStringBuf.push_back(opt.GetAsString()); // Store string in internal buffer - break; - - case cmVAR: - stVal.push(opt); - m_vRPN.AddVar(static_cast(opt.GetVar())); - break; - - case cmVAL: - stVal.push(opt); - m_vRPN.AddVal(opt.GetVal()); - break; - - case cmELSE: - if (stArgCount.empty()) - Error(ecMISPLACED_COLON, m_pTokenReader->GetPos()); - - if (stArgCount.top() > 1) - Error(ecUNEXPECTED_ARG_SEP, m_pTokenReader->GetPos()); - - stArgCount.pop(); - - ifElseCounter--; - if (ifElseCounter < 0) - Error(ecMISPLACED_COLON, m_pTokenReader->GetPos()); - - ApplyRemainingOprt(stOpt, stVal); - m_vRPN.AddIfElse(cmELSE); - stOpt.push(opt); - break; - - case cmARG_SEP: - if (!stOpt.empty() && stOpt.top().GetCode() == cmIF) - Error(ecUNEXPECTED_ARG_SEP, m_pTokenReader->GetPos()); - - if (stArgCount.empty()) - Error(ecUNEXPECTED_ARG_SEP, m_pTokenReader->GetPos()); - - ++stArgCount.top(); - // Falls through. - // intentional (no break!) - - case cmEND: - ApplyRemainingOprt(stOpt, stVal); - break; - - case cmBC: - { - // The argument count for parameterless functions is zero - // by default an opening bracket sets parameter count to 1 - // in preparation of arguments to come. If the last token - // was an opening bracket we know better... - if (opta.GetCode() == cmBO) - --stArgCount.top(); - - ApplyRemainingOprt(stOpt, stVal); - - // Check if the bracket content has been evaluated completely - if (stOpt.size() && stOpt.top().GetCode() == cmBO) - { - // if opt is ")" and opta is "(" the bracket has been evaluated, now its time to check - // if there is either a function or a sign pending - // neither the opening nor the closing bracket will be pushed back to - // the operator stack - // Check if a function is standing in front of the opening bracket, - // if yes evaluate it afterwards check for infix operators - MUP_ASSERT(stArgCount.size()); - int iArgCount = stArgCount.top(); - stArgCount.pop(); - - stOpt.pop(); // Take opening bracket from stack - - if (iArgCount > 1 && (stOpt.size() == 0 || - (stOpt.top().GetCode() != cmFUNC && - stOpt.top().GetCode() != cmFUNC_BULK && - stOpt.top().GetCode() != cmFUNC_STR))) - Error(ecUNEXPECTED_ARG, m_pTokenReader->GetPos()); - - // The opening bracket was popped from the stack now check if there - // was a function before this bracket - if (stOpt.size() && - stOpt.top().GetCode() != cmOPRT_INFIX && - stOpt.top().GetCode() != cmOPRT_BIN && - stOpt.top().GetFuncAddr() != 0) - { - ApplyFunc(stOpt, stVal, iArgCount); - } - } - } // if bracket content is evaluated - break; - - // - // Next are the binary operator entries - // - case cmIF: - ifElseCounter++; - stArgCount.push(1); - // Falls through. - // intentional (no break!) - - case cmLAND: - case cmLOR: - case cmLT: - case cmGT: - case cmLE: - case cmGE: - case cmNEQ: - case cmEQ: - case cmADD: - case cmSUB: - case cmMUL: - case cmDIV: - case cmPOW: - case cmASSIGN: - case cmOPRT_BIN: - - // A binary operator (user defined or built in) has been found. - while ( - stOpt.size() && - stOpt.top().GetCode() != cmBO && - stOpt.top().GetCode() != cmELSE && - stOpt.top().GetCode() != cmIF) - { - int nPrec1 = GetOprtPrecedence(stOpt.top()), - nPrec2 = GetOprtPrecedence(opt); - - if (stOpt.top().GetCode() == opt.GetCode()) - { - - // Deal with operator associativity - EOprtAssociativity eOprtAsct = GetOprtAssociativity(opt); - if ((eOprtAsct == oaRIGHT && (nPrec1 <= nPrec2)) || - (eOprtAsct == oaLEFT && (nPrec1 < nPrec2))) - { - break; - } - } - else if (nPrec1 < nPrec2) - { - // In case the operators are not equal the precedence decides alone... - break; - } - - if (stOpt.top().GetCode() == cmOPRT_INFIX) - ApplyFunc(stOpt, stVal, 1); - else - ApplyBinOprt(stOpt, stVal); - } // while ( ... ) - - if (opt.GetCode() == cmIF) - m_vRPN.AddIfElse(opt.GetCode()); - - // The operator can't be evaluated right now, push back to the operator stack - stOpt.push(opt); - break; - - // - // Last section contains functions and operators implicitly mapped to functions - // - case cmBO: - stArgCount.push(1); - stOpt.push(opt); - break; - - case cmOPRT_INFIX: - case cmFUNC: - case cmFUNC_BULK: - case cmFUNC_STR: - stOpt.push(opt); - break; - - case cmOPRT_POSTFIX: - stOpt.push(opt); - ApplyFunc(stOpt, stVal, 1); // this is the postfix operator - break; - - default: Error(ecINTERNAL_ERROR, 3); - } // end of switch operator-token - - opta = opt; - - if (opt.GetCode() == cmEND) - { - m_vRPN.Finalize(); - break; - } - - if (ParserBase::g_DbgDumpStack) - { - StackDump(stVal, stOpt); - m_vRPN.AsciiDump(); - } - -// if (ParserBase::g_DbgDumpCmdCode) - //m_vRPN.AsciiDump(); - } // while (true) - - if (ParserBase::g_DbgDumpCmdCode) - m_vRPN.AsciiDump(); - - if (ifElseCounter > 0) - Error(ecMISSING_ELSE_CLAUSE); - - // get the last value (= final result) from the stack - MUP_ASSERT(stArgCount.size() == 1); - m_nFinalResultIdx = stArgCount.top(); - if (m_nFinalResultIdx == 0) - Error(ecINTERNAL_ERROR, 9); - - if (stVal.size() == 0) - Error(ecEMPTY_EXPRESSION); - - // 2020-09-17; fix for https://oss-fuzz.com/testcase-detail/5758791700971520 - // I don't need the value stack any more. Destructively check if all values in the value - // stack represent floating point values - while (stVal.size()) - { - if (stVal.top().GetType() != tpDBL) - Error(ecSTR_RESULT); - - stVal.pop(); - } - - m_vStackBuffer.resize(m_vRPN.GetMaxStackSize() * s_MaxNumOpenMPThreads); - } - - //--------------------------------------------------------------------------- - /** \brief One of the two main parse functions. - \sa ParseCmdCode(...) - - Parse expression from input string. Perform syntax checking and create - bytecode. After parsing the string and creating the bytecode the function - pointer #m_pParseFormula will be changed to the second parse routine the - uses bytecode instead of string parsing. - */ - value_type ParserBase::ParseString() const - { - try - { - CreateRPN(); - - if (m_vRPN.GetSize() == 2) - { - m_pParseFormula = &ParserBase::ParseCmdCodeShort; - m_vStackBuffer[1] = (this->*m_pParseFormula)(); - return m_vStackBuffer[1]; - } - else - { - m_pParseFormula = &ParserBase::ParseCmdCode; - return (this->*m_pParseFormula)(); - } - } - catch (ParserError& exc) - { - exc.SetFormula(m_pTokenReader->GetExpr()); - throw; - } - } - - //--------------------------------------------------------------------------- - /** \brief Create an error containing the parse error position. - - This function will create an Parser Exception object containing the error text and - its position. - - \param a_iErrc [in] The error code of type #EErrorCodes. - \param a_iPos [in] The position where the error was detected. - \param a_strTok [in] The token string representation associated with the error. - \throw ParserException always throws that's the only purpose of this function. - */ - void ParserBase::Error(EErrorCodes a_iErrc, int a_iPos, const string_type& a_sTok) const - { - throw exception_type(a_iErrc, a_sTok, m_pTokenReader->GetExpr(), a_iPos); - } - - //------------------------------------------------------------------------------ - /** \brief Clear all user defined variables. - \throw nothrow - - Resets the parser to string parsing mode by calling #ReInit. - */ - void ParserBase::ClearVar() - { - m_VarDef.clear(); - ReInit(); - } - - //------------------------------------------------------------------------------ - /** \brief Remove a variable from internal storage. - \throw nothrow - - Removes a variable if it exists. If the Variable does not exist nothing will be done. - */ - void ParserBase::RemoveVar(const string_type& a_strVarName) - { - varmap_type::iterator item = m_VarDef.find(a_strVarName); - if (item != m_VarDef.end()) - { - m_VarDef.erase(item); - ReInit(); - } - } - - //------------------------------------------------------------------------------ - /** \brief Clear all functions. - \post Resets the parser to string parsing mode. - \throw nothrow - */ - void ParserBase::ClearFun() - { - m_FunDef.clear(); - ReInit(); - } - - //------------------------------------------------------------------------------ - /** \brief Clear all user defined constants. - - Both numeric and string constants will be removed from the internal storage. - \post Resets the parser to string parsing mode. - \throw nothrow - */ - void ParserBase::ClearConst() - { - m_ConstDef.clear(); - m_StrVarDef.clear(); - ReInit(); - } - - //------------------------------------------------------------------------------ - /** \brief Clear all user defined postfix operators. - \post Resets the parser to string parsing mode. - \throw nothrow - */ - void ParserBase::ClearPostfixOprt() - { - m_PostOprtDef.clear(); - ReInit(); - } - - //------------------------------------------------------------------------------ - /** \brief Clear all user defined binary operators. - \post Resets the parser to string parsing mode. - \throw nothrow - */ - void ParserBase::ClearOprt() - { - m_OprtDef.clear(); - ReInit(); - } - - //------------------------------------------------------------------------------ - /** \brief Clear the user defined Prefix operators. - \post Resets the parser to string parser mode. - \throw nothrow - */ - void ParserBase::ClearInfixOprt() - { - m_InfixOprtDef.clear(); - ReInit(); - } - - //------------------------------------------------------------------------------ - /** \brief Enable or disable the formula optimization feature. - \post Resets the parser to string parser mode. - \throw nothrow - */ - void ParserBase::EnableOptimizer(bool a_bIsOn) - { - m_vRPN.EnableOptimizer(a_bIsOn); - ReInit(); - } - - //--------------------------------------------------------------------------- - /** \brief Enable the dumping of bytecode and stack content on the console. - \param bDumpCmd Flag to enable dumping of the current bytecode to the console. - \param bDumpStack Flag to enable dumping of the stack content is written to the console. - - This function is for debug purposes only! - */ - void ParserBase::EnableDebugDump(bool bDumpCmd, bool bDumpStack) - { - ParserBase::g_DbgDumpCmdCode = bDumpCmd; - ParserBase::g_DbgDumpStack = bDumpStack; - } - - //------------------------------------------------------------------------------ - /** \brief Enable or disable the built in binary operators. - \throw nothrow - \sa m_bBuiltInOp, ReInit() - - If you disable the built in binary operators there will be no binary operators - defined. Thus you must add them manually one by one. It is not possible to - disable built in operators selectively. This function will Reinitialize the - parser by calling ReInit(). - */ - void ParserBase::EnableBuiltInOprt(bool a_bIsOn) - { - m_bBuiltInOp = a_bIsOn; - ReInit(); - } - - //------------------------------------------------------------------------------ - /** \brief Query status of built in variables. - \return #m_bBuiltInOp; true if built in operators are enabled. - \throw nothrow - */ - bool ParserBase::HasBuiltInOprt() const - { - return m_bBuiltInOp; - } - - //------------------------------------------------------------------------------ - /** \brief Get the argument separator character. - */ - char_type ParserBase::GetArgSep() const - { - return m_pTokenReader->GetArgSep(); - } - - //------------------------------------------------------------------------------ - /** \brief Set argument separator. - \param cArgSep the argument separator character. - */ - void ParserBase::SetArgSep(char_type cArgSep) - { - m_pTokenReader->SetArgSep(cArgSep); - } - - //------------------------------------------------------------------------------ - /** \brief Dump stack content. - - This function is used for debugging only. - */ - void ParserBase::StackDump(const std::stack& a_stVal, const std::stack& a_stOprt) const - { - std::stack stOprt(a_stOprt); - std::stack stVal(a_stVal); - - mu::console() << _T("\nValue stack:\n"); - while (!stVal.empty()) - { - token_type val = stVal.top(); - stVal.pop(); - - if (val.GetType() == tpSTR) - mu::console() << _T(" \"") << val.GetAsString() << _T("\" "); - else - mu::console() << _T(" ") << val.GetVal() << _T(" "); - } - mu::console() << "\nOperator stack:\n"; - - while (!stOprt.empty()) - { - if (stOprt.top().GetCode() <= cmASSIGN) - { - mu::console() << _T("OPRT_INTRNL \"") - << ParserBase::c_DefaultOprt[stOprt.top().GetCode()] - << _T("\" \n"); - } - else - { - switch (stOprt.top().GetCode()) - { - case cmVAR: mu::console() << _T("VAR\n"); break; - case cmVAL: mu::console() << _T("VAL\n"); break; - case cmFUNC: - mu::console() - << _T("FUNC \"") - << stOprt.top().GetAsString() - << _T("\"\n"); - break; - - case cmFUNC_BULK: - mu::console() - << _T("FUNC_BULK \"") - << stOprt.top().GetAsString() - << _T("\"\n"); - break; - - case cmOPRT_INFIX: - mu::console() << _T("OPRT_INFIX \"") - << stOprt.top().GetAsString() - << _T("\"\n"); - break; - - case cmOPRT_BIN: - mu::console() << _T("OPRT_BIN \"") - << stOprt.top().GetAsString() - << _T("\"\n"); - break; - - case cmFUNC_STR: mu::console() << _T("FUNC_STR\n"); break; - case cmEND: mu::console() << _T("END\n"); break; - case cmUNKNOWN: mu::console() << _T("UNKNOWN\n"); break; - case cmBO: mu::console() << _T("BRACKET \"(\"\n"); break; - case cmBC: mu::console() << _T("BRACKET \")\"\n"); break; - case cmIF: mu::console() << _T("IF\n"); break; - case cmELSE: mu::console() << _T("ELSE\n"); break; - case cmENDIF: mu::console() << _T("ENDIF\n"); break; - default: mu::console() << stOprt.top().GetCode() << _T(" "); break; - } - } - stOprt.pop(); - } - - mu::console() << dec << endl; - } - - /** \brief Calculate the result. - - A note on const correctness: - I consider it important that Calc is a const function. - Due to caching operations Calc changes only the state of internal variables with one exception - m_UsedVar this is reset during string parsing and accessible from the outside. Instead of making - Calc non const GetUsedVar is non const because it explicitly calls Eval() forcing this update. - - \pre A formula must be set. - \pre Variables must have been set (if needed) - - \sa #m_pParseFormula - \return The evaluation result - \throw ParseException if no Formula is set or in case of any other error related to the formula. - */ - value_type ParserBase::Eval() const - { - return (this->*m_pParseFormula)(); - } - - //------------------------------------------------------------------------------ - /** \brief Evaluate an expression containing comma separated subexpressions - \param [out] nStackSize The total number of results available - \return Pointer to the array containing all expression results - - This member function can be used to retrieve all results of an expression - made up of multiple comma separated subexpressions (i.e. "x+y,sin(x),cos(y)") - */ - value_type* ParserBase::Eval(int& nStackSize) const - { - if (m_vRPN.GetSize() > 0) - { - ParseCmdCode(); - } - else - { - ParseString(); - } - - nStackSize = m_nFinalResultIdx; - - // (for historic reasons the stack starts at position 1) - return &m_vStackBuffer[1]; - } - - //--------------------------------------------------------------------------- - /** \brief Return the number of results on the calculation stack. - - If the expression contains comma separated subexpressions (i.e. "sin(y), x+y"). - There may be more than one return value. This function returns the number of - available results. - */ - int ParserBase::GetNumResults() const - { - return m_nFinalResultIdx; - } - - //--------------------------------------------------------------------------- - void ParserBase::Eval(value_type* results, int nBulkSize) - { - CreateRPN(); - - int i = 0; + ss << _T(")"); + } + + return ss.str(); + } + + //--------------------------------------------------------------------------- + /** \brief Add a value parsing function. + + When parsing an expression muParser tries to detect values in the expression + string using different valident callbacks. Thus it's possible to parse + for hex values, binary values and floating point values. + */ + void + ParserBase::AddValIdent(identfun_type a_pCallback) { + m_pTokenReader->AddValIdent(a_pCallback); + } + + //--------------------------------------------------------------------------- + /** \brief Set a function that can create variable pointer for unknown expression variables. + \param a_pFactory A pointer to the variable factory. + \param pUserData A user defined context pointer. + */ + void + ParserBase::SetVarFactory(facfun_type a_pFactory, + void* pUserData) { + m_pTokenReader->SetVarCreator(a_pFactory, pUserData); + } + + //--------------------------------------------------------------------------- + /** \brief Add a function or operator callback to the parser. */ + void + ParserBase::AddCallback(const string_type& a_strName, + const ParserCallback& a_Callback, + funmap_type& a_Storage, + const char_type* a_szCharSet) { + if (!a_Callback.IsValid()) + Error(ecINVALID_FUN_PTR); + + const funmap_type* pFunMap = &a_Storage; + + // Check for conflicting operator or function names + if (pFunMap != &m_FunDef && m_FunDef.find(a_strName) != m_FunDef.end()) + Error(ecNAME_CONFLICT, -1, a_strName); + + if (pFunMap != &m_PostOprtDef && m_PostOprtDef.find(a_strName) != m_PostOprtDef.end()) + Error(ecNAME_CONFLICT, -1, a_strName); + + if (pFunMap != &m_InfixOprtDef && pFunMap != &m_OprtDef && + m_InfixOprtDef.find(a_strName) != m_InfixOprtDef.end()) + Error(ecNAME_CONFLICT, -1, a_strName); + + if (pFunMap != &m_InfixOprtDef && pFunMap != &m_OprtDef && m_OprtDef.find(a_strName) != m_OprtDef.end()) + Error(ecNAME_CONFLICT, -1, a_strName); + + CheckOprt(a_strName, a_Callback, a_szCharSet); + a_Storage[a_strName] = a_Callback; + ReInit(); + } + + //--------------------------------------------------------------------------- + /** \brief Check if a name contains invalid characters. + + \throw ParserException if the name contains invalid characters. + */ + void + ParserBase::CheckOprt(const string_type& a_sName, + const ParserCallback& a_Callback, + const string_type& a_szCharSet) const { + if (!a_sName.length() || (a_sName.find_first_not_of(a_szCharSet) != string_type::npos) || + (a_sName[0] >= '0' && a_sName[0] <= '9')) { + switch (a_Callback.GetCode()) { + case cmOPRT_POSTFIX: + Error(ecINVALID_POSTFIX_IDENT, -1, a_sName); + break; + case cmOPRT_INFIX: + Error(ecINVALID_INFIX_IDENT, -1, a_sName); + break; + default: + Error(ecINVALID_NAME, -1, a_sName); + } + } + } + + + /** \brief Check if a name contains invalid characters. + \throw ParserException if the name contains invalid characters. + */ + void + ParserBase::CheckName(const string_type& a_sName, + const string_type& a_szCharSet) const { + if (!a_sName.length() || (a_sName.find_first_not_of(a_szCharSet) != string_type::npos) || + (a_sName[0] >= '0' && a_sName[0] <= '9')) { + Error(ecINVALID_NAME); + } + } + + /** \brief Set the formula. + \param a_strFormula Formula as string_type + \throw ParserException in case of syntax errors. + + Triggers first time calculation thus the creation of the bytecode and + scanning of used variables. + */ + void + ParserBase::SetExpr(const string_type& a_sExpr) { + // Check locale compatibility + if (m_pTokenReader->GetArgSep() == std::use_facet>(s_locale).decimal_point()) + Error(ecLOCALE); + + // Check maximum allowed expression length. An arbitrary value small enough so i can debug expressions sent to + // me + if (a_sExpr.length() >= MaxLenExpression) + Error(ecEXPRESSION_TOO_LONG, 0, a_sExpr); + + m_pTokenReader->SetFormula(a_sExpr + _T(" ")); + ReInit(); + } + + //--------------------------------------------------------------------------- + /** \brief Get the default symbols used for the built in operators. + \sa c_DefaultOprt + */ + const char_type** + ParserBase::GetOprtDef() const { + return (const char_type**)(&c_DefaultOprt[0]); + } + + //--------------------------------------------------------------------------- + /** \brief Define the set of valid characters to be used in names of + functions, variables, constants. + */ + void + ParserBase::DefineNameChars(const char_type* a_szCharset) { + m_sNameChars = a_szCharset; + } + + //--------------------------------------------------------------------------- + /** \brief Define the set of valid characters to be used in names of + binary operators and postfix operators. + */ + void + ParserBase::DefineOprtChars(const char_type* a_szCharset) { + m_sOprtChars = a_szCharset; + } + + //--------------------------------------------------------------------------- + /** \brief Define the set of valid characters to be used in names of + infix operators. + */ + void + ParserBase::DefineInfixOprtChars(const char_type* a_szCharset) { + m_sInfixOprtChars = a_szCharset; + } + + //--------------------------------------------------------------------------- + /** \brief Virtual function that defines the characters allowed in name identifiers. + \sa #ValidOprtChars, #ValidPrefixOprtChars + */ + const char_type* + ParserBase::ValidNameChars() const { + MUP_ASSERT(m_sNameChars.size()); + return m_sNameChars.c_str(); + } + + //--------------------------------------------------------------------------- + /** \brief Virtual function that defines the characters allowed in operator definitions. + \sa #ValidNameChars, #ValidPrefixOprtChars + */ + const char_type* + ParserBase::ValidOprtChars() const { + MUP_ASSERT(m_sOprtChars.size()); + return m_sOprtChars.c_str(); + } + + //--------------------------------------------------------------------------- + /** \brief Virtual function that defines the characters allowed in infix operator definitions. + \sa #ValidNameChars, #ValidOprtChars + */ + const char_type* + ParserBase::ValidInfixOprtChars() const { + MUP_ASSERT(m_sInfixOprtChars.size()); + return m_sInfixOprtChars.c_str(); + } + + //--------------------------------------------------------------------------- + /** \brief Add a user defined operator. + \post Will reset the Parser to string parsing mode. + */ + void + ParserBase::DefinePostfixOprt(const string_type& a_sName, + fun_type1 a_pFun, + bool a_bAllowOpt) { + if (a_sName.length() > MaxLenIdentifier) + Error(ecIDENTIFIER_TOO_LONG); + + AddCallback(a_sName, + ParserCallback(a_pFun, a_bAllowOpt, prPOSTFIX, cmOPRT_POSTFIX), + m_PostOprtDef, + ValidOprtChars()); + } + + //--------------------------------------------------------------------------- + /** \brief Initialize user defined functions. + + Calls the virtual functions InitFun(), InitConst() and InitOprt(). + */ + void + ParserBase::Init() { + InitCharSets(); + InitFun(); + InitConst(); + InitOprt(); + } + + //--------------------------------------------------------------------------- + /** \brief Add a user defined operator. + \post Will reset the Parser to string parsing mode. + \param [in] a_sName operator Identifier + \param [in] a_pFun Operator callback function + \param [in] a_iPrec Operator Precedence (default=prSIGN) + \param [in] a_bAllowOpt True if operator is volatile (default=false) + \sa EPrec + */ + void + ParserBase::DefineInfixOprt(const string_type& a_sName, + fun_type1 a_pFun, + int a_iPrec, + bool a_bAllowOpt) { + if (a_sName.length() > MaxLenIdentifier) + Error(ecIDENTIFIER_TOO_LONG); + + AddCallback(a_sName, + ParserCallback(a_pFun, a_bAllowOpt, a_iPrec, cmOPRT_INFIX), + m_InfixOprtDef, + ValidInfixOprtChars()); + } + + + //--------------------------------------------------------------------------- + /** \brief Define a binary operator. + \param [in] a_sName The identifier of the operator. + \param [in] a_pFun Pointer to the callback function. + \param [in] a_iPrec Precedence of the operator. + \param [in] a_eAssociativity The associativity of the operator. + \param [in] a_bAllowOpt If this is true the operator may be optimized away. + + Adds a new Binary operator the the parser instance. + */ + void + ParserBase::DefineOprt(const string_type& a_sName, + fun_type2 a_pFun, + unsigned a_iPrec, + EOprtAssociativity a_eAssociativity, + bool a_bAllowOpt) { + if (a_sName.length() > MaxLenIdentifier) + Error(ecIDENTIFIER_TOO_LONG); + + // Check for conflicts with built in operator names + for (int i = 0; m_bBuiltInOp && i < cmENDIF; ++i) { + if (a_sName == string_type(c_DefaultOprt[i])) { + Error(ecBUILTIN_OVERLOAD, -1, a_sName); + } + } + + AddCallback(a_sName, + ParserCallback(a_pFun, a_bAllowOpt, a_iPrec, a_eAssociativity), + m_OprtDef, + ValidOprtChars()); + } + + //--------------------------------------------------------------------------- + /** \brief Define a new string constant. + \param [in] a_strName The name of the constant. + \param [in] a_strVal the value of the constant. + */ + void + ParserBase::DefineStrConst(const string_type& a_strName, + const string_type& a_strVal) { + // Test if a constant with that names already exists + if (m_StrVarDef.find(a_strName) != m_StrVarDef.end()) + Error(ecNAME_CONFLICT); + + CheckName(a_strName, ValidNameChars()); + + m_vStringVarBuf.push_back(a_strVal); // Store variable string in internal buffer + m_StrVarDef[a_strName] = m_vStringVarBuf.size() - 1; // bind buffer index to variable name + + ReInit(); + } + + //--------------------------------------------------------------------------- + /** \brief Add a user defined variable. + \param [in] a_sName the variable name + \param [in] a_pVar A pointer to the variable value. + \post Will reset the Parser to string parsing mode. + \throw ParserException in case the name contains invalid signs or a_pVar is nullptr. + */ + void + ParserBase::DefineVar(const string_type& a_sName, + value_type* a_pVar) { + if (a_pVar == 0) + Error(ecINVALID_VAR_PTR); + + if (a_sName.length() > MaxLenIdentifier) + Error(ecIDENTIFIER_TOO_LONG); + + // Test if a constant with that names already exists + if (m_ConstDef.find(a_sName) != m_ConstDef.end()) + Error(ecNAME_CONFLICT); + + CheckName(a_sName, ValidNameChars()); + m_VarDef[a_sName] = a_pVar; + ReInit(); + } + + //--------------------------------------------------------------------------- + /** \brief Add a user defined constant. + \param [in] a_sName The name of the constant. + \param [in] a_fVal the value of the constant. + \post Will reset the Parser to string parsing mode. + \throw ParserException in case the name contains invalid signs. + */ + void + ParserBase::DefineConst(const string_type& a_sName, + value_type a_fVal) { + if (a_sName.length() > MaxLenIdentifier) + Error(ecIDENTIFIER_TOO_LONG); + + CheckName(a_sName, ValidNameChars()); + m_ConstDef[a_sName] = a_fVal; + ReInit(); + } + + //--------------------------------------------------------------------------- + /** \brief Get operator priority. + \throw ParserException if a_Oprt is no operator code + */ + int + ParserBase::GetOprtPrecedence(const token_type& a_Tok) const { + switch (a_Tok.GetCode()) { + // built in operators + case cmEND: + return -5; + case cmARG_SEP: + return -4; + case cmASSIGN: + return -1; + case cmELSE: + case cmIF: + return 0; + case cmLAND: + return prLAND; + case cmLOR: + return prLOR; + case cmLT: + case cmGT: + case cmLE: + case cmGE: + case cmNEQ: + case cmEQ: + return prCMP; + case cmADD: + case cmSUB: + return prADD_SUB; + case cmMUL: + case cmDIV: + return prMUL_DIV; + case cmPOW: + return prPOW; + + // user defined binary operators + case cmOPRT_INFIX: + case cmOPRT_BIN: + return a_Tok.GetPri(); + default: + throw exception_type(ecINTERNAL_ERROR, 5, _T("")); + } + } + + //--------------------------------------------------------------------------- + /** \brief Get operator priority. + \throw ParserException if a_Oprt is no operator code + */ + EOprtAssociativity + ParserBase::GetOprtAssociativity(const token_type& a_Tok) const { + switch (a_Tok.GetCode()) { + case cmASSIGN: + case cmLAND: + case cmLOR: + case cmLT: + case cmGT: + case cmLE: + case cmGE: + case cmNEQ: + case cmEQ: + case cmADD: + case cmSUB: + case cmMUL: + case cmDIV: + return oaLEFT; + case cmPOW: + return oaRIGHT; + case cmOPRT_BIN: + return a_Tok.GetAssociativity(); + default: + return oaNONE; + } + } + + //--------------------------------------------------------------------------- + /** \brief Return a map containing the used variables only. */ + const varmap_type& + ParserBase::GetUsedVar() const { + try { + m_pTokenReader->IgnoreUndefVar(true); + CreateRPN(); // try to create bytecode, but don't use it for any further calculations since it + // may contain references to nonexisting variables. + m_pParseFormula = &ParserBase::ParseString; + m_pTokenReader->IgnoreUndefVar(false); + } catch (exception_type& /*e*/) { + // Make sure to stay in string parse mode, don't call ReInit() + // because it deletes the array with the used variables + m_pParseFormula = &ParserBase::ParseString; + m_pTokenReader->IgnoreUndefVar(false); + throw; + } + + return m_pTokenReader->GetUsedVar(); + } + + //--------------------------------------------------------------------------- + /** \brief Return a map containing the used variables only. */ + const varmap_type& + ParserBase::GetVar() const { + return m_VarDef; + } + + //--------------------------------------------------------------------------- + /** \brief Return a map containing all parser constants. */ + const valmap_type& + ParserBase::GetConst() const { + return m_ConstDef; + } + + //--------------------------------------------------------------------------- + /** \brief Return prototypes of all parser functions. + \return #m_FunDef + \sa FunProt + \throw nothrow + + The return type is a map of the public type #funmap_type containing the prototype + definitions for all numerical parser functions. String functions are not part of + this map. The Prototype definition is encapsulated in objects of the class FunProt + one per parser function each associated with function names via a map construct. + */ + const funmap_type& + ParserBase::GetFunDef() const { + return m_FunDef; + } + + //--------------------------------------------------------------------------- + /** \brief Retrieve the formula. */ + const string_type& + ParserBase::GetExpr() const { + return m_pTokenReader->GetExpr(); + } + + //--------------------------------------------------------------------------- + /** \brief Execute a function that takes a single string argument. + \param a_FunTok Function token. + \throw exception_type If the function token is not a string function + */ + ParserBase::token_type + ParserBase::ApplyStrFunc(const token_type& a_FunTok, + const std::vector& a_vArg) const { + if (a_vArg.back().GetCode() != cmSTRING) + Error(ecSTRING_EXPECTED, m_pTokenReader->GetPos(), a_FunTok.GetAsString()); + + token_type valTok; + generic_callable_type pFunc = a_FunTok.GetFuncAddr(); + MUP_ASSERT(pFunc); + + try { + // Check function arguments; write dummy value into valtok to represent the result + switch (a_FunTok.GetArgCount()) { + case 0: + valTok.SetVal(1); + a_vArg[0].GetAsString(); + break; + case 1: + valTok.SetVal(1); + a_vArg[1].GetAsString(); + a_vArg[0].GetVal(); + break; + case 2: + valTok.SetVal(1); + a_vArg[2].GetAsString(); + a_vArg[1].GetVal(); + a_vArg[0].GetVal(); + break; + case 3: + valTok.SetVal(1); + a_vArg[3].GetAsString(); + a_vArg[2].GetVal(); + a_vArg[1].GetVal(); + a_vArg[0].GetVal(); + break; + case 4: + valTok.SetVal(1); + a_vArg[4].GetAsString(); + a_vArg[3].GetVal(); + a_vArg[2].GetVal(); + a_vArg[1].GetVal(); + a_vArg[0].GetVal(); + break; + case 5: + valTok.SetVal(1); + a_vArg[5].GetAsString(); + a_vArg[4].GetVal(); + a_vArg[3].GetVal(); + a_vArg[2].GetVal(); + a_vArg[1].GetVal(); + a_vArg[0].GetVal(); + break; + default: + Error(ecINTERNAL_ERROR); + } + } catch (ParserError&) { + Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), a_FunTok.GetAsString()); + } + + // string functions won't be optimized + m_vRPN.AddStrFun(pFunc, a_FunTok.GetArgCount(), a_vArg.back().GetIdx()); + + // Push dummy value representing the function result to the stack + return valTok; + } + + //--------------------------------------------------------------------------- + /** \brief Apply a function token. + \param iArgCount Number of Arguments actually gathered used only for multiarg functions. + \post The result is pushed to the value stack + \post The function token is removed from the stack + \throw exception_type if Argument count does not match function requirements. + */ + void + ParserBase::ApplyFunc(std::stack& a_stOpt, + std::stack& a_stVal, + int a_iArgCount) const { + MUP_ASSERT(m_pTokenReader.get()); + + // Operator stack empty or does not contain tokens with callback functions + if (a_stOpt.empty() || a_stOpt.top().GetFuncAddr() == 0) + return; + + token_type funTok = a_stOpt.top(); + a_stOpt.pop(); + MUP_ASSERT(funTok.GetFuncAddr() != nullptr); + + // Binary operators must rely on their internal operator number + // since counting of operators relies on commas for function arguments + // binary operators do not have commas in their expression + int iArgCount = (funTok.GetCode() == cmOPRT_BIN) ? funTok.GetArgCount() : a_iArgCount; + + // determine how many parameters the function needs. To remember iArgCount includes the + // string parameter whilst GetArgCount() counts only numeric parameters. + int iArgRequired = funTok.GetArgCount() + ((funTok.GetType() == tpSTR) ? 1 : 0); + + // That's the number of numerical parameters + int iArgNumerical = iArgCount - ((funTok.GetType() == tpSTR) ? 1 : 0); + + if (funTok.GetCode() == cmFUNC_STR && iArgCount - iArgNumerical > 1) + Error(ecINTERNAL_ERROR); + + if (funTok.GetArgCount() >= 0 && iArgCount > iArgRequired) + Error(ecTOO_MANY_PARAMS, m_pTokenReader->GetPos() - 1, funTok.GetAsString()); + + if (funTok.GetCode() != cmOPRT_BIN && iArgCount < iArgRequired) + Error(ecTOO_FEW_PARAMS, m_pTokenReader->GetPos() - 1, funTok.GetAsString()); + + if (funTok.GetCode() == cmFUNC_STR && iArgCount > iArgRequired) + Error(ecTOO_MANY_PARAMS, m_pTokenReader->GetPos() - 1, funTok.GetAsString()); + + // Collect the numeric function arguments from the value stack and store them + // in a vector + std::vector stArg; + for (int i = 0; i < iArgNumerical; ++i) { + if (a_stVal.empty()) + Error(ecINTERNAL_ERROR, m_pTokenReader->GetPos(), funTok.GetAsString()); + + stArg.push_back(a_stVal.top()); + a_stVal.pop(); + + if (stArg.back().GetType() == tpSTR && funTok.GetType() != tpSTR) + Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), funTok.GetAsString()); + } + + switch (funTok.GetCode()) { + case cmFUNC_STR: + if (a_stVal.empty()) + Error(ecINTERNAL_ERROR, m_pTokenReader->GetPos(), funTok.GetAsString()); + + stArg.push_back(a_stVal.top()); + a_stVal.pop(); + + if (stArg.back().GetType() == tpSTR && funTok.GetType() != tpSTR) + Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), funTok.GetAsString()); + + ApplyStrFunc(funTok, stArg); + break; + + case cmFUNC_BULK: + m_vRPN.AddBulkFun(funTok.GetFuncAddr(), (int)stArg.size()); + break; + + case cmOPRT_BIN: + case cmOPRT_POSTFIX: + case cmOPRT_INFIX: + case cmFUNC: + if (funTok.GetArgCount() == -1 && iArgCount == 0) + Error(ecTOO_FEW_PARAMS, m_pTokenReader->GetPos(), funTok.GetAsString()); + + m_vRPN.AddFun(funTok.GetFuncAddr(), + (funTok.GetArgCount() == -1) ? -iArgNumerical : iArgNumerical, + funTok.IsOptimizable()); + break; + default: + break; + } + + // Push dummy value representing the function result to the stack + token_type token; + token.SetVal(1); + a_stVal.push(token); + } + + //--------------------------------------------------------------------------- + void + ParserBase::ApplyIfElse(std::stack& a_stOpt, + std::stack& a_stVal) const { + // Check if there is an if Else clause to be calculated + while (a_stOpt.size() && a_stOpt.top().GetCode() == cmELSE) { + MUP_ASSERT(!a_stOpt.empty()) + token_type opElse = a_stOpt.top(); + a_stOpt.pop(); + + // Take the value associated with the else branch from the value stack + MUP_ASSERT(!a_stVal.empty()); + token_type vVal2 = a_stVal.top(); + if (vVal2.GetType() != tpDBL) + Error(ecUNEXPECTED_STR, m_pTokenReader->GetPos()); + + a_stVal.pop(); + + // it then else is a ternary operator Pop all three values from the value s + // tack and just return the right value + MUP_ASSERT(!a_stVal.empty()); + token_type vVal1 = a_stVal.top(); + if (vVal1.GetType() != tpDBL) + Error(ecUNEXPECTED_STR, m_pTokenReader->GetPos()); + + a_stVal.pop(); + + MUP_ASSERT(!a_stVal.empty()); + token_type vExpr = a_stVal.top(); + a_stVal.pop(); + + a_stVal.push((vExpr.GetVal() != 0) ? vVal1 : vVal2); + + token_type opIf = a_stOpt.top(); + a_stOpt.pop(); + + MUP_ASSERT(opElse.GetCode() == cmELSE); + + if (opIf.GetCode() != cmIF) + Error(ecMISPLACED_COLON, m_pTokenReader->GetPos()); + + m_vRPN.AddIfElse(cmENDIF); + } // while pending if-else-clause found + } + + //--------------------------------------------------------------------------- + /** \brief Performs the necessary steps to write code for + the execution of binary operators into the bytecode. + */ + void + ParserBase::ApplyBinOprt(std::stack& a_stOpt, + std::stack& a_stVal) const { + // is it a user defined binary operator? + if (a_stOpt.top().GetCode() == cmOPRT_BIN) { + ApplyFunc(a_stOpt, a_stVal, 2); + } else { + if (a_stVal.size() < 2) + Error(ecINTERNAL_ERROR, + m_pTokenReader->GetPos(), + _T("ApplyBinOprt: not enough values in value stack!")); + + token_type valTok1 = a_stVal.top(); + a_stVal.pop(); + + token_type valTok2 = a_stVal.top(); + a_stVal.pop(); + + token_type optTok = a_stOpt.top(); + a_stOpt.pop(); + + token_type resTok; + + if (valTok1.GetType() != valTok2.GetType() || (valTok1.GetType() == tpSTR && valTok2.GetType() == tpSTR)) + Error(ecOPRT_TYPE_CONFLICT, m_pTokenReader->GetPos(), optTok.GetAsString()); + + if (optTok.GetCode() == cmASSIGN) { + if (valTok2.GetCode() != cmVAR) + Error(ecUNEXPECTED_OPERATOR, -1, _T("=")); + + m_vRPN.AddAssignOp(valTok2.GetVar()); + } else + m_vRPN.AddOp(optTok.GetCode()); + + resTok.SetVal(1); + a_stVal.push(resTok); + } + } + + //--------------------------------------------------------------------------- + /** \brief Apply a binary operator. + \param a_stOpt The operator stack + \param a_stVal The value stack + */ + void + ParserBase::ApplyRemainingOprt(std::stack& stOpt, + std::stack& stVal) const { + while (stOpt.size() && stOpt.top().GetCode() != cmBO && stOpt.top().GetCode() != cmIF) { + token_type tok = stOpt.top(); + switch (tok.GetCode()) { + case cmOPRT_INFIX: + case cmOPRT_BIN: + case cmLE: + case cmGE: + case cmNEQ: + case cmEQ: + case cmLT: + case cmGT: + case cmADD: + case cmSUB: + case cmMUL: + case cmDIV: + case cmPOW: + case cmLAND: + case cmLOR: + case cmASSIGN: + if (stOpt.top().GetCode() == cmOPRT_INFIX) + ApplyFunc(stOpt, stVal, 1); + else + ApplyBinOprt(stOpt, stVal); + break; + + case cmELSE: + ApplyIfElse(stOpt, stVal); + break; + + default: + Error(ecINTERNAL_ERROR); + } + } + } + + //--------------------------------------------------------------------------- + /** \brief Parse the command code. + \sa ParseString(...) + + Command code contains precalculated stack positions of the values and the + associated operators. The Stack is filled beginning from index one the + value at index zero is not used at all. + */ + value_type + ParserBase::ParseCmdCode() const { + return ParseCmdCodeBulk(0, 0); + } + + value_type + ParserBase::ParseCmdCodeShort() const { + const SToken* const tok = m_vRPN.GetBase(); + value_type buf; + + switch (tok->Cmd) { + case cmVAL: + return tok->Val.data2; + + case cmVAR: + return *tok->Val.ptr; + + case cmVARMUL: + return *tok->Val.ptr * tok->Val.data + tok->Val.data2; + + case cmVARPOW2: + buf = *(tok->Val.ptr); + return buf * buf; + + case cmVARPOW3: + buf = *(tok->Val.ptr); + return buf * buf * buf; + + case cmVARPOW4: + buf = *(tok->Val.ptr); + return buf * buf * buf * buf; + + // numerical function without any argument + case cmFUNC: + return tok->Fun.cb.call_fun<0>(); + + // String function without a numerical argument + case cmFUNC_STR: + return tok->Fun.cb.call_strfun<1>(m_vStringBuf[0].c_str()); + + default: + throw ParserError(ecINTERNAL_ERROR); + } + } + + //--------------------------------------------------------------------------- + /** \brief Evaluate the RPN. + \param nOffset The offset added to variable addresses (for bulk mode) + \param nThreadID OpenMP Thread id of the calling thread + */ + value_type + ParserBase::ParseCmdCodeBulk(int nOffset, + int nThreadID) const { + assert(nThreadID <= s_MaxNumOpenMPThreads); + + // Note: The check for nOffset==0 and nThreadID here is not necessary but + // brings a minor performance gain when not in bulk mode. + value_type* stack = ((nOffset == 0) && (nThreadID == 0)) + ? &m_vStackBuffer[0] + : &m_vStackBuffer[nThreadID * (m_vStackBuffer.size() / s_MaxNumOpenMPThreads)]; + value_type buf; + int sidx(0); + for (const SToken* pTok = m_vRPN.GetBase(); pTok->Cmd != cmEND; ++pTok) { + switch (pTok->Cmd) { + // built in binary operators + case cmLE: + --sidx; + stack[sidx] = stack[sidx] <= stack[sidx + 1]; + continue; + case cmGE: + --sidx; + stack[sidx] = stack[sidx] >= stack[sidx + 1]; + continue; + case cmNEQ: + --sidx; + stack[sidx] = stack[sidx] != stack[sidx + 1]; + continue; + case cmEQ: + --sidx; + stack[sidx] = stack[sidx] == stack[sidx + 1]; + continue; + case cmLT: + --sidx; + stack[sidx] = stack[sidx] < stack[sidx + 1]; + continue; + case cmGT: + --sidx; + stack[sidx] = stack[sidx] > stack[sidx + 1]; + continue; + case cmADD: + --sidx; + stack[sidx] += stack[1 + sidx]; + continue; + case cmSUB: + --sidx; + stack[sidx] -= stack[1 + sidx]; + continue; + case cmMUL: + --sidx; + stack[sidx] *= stack[1 + sidx]; + continue; + case cmDIV: + --sidx; + stack[sidx] /= stack[1 + sidx]; + continue; + + case cmPOW: + --sidx; + stack[sidx] = MathImpl::Pow(stack[sidx], stack[1 + sidx]); + continue; + + case cmLAND: + --sidx; + stack[sidx] = stack[sidx] && stack[sidx + 1]; + continue; + case cmLOR: + --sidx; + stack[sidx] = stack[sidx] || stack[sidx + 1]; + continue; + + case cmASSIGN: + // Bugfix for Bulkmode: + // for details see: + // https://groups.google.com/forum/embed/?place=forum/muparser-dev&showsearch=true&showpopout=true&showtabs=false&parenturl=http://muparser.beltoforion.de/mup_forum.html&afterlogin&pli=1#!topic/muparser-dev/szgatgoHTws + --sidx; + stack[sidx] = *(pTok->Oprt.ptr + nOffset) = stack[sidx + 1]; + continue; + // original code: + //--sidx; Stack[sidx] = *pTok->Oprt.ptr = Stack[sidx+1]; continue; + + case cmIF: + if (stack[sidx--] == 0) { + MUP_ASSERT(sidx >= 0); + pTok += pTok->Oprt.offset; + } + continue; + + case cmELSE: + pTok += pTok->Oprt.offset; + continue; + + case cmENDIF: + continue; + + // value and variable tokens + case cmVAR: + stack[++sidx] = *(pTok->Val.ptr + nOffset); + continue; + case cmVAL: + stack[++sidx] = pTok->Val.data2; + continue; + + case cmVARPOW2: + buf = *(pTok->Val.ptr + nOffset); + stack[++sidx] = buf * buf; + continue; + + case cmVARPOW3: + buf = *(pTok->Val.ptr + nOffset); + stack[++sidx] = buf * buf * buf; + continue; + + case cmVARPOW4: + buf = *(pTok->Val.ptr + nOffset); + stack[++sidx] = buf * buf * buf * buf; + continue; + + case cmVARMUL: + stack[++sidx] = *(pTok->Val.ptr + nOffset) * pTok->Val.data + pTok->Val.data2; + continue; + + // Next is treatment of numeric functions + case cmFUNC: { + int iArgCount = pTok->Fun.argc; + + // switch according to argument count + switch (iArgCount) { + case 0: + sidx += 1; + stack[sidx] = pTok->Fun.cb.call_fun<0>(); + continue; + case 1: + stack[sidx] = pTok->Fun.cb.call_fun<1>(stack[sidx]); + continue; + case 2: + sidx -= 1; + stack[sidx] = pTok->Fun.cb.call_fun<2>(stack[sidx], stack[sidx + 1]); + continue; + case 3: + sidx -= 2; + stack[sidx] = pTok->Fun.cb.call_fun<3>(stack[sidx], stack[sidx + 1], stack[sidx + 2]); + continue; + case 4: + sidx -= 3; + stack[sidx] = + pTok->Fun.cb.call_fun<4>(stack[sidx], stack[sidx + 1], stack[sidx + 2], stack[sidx + 3]); + continue; + case 5: + sidx -= 4; + stack[sidx] = pTok->Fun.cb.call_fun<5>(stack[sidx], + stack[sidx + 1], + stack[sidx + 2], + stack[sidx + 3], + stack[sidx + 4]); + continue; + case 6: + sidx -= 5; + stack[sidx] = pTok->Fun.cb.call_fun<6>(stack[sidx], + stack[sidx + 1], + stack[sidx + 2], + stack[sidx + 3], + stack[sidx + 4], + stack[sidx + 5]); + continue; + case 7: + sidx -= 6; + stack[sidx] = pTok->Fun.cb.call_fun<7>(stack[sidx], + stack[sidx + 1], + stack[sidx + 2], + stack[sidx + 3], + stack[sidx + 4], + stack[sidx + 5], + stack[sidx + 6]); + continue; + case 8: + sidx -= 7; + stack[sidx] = pTok->Fun.cb.call_fun<8>(stack[sidx], + stack[sidx + 1], + stack[sidx + 2], + stack[sidx + 3], + stack[sidx + 4], + stack[sidx + 5], + stack[sidx + 6], + stack[sidx + 7]); + continue; + case 9: + sidx -= 8; + stack[sidx] = pTok->Fun.cb.call_fun<9>(stack[sidx], + stack[sidx + 1], + stack[sidx + 2], + stack[sidx + 3], + stack[sidx + 4], + stack[sidx + 5], + stack[sidx + 6], + stack[sidx + 7], + stack[sidx + 8]); + continue; + case 10: + sidx -= 9; + stack[sidx] = pTok->Fun.cb.call_fun<10>(stack[sidx], + stack[sidx + 1], + stack[sidx + 2], + stack[sidx + 3], + stack[sidx + 4], + stack[sidx + 5], + stack[sidx + 6], + stack[sidx + 7], + stack[sidx + 8], + stack[sidx + 9]); + continue; + default: + // function with variable arguments store the number as a negative value + if (iArgCount > 0) + Error(ecINTERNAL_ERROR, -1); + + sidx -= -iArgCount - 1; + + // From oss-fuzz. Happend when Multiarg functions and if-then-else are used + // incorrectly. Expressions where this was observed: + // sum(0?1,2,3,4,5:6) -> fixed + // avg(0>3?4:(""),0^3?4:("")) + // + // The final result normally lieas at position 1. If sixd is smaller there is something wrong. + if (sidx <= 0) + Error(ecINTERNAL_ERROR, -1); + // + + stack[sidx] = pTok->Fun.cb.call_multfun(&stack[sidx], -iArgCount); + continue; + } + } + + // Next is treatment of string functions + case cmFUNC_STR: { + sidx -= pTok->Fun.argc - 1; + + // The index of the string argument in the string table + int iIdxStack = pTok->Fun.idx; + if (iIdxStack < 0 || iIdxStack >= (int)m_vStringBuf.size()) + Error(ecINTERNAL_ERROR, m_pTokenReader->GetPos()); + + switch (pTok->Fun.argc) // switch according to argument count + { + case 0: + stack[sidx] = pTok->Fun.cb.call_strfun<1>(m_vStringBuf[iIdxStack].c_str()); + continue; + case 1: + stack[sidx] = pTok->Fun.cb.call_strfun<2>(m_vStringBuf[iIdxStack].c_str(), stack[sidx]); + continue; + case 2: + stack[sidx] = + pTok->Fun.cb.call_strfun<3>(m_vStringBuf[iIdxStack].c_str(), stack[sidx], stack[sidx + 1]); + continue; + case 3: + stack[sidx] = pTok->Fun.cb.call_strfun<4>(m_vStringBuf[iIdxStack].c_str(), + stack[sidx], + stack[sidx + 1], + stack[sidx + 2]); + continue; + case 4: + stack[sidx] = pTok->Fun.cb.call_strfun<5>(m_vStringBuf[iIdxStack].c_str(), + stack[sidx], + stack[sidx + 1], + stack[sidx + 2], + stack[sidx + 3]); + continue; + case 5: + stack[sidx] = pTok->Fun.cb.call_strfun<6>(m_vStringBuf[iIdxStack].c_str(), + stack[sidx], + stack[sidx + 1], + stack[sidx + 2], + stack[sidx + 3], + stack[sidx + 4]); + continue; + } + + continue; + } + + case cmFUNC_BULK: { + int iArgCount = pTok->Fun.argc; + + // switch according to argument count + switch (iArgCount) { + case 0: + sidx += 1; + stack[sidx] = pTok->Fun.cb.call_bulkfun<0>(nOffset, nThreadID); + continue; + case 1: + stack[sidx] = pTok->Fun.cb.call_bulkfun<1>(nOffset, nThreadID, stack[sidx]); + continue; + case 2: + sidx -= 1; + stack[sidx] = pTok->Fun.cb.call_bulkfun<2>(nOffset, nThreadID, stack[sidx], stack[sidx + 1]); + continue; + case 3: + sidx -= 2; + stack[sidx] = + pTok->Fun.cb.call_bulkfun<3>(nOffset, nThreadID, stack[sidx], stack[sidx + 1], stack[sidx + 2]); + continue; + case 4: + sidx -= 3; + stack[sidx] = pTok->Fun.cb.call_bulkfun<4>(nOffset, + nThreadID, + stack[sidx], + stack[sidx + 1], + stack[sidx + 2], + stack[sidx + 3]); + continue; + case 5: + sidx -= 4; + stack[sidx] = pTok->Fun.cb.call_bulkfun<5>(nOffset, + nThreadID, + stack[sidx], + stack[sidx + 1], + stack[sidx + 2], + stack[sidx + 3], + stack[sidx + 4]); + continue; + case 6: + sidx -= 5; + stack[sidx] = pTok->Fun.cb.call_bulkfun<6>(nOffset, + nThreadID, + stack[sidx], + stack[sidx + 1], + stack[sidx + 2], + stack[sidx + 3], + stack[sidx + 4], + stack[sidx + 5]); + continue; + case 7: + sidx -= 6; + stack[sidx] = pTok->Fun.cb.call_bulkfun<7>(nOffset, + nThreadID, + stack[sidx], + stack[sidx + 1], + stack[sidx + 2], + stack[sidx + 3], + stack[sidx + 4], + stack[sidx + 5], + stack[sidx + 6]); + continue; + case 8: + sidx -= 7; + stack[sidx] = pTok->Fun.cb.call_bulkfun<8>(nOffset, + nThreadID, + stack[sidx], + stack[sidx + 1], + stack[sidx + 2], + stack[sidx + 3], + stack[sidx + 4], + stack[sidx + 5], + stack[sidx + 6], + stack[sidx + 7]); + continue; + case 9: + sidx -= 8; + stack[sidx] = pTok->Fun.cb.call_bulkfun<9>(nOffset, + nThreadID, + stack[sidx], + stack[sidx + 1], + stack[sidx + 2], + stack[sidx + 3], + stack[sidx + 4], + stack[sidx + 5], + stack[sidx + 6], + stack[sidx + 7], + stack[sidx + 8]); + continue; + case 10: + sidx -= 9; + stack[sidx] = pTok->Fun.cb.call_bulkfun<10>(nOffset, + nThreadID, + stack[sidx], + stack[sidx + 1], + stack[sidx + 2], + stack[sidx + 3], + stack[sidx + 4], + stack[sidx + 5], + stack[sidx + 6], + stack[sidx + 7], + stack[sidx + 8], + stack[sidx + 9]); + continue; + default: + throw exception_type(ecINTERNAL_ERROR, 2, _T("")); + } + } + + default: + throw exception_type(ecINTERNAL_ERROR, 3, _T("")); + } // switch CmdCode + } // for all bytecode tokens + + return stack[m_nFinalResultIdx]; + } + + //--------------------------------------------------------------------------- + void + ParserBase::CreateRPN() const { + if (!m_pTokenReader->GetExpr().length()) + Error(ecUNEXPECTED_EOF, 0); + + std::stack stOpt, stVal; + std::stack stArgCount; + token_type opta, opt; // for storing operators + token_type val, tval; // for storing value + int ifElseCounter = 0; + + ReInit(); + + // The outermost counter counts the number of separated items + // such as in "a=10,b=20,c=c+a" + stArgCount.push(1); + + for (;;) { + opt = m_pTokenReader->ReadNextToken(); + + switch (opt.GetCode()) { + // + // Next three are different kind of value entries + // + case cmSTRING: + if (stOpt.empty()) + Error(ecSTR_RESULT, m_pTokenReader->GetPos(), opt.GetAsString()); + + opt.SetIdx((int)m_vStringBuf.size()); // Assign buffer index to token + stVal.push(opt); + m_vStringBuf.push_back(opt.GetAsString()); // Store string in internal buffer + break; + + case cmVAR: + stVal.push(opt); + m_vRPN.AddVar(static_cast(opt.GetVar())); + break; + + case cmVAL: + stVal.push(opt); + m_vRPN.AddVal(opt.GetVal()); + break; + + case cmELSE: + if (stArgCount.empty()) + Error(ecMISPLACED_COLON, m_pTokenReader->GetPos()); + + if (stArgCount.top() > 1) + Error(ecUNEXPECTED_ARG_SEP, m_pTokenReader->GetPos()); + + stArgCount.pop(); + + ifElseCounter--; + if (ifElseCounter < 0) + Error(ecMISPLACED_COLON, m_pTokenReader->GetPos()); + + ApplyRemainingOprt(stOpt, stVal); + m_vRPN.AddIfElse(cmELSE); + stOpt.push(opt); + break; + + case cmARG_SEP: + if (!stOpt.empty() && stOpt.top().GetCode() == cmIF) + Error(ecUNEXPECTED_ARG_SEP, m_pTokenReader->GetPos()); + + if (stArgCount.empty()) + Error(ecUNEXPECTED_ARG_SEP, m_pTokenReader->GetPos()); + + ++stArgCount.top(); + // Falls through. + // intentional (no break!) + + case cmEND: + ApplyRemainingOprt(stOpt, stVal); + break; + + case cmBC: { + // The argument count for parameterless functions is zero + // by default an opening bracket sets parameter count to 1 + // in preparation of arguments to come. If the last token + // was an opening bracket we know better... + if (opta.GetCode() == cmBO) + --stArgCount.top(); + + ApplyRemainingOprt(stOpt, stVal); + + // Check if the bracket content has been evaluated completely + if (stOpt.size() && stOpt.top().GetCode() == cmBO) { + // if opt is ")" and opta is "(" the bracket has been evaluated, now its time to check + // if there is either a function or a sign pending + // neither the opening nor the closing bracket will be pushed back to + // the operator stack + // Check if a function is standing in front of the opening bracket, + // if yes evaluate it afterwards check for infix operators + MUP_ASSERT(stArgCount.size()); + int iArgCount = stArgCount.top(); + stArgCount.pop(); + + stOpt.pop(); // Take opening bracket from stack + + if (iArgCount > 1 && (stOpt.size() == 0 || + (stOpt.top().GetCode() != cmFUNC && stOpt.top().GetCode() != cmFUNC_BULK && + stOpt.top().GetCode() != cmFUNC_STR))) + Error(ecUNEXPECTED_ARG, m_pTokenReader->GetPos()); + + // The opening bracket was popped from the stack now check if there + // was a function before this bracket + if (stOpt.size() && stOpt.top().GetCode() != cmOPRT_INFIX && stOpt.top().GetCode() != cmOPRT_BIN && + stOpt.top().GetFuncAddr() != 0) { + ApplyFunc(stOpt, stVal, iArgCount); + } + } + } // if bracket content is evaluated + break; + + // + // Next are the binary operator entries + // + case cmIF: + ifElseCounter++; + stArgCount.push(1); + // Falls through. + // intentional (no break!) + + case cmLAND: + case cmLOR: + case cmLT: + case cmGT: + case cmLE: + case cmGE: + case cmNEQ: + case cmEQ: + case cmADD: + case cmSUB: + case cmMUL: + case cmDIV: + case cmPOW: + case cmASSIGN: + case cmOPRT_BIN: + + // A binary operator (user defined or built in) has been found. + while (stOpt.size() && stOpt.top().GetCode() != cmBO && stOpt.top().GetCode() != cmELSE && + stOpt.top().GetCode() != cmIF) { + int nPrec1 = GetOprtPrecedence(stOpt.top()), nPrec2 = GetOprtPrecedence(opt); + + if (stOpt.top().GetCode() == opt.GetCode()) { + + // Deal with operator associativity + EOprtAssociativity eOprtAsct = GetOprtAssociativity(opt); + if ((eOprtAsct == oaRIGHT && (nPrec1 <= nPrec2)) || + (eOprtAsct == oaLEFT && (nPrec1 < nPrec2))) { + break; + } + } else if (nPrec1 < nPrec2) { + // In case the operators are not equal the precedence decides alone... + break; + } + + if (stOpt.top().GetCode() == cmOPRT_INFIX) + ApplyFunc(stOpt, stVal, 1); + else + ApplyBinOprt(stOpt, stVal); + } // while ( ... ) + + if (opt.GetCode() == cmIF) + m_vRPN.AddIfElse(opt.GetCode()); + + // The operator can't be evaluated right now, push back to the operator stack + stOpt.push(opt); + break; + + // + // Last section contains functions and operators implicitly mapped to functions + // + case cmBO: + stArgCount.push(1); + stOpt.push(opt); + break; + + case cmOPRT_INFIX: + case cmFUNC: + case cmFUNC_BULK: + case cmFUNC_STR: + stOpt.push(opt); + break; + + case cmOPRT_POSTFIX: + stOpt.push(opt); + ApplyFunc(stOpt, stVal, 1); // this is the postfix operator + break; + + default: + Error(ecINTERNAL_ERROR, 3); + } // end of switch operator-token + + opta = opt; + + if (opt.GetCode() == cmEND) { + m_vRPN.Finalize(); + break; + } + + if (ParserBase::g_DbgDumpStack) { + StackDump(stVal, stOpt); + m_vRPN.AsciiDump(); + } + + // if (ParserBase::g_DbgDumpCmdCode) + // m_vRPN.AsciiDump(); + } // while (true) + + if (ParserBase::g_DbgDumpCmdCode) + m_vRPN.AsciiDump(); + + if (ifElseCounter > 0) + Error(ecMISSING_ELSE_CLAUSE); + + // get the last value (= final result) from the stack + MUP_ASSERT(stArgCount.size() == 1); + m_nFinalResultIdx = stArgCount.top(); + if (m_nFinalResultIdx == 0) + Error(ecINTERNAL_ERROR, 9); + + if (stVal.size() == 0) + Error(ecEMPTY_EXPRESSION); + + // 2020-09-17; fix for https://oss-fuzz.com/testcase-detail/5758791700971520 + // I don't need the value stack any more. Destructively check if all values in the value + // stack represent floating point values + while (stVal.size()) { + if (stVal.top().GetType() != tpDBL) + Error(ecSTR_RESULT); + + stVal.pop(); + } + + m_vStackBuffer.resize(m_vRPN.GetMaxStackSize() * s_MaxNumOpenMPThreads); + } + + //--------------------------------------------------------------------------- + /** \brief One of the two main parse functions. + \sa ParseCmdCode(...) + + Parse expression from input string. Perform syntax checking and create + bytecode. After parsing the string and creating the bytecode the function + pointer #m_pParseFormula will be changed to the second parse routine the + uses bytecode instead of string parsing. + */ + value_type + ParserBase::ParseString() const { + try { + CreateRPN(); + + if (m_vRPN.GetSize() == 2) { + m_pParseFormula = &ParserBase::ParseCmdCodeShort; + m_vStackBuffer[1] = (this->*m_pParseFormula)(); + return m_vStackBuffer[1]; + } else { + m_pParseFormula = &ParserBase::ParseCmdCode; + return (this->*m_pParseFormula)(); + } + } catch (ParserError& exc) { + exc.SetFormula(m_pTokenReader->GetExpr()); + throw; + } + } + + //--------------------------------------------------------------------------- + /** \brief Create an error containing the parse error position. + + This function will create an Parser Exception object containing the error text and + its position. + + \param a_iErrc [in] The error code of type #EErrorCodes. + \param a_iPos [in] The position where the error was detected. + \param a_strTok [in] The token string representation associated with the error. + \throw ParserException always throws that's the only purpose of this function. + */ + void + ParserBase::Error(EErrorCodes a_iErrc, + int a_iPos, + const string_type& a_sTok) const { + throw exception_type(a_iErrc, a_sTok, m_pTokenReader->GetExpr(), a_iPos); + } + + //------------------------------------------------------------------------------ + /** \brief Clear all user defined variables. + \throw nothrow + + Resets the parser to string parsing mode by calling #ReInit. + */ + void + ParserBase::ClearVar() { + m_VarDef.clear(); + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Remove a variable from internal storage. + \throw nothrow + + Removes a variable if it exists. If the Variable does not exist nothing will be done. + */ + void + ParserBase::RemoveVar(const string_type& a_strVarName) { + varmap_type::iterator item = m_VarDef.find(a_strVarName); + if (item != m_VarDef.end()) { + m_VarDef.erase(item); + ReInit(); + } + } + + //------------------------------------------------------------------------------ + /** \brief Clear all functions. + \post Resets the parser to string parsing mode. + \throw nothrow + */ + void + ParserBase::ClearFun() { + m_FunDef.clear(); + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Clear all user defined constants. + + Both numeric and string constants will be removed from the internal storage. + \post Resets the parser to string parsing mode. + \throw nothrow + */ + void + ParserBase::ClearConst() { + m_ConstDef.clear(); + m_StrVarDef.clear(); + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Clear all user defined postfix operators. + \post Resets the parser to string parsing mode. + \throw nothrow + */ + void + ParserBase::ClearPostfixOprt() { + m_PostOprtDef.clear(); + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Clear all user defined binary operators. + \post Resets the parser to string parsing mode. + \throw nothrow + */ + void + ParserBase::ClearOprt() { + m_OprtDef.clear(); + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Clear the user defined Prefix operators. + \post Resets the parser to string parser mode. + \throw nothrow + */ + void + ParserBase::ClearInfixOprt() { + m_InfixOprtDef.clear(); + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Enable or disable the formula optimization feature. + \post Resets the parser to string parser mode. + \throw nothrow + */ + void + ParserBase::EnableOptimizer(bool a_bIsOn) { + m_vRPN.EnableOptimizer(a_bIsOn); + ReInit(); + } + + //--------------------------------------------------------------------------- + /** \brief Enable the dumping of bytecode and stack content on the console. + \param bDumpCmd Flag to enable dumping of the current bytecode to the console. + \param bDumpStack Flag to enable dumping of the stack content is written to the console. + + This function is for debug purposes only! + */ + void + ParserBase::EnableDebugDump(bool bDumpCmd, + bool bDumpStack) { + ParserBase::g_DbgDumpCmdCode = bDumpCmd; + ParserBase::g_DbgDumpStack = bDumpStack; + } + + //------------------------------------------------------------------------------ + /** \brief Enable or disable the built in binary operators. + \throw nothrow + \sa m_bBuiltInOp, ReInit() + + If you disable the built in binary operators there will be no binary operators + defined. Thus you must add them manually one by one. It is not possible to + disable built in operators selectively. This function will Reinitialize the + parser by calling ReInit(). + */ + void + ParserBase::EnableBuiltInOprt(bool a_bIsOn) { + m_bBuiltInOp = a_bIsOn; + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Query status of built in variables. + \return #m_bBuiltInOp; true if built in operators are enabled. + \throw nothrow + */ + bool + ParserBase::HasBuiltInOprt() const { + return m_bBuiltInOp; + } + + //------------------------------------------------------------------------------ + /** \brief Get the argument separator character. + */ + char_type + ParserBase::GetArgSep() const { + return m_pTokenReader->GetArgSep(); + } + + //------------------------------------------------------------------------------ + /** \brief Set argument separator. + \param cArgSep the argument separator character. + */ + void + ParserBase::SetArgSep(char_type cArgSep) { + m_pTokenReader->SetArgSep(cArgSep); + } + + //------------------------------------------------------------------------------ + /** \brief Dump stack content. + + This function is used for debugging only. + */ + void + ParserBase::StackDump(const std::stack& a_stVal, + const std::stack& a_stOprt) const { + std::stack stOprt(a_stOprt); + std::stack stVal(a_stVal); + + mu::console() << _T("\nValue stack:\n"); + while (!stVal.empty()) { + token_type val = stVal.top(); + stVal.pop(); + + if (val.GetType() == tpSTR) + mu::console() << _T(" \"") << val.GetAsString() << _T("\" "); + else + mu::console() << _T(" ") << val.GetVal() << _T(" "); + } + mu::console() << "\nOperator stack:\n"; + + while (!stOprt.empty()) { + if (stOprt.top().GetCode() <= cmASSIGN) { + mu::console() << _T("OPRT_INTRNL \"") << ParserBase::c_DefaultOprt[stOprt.top().GetCode()] + << _T("\" \n"); + } else { + switch (stOprt.top().GetCode()) { + case cmVAR: + mu::console() << _T("VAR\n"); + break; + case cmVAL: + mu::console() << _T("VAL\n"); + break; + case cmFUNC: + mu::console() << _T("FUNC \"") << stOprt.top().GetAsString() << _T("\"\n"); + break; + + case cmFUNC_BULK: + mu::console() << _T("FUNC_BULK \"") << stOprt.top().GetAsString() << _T("\"\n"); + break; + + case cmOPRT_INFIX: + mu::console() << _T("OPRT_INFIX \"") << stOprt.top().GetAsString() << _T("\"\n"); + break; + + case cmOPRT_BIN: + mu::console() << _T("OPRT_BIN \"") << stOprt.top().GetAsString() << _T("\"\n"); + break; + + case cmFUNC_STR: + mu::console() << _T("FUNC_STR\n"); + break; + case cmEND: + mu::console() << _T("END\n"); + break; + case cmUNKNOWN: + mu::console() << _T("UNKNOWN\n"); + break; + case cmBO: + mu::console() << _T("BRACKET \"(\"\n"); + break; + case cmBC: + mu::console() << _T("BRACKET \")\"\n"); + break; + case cmIF: + mu::console() << _T("IF\n"); + break; + case cmELSE: + mu::console() << _T("ELSE\n"); + break; + case cmENDIF: + mu::console() << _T("ENDIF\n"); + break; + default: + mu::console() << stOprt.top().GetCode() << _T(" "); + break; + } + } + stOprt.pop(); + } + + mu::console() << dec << endl; + } + + /** \brief Calculate the result. + + A note on const correctness: + I consider it important that Calc is a const function. + Due to caching operations Calc changes only the state of internal variables with one exception + m_UsedVar this is reset during string parsing and accessible from the outside. Instead of making + Calc non const GetUsedVar is non const because it explicitly calls Eval() forcing this update. + + \pre A formula must be set. + \pre Variables must have been set (if needed) + + \sa #m_pParseFormula + \return The evaluation result + \throw ParseException if no Formula is set or in case of any other error related to the formula. + */ + value_type + ParserBase::Eval() const { + return (this->*m_pParseFormula)(); + } + + //------------------------------------------------------------------------------ + /** \brief Evaluate an expression containing comma separated subexpressions + \param [out] nStackSize The total number of results available + \return Pointer to the array containing all expression results + + This member function can be used to retrieve all results of an expression + made up of multiple comma separated subexpressions (i.e. "x+y,sin(x),cos(y)") + */ + value_type* + ParserBase::Eval(int& nStackSize) const { + if (m_vRPN.GetSize() > 0) { + ParseCmdCode(); + } else { + ParseString(); + } + + nStackSize = m_nFinalResultIdx; + + // (for historic reasons the stack starts at position 1) + return &m_vStackBuffer[1]; + } + + //--------------------------------------------------------------------------- + /** \brief Return the number of results on the calculation stack. + + If the expression contains comma separated subexpressions (i.e. "sin(y), x+y"). + There may be more than one return value. This function returns the number of + available results. + */ + int + ParserBase::GetNumResults() const { + return m_nFinalResultIdx; + } + + //--------------------------------------------------------------------------- + void + ParserBase::Eval(value_type* results, + int nBulkSize) { + CreateRPN(); + + int i = 0; #ifdef MUP_USE_OPENMP - //#define DEBUG_OMP_STUFF + // #define DEBUG_OMP_STUFF #ifdef DEBUG_OMP_STUFF - int* pThread = new int[nBulkSize]; - int* pIdx = new int[nBulkSize]; + int* pThread = new int[nBulkSize]; + int* pIdx = new int[nBulkSize]; #endif - int nMaxThreads = std::min(omp_get_max_threads(), s_MaxNumOpenMPThreads); - int nThreadID = 0; + int nMaxThreads = std::min(omp_get_max_threads(), s_MaxNumOpenMPThreads); + int nThreadID = 0; #ifdef DEBUG_OMP_STUFF - int ct = 0; + int ct = 0; #endif - omp_set_num_threads(nMaxThreads); + omp_set_num_threads(nMaxThreads); -#pragma omp parallel for schedule(static, std::max(nBulkSize/nMaxThreads, 1)) private(nThreadID) - for (i = 0; i < nBulkSize; ++i) - { - nThreadID = omp_get_thread_num(); - results[i] = ParseCmdCodeBulk(i, nThreadID); +#pragma omp parallel for schedule(static, std::max(nBulkSize / nMaxThreads, 1)) private(nThreadID) + for (i = 0; i < nBulkSize; ++i) { + nThreadID = omp_get_thread_num(); + results[i] = ParseCmdCodeBulk(i, nThreadID); #ifdef DEBUG_OMP_STUFF #pragma omp critical - { - pThread[ct] = nThreadID; - pIdx[ct] = i; - ct++; - } + { + pThread[ct] = nThreadID; + pIdx[ct] = i; + ct++; + } #endif - } + } #ifdef DEBUG_OMP_STUFF - FILE* pFile = fopen("bulk_dbg.txt", "w"); - for (i = 0; i < nBulkSize; ++i) - { - fprintf(pFile, "idx: %d thread: %d \n", pIdx[i], pThread[i]); - } + FILE* pFile = fopen("bulk_dbg.txt", "w"); + for (i = 0; i < nBulkSize; ++i) { + fprintf(pFile, "idx: %d thread: %d \n", pIdx[i], pThread[i]); + } - delete[] pIdx; - delete[] pThread; + delete[] pIdx; + delete[] pThread; - fclose(pFile); + fclose(pFile); #endif #else - for (i = 0; i < nBulkSize; ++i) - { - results[i] = ParseCmdCodeBulk(i, 0); - } + for (i = 0; i < nBulkSize; ++i) { + results[i] = ParseCmdCodeBulk(i, 0); + } #endif - - } + } } // namespace mu #if defined(_MSC_VER) - #pragma warning(pop) +#pragma warning(pop) #endif - diff --git a/libsrc/spatialdata/muparser/muParserBase.h b/libsrc/spatialdata/muparser/muParserBase.h index 6d32f2f4..0bfde389 100644 --- a/libsrc/spatialdata/muparser/muParserBase.h +++ b/libsrc/spatialdata/muparser/muParserBase.h @@ -1,317 +1,346 @@ /* - - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2004 - 2021 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #ifndef MU_PARSER_BASE_H #define MU_PARSER_BASE_H //--- Standard includes ------------------------------------------------------------------------ #include -#include #include +#include +#include #include #include -#include -#include +#include //--- Parser includes -------------------------------------------------------------------------- -#include "muParserDef.h" -#include "muParserTokenReader.h" #include "muParserBytecode.h" +#include "muParserDef.h" #include "muParserError.h" +#include "muParserTokenReader.h" #if defined(_MSC_VER) - #pragma warning(push) - #pragma warning(disable : 4251) // ...needs to have dll-interface to be used by clients of class ... +#pragma warning(push) +#pragma warning(disable : 4251) // ...needs to have dll-interface to be used by clients of class ... #endif -namespace mu -{ - /** \file - \brief This file contains the class definition of the muparser engine. - */ - - /** \brief Mathematical expressions parser (base parser engine). - - This is the implementation of a bytecode based mathematical expressions parser. - The formula will be parsed from string and converted into a bytecode. - Future calculations will be done with the bytecode instead the formula string - resulting in a significant performance increase. - Complementary to a set of internally implemented functions the parser is able to handle - user defined functions and variables. - */ - class API_EXPORT_CXX ParserBase - { - friend class ParserTokenReader; - - private: - - /** \brief Typedef for the parse functions. - - The parse function do the actual work. The parser exchanges - the function pointer to the parser function depending on - which state it is in. (i.e. bytecode parser vs. string parser) - */ - typedef value_type(ParserBase::* ParseFunction)() const; - - /** \brief Type used for storing an array of values. */ - typedef std::vector valbuf_type; - - /** \brief Type for a vector of strings. */ - typedef std::vector stringbuf_type; - - /** \brief Typedef for the token reader. */ - typedef ParserTokenReader token_reader_type; - - /** \brief Type used for parser tokens. */ - typedef ParserToken token_type; - - /** \brief Maximum number of threads spawned by OpenMP when using the bulk mode. */ - static const int s_MaxNumOpenMPThreads; - - public: - - /** \brief Type of the error class. - - Included for backwards compatibility. - */ - typedef ParserError exception_type; - - static void EnableDebugDump(bool bDumpCmd, bool bDumpStack); - - ParserBase(); - ParserBase(const ParserBase& a_Parser); - ParserBase& operator=(const ParserBase& a_Parser); - - virtual ~ParserBase(); - - value_type Eval() const; - value_type* Eval(int& nStackSize) const; - void Eval(value_type* results, int nBulkSize); - - int GetNumResults() const; - - void SetExpr(const string_type& a_sExpr); - void SetVarFactory(facfun_type a_pFactory, void* pUserData = nullptr); - - void SetDecSep(char_type cDecSep); - void SetThousandsSep(char_type cThousandsSep = 0); - void ResetLocale(); - - void EnableOptimizer(bool a_bIsOn = true); - void EnableBuiltInOprt(bool a_bIsOn = true); - - bool HasBuiltInOprt() const; - void AddValIdent(identfun_type a_pCallback); - - /** \fn void mu::ParserBase::DefineFun(const string_type &a_strName, fun_type0 a_pFun, bool a_bAllowOpt = true) - \brief Define a parser function without arguments. - \param a_strName Name of the function - \param a_pFun Pointer to the callback function - \param a_bAllowOpt A flag indicating this function may be optimized - */ - template - void DefineFun(const string_type& a_strName, T a_pFun, bool a_bAllowOpt = true) - { - AddCallback(a_strName, ParserCallback(a_pFun, a_bAllowOpt), m_FunDef, ValidNameChars()); - } - - /** \fn void mu::ParserBase::DefineFunUserData - \brief Define a parser function with user data (not null). - \param a_strName Name of the function - \param a_pFun Pointer to the callback function - \param a_pUserData Pointer that will be passed back to callback (shall not be nullptr) - \param a_bAllowOpt A flag indicating this function may be optimized - */ - template - void DefineFunUserData(const string_type& a_strName, T a_pFun, void* a_pUserData, bool a_bAllowOpt = true) - { - AddCallback(a_strName, ParserCallback(a_pFun, a_pUserData, a_bAllowOpt), m_FunDef, ValidNameChars()); - } - - void DefineOprt(const string_type& a_strName, fun_type2 a_pFun, unsigned a_iPri = 0, EOprtAssociativity a_eAssociativity = oaLEFT, bool a_bAllowOpt = false); - void DefineConst(const string_type& a_sName, value_type a_fVal); - void DefineStrConst(const string_type& a_sName, const string_type& a_strVal); - void DefineVar(const string_type& a_sName, value_type* a_fVar); - void DefinePostfixOprt(const string_type& a_strFun, fun_type1 a_pOprt, bool a_bAllowOpt = true); - void DefineInfixOprt(const string_type& a_strName, fun_type1 a_pOprt, int a_iPrec = prINFIX, bool a_bAllowOpt = true); - - // Clear user defined variables, constants or functions - void ClearVar(); - void ClearFun(); - void ClearConst(); - void ClearInfixOprt(); - void ClearPostfixOprt(); - void ClearOprt(); - - void RemoveVar(const string_type& a_strVarName); - const varmap_type& GetUsedVar() const; - const varmap_type& GetVar() const; - const valmap_type& GetConst() const; - const string_type& GetExpr() const; - const funmap_type& GetFunDef() const; - string_type GetVersion(EParserVersionInfo eInfo = pviFULL) const; - const ParserByteCode& GetByteCode() const; - - const char_type** GetOprtDef() const; - void DefineNameChars(const char_type* a_szCharset); - void DefineOprtChars(const char_type* a_szCharset); - void DefineInfixOprtChars(const char_type* a_szCharset); - - const char_type* ValidNameChars() const; - const char_type* ValidOprtChars() const; - const char_type* ValidInfixOprtChars() const; - - void SetArgSep(char_type cArgSep); - char_type GetArgSep() const; - - protected: - - void Init(); - void Error(EErrorCodes a_iErrc, int a_iPos = static_cast(mu::string_type::npos), const string_type& a_strTok = string_type()) const; - - virtual void InitCharSets() = 0; - virtual void InitFun() = 0; - virtual void InitConst() = 0; - virtual void InitOprt() = 0; - - virtual void OnDetectVar(string_type* pExpr, int& nStart, int& nEnd); - - static const char_type* c_DefaultOprt[]; - static std::locale s_locale; ///< The locale used by the parser - static bool g_DbgDumpCmdCode; - static bool g_DbgDumpStack; - - /** \brief A facet class used to change decimal and thousands separator. */ - template - class change_dec_sep : public std::numpunct - { - public: - - explicit change_dec_sep(char_type cDecSep, char_type cThousandsSep = 0, int nGroup = 3) - :std::numpunct() - ,m_nGroup(nGroup) - ,m_cDecPoint(cDecSep) - ,m_cThousandsSep(cThousandsSep) - {} - - protected: - - char_type do_decimal_point() const override - { - return m_cDecPoint; - } - - char_type do_thousands_sep() const override - { - return m_cThousandsSep; - } - - std::string do_grouping() const override - { - // fix for issue 4: https://code.google.com/p/muparser/issues/detail?id=4 - // courtesy of Jens Bartsch - // original code: - // return std::string(1, (char)m_nGroup); - // new code: - return std::string(1, (char)(m_cThousandsSep > 0 ? m_nGroup : CHAR_MAX)); - } - - private: - - int m_nGroup; - char_type m_cDecPoint; - char_type m_cThousandsSep; - }; - - private: - - void Assign(const ParserBase& a_Parser); - void InitTokenReader(); - void ReInit() const; - - void AddCallback(const string_type& a_strName, const ParserCallback& a_Callback, funmap_type& a_Storage, const char_type* a_szCharSet); - void ApplyRemainingOprt(std::stack& a_stOpt, std::stack& a_stVal) const; - void ApplyBinOprt(std::stack& a_stOpt, std::stack& a_stVal) const; - void ApplyIfElse(std::stack& a_stOpt, std::stack& a_stVal) const; - void ApplyFunc(std::stack& a_stOpt, std::stack& a_stVal, int iArgCount) const; - - token_type ApplyStrFunc(const token_type& a_FunTok, const std::vector& a_vArg) const; - - int GetOprtPrecedence(const token_type& a_Tok) const; - EOprtAssociativity GetOprtAssociativity(const token_type& a_Tok) const; - - void CreateRPN() const; - - value_type ParseString() const; - value_type ParseCmdCode() const; - value_type ParseCmdCodeShort() const; - value_type ParseCmdCodeBulk(int nOffset, int nThreadID) const; - - void CheckName(const string_type& a_strName, const string_type& a_CharSet) const; - void CheckOprt(const string_type& a_sName, const ParserCallback& a_Callback, const string_type& a_szCharSet) const; - - void StackDump(const std::stack& a_stVal, const std::stack& a_stOprt) const; - - /** \brief Pointer to the parser function. - - Eval() calls the function whose address is stored there. - */ - mutable ParseFunction m_pParseFormula; - mutable ParserByteCode m_vRPN; ///< The Bytecode class. - mutable stringbuf_type m_vStringBuf; ///< String buffer, used for storing string function arguments - stringbuf_type m_vStringVarBuf; - - std::unique_ptr m_pTokenReader; ///< Managed pointer to the token reader object. - - funmap_type m_FunDef; ///< Map of function names and pointers. - funmap_type m_PostOprtDef; ///< Postfix operator callbacks - funmap_type m_InfixOprtDef; ///< unary infix operator. - funmap_type m_OprtDef; ///< Binary operator callbacks - valmap_type m_ConstDef; ///< user constants. - strmap_type m_StrVarDef; ///< user defined string constants - varmap_type m_VarDef; ///< user defind variables. - - bool m_bBuiltInOp; ///< Flag that can be used for switching built in operators on and off - - string_type m_sNameChars; ///< Charset for names - string_type m_sOprtChars; ///< Charset for postfix/ binary operator tokens - string_type m_sInfixOprtChars; ///< Charset for infix operator tokens - - // items merely used for caching state information - mutable valbuf_type m_vStackBuffer; ///< This is merely a buffer used for the stack in the cmd parsing routine - mutable int m_nFinalResultIdx; - }; +namespace mu { + /** \file + \brief This file contains the class definition of the muparser engine. + */ + + /** \brief Mathematical expressions parser (base parser engine). + + This is the implementation of a bytecode based mathematical expressions parser. + The formula will be parsed from string and converted into a bytecode. + Future calculations will be done with the bytecode instead the formula string + resulting in a significant performance increase. + Complementary to a set of internally implemented functions the parser is able to handle + user defined functions and variables. + */ + class API_EXPORT_CXX ParserBase { + friend class ParserTokenReader; + + private: + /** \brief Typedef for the parse functions. + + The parse function do the actual work. The parser exchanges + the function pointer to the parser function depending on + which state it is in. (i.e. bytecode parser vs. string parser) + */ + typedef value_type (ParserBase::*ParseFunction)() const; + + /** \brief Type used for storing an array of values. */ + typedef std::vector valbuf_type; + + /** \brief Type for a vector of strings. */ + typedef std::vector stringbuf_type; + + /** \brief Typedef for the token reader. */ + typedef ParserTokenReader token_reader_type; + + /** \brief Type used for parser tokens. */ + typedef ParserToken token_type; + + /** \brief Maximum number of threads spawned by OpenMP when using the bulk mode. */ + static const int s_MaxNumOpenMPThreads; + + public: + /** \brief Type of the error class. + + Included for backwards compatibility. + */ + typedef ParserError exception_type; + + static void EnableDebugDump(bool bDumpCmd, + bool bDumpStack); + + ParserBase(); + ParserBase(const ParserBase& a_Parser); + ParserBase& operator=(const ParserBase& a_Parser); + + virtual ~ParserBase(); + + value_type Eval() const; + value_type* Eval(int& nStackSize) const; + void Eval(value_type* results, + int nBulkSize); + + int GetNumResults() const; + + void SetExpr(const string_type& a_sExpr); + void SetVarFactory(facfun_type a_pFactory, + void* pUserData = nullptr); + + void SetDecSep(char_type cDecSep); + void SetThousandsSep(char_type cThousandsSep = 0); + void ResetLocale(); + + void EnableOptimizer(bool a_bIsOn = true); + void EnableBuiltInOprt(bool a_bIsOn = true); + + bool HasBuiltInOprt() const; + void AddValIdent(identfun_type a_pCallback); + + /** \fn void mu::ParserBase::DefineFun(const string_type &a_strName, fun_type0 a_pFun, bool a_bAllowOpt = true) + \brief Define a parser function without arguments. + \param a_strName Name of the function + \param a_pFun Pointer to the callback function + \param a_bAllowOpt A flag indicating this function may be optimized + */ + template + void + DefineFun(const string_type& a_strName, + T a_pFun, + bool a_bAllowOpt = true) { + AddCallback(a_strName, ParserCallback(a_pFun, a_bAllowOpt), m_FunDef, ValidNameChars()); + } + + /** \fn void mu::ParserBase::DefineFunUserData + \brief Define a parser function with user data (not null). + \param a_strName Name of the function + \param a_pFun Pointer to the callback function + \param a_pUserData Pointer that will be passed back to callback (shall not be nullptr) + \param a_bAllowOpt A flag indicating this function may be optimized + */ + template + void + DefineFunUserData(const string_type& a_strName, + T a_pFun, + void* a_pUserData, + bool a_bAllowOpt = true) { + AddCallback(a_strName, ParserCallback(a_pFun, a_pUserData, a_bAllowOpt), m_FunDef, ValidNameChars()); + } + + void DefineOprt(const string_type& a_strName, + fun_type2 a_pFun, + unsigned a_iPri = 0, + EOprtAssociativity a_eAssociativity = oaLEFT, + bool a_bAllowOpt = false); + void DefineConst(const string_type& a_sName, + value_type a_fVal); + void DefineStrConst(const string_type& a_sName, + const string_type& a_strVal); + void DefineVar(const string_type& a_sName, + value_type* a_fVar); + void DefinePostfixOprt(const string_type& a_strFun, + fun_type1 a_pOprt, + bool a_bAllowOpt = true); + void DefineInfixOprt(const string_type& a_strName, + fun_type1 a_pOprt, + int a_iPrec = prINFIX, + bool a_bAllowOpt = true); + + // Clear user defined variables, constants or functions + void ClearVar(); + void ClearFun(); + void ClearConst(); + void ClearInfixOprt(); + void ClearPostfixOprt(); + void ClearOprt(); + + void RemoveVar(const string_type& a_strVarName); + const varmap_type& GetUsedVar() const; + const varmap_type& GetVar() const; + const valmap_type& GetConst() const; + const string_type& GetExpr() const; + const funmap_type& GetFunDef() const; + string_type GetVersion(EParserVersionInfo eInfo = pviFULL) const; + const ParserByteCode& GetByteCode() const; + + const char_type** GetOprtDef() const; + void DefineNameChars(const char_type* a_szCharset); + void DefineOprtChars(const char_type* a_szCharset); + void DefineInfixOprtChars(const char_type* a_szCharset); + + const char_type* ValidNameChars() const; + const char_type* ValidOprtChars() const; + const char_type* ValidInfixOprtChars() const; + + void SetArgSep(char_type cArgSep); + char_type GetArgSep() const; + + protected: + void Init(); + void Error(EErrorCodes a_iErrc, + int a_iPos = static_cast(mu::string_type::npos), + const string_type& a_strTok = string_type()) const; + + virtual void InitCharSets() = 0; + virtual void InitFun() = 0; + virtual void InitConst() = 0; + virtual void InitOprt() = 0; + + virtual void OnDetectVar(string_type* pExpr, + int& nStart, + int& nEnd); + + static const char_type* c_DefaultOprt[]; + static std::locale s_locale; ///< The locale used by the parser + static bool g_DbgDumpCmdCode; + static bool g_DbgDumpStack; + + /** \brief A facet class used to change decimal and thousands separator. */ + template class change_dec_sep : public std::numpunct { + public: + explicit change_dec_sep(char_type cDecSep, + char_type cThousandsSep = 0, + int nGroup = 3) : + std::numpunct(), + m_nGroup(nGroup), + m_cDecPoint(cDecSep), + m_cThousandsSep(cThousandsSep) { + } + + protected: + char_type + do_decimal_point() const override { + return m_cDecPoint; + } + + char_type + do_thousands_sep() const override { + return m_cThousandsSep; + } + + std::string + do_grouping() const override { + // fix for issue 4: https://code.google.com/p/muparser/issues/detail?id=4 + // courtesy of Jens Bartsch + // original code: + // return std::string(1, (char)m_nGroup); + // new code: + return std::string(1, (char)(m_cThousandsSep > 0 ? m_nGroup : CHAR_MAX)); + } + + private: + int m_nGroup; + char_type m_cDecPoint; + char_type m_cThousandsSep; + }; + + private: + void Assign(const ParserBase& a_Parser); + void InitTokenReader(); + void ReInit() const; + + void AddCallback(const string_type& a_strName, + const ParserCallback& a_Callback, + funmap_type& a_Storage, + const char_type* a_szCharSet); + void ApplyRemainingOprt(std::stack& a_stOpt, + std::stack& a_stVal) const; + void ApplyBinOprt(std::stack& a_stOpt, + std::stack& a_stVal) const; + void ApplyIfElse(std::stack& a_stOpt, + std::stack& a_stVal) const; + void ApplyFunc(std::stack& a_stOpt, + std::stack& a_stVal, + int iArgCount) const; + + token_type ApplyStrFunc(const token_type& a_FunTok, + const std::vector& a_vArg) const; + + int GetOprtPrecedence(const token_type& a_Tok) const; + EOprtAssociativity GetOprtAssociativity(const token_type& a_Tok) const; + + void CreateRPN() const; + + value_type ParseString() const; + value_type ParseCmdCode() const; + value_type ParseCmdCodeShort() const; + value_type ParseCmdCodeBulk(int nOffset, + int nThreadID) const; + + void CheckName(const string_type& a_strName, + const string_type& a_CharSet) const; + void CheckOprt(const string_type& a_sName, + const ParserCallback& a_Callback, + const string_type& a_szCharSet) const; + + void StackDump(const std::stack& a_stVal, + const std::stack& a_stOprt) const; + + /** \brief Pointer to the parser function. + + Eval() calls the function whose address is stored there. + */ + mutable ParseFunction m_pParseFormula; + mutable ParserByteCode m_vRPN; ///< The Bytecode class. + mutable stringbuf_type m_vStringBuf; ///< String buffer, used for storing string function arguments + stringbuf_type m_vStringVarBuf; + + std::unique_ptr m_pTokenReader; ///< Managed pointer to the token reader object. + + funmap_type m_FunDef; ///< Map of function names and pointers. + funmap_type m_PostOprtDef; ///< Postfix operator callbacks + funmap_type m_InfixOprtDef; ///< unary infix operator. + funmap_type m_OprtDef; ///< Binary operator callbacks + valmap_type m_ConstDef; ///< user constants. + strmap_type m_StrVarDef; ///< user defined string constants + varmap_type m_VarDef; ///< user defind variables. + + bool m_bBuiltInOp; ///< Flag that can be used for switching built in operators on and off + + string_type m_sNameChars; ///< Charset for names + string_type m_sOprtChars; ///< Charset for postfix/ binary operator tokens + string_type m_sInfixOprtChars; ///< Charset for infix operator tokens + + // items merely used for caching state information + mutable valbuf_type m_vStackBuffer; ///< This is merely a buffer used for the stack in the cmd parsing routine + mutable int m_nFinalResultIdx; + }; } // namespace mu #if defined(_MSC_VER) - #pragma warning(pop) +#pragma warning(pop) #endif #endif diff --git a/libsrc/spatialdata/muparser/muParserBytecode.cpp b/libsrc/spatialdata/muparser/muParserBytecode.cpp index 54427b94..1509d4f0 100644 --- a/libsrc/spatialdata/muparser/muParserBytecode.cpp +++ b/libsrc/spatialdata/muparser/muParserBytecode.cpp @@ -1,644 +1,757 @@ /* - - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2004 - 2021 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include "muParserBytecode.h" #include -#include +#include #include +#include #include -#include #include "muParserDef.h" #include "muParserError.h" -#include "muParserToken.h" #include "muParserTemplateMagic.h" +#include "muParserToken.h" #if defined(_MSC_VER) - #pragma warning(push) - #pragma warning(disable : 26812) +#pragma warning(push) +#pragma warning(disable : 26812) #endif -namespace mu -{ - /** \brief Bytecode default constructor. */ - ParserByteCode::ParserByteCode() - :m_iStackPos(0) - , m_iMaxStackSize(0) - , m_vRPN() - , m_bEnableOptimizer(true) - { - m_vRPN.reserve(50); - } - - - /** \brief Copy constructor. - - Implemented in Terms of Assign(const ParserByteCode &a_ByteCode) - */ - ParserByteCode::ParserByteCode(const ParserByteCode& a_ByteCode) - { - Assign(a_ByteCode); - } - - - /** \brief Assignment operator. - - Implemented in Terms of Assign(const ParserByteCode &a_ByteCode) - */ - ParserByteCode& ParserByteCode::operator=(const ParserByteCode& a_ByteCode) - { - Assign(a_ByteCode); - return *this; - } - - - void ParserByteCode::EnableOptimizer(bool bStat) - { - m_bEnableOptimizer = bStat; - } - - - /** \brief Copy state of another object to this. - - \throw nowthrow - */ - void ParserByteCode::Assign(const ParserByteCode& a_ByteCode) - { - if (this == &a_ByteCode) - return; - - m_iStackPos = a_ByteCode.m_iStackPos; - m_vRPN = a_ByteCode.m_vRPN; - m_iMaxStackSize = a_ByteCode.m_iMaxStackSize; - m_bEnableOptimizer = a_ByteCode.m_bEnableOptimizer; - } - - - /** \brief Add a Variable pointer to bytecode. - \param a_pVar Pointer to be added. - \throw nothrow - */ - void ParserByteCode::AddVar(value_type* a_pVar) - { - ++m_iStackPos; - m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); - - // optimization does not apply - SToken tok; - tok.Cmd = cmVAR; - tok.Val.ptr = a_pVar; - tok.Val.data = 1; - tok.Val.data2 = 0; - m_vRPN.push_back(tok); - } - - - /** \brief Add a Variable pointer to bytecode. - - Value entries in byte code consist of: -
    -
  • value array position of the value
  • -
  • the operator code according to ParserToken::cmVAL
  • -
  • the value stored in #mc_iSizeVal number of bytecode entries.
  • -
- - \param a_pVal Value to be added. - \throw nothrow - */ - void ParserByteCode::AddVal(value_type a_fVal) - { - ++m_iStackPos; - m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); - - // If optimization does not apply - SToken tok; - tok.Cmd = cmVAL; - tok.Val.ptr = nullptr; - tok.Val.data = 0; - tok.Val.data2 = a_fVal; - m_vRPN.push_back(tok); - } - - - void ParserByteCode::ConstantFolding(ECmdCode a_Oprt) - { - std::size_t sz = m_vRPN.size(); - value_type& x = m_vRPN[sz - 2].Val.data2; - value_type& y = m_vRPN[sz - 1].Val.data2; - - switch (a_Oprt) - { - case cmLAND: x = (int)x && (int)y; m_vRPN.pop_back(); break; - case cmLOR: x = (int)x || (int)y; m_vRPN.pop_back(); break; - case cmLT: x = x < y; m_vRPN.pop_back(); break; - case cmGT: x = x > y; m_vRPN.pop_back(); break; - case cmLE: x = x <= y; m_vRPN.pop_back(); break; - case cmGE: x = x >= y; m_vRPN.pop_back(); break; - case cmNEQ: x = x != y; m_vRPN.pop_back(); break; - case cmEQ: x = x == y; m_vRPN.pop_back(); break; - case cmADD: x = x + y; m_vRPN.pop_back(); break; - case cmSUB: x = x - y; m_vRPN.pop_back(); break; - case cmMUL: x = x * y; m_vRPN.pop_back(); break; - case cmDIV: - x = x / y; - m_vRPN.pop_back(); - break; - - case cmPOW: x = MathImpl::Pow(x, y); - m_vRPN.pop_back(); - break; - - default: - break; - } // switch opcode - } - - - /** \brief Add an operator identifier to bytecode. - - Operator entries in byte code consist of: -
    -
  • value array position of the result
  • -
  • the operator code according to ParserToken::ECmdCode
  • -
- - \sa ParserToken::ECmdCode - */ - void ParserByteCode::AddOp(ECmdCode a_Oprt) - { - bool bOptimized = false; - - if (m_bEnableOptimizer) - { - std::size_t sz = m_vRPN.size(); - - // Check for foldable constants like: - // cmVAL cmVAL cmADD - // where cmADD can stand fopr any binary operator applied to - // two constant values. - if (sz >= 2 && m_vRPN[sz - 2].Cmd == cmVAL && m_vRPN[sz - 1].Cmd == cmVAL) - { - ConstantFolding(a_Oprt); - bOptimized = true; - } - else - { - switch (a_Oprt) - { - case cmPOW: - // Optimization for polynomials of low order - if (m_vRPN[sz - 2].Cmd == cmVAR && m_vRPN[sz - 1].Cmd == cmVAL) - { - if (m_vRPN[sz - 1].Val.data2 == 0) - { - m_vRPN[sz - 2].Cmd = cmVAL; - m_vRPN[sz - 2].Val.ptr = nullptr; - m_vRPN[sz - 2].Val.data = 0; - m_vRPN[sz - 2].Val.data2 = 1; - } - else if (m_vRPN[sz - 1].Val.data2 == 1) - m_vRPN[sz - 2].Cmd = cmVAR; - else if (m_vRPN[sz - 1].Val.data2 == 2) - m_vRPN[sz - 2].Cmd = cmVARPOW2; - else if (m_vRPN[sz - 1].Val.data2 == 3) - m_vRPN[sz - 2].Cmd = cmVARPOW3; - else if (m_vRPN[sz - 1].Val.data2 == 4) - m_vRPN[sz - 2].Cmd = cmVARPOW4; - else - break; - - m_vRPN.pop_back(); - bOptimized = true; - } - break; - - case cmSUB: - case cmADD: - // Simple optimization based on pattern recognition for a shitload of different - // bytecode combinations of addition/subtraction - if ((m_vRPN[sz - 1].Cmd == cmVAR && m_vRPN[sz - 2].Cmd == cmVAL) || - (m_vRPN[sz - 1].Cmd == cmVAL && m_vRPN[sz - 2].Cmd == cmVAR) || - (m_vRPN[sz - 1].Cmd == cmVAL && m_vRPN[sz - 2].Cmd == cmVARMUL) || - (m_vRPN[sz - 1].Cmd == cmVARMUL && m_vRPN[sz - 2].Cmd == cmVAL) || - (m_vRPN[sz - 1].Cmd == cmVAR && m_vRPN[sz - 2].Cmd == cmVAR && m_vRPN[sz - 2].Val.ptr == m_vRPN[sz - 1].Val.ptr) || - (m_vRPN[sz - 1].Cmd == cmVAR && m_vRPN[sz - 2].Cmd == cmVARMUL && m_vRPN[sz - 2].Val.ptr == m_vRPN[sz - 1].Val.ptr) || - (m_vRPN[sz - 1].Cmd == cmVARMUL && m_vRPN[sz - 2].Cmd == cmVAR && m_vRPN[sz - 2].Val.ptr == m_vRPN[sz - 1].Val.ptr) || - (m_vRPN[sz - 1].Cmd == cmVARMUL && m_vRPN[sz - 2].Cmd == cmVARMUL && m_vRPN[sz - 2].Val.ptr == m_vRPN[sz - 1].Val.ptr)) - { - MUP_ASSERT( - (m_vRPN[sz - 2].Val.ptr == nullptr && m_vRPN[sz - 1].Val.ptr != nullptr) || - (m_vRPN[sz - 2].Val.ptr != nullptr && m_vRPN[sz - 1].Val.ptr == nullptr) || - (m_vRPN[sz - 2].Val.ptr == m_vRPN[sz - 1].Val.ptr)); - - m_vRPN[sz - 2].Cmd = cmVARMUL; - m_vRPN[sz - 2].Val.ptr = (value_type*)((long long)(m_vRPN[sz - 2].Val.ptr) | (long long)(m_vRPN[sz - 1].Val.ptr)); // variable - m_vRPN[sz - 2].Val.data2 += ((a_Oprt == cmSUB) ? -1 : 1) * m_vRPN[sz - 1].Val.data2; // offset - m_vRPN[sz - 2].Val.data += ((a_Oprt == cmSUB) ? -1 : 1) * m_vRPN[sz - 1].Val.data; // multiplicand - m_vRPN.pop_back(); - bOptimized = true; - } - break; - - case cmMUL: - if ((m_vRPN[sz - 1].Cmd == cmVAR && m_vRPN[sz - 2].Cmd == cmVAL) || - (m_vRPN[sz - 1].Cmd == cmVAL && m_vRPN[sz - 2].Cmd == cmVAR)) - { - m_vRPN[sz - 2].Cmd = cmVARMUL; - m_vRPN[sz - 2].Val.ptr = (value_type*)((long long)(m_vRPN[sz - 2].Val.ptr) | (long long)(m_vRPN[sz - 1].Val.ptr)); - m_vRPN[sz - 2].Val.data = m_vRPN[sz - 2].Val.data2 + m_vRPN[sz - 1].Val.data2; - m_vRPN[sz - 2].Val.data2 = 0; - m_vRPN.pop_back(); - bOptimized = true; - } - else if ( - (m_vRPN[sz - 1].Cmd == cmVAL && m_vRPN[sz - 2].Cmd == cmVARMUL) || - (m_vRPN[sz - 1].Cmd == cmVARMUL && m_vRPN[sz - 2].Cmd == cmVAL)) - { - // Optimization: 2*(3*b+1) or (3*b+1)*2 -> 6*b+2 - m_vRPN[sz - 2].Cmd = cmVARMUL; - m_vRPN[sz - 2].Val.ptr = (value_type*)((long long)(m_vRPN[sz - 2].Val.ptr) | (long long)(m_vRPN[sz - 1].Val.ptr)); - if (m_vRPN[sz - 1].Cmd == cmVAL) - { - m_vRPN[sz - 2].Val.data *= m_vRPN[sz - 1].Val.data2; - m_vRPN[sz - 2].Val.data2 *= m_vRPN[sz - 1].Val.data2; - } - else - { - m_vRPN[sz - 2].Val.data = m_vRPN[sz - 1].Val.data * m_vRPN[sz - 2].Val.data2; - m_vRPN[sz - 2].Val.data2 = m_vRPN[sz - 1].Val.data2 * m_vRPN[sz - 2].Val.data2; - } - m_vRPN.pop_back(); - bOptimized = true; - } - else if ( - m_vRPN[sz - 1].Cmd == cmVAR && m_vRPN[sz - 2].Cmd == cmVAR && - m_vRPN[sz - 1].Val.ptr == m_vRPN[sz - 2].Val.ptr) - { - // Optimization: a*a -> a^2 - m_vRPN[sz - 2].Cmd = cmVARPOW2; - m_vRPN.pop_back(); - bOptimized = true; - } - break; - - case cmDIV: - if (m_vRPN[sz - 1].Cmd == cmVAL && m_vRPN[sz - 2].Cmd == cmVARMUL && m_vRPN[sz - 1].Val.data2 != 0) - { - // Optimization: 4*a/2 -> 2*a - m_vRPN[sz - 2].Val.data /= m_vRPN[sz - 1].Val.data2; - m_vRPN[sz - 2].Val.data2 /= m_vRPN[sz - 1].Val.data2; - m_vRPN.pop_back(); - bOptimized = true; - } - break; - - // no optimization for other opcodes - default: - break; - } // switch a_Oprt - } - } - - // If optimization can't be applied just write the value - if (!bOptimized) - { - --m_iStackPos; - SToken tok; - tok.Cmd = a_Oprt; - m_vRPN.push_back(tok); - } - } - - - void ParserByteCode::AddIfElse(ECmdCode a_Oprt) - { - SToken tok; - tok.Cmd = a_Oprt; - m_vRPN.push_back(tok); - } - - - /** \brief Add an assignment operator - - Operator entries in byte code consist of: -
    -
  • cmASSIGN code
  • -
  • the pointer of the destination variable
  • -
- - \sa ParserToken::ECmdCode - */ - void ParserByteCode::AddAssignOp(value_type* a_pVar) - { - --m_iStackPos; - - SToken tok; - tok.Cmd = cmASSIGN; - tok.Oprt.ptr = a_pVar; - m_vRPN.push_back(tok); - } - - - /** \brief Add function to bytecode. - - \param a_iArgc Number of arguments, negative numbers indicate multiarg functions. - \param a_pFun Pointer to function callback. - */ - void ParserByteCode::AddFun(generic_callable_type a_pFun, int a_iArgc, bool isFunctionOptimizable) - { - std::size_t sz = m_vRPN.size(); - bool optimize = false; - - // only optimize functions with fixed number of more than a single arguments - if (isFunctionOptimizable && m_bEnableOptimizer && a_iArgc > 0) - { - // Unary Plus is a no-op - if (a_pFun == generic_callable_type{(erased_fun_type)&MathImpl::UnaryPlus, nullptr}) - return; - - optimize = true; - - for (int i = 0; i < std::abs(a_iArgc); ++i) - { - if (m_vRPN[sz - i - 1].Cmd != cmVAL) - { - optimize = false; - break; - } - } - } - - if (optimize) - { - value_type val = 0; - switch (a_iArgc) - { - case 1: val = a_pFun.call_fun<1>(m_vRPN[sz - 1].Val.data2); break; - case 2: val = a_pFun.call_fun<2>(m_vRPN[sz - 2].Val.data2, m_vRPN[sz - 1].Val.data2); break; - case 3: val = a_pFun.call_fun<3>(m_vRPN[sz - 3].Val.data2, m_vRPN[sz - 2].Val.data2, m_vRPN[sz - 1].Val.data2); break; - case 4: val = a_pFun.call_fun<4>(m_vRPN[sz - 4].Val.data2, m_vRPN[sz - 3].Val.data2, m_vRPN[sz - 2].Val.data2, m_vRPN[sz - 1].Val.data2); break; - case 5: val = a_pFun.call_fun<5>(m_vRPN[sz - 5].Val.data2, m_vRPN[sz - 4].Val.data2, m_vRPN[sz - 3].Val.data2, m_vRPN[sz - 2].Val.data2, m_vRPN[sz - 1].Val.data2); break; - case 6: val = a_pFun.call_fun<6>(m_vRPN[sz - 6].Val.data2, m_vRPN[sz - 5].Val.data2, m_vRPN[sz - 4].Val.data2, m_vRPN[sz - 3].Val.data2, m_vRPN[sz - 2].Val.data2, m_vRPN[sz - 1].Val.data2); break; - case 7: val = a_pFun.call_fun<7>(m_vRPN[sz - 7].Val.data2, m_vRPN[sz - 6].Val.data2, m_vRPN[sz - 5].Val.data2, m_vRPN[sz - 4].Val.data2, m_vRPN[sz - 3].Val.data2, m_vRPN[sz - 2].Val.data2, m_vRPN[sz - 1].Val.data2); break; - case 8: val = a_pFun.call_fun<8>(m_vRPN[sz - 8].Val.data2, m_vRPN[sz - 7].Val.data2, m_vRPN[sz - 6].Val.data2, m_vRPN[sz - 5].Val.data2, m_vRPN[sz - 4].Val.data2, m_vRPN[sz - 3].Val.data2, m_vRPN[sz - 2].Val.data2, m_vRPN[sz - 1].Val.data2); break; - case 9: val = a_pFun.call_fun<9>(m_vRPN[sz - 9].Val.data2, m_vRPN[sz - 8].Val.data2, m_vRPN[sz - 7].Val.data2, m_vRPN[sz - 6].Val.data2, m_vRPN[sz - 5].Val.data2, m_vRPN[sz - 4].Val.data2, m_vRPN[sz - 3].Val.data2, m_vRPN[sz - 2].Val.data2, m_vRPN[sz - 1].Val.data2); break; - case 10: val = a_pFun.call_fun<10>(m_vRPN[sz - 10].Val.data2, m_vRPN[sz - 9].Val.data2, m_vRPN[sz - 8].Val.data2, m_vRPN[sz - 7].Val.data2, m_vRPN[sz - 6].Val.data2, m_vRPN[sz - 5].Val.data2, m_vRPN[sz - 4].Val.data2, m_vRPN[sz - 3].Val.data2, m_vRPN[sz - 2].Val.data2, m_vRPN[sz - 1].Val.data2); break; - default: - // For now functions with unlimited number of arguments are not optimized - throw ParserError(ecINTERNAL_ERROR); - } - - // remove the folded values - m_vRPN.erase(m_vRPN.end() - a_iArgc, m_vRPN.end()); - - SToken tok; - tok.Cmd = cmVAL; - tok.Val.data = 0; - tok.Val.data2 = val; - tok.Val.ptr = nullptr; - m_vRPN.push_back(tok); - } - else - { - SToken tok; - tok.Cmd = cmFUNC; - tok.Fun.argc = a_iArgc; - tok.Fun.cb = a_pFun; - m_vRPN.push_back(tok); - } - - m_iStackPos = m_iStackPos - std::abs(a_iArgc) + 1; - m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); - - } - - - /** \brief Add a bulk function to bytecode. - - \param a_iArgc Number of arguments, negative numbers indicate multiarg functions. - \param a_pFun Pointer to function callback. - */ - void ParserByteCode::AddBulkFun(generic_callable_type a_pFun, int a_iArgc) - { - m_iStackPos = m_iStackPos - a_iArgc + 1; - m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); - - SToken tok; - tok.Cmd = cmFUNC_BULK; - tok.Fun.argc = a_iArgc; - tok.Fun.cb = a_pFun; - m_vRPN.push_back(tok); - } - - - /** \brief Add Strung function entry to the parser bytecode. - \throw nothrow - - A string function entry consists of the stack position of the return value, - followed by a cmSTRFUNC code, the function pointer and an index into the - string buffer maintained by the parser. - */ - void ParserByteCode::AddStrFun(generic_callable_type a_pFun, int a_iArgc, int a_iIdx) - { - m_iStackPos = m_iStackPos - a_iArgc + 1; - - SToken tok; - tok.Cmd = cmFUNC_STR; - tok.Fun.argc = a_iArgc; - tok.Fun.idx = a_iIdx; - tok.Fun.cb = a_pFun; - m_vRPN.push_back(tok); - - m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); - } - - - /** \brief Add end marker to bytecode. - - \throw nothrow - */ - void ParserByteCode::Finalize() - { - SToken tok; - tok.Cmd = cmEND; - m_vRPN.push_back(tok); - rpn_type(m_vRPN).swap(m_vRPN); // shrink bytecode vector to fit - - // Determine the if-then-else jump offsets - std::stack stIf, stElse; - int idx; - for (int i = 0; i < (int)m_vRPN.size(); ++i) - { - switch (m_vRPN[i].Cmd) - { - case cmIF: - stIf.push(i); - break; - - case cmELSE: - stElse.push(i); - idx = stIf.top(); - stIf.pop(); - m_vRPN[idx].Oprt.offset = i - idx; - break; - - case cmENDIF: - idx = stElse.top(); - stElse.pop(); - m_vRPN[idx].Oprt.offset = i - idx; - break; - - default: - break; - } - } - } - - - std::size_t ParserByteCode::GetMaxStackSize() const - { - return m_iMaxStackSize + 1; - } - - - /** \brief Delete the bytecode. - - \throw nothrow - - The name of this function is a violation of my own coding guidelines - but this way it's more in line with the STL functions thus more - intuitive. - */ - void ParserByteCode::clear() - { - m_vRPN.clear(); - m_iStackPos = 0; - m_iMaxStackSize = 0; - } - - - /** \brief Dump bytecode (for debugging only!). */ - void ParserByteCode::AsciiDump() - { - if (!m_vRPN.size()) - { - mu::console() << _T("No bytecode available\n"); - return; - } - - mu::console() << _T("Number of RPN tokens:") << (int)m_vRPN.size() << _T("\n"); - for (std::size_t i = 0; i < m_vRPN.size() && m_vRPN[i].Cmd != cmEND; ++i) - { - mu::console() << std::dec << i << _T(" : \t"); - switch (m_vRPN[i].Cmd) - { - case cmVAL: mu::console() << _T("VAL \t"); - mu::console() << _T("[") << m_vRPN[i].Val.data2 << _T("]\n"); - break; - - case cmVAR: mu::console() << _T("VAR \t"); - mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]\n"); - break; - - case cmVARPOW2: mu::console() << _T("VARPOW2 \t"); - mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]\n"); - break; - - case cmVARPOW3: mu::console() << _T("VARPOW3 \t"); - mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]\n"); - break; - - case cmVARPOW4: mu::console() << _T("VARPOW4 \t"); - mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]\n"); - break; - - case cmVARMUL: mu::console() << _T("VARMUL \t"); - mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]"); - mu::console() << _T(" * [") << m_vRPN[i].Val.data << _T("]"); - mu::console() << _T(" + [") << m_vRPN[i].Val.data2 << _T("]\n"); - break; - - case cmFUNC: mu::console() << _T("CALL\t"); - mu::console() << _T("[ARG:") << std::dec << m_vRPN[i].Fun.argc << _T("]"); - mu::console() << _T("[ADDR: 0x") << std::hex << reinterpret_cast(m_vRPN[i].Fun.cb._pRawFun) << _T("]"); - mu::console() << _T("[USERDATA: 0x") << std::hex << reinterpret_cast(m_vRPN[i].Fun.cb._pUserData) << _T("]"); - mu::console() << _T("\n"); - break; - - case cmFUNC_STR: - mu::console() << _T("CALL STRFUNC\t"); - mu::console() << _T("[ARG:") << std::dec << m_vRPN[i].Fun.argc << _T("]"); - mu::console() << _T("[IDX:") << std::dec << m_vRPN[i].Fun.idx << _T("]"); - mu::console() << _T("[ADDR: 0x") << std::hex << reinterpret_cast(m_vRPN[i].Fun.cb._pRawFun) << _T("]"); - mu::console() << _T("[USERDATA: 0x") << std::hex << reinterpret_cast(m_vRPN[i].Fun.cb._pUserData) << _T("]"); - mu::console() << _T("\n"); - break; - - case cmLT: mu::console() << _T("LT\n"); break; - case cmGT: mu::console() << _T("GT\n"); break; - case cmLE: mu::console() << _T("LE\n"); break; - case cmGE: mu::console() << _T("GE\n"); break; - case cmEQ: mu::console() << _T("EQ\n"); break; - case cmNEQ: mu::console() << _T("NEQ\n"); break; - case cmADD: mu::console() << _T("ADD\n"); break; - case cmLAND: mu::console() << _T("&&\n"); break; - case cmLOR: mu::console() << _T("||\n"); break; - case cmSUB: mu::console() << _T("SUB\n"); break; - case cmMUL: mu::console() << _T("MUL\n"); break; - case cmDIV: mu::console() << _T("DIV\n"); break; - case cmPOW: mu::console() << _T("POW\n"); break; - - case cmIF: mu::console() << _T("IF\t"); - mu::console() << _T("[OFFSET:") << std::dec << m_vRPN[i].Oprt.offset << _T("]\n"); - break; - - case cmELSE: mu::console() << _T("ELSE\t"); - mu::console() << _T("[OFFSET:") << std::dec << m_vRPN[i].Oprt.offset << _T("]\n"); - break; - - case cmENDIF: mu::console() << _T("ENDIF\n"); break; - - case cmASSIGN: - mu::console() << _T("ASSIGN\t"); - mu::console() << _T("[ADDR: 0x") << m_vRPN[i].Oprt.ptr << _T("]\n"); - break; - - default: mu::console() << _T("(unknown code: ") << m_vRPN[i].Cmd << _T(")\n"); - break; - } // switch cmdCode - } // while bytecode - - mu::console() << _T("END") << std::endl; - } +namespace mu { + /** \brief Bytecode default constructor. */ + ParserByteCode::ParserByteCode() : + m_iStackPos(0), + m_iMaxStackSize(0), + m_vRPN(), + m_bEnableOptimizer(true) { + m_vRPN.reserve(50); + } + + + /** \brief Copy constructor. + + Implemented in Terms of Assign(const ParserByteCode &a_ByteCode) + */ + ParserByteCode::ParserByteCode(const ParserByteCode& a_ByteCode) { + Assign(a_ByteCode); + } + + + /** \brief Assignment operator. + + Implemented in Terms of Assign(const ParserByteCode &a_ByteCode) + */ + ParserByteCode& + ParserByteCode::operator=(const ParserByteCode& a_ByteCode) { + Assign(a_ByteCode); + return *this; + } + + + void + ParserByteCode::EnableOptimizer(bool bStat) { + m_bEnableOptimizer = bStat; + } + + + /** \brief Copy state of another object to this. + + \throw nowthrow + */ + void + ParserByteCode::Assign(const ParserByteCode& a_ByteCode) { + if (this == &a_ByteCode) + return; + + m_iStackPos = a_ByteCode.m_iStackPos; + m_vRPN = a_ByteCode.m_vRPN; + m_iMaxStackSize = a_ByteCode.m_iMaxStackSize; + m_bEnableOptimizer = a_ByteCode.m_bEnableOptimizer; + } + + + /** \brief Add a Variable pointer to bytecode. + \param a_pVar Pointer to be added. + \throw nothrow + */ + void + ParserByteCode::AddVar(value_type* a_pVar) { + ++m_iStackPos; + m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); + + // optimization does not apply + SToken tok; + tok.Cmd = cmVAR; + tok.Val.ptr = a_pVar; + tok.Val.data = 1; + tok.Val.data2 = 0; + m_vRPN.push_back(tok); + } + + + /** \brief Add a Variable pointer to bytecode. + + Value entries in byte code consist of: +
    +
  • value array position of the value
  • +
  • the operator code according to ParserToken::cmVAL
  • +
  • the value stored in #mc_iSizeVal number of bytecode entries.
  • +
+ + \param a_pVal Value to be added. + \throw nothrow + */ + void + ParserByteCode::AddVal(value_type a_fVal) { + ++m_iStackPos; + m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); + + // If optimization does not apply + SToken tok; + tok.Cmd = cmVAL; + tok.Val.ptr = nullptr; + tok.Val.data = 0; + tok.Val.data2 = a_fVal; + m_vRPN.push_back(tok); + } + + + void + ParserByteCode::ConstantFolding(ECmdCode a_Oprt) { + std::size_t sz = m_vRPN.size(); + value_type& x = m_vRPN[sz - 2].Val.data2; + value_type& y = m_vRPN[sz - 1].Val.data2; + + switch (a_Oprt) { + case cmLAND: + x = (int)x && (int)y; + m_vRPN.pop_back(); + break; + case cmLOR: + x = (int)x || (int)y; + m_vRPN.pop_back(); + break; + case cmLT: + x = x < y; + m_vRPN.pop_back(); + break; + case cmGT: + x = x > y; + m_vRPN.pop_back(); + break; + case cmLE: + x = x <= y; + m_vRPN.pop_back(); + break; + case cmGE: + x = x >= y; + m_vRPN.pop_back(); + break; + case cmNEQ: + x = x != y; + m_vRPN.pop_back(); + break; + case cmEQ: + x = x == y; + m_vRPN.pop_back(); + break; + case cmADD: + x = x + y; + m_vRPN.pop_back(); + break; + case cmSUB: + x = x - y; + m_vRPN.pop_back(); + break; + case cmMUL: + x = x * y; + m_vRPN.pop_back(); + break; + case cmDIV: + x = x / y; + m_vRPN.pop_back(); + break; + + case cmPOW: + x = MathImpl::Pow(x, y); + m_vRPN.pop_back(); + break; + + default: + break; + } // switch opcode + } + + + /** \brief Add an operator identifier to bytecode. + + Operator entries in byte code consist of: +
    +
  • value array position of the result
  • +
  • the operator code according to ParserToken::ECmdCode
  • +
+ + \sa ParserToken::ECmdCode + */ + void + ParserByteCode::AddOp(ECmdCode a_Oprt) { + bool bOptimized = false; + + if (m_bEnableOptimizer) { + std::size_t sz = m_vRPN.size(); + + // Check for foldable constants like: + // cmVAL cmVAL cmADD + // where cmADD can stand fopr any binary operator applied to + // two constant values. + if (sz >= 2 && m_vRPN[sz - 2].Cmd == cmVAL && m_vRPN[sz - 1].Cmd == cmVAL) { + ConstantFolding(a_Oprt); + bOptimized = true; + } else { + switch (a_Oprt) { + case cmPOW: + // Optimization for polynomials of low order + if (m_vRPN[sz - 2].Cmd == cmVAR && m_vRPN[sz - 1].Cmd == cmVAL) { + if (m_vRPN[sz - 1].Val.data2 == 0) { + m_vRPN[sz - 2].Cmd = cmVAL; + m_vRPN[sz - 2].Val.ptr = nullptr; + m_vRPN[sz - 2].Val.data = 0; + m_vRPN[sz - 2].Val.data2 = 1; + } else if (m_vRPN[sz - 1].Val.data2 == 1) + m_vRPN[sz - 2].Cmd = cmVAR; + else if (m_vRPN[sz - 1].Val.data2 == 2) + m_vRPN[sz - 2].Cmd = cmVARPOW2; + else if (m_vRPN[sz - 1].Val.data2 == 3) + m_vRPN[sz - 2].Cmd = cmVARPOW3; + else if (m_vRPN[sz - 1].Val.data2 == 4) + m_vRPN[sz - 2].Cmd = cmVARPOW4; + else + break; + + m_vRPN.pop_back(); + bOptimized = true; + } + break; + + case cmSUB: + case cmADD: + // Simple optimization based on pattern recognition for a shitload of different + // bytecode combinations of addition/subtraction + if ((m_vRPN[sz - 1].Cmd == cmVAR && m_vRPN[sz - 2].Cmd == cmVAL) || + (m_vRPN[sz - 1].Cmd == cmVAL && m_vRPN[sz - 2].Cmd == cmVAR) || + (m_vRPN[sz - 1].Cmd == cmVAL && m_vRPN[sz - 2].Cmd == cmVARMUL) || + (m_vRPN[sz - 1].Cmd == cmVARMUL && m_vRPN[sz - 2].Cmd == cmVAL) || + (m_vRPN[sz - 1].Cmd == cmVAR && m_vRPN[sz - 2].Cmd == cmVAR && + m_vRPN[sz - 2].Val.ptr == m_vRPN[sz - 1].Val.ptr) || + (m_vRPN[sz - 1].Cmd == cmVAR && m_vRPN[sz - 2].Cmd == cmVARMUL && + m_vRPN[sz - 2].Val.ptr == m_vRPN[sz - 1].Val.ptr) || + (m_vRPN[sz - 1].Cmd == cmVARMUL && m_vRPN[sz - 2].Cmd == cmVAR && + m_vRPN[sz - 2].Val.ptr == m_vRPN[sz - 1].Val.ptr) || + (m_vRPN[sz - 1].Cmd == cmVARMUL && m_vRPN[sz - 2].Cmd == cmVARMUL && + m_vRPN[sz - 2].Val.ptr == m_vRPN[sz - 1].Val.ptr)) { + MUP_ASSERT((m_vRPN[sz - 2].Val.ptr == nullptr && m_vRPN[sz - 1].Val.ptr != nullptr) || + (m_vRPN[sz - 2].Val.ptr != nullptr && m_vRPN[sz - 1].Val.ptr == nullptr) || + (m_vRPN[sz - 2].Val.ptr == m_vRPN[sz - 1].Val.ptr)); + + m_vRPN[sz - 2].Cmd = cmVARMUL; + m_vRPN[sz - 2].Val.ptr = (value_type*)((long long)(m_vRPN[sz - 2].Val.ptr) | + (long long)(m_vRPN[sz - 1].Val.ptr)); // variable + m_vRPN[sz - 2].Val.data2 += ((a_Oprt == cmSUB) ? -1 : 1) * m_vRPN[sz - 1].Val.data2; // offset + m_vRPN[sz - 2].Val.data += + ((a_Oprt == cmSUB) ? -1 : 1) * m_vRPN[sz - 1].Val.data; // multiplicand + m_vRPN.pop_back(); + bOptimized = true; + } + break; + + case cmMUL: + if ((m_vRPN[sz - 1].Cmd == cmVAR && m_vRPN[sz - 2].Cmd == cmVAL) || + (m_vRPN[sz - 1].Cmd == cmVAL && m_vRPN[sz - 2].Cmd == cmVAR)) { + m_vRPN[sz - 2].Cmd = cmVARMUL; + m_vRPN[sz - 2].Val.ptr = + (value_type*)((long long)(m_vRPN[sz - 2].Val.ptr) | (long long)(m_vRPN[sz - 1].Val.ptr)); + m_vRPN[sz - 2].Val.data = m_vRPN[sz - 2].Val.data2 + m_vRPN[sz - 1].Val.data2; + m_vRPN[sz - 2].Val.data2 = 0; + m_vRPN.pop_back(); + bOptimized = true; + } else if ((m_vRPN[sz - 1].Cmd == cmVAL && m_vRPN[sz - 2].Cmd == cmVARMUL) || + (m_vRPN[sz - 1].Cmd == cmVARMUL && m_vRPN[sz - 2].Cmd == cmVAL)) { + // Optimization: 2*(3*b+1) or (3*b+1)*2 -> 6*b+2 + m_vRPN[sz - 2].Cmd = cmVARMUL; + m_vRPN[sz - 2].Val.ptr = + (value_type*)((long long)(m_vRPN[sz - 2].Val.ptr) | (long long)(m_vRPN[sz - 1].Val.ptr)); + if (m_vRPN[sz - 1].Cmd == cmVAL) { + m_vRPN[sz - 2].Val.data *= m_vRPN[sz - 1].Val.data2; + m_vRPN[sz - 2].Val.data2 *= m_vRPN[sz - 1].Val.data2; + } else { + m_vRPN[sz - 2].Val.data = m_vRPN[sz - 1].Val.data * m_vRPN[sz - 2].Val.data2; + m_vRPN[sz - 2].Val.data2 = m_vRPN[sz - 1].Val.data2 * m_vRPN[sz - 2].Val.data2; + } + m_vRPN.pop_back(); + bOptimized = true; + } else if (m_vRPN[sz - 1].Cmd == cmVAR && m_vRPN[sz - 2].Cmd == cmVAR && + m_vRPN[sz - 1].Val.ptr == m_vRPN[sz - 2].Val.ptr) { + // Optimization: a*a -> a^2 + m_vRPN[sz - 2].Cmd = cmVARPOW2; + m_vRPN.pop_back(); + bOptimized = true; + } + break; + + case cmDIV: + if (m_vRPN[sz - 1].Cmd == cmVAL && m_vRPN[sz - 2].Cmd == cmVARMUL && + m_vRPN[sz - 1].Val.data2 != 0) { + // Optimization: 4*a/2 -> 2*a + m_vRPN[sz - 2].Val.data /= m_vRPN[sz - 1].Val.data2; + m_vRPN[sz - 2].Val.data2 /= m_vRPN[sz - 1].Val.data2; + m_vRPN.pop_back(); + bOptimized = true; + } + break; + + // no optimization for other opcodes + default: + break; + } // switch a_Oprt + } + } + + // If optimization can't be applied just write the value + if (!bOptimized) { + --m_iStackPos; + SToken tok; + tok.Cmd = a_Oprt; + m_vRPN.push_back(tok); + } + } + + + void + ParserByteCode::AddIfElse(ECmdCode a_Oprt) { + SToken tok; + tok.Cmd = a_Oprt; + m_vRPN.push_back(tok); + } + + + /** \brief Add an assignment operator + + Operator entries in byte code consist of: +
    +
  • cmASSIGN code
  • +
  • the pointer of the destination variable
  • +
+ + \sa ParserToken::ECmdCode + */ + void + ParserByteCode::AddAssignOp(value_type* a_pVar) { + --m_iStackPos; + + SToken tok; + tok.Cmd = cmASSIGN; + tok.Oprt.ptr = a_pVar; + m_vRPN.push_back(tok); + } + + + /** \brief Add function to bytecode. + + \param a_iArgc Number of arguments, negative numbers indicate multiarg functions. + \param a_pFun Pointer to function callback. + */ + void + ParserByteCode::AddFun(generic_callable_type a_pFun, + int a_iArgc, + bool isFunctionOptimizable) { + std::size_t sz = m_vRPN.size(); + bool optimize = false; + + // only optimize functions with fixed number of more than a single arguments + if (isFunctionOptimizable && m_bEnableOptimizer && a_iArgc > 0) { + // Unary Plus is a no-op + if (a_pFun == generic_callable_type{(erased_fun_type)&MathImpl::UnaryPlus, nullptr}) + return; + + optimize = true; + + for (int i = 0; i < std::abs(a_iArgc); ++i) { + if (m_vRPN[sz - i - 1].Cmd != cmVAL) { + optimize = false; + break; + } + } + } + + if (optimize) { + value_type val = 0; + switch (a_iArgc) { + case 1: + val = a_pFun.call_fun<1>(m_vRPN[sz - 1].Val.data2); + break; + case 2: + val = a_pFun.call_fun<2>(m_vRPN[sz - 2].Val.data2, m_vRPN[sz - 1].Val.data2); + break; + case 3: + val = a_pFun.call_fun<3>(m_vRPN[sz - 3].Val.data2, m_vRPN[sz - 2].Val.data2, m_vRPN[sz - 1].Val.data2); + break; + case 4: + val = a_pFun.call_fun<4>(m_vRPN[sz - 4].Val.data2, + m_vRPN[sz - 3].Val.data2, + m_vRPN[sz - 2].Val.data2, + m_vRPN[sz - 1].Val.data2); + break; + case 5: + val = a_pFun.call_fun<5>(m_vRPN[sz - 5].Val.data2, + m_vRPN[sz - 4].Val.data2, + m_vRPN[sz - 3].Val.data2, + m_vRPN[sz - 2].Val.data2, + m_vRPN[sz - 1].Val.data2); + break; + case 6: + val = a_pFun.call_fun<6>(m_vRPN[sz - 6].Val.data2, + m_vRPN[sz - 5].Val.data2, + m_vRPN[sz - 4].Val.data2, + m_vRPN[sz - 3].Val.data2, + m_vRPN[sz - 2].Val.data2, + m_vRPN[sz - 1].Val.data2); + break; + case 7: + val = a_pFun.call_fun<7>(m_vRPN[sz - 7].Val.data2, + m_vRPN[sz - 6].Val.data2, + m_vRPN[sz - 5].Val.data2, + m_vRPN[sz - 4].Val.data2, + m_vRPN[sz - 3].Val.data2, + m_vRPN[sz - 2].Val.data2, + m_vRPN[sz - 1].Val.data2); + break; + case 8: + val = a_pFun.call_fun<8>(m_vRPN[sz - 8].Val.data2, + m_vRPN[sz - 7].Val.data2, + m_vRPN[sz - 6].Val.data2, + m_vRPN[sz - 5].Val.data2, + m_vRPN[sz - 4].Val.data2, + m_vRPN[sz - 3].Val.data2, + m_vRPN[sz - 2].Val.data2, + m_vRPN[sz - 1].Val.data2); + break; + case 9: + val = a_pFun.call_fun<9>(m_vRPN[sz - 9].Val.data2, + m_vRPN[sz - 8].Val.data2, + m_vRPN[sz - 7].Val.data2, + m_vRPN[sz - 6].Val.data2, + m_vRPN[sz - 5].Val.data2, + m_vRPN[sz - 4].Val.data2, + m_vRPN[sz - 3].Val.data2, + m_vRPN[sz - 2].Val.data2, + m_vRPN[sz - 1].Val.data2); + break; + case 10: + val = a_pFun.call_fun<10>(m_vRPN[sz - 10].Val.data2, + m_vRPN[sz - 9].Val.data2, + m_vRPN[sz - 8].Val.data2, + m_vRPN[sz - 7].Val.data2, + m_vRPN[sz - 6].Val.data2, + m_vRPN[sz - 5].Val.data2, + m_vRPN[sz - 4].Val.data2, + m_vRPN[sz - 3].Val.data2, + m_vRPN[sz - 2].Val.data2, + m_vRPN[sz - 1].Val.data2); + break; + default: + // For now functions with unlimited number of arguments are not optimized + throw ParserError(ecINTERNAL_ERROR); + } + + // remove the folded values + m_vRPN.erase(m_vRPN.end() - a_iArgc, m_vRPN.end()); + + SToken tok; + tok.Cmd = cmVAL; + tok.Val.data = 0; + tok.Val.data2 = val; + tok.Val.ptr = nullptr; + m_vRPN.push_back(tok); + } else { + SToken tok; + tok.Cmd = cmFUNC; + tok.Fun.argc = a_iArgc; + tok.Fun.cb = a_pFun; + m_vRPN.push_back(tok); + } + + m_iStackPos = m_iStackPos - std::abs(a_iArgc) + 1; + m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); + } + + + /** \brief Add a bulk function to bytecode. + + \param a_iArgc Number of arguments, negative numbers indicate multiarg functions. + \param a_pFun Pointer to function callback. + */ + void + ParserByteCode::AddBulkFun(generic_callable_type a_pFun, + int a_iArgc) { + m_iStackPos = m_iStackPos - a_iArgc + 1; + m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); + + SToken tok; + tok.Cmd = cmFUNC_BULK; + tok.Fun.argc = a_iArgc; + tok.Fun.cb = a_pFun; + m_vRPN.push_back(tok); + } + + + /** \brief Add Strung function entry to the parser bytecode. + \throw nothrow + + A string function entry consists of the stack position of the return value, + followed by a cmSTRFUNC code, the function pointer and an index into the + string buffer maintained by the parser. + */ + void + ParserByteCode::AddStrFun(generic_callable_type a_pFun, + int a_iArgc, + int a_iIdx) { + m_iStackPos = m_iStackPos - a_iArgc + 1; + + SToken tok; + tok.Cmd = cmFUNC_STR; + tok.Fun.argc = a_iArgc; + tok.Fun.idx = a_iIdx; + tok.Fun.cb = a_pFun; + m_vRPN.push_back(tok); + + m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); + } + + + /** \brief Add end marker to bytecode. + + \throw nothrow + */ + void + ParserByteCode::Finalize() { + SToken tok; + tok.Cmd = cmEND; + m_vRPN.push_back(tok); + rpn_type(m_vRPN).swap(m_vRPN); // shrink bytecode vector to fit + + // Determine the if-then-else jump offsets + std::stack stIf, stElse; + int idx; + for (int i = 0; i < (int)m_vRPN.size(); ++i) { + switch (m_vRPN[i].Cmd) { + case cmIF: + stIf.push(i); + break; + + case cmELSE: + stElse.push(i); + idx = stIf.top(); + stIf.pop(); + m_vRPN[idx].Oprt.offset = i - idx; + break; + + case cmENDIF: + idx = stElse.top(); + stElse.pop(); + m_vRPN[idx].Oprt.offset = i - idx; + break; + + default: + break; + } + } + } + + + std::size_t + ParserByteCode::GetMaxStackSize() const { + return m_iMaxStackSize + 1; + } + + + /** \brief Delete the bytecode. + + \throw nothrow + + The name of this function is a violation of my own coding guidelines + but this way it's more in line with the STL functions thus more + intuitive. + */ + void + ParserByteCode::clear() { + m_vRPN.clear(); + m_iStackPos = 0; + m_iMaxStackSize = 0; + } + + + /** \brief Dump bytecode (for debugging only!). */ + void + ParserByteCode::AsciiDump() { + if (!m_vRPN.size()) { + mu::console() << _T("No bytecode available\n"); + return; + } + + mu::console() << _T("Number of RPN tokens:") << (int)m_vRPN.size() << _T("\n"); + for (std::size_t i = 0; i < m_vRPN.size() && m_vRPN[i].Cmd != cmEND; ++i) { + mu::console() << std::dec << i << _T(" : \t"); + switch (m_vRPN[i].Cmd) { + case cmVAL: + mu::console() << _T("VAL \t"); + mu::console() << _T("[") << m_vRPN[i].Val.data2 << _T("]\n"); + break; + + case cmVAR: + mu::console() << _T("VAR \t"); + mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]\n"); + break; + + case cmVARPOW2: + mu::console() << _T("VARPOW2 \t"); + mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]\n"); + break; + + case cmVARPOW3: + mu::console() << _T("VARPOW3 \t"); + mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]\n"); + break; + + case cmVARPOW4: + mu::console() << _T("VARPOW4 \t"); + mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]\n"); + break; + + case cmVARMUL: + mu::console() << _T("VARMUL \t"); + mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]"); + mu::console() << _T(" * [") << m_vRPN[i].Val.data << _T("]"); + mu::console() << _T(" + [") << m_vRPN[i].Val.data2 << _T("]\n"); + break; + + case cmFUNC: + mu::console() << _T("CALL\t"); + mu::console() << _T("[ARG:") << std::dec << m_vRPN[i].Fun.argc << _T("]"); + mu::console() << _T("[ADDR: 0x") << std::hex << reinterpret_cast(m_vRPN[i].Fun.cb._pRawFun) + << _T("]"); + mu::console() << _T("[USERDATA: 0x") << std::hex << reinterpret_cast(m_vRPN[i].Fun.cb._pUserData) + << _T("]"); + mu::console() << _T("\n"); + break; + + case cmFUNC_STR: + mu::console() << _T("CALL STRFUNC\t"); + mu::console() << _T("[ARG:") << std::dec << m_vRPN[i].Fun.argc << _T("]"); + mu::console() << _T("[IDX:") << std::dec << m_vRPN[i].Fun.idx << _T("]"); + mu::console() << _T("[ADDR: 0x") << std::hex << reinterpret_cast(m_vRPN[i].Fun.cb._pRawFun) + << _T("]"); + mu::console() << _T("[USERDATA: 0x") << std::hex << reinterpret_cast(m_vRPN[i].Fun.cb._pUserData) + << _T("]"); + mu::console() << _T("\n"); + break; + + case cmLT: + mu::console() << _T("LT\n"); + break; + case cmGT: + mu::console() << _T("GT\n"); + break; + case cmLE: + mu::console() << _T("LE\n"); + break; + case cmGE: + mu::console() << _T("GE\n"); + break; + case cmEQ: + mu::console() << _T("EQ\n"); + break; + case cmNEQ: + mu::console() << _T("NEQ\n"); + break; + case cmADD: + mu::console() << _T("ADD\n"); + break; + case cmLAND: + mu::console() << _T("&&\n"); + break; + case cmLOR: + mu::console() << _T("||\n"); + break; + case cmSUB: + mu::console() << _T("SUB\n"); + break; + case cmMUL: + mu::console() << _T("MUL\n"); + break; + case cmDIV: + mu::console() << _T("DIV\n"); + break; + case cmPOW: + mu::console() << _T("POW\n"); + break; + + case cmIF: + mu::console() << _T("IF\t"); + mu::console() << _T("[OFFSET:") << std::dec << m_vRPN[i].Oprt.offset << _T("]\n"); + break; + + case cmELSE: + mu::console() << _T("ELSE\t"); + mu::console() << _T("[OFFSET:") << std::dec << m_vRPN[i].Oprt.offset << _T("]\n"); + break; + + case cmENDIF: + mu::console() << _T("ENDIF\n"); + break; + + case cmASSIGN: + mu::console() << _T("ASSIGN\t"); + mu::console() << _T("[ADDR: 0x") << m_vRPN[i].Oprt.ptr << _T("]\n"); + break; + + default: + mu::console() << _T("(unknown code: ") << m_vRPN[i].Cmd << _T(")\n"); + break; + } // switch cmdCode + } // while bytecode + + mu::console() << _T("END") << std::endl; + } } // namespace mu #if defined(_MSC_VER) - #pragma warning(pop) +#pragma warning(pop) #endif diff --git a/libsrc/spatialdata/muparser/muParserBytecode.h b/libsrc/spatialdata/muparser/muParserBytecode.h index cf16e206..3528768c 100644 --- a/libsrc/spatialdata/muparser/muParserBytecode.h +++ b/libsrc/spatialdata/muparser/muParserBytecode.h @@ -1,36 +1,36 @@ /* - - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2004 - 2021 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #ifndef MU_PARSER_BYTECODE_H #define MU_PARSER_BYTECODE_H -#include #include +#include #include #include "muParserDef.h" @@ -38,115 +38,112 @@ #include "muParserToken.h" /** \file - \brief Definition of the parser bytecode class. + \brief Definition of the parser bytecode class. */ -namespace mu -{ - struct SToken - { - ECmdCode Cmd; - - union - { - struct // SValData - { - value_type* ptr; - value_type data; - value_type data2; - } Val; - - struct // SFunData - { - // Note: the type is erased in generic_callable_type and the signature of the - // function to call is tracked elsewhere in regard with the number of - // parameters (args) and the general kind of function (Cmd: cmFUNC, - // cmFUNC_STR, or cmFUNC_BULK) - generic_callable_type cb; - int argc; - int idx; - } Fun; - - struct // SOprtData - { - value_type* ptr; - int offset; - } Oprt; - }; - }; - - - /** \brief Bytecode implementation of the Math Parser. - - The bytecode contains the formula converted to revers polish notation stored in a continious - memory area. Associated with this data are operator codes, variable pointers, constant - values and function pointers. Those are necessary in order to calculate the result. - All those data items will be casted to the underlying datatype of the bytecode. - */ - class ParserByteCode final - { - private: - - /** \brief Token type for internal use only. */ - typedef ParserToken token_type; - - /** \brief Token vector for storing the RPN. */ - typedef std::vector rpn_type; - - /** \brief Position in the Calculation array. */ - unsigned m_iStackPos; - - /** \brief Maximum size needed for the stack. */ - std::size_t m_iMaxStackSize; - - /** \brief The actual rpn storage. */ - rpn_type m_vRPN; - - bool m_bEnableOptimizer; - - void ConstantFolding(ECmdCode a_Oprt); - - public: - - ParserByteCode(); - ParserByteCode(const ParserByteCode& a_ByteCode); - ParserByteCode& operator=(const ParserByteCode& a_ByteCode); - void Assign(const ParserByteCode& a_ByteCode); - - void AddVar(value_type* a_pVar); - void AddVal(value_type a_fVal); - void AddOp(ECmdCode a_Oprt); - void AddIfElse(ECmdCode a_Oprt); - void AddAssignOp(value_type* a_pVar); - void AddFun(generic_callable_type a_pFun, int a_iArgc, bool isOptimizable); - void AddBulkFun(generic_callable_type a_pFun, int a_iArgc); - void AddStrFun(generic_callable_type a_pFun, int a_iArgc, int a_iIdx); - - void EnableOptimizer(bool bStat); - - void Finalize(); - void clear(); - std::size_t GetMaxStackSize() const; - - std::size_t GetSize() const - { - return m_vRPN.size(); - } - - inline const SToken* GetBase() const - { - if (m_vRPN.size() == 0) - throw ParserError(ecINTERNAL_ERROR); - else - return &m_vRPN[0]; - } - - void AsciiDump(); - }; +namespace mu { + struct SToken { + ECmdCode Cmd; + + union { + struct // SValData + { + value_type* ptr; + value_type data; + value_type data2; + } Val; + + struct // SFunData + { + // Note: the type is erased in generic_callable_type and the signature of the + // function to call is tracked elsewhere in regard with the number of + // parameters (args) and the general kind of function (Cmd: cmFUNC, + // cmFUNC_STR, or cmFUNC_BULK) + generic_callable_type cb; + int argc; + int idx; + } Fun; + + struct // SOprtData + { + value_type* ptr; + int offset; + } Oprt; + }; + }; + + + /** \brief Bytecode implementation of the Math Parser. + + The bytecode contains the formula converted to revers polish notation stored in a continious + memory area. Associated with this data are operator codes, variable pointers, constant + values and function pointers. Those are necessary in order to calculate the result. + All those data items will be casted to the underlying datatype of the bytecode. + */ + class ParserByteCode final { + private: + /** \brief Token type for internal use only. */ + typedef ParserToken token_type; + + /** \brief Token vector for storing the RPN. */ + typedef std::vector rpn_type; + + /** \brief Position in the Calculation array. */ + unsigned m_iStackPos; + + /** \brief Maximum size needed for the stack. */ + std::size_t m_iMaxStackSize; + + /** \brief The actual rpn storage. */ + rpn_type m_vRPN; + + bool m_bEnableOptimizer; + + void ConstantFolding(ECmdCode a_Oprt); + + public: + ParserByteCode(); + ParserByteCode(const ParserByteCode& a_ByteCode); + ParserByteCode& operator=(const ParserByteCode& a_ByteCode); + void Assign(const ParserByteCode& a_ByteCode); + + void AddVar(value_type* a_pVar); + void AddVal(value_type a_fVal); + void AddOp(ECmdCode a_Oprt); + void AddIfElse(ECmdCode a_Oprt); + void AddAssignOp(value_type* a_pVar); + void AddFun(generic_callable_type a_pFun, + int a_iArgc, + bool isOptimizable); + void AddBulkFun(generic_callable_type a_pFun, + int a_iArgc); + void AddStrFun(generic_callable_type a_pFun, + int a_iArgc, + int a_iIdx); + + void EnableOptimizer(bool bStat); + + void Finalize(); + void clear(); + std::size_t GetMaxStackSize() const; + + std::size_t + GetSize() const { + return m_vRPN.size(); + } + + inline const SToken* + GetBase() const { + if (m_vRPN.size() == 0) + throw ParserError(ecINTERNAL_ERROR); + else + return &m_vRPN[0]; + } + + void AsciiDump(); + }; } // namespace mu #endif - - diff --git a/libsrc/spatialdata/muparser/muParserCallback.cpp b/libsrc/spatialdata/muparser/muParserCallback.cpp index 8f2265b2..f9c7a70d 100644 --- a/libsrc/spatialdata/muparser/muParserCallback.cpp +++ b/libsrc/spatialdata/muparser/muParserCallback.cpp @@ -1,894 +1,1009 @@ /* - - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2022 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include "muParserCallback.h" #if defined(_MSC_VER) - #pragma warning(push) - #pragma warning(disable : 26812) +#pragma warning(push) +#pragma warning(disable : 26812) #endif /** \file - \brief Implementation of the parser callback class. + \brief Implementation of the parser callback class. */ -namespace mu -{ - static constexpr int CALLBACK_INTERNAL_VAR_ARGS = 1 << 14; - static constexpr int CALLBACK_INTERNAL_FIXED_ARGS_MASK = 0xf; - static constexpr int CALLBACK_INTERNAL_WITH_USER_DATA = 1 << 13; - - struct CbWithUserData - { - void* pFun; - void* pUserData; - }; - - - ParserCallback::ParserCallback(fun_type0 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(0) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec, ECmdCode a_iCode) - :m_pFun((void*)a_pFun) - , m_iArgc(1) - , m_iPri(a_iPrec) - , m_eOprtAsct(oaNONE) - , m_iCode(a_iCode) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_type1 a_pFun, bool a_bAllowOpti) - : ParserCallback(a_pFun, a_bAllowOpti, -1, cmFUNC) - {} - - - /** \brief Constructor for constructing function callbacks taking two arguments. - \throw nothrow - */ - ParserCallback::ParserCallback(fun_type2 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(2) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - /** \brief Constructor for constructing binary operator callbacks. - \param a_pFun Pointer to a static function taking two arguments - \param a_bAllowOpti A flag indicating this function can be optimized - \param a_iPrec The operator precedence - \param a_eOprtAsct The operators associativity - \throw nothrow - */ - ParserCallback::ParserCallback(fun_type2 a_pFun, - bool a_bAllowOpti, - int a_iPrec, - EOprtAssociativity a_eOprtAsct) - :m_pFun((void*)a_pFun) - , m_iArgc(2) - , m_iPri(a_iPrec) - , m_eOprtAsct(a_eOprtAsct) - , m_iCode(cmOPRT_BIN) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_type3 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(3) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_type4 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(4) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_type5 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(5) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_type6 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(6) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_type7 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(7) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_type8 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(8) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_type9 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(9) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_type10 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(10) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_userdata_type0 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(0 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_userdata_type1 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(1 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_userdata_type2 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(2 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_userdata_type3 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(3 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_userdata_type4 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(4 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_userdata_type5 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(5 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_userdata_type6 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(6 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_userdata_type7 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(7 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_userdata_type8 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(8 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_userdata_type9 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(9 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(fun_userdata_type10 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(10 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_type0 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(0) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_type1 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(1) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - /** \brief Constructor for constructing function callbacks taking two arguments. - \throw nothrow - */ - ParserCallback::ParserCallback(bulkfun_type2 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(2) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_type3 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(3) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_type4 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(4) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_type5 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(5) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_type6 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(6) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_type7 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(7) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_type8 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(8) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_type9 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(9) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_type10 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(10) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_userdata_type0 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(0 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_userdata_type1 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(1 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_userdata_type2 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(2 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_userdata_type3 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(3 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_userdata_type4 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(4 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_userdata_type5 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(5 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_userdata_type6 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(6 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_userdata_type7 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(7 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_userdata_type8 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(8 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_userdata_type9 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(9 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(bulkfun_userdata_type10 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(10 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_BULK) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(multfun_type a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(CALLBACK_INTERNAL_VAR_ARGS) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(multfun_userdata_type a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(CALLBACK_INTERNAL_VAR_ARGS | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC) - , m_iType(tpDBL) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(strfun_type1 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(0) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_STR) - , m_iType(tpSTR) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(strfun_type2 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(1) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_STR) - , m_iType(tpSTR) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(strfun_type3 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(2) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_STR) - , m_iType(tpSTR) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(strfun_type4 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(3) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_STR) - , m_iType(tpSTR) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(strfun_type5 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(4) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_STR) - , m_iType(tpSTR) - , m_bAllowOpti(a_bAllowOpti) - {} - - ParserCallback::ParserCallback(strfun_type6 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - , m_iArgc(5) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_STR) - , m_iType(tpSTR) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(strfun_userdata_type1 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(0 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_STR) - , m_iType(tpSTR) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(strfun_userdata_type2 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(1 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_STR) - , m_iType(tpSTR) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(strfun_userdata_type3 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(2 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_STR) - , m_iType(tpSTR) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(strfun_userdata_type4 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(3 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_STR) - , m_iType(tpSTR) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(strfun_userdata_type5 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), a_pUserData}) - , m_iArgc(4 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_STR) - , m_iType(tpSTR) - , m_bAllowOpti(a_bAllowOpti) - {} - - - ParserCallback::ParserCallback(strfun_userdata_type6 a_pFun, void* a_pUserData, bool a_bAllowOpti) - :m_pFun(new CbWithUserData{ reinterpret_cast(a_pFun), a_pUserData }) - , m_iArgc(5 | CALLBACK_INTERNAL_WITH_USER_DATA) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmFUNC_STR) - , m_iType(tpSTR) - , m_bAllowOpti(a_bAllowOpti) - {} - - /** \brief Default constructor. - \throw nothrow - */ - ParserCallback::ParserCallback() - :m_pFun(0) - , m_iArgc(0) - , m_iPri(-1) - , m_eOprtAsct(oaNONE) - , m_iCode(cmUNKNOWN) - , m_iType(tpVOID) - , m_bAllowOpti(0) - {} - - - /** \brief Copy constructor. - \throw nothrow - */ - ParserCallback::ParserCallback(const ParserCallback& ref) - :ParserCallback() - { - Assign(ref); - } - - ParserCallback & ParserCallback::operator=(const ParserCallback & ref) - { - Assign(ref); - return *this; - } - - - ParserCallback::~ParserCallback() - { - if (m_iArgc & CALLBACK_INTERNAL_WITH_USER_DATA) - delete reinterpret_cast(m_pFun); - } - - - /** \brief Copy callback from argument. - - \throw nothrow - */ - void ParserCallback::Assign(const ParserCallback& ref) - { - if (this == &ref) - return; - - if (m_iArgc & CALLBACK_INTERNAL_WITH_USER_DATA) { - delete reinterpret_cast(m_pFun); - m_pFun = nullptr; - } - - if (ref.m_iArgc & CALLBACK_INTERNAL_WITH_USER_DATA) - m_pFun = new CbWithUserData(*reinterpret_cast(ref.m_pFun)); - else - m_pFun = ref.m_pFun; - m_iArgc = ref.m_iArgc; - m_bAllowOpti = ref.m_bAllowOpti; - m_iCode = ref.m_iCode; - m_iType = ref.m_iType; - m_iPri = ref.m_iPri; - m_eOprtAsct = ref.m_eOprtAsct; - } - - - /** \brief Clone this instance and return a pointer to the new instance. */ - ParserCallback* ParserCallback::Clone() const - { - return new ParserCallback(*this); - } - - - /** \brief Return tru if the function is conservative. - - Conservative functions return always the same result for the same argument. - \throw nothrow - */ - bool ParserCallback::IsOptimizable() const - { - return m_bAllowOpti; - } - - - /** \brief Get the callback address for the parser function. - - The type of the address is void. It needs to be recasted according to the - argument number to the right type. - - \throw nothrow - */ - void* ParserCallback::GetAddr() const - { - if (m_iArgc & CALLBACK_INTERNAL_WITH_USER_DATA) - return reinterpret_cast(m_pFun)->pFun; - else - return m_pFun; - } - - - /** \brief Get the user data if present, else nullptr - - \throw nothrow - */ - void* ParserCallback::GetUserData() const - { - if (m_iArgc & CALLBACK_INTERNAL_WITH_USER_DATA) - return reinterpret_cast(m_pFun)->pUserData; - else - return nullptr; - } - - - /** \brief Check that the callback looks valid - \throw nothrow - - Check that the function pointer is not null, - and if there are user data that they are not null. - */ - bool ParserCallback::IsValid() const - { - return GetAddr() != nullptr - && !((m_iArgc & CALLBACK_INTERNAL_WITH_USER_DATA) - && GetUserData() == nullptr); - } - - - /** \brief Return the callback code. */ - ECmdCode ParserCallback::GetCode() const - { - return m_iCode; - } - - - ETypeCode ParserCallback::GetType() const - { - return m_iType; - } - - - /** \brief Return the operator precedence. - \throw nothrown - - Only valid if the callback token is an operator token (binary or infix). - */ - int ParserCallback::GetPri() const - { - return m_iPri; - } - - - /** \brief Return the operators associativity. - \throw nothrown - - Only valid if the callback token is a binary operator token. - */ - EOprtAssociativity ParserCallback::GetAssociativity() const - { - return m_eOprtAsct; - } +namespace mu { + static constexpr int CALLBACK_INTERNAL_VAR_ARGS = 1 << 14; + static constexpr int CALLBACK_INTERNAL_FIXED_ARGS_MASK = 0xf; + static constexpr int CALLBACK_INTERNAL_WITH_USER_DATA = 1 << 13; + + struct CbWithUserData { + void* pFun; + void* pUserData; + }; + + + ParserCallback::ParserCallback(fun_type0 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(0), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_type1 a_pFun, + bool a_bAllowOpti, + int a_iPrec, + ECmdCode a_iCode) : + m_pFun((void*)a_pFun), + m_iArgc(1), + m_iPri(a_iPrec), + m_eOprtAsct(oaNONE), + m_iCode(a_iCode), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_type1 a_pFun, + bool a_bAllowOpti) : + ParserCallback(a_pFun, + a_bAllowOpti, + -1, + cmFUNC) { + } + + + /** \brief Constructor for constructing function callbacks taking two arguments. + \throw nothrow + */ + ParserCallback::ParserCallback(fun_type2 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(2), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + /** \brief Constructor for constructing binary operator callbacks. + \param a_pFun Pointer to a static function taking two arguments + \param a_bAllowOpti A flag indicating this function can be optimized + \param a_iPrec The operator precedence + \param a_eOprtAsct The operators associativity + \throw nothrow + */ + ParserCallback::ParserCallback(fun_type2 a_pFun, + bool a_bAllowOpti, + int a_iPrec, + EOprtAssociativity a_eOprtAsct) : + m_pFun((void*)a_pFun), + m_iArgc(2), + m_iPri(a_iPrec), + m_eOprtAsct(a_eOprtAsct), + m_iCode(cmOPRT_BIN), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_type3 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(3), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_type4 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(4), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_type5 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(5), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_type6 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(6), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_type7 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(7), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_type8 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(8), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_type9 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(9), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_type10 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(10), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_userdata_type0 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(0 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_userdata_type1 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(1 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_userdata_type2 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(2 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_userdata_type3 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(3 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_userdata_type4 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(4 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_userdata_type5 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(5 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_userdata_type6 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(6 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_userdata_type7 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(7 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_userdata_type8 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(8 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_userdata_type9 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(9 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(fun_userdata_type10 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(10 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_type0 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(0), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_type1 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(1), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + /** \brief Constructor for constructing function callbacks taking two arguments. + \throw nothrow + */ + ParserCallback::ParserCallback(bulkfun_type2 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(2), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_type3 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(3), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_type4 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(4), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_type5 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(5), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_type6 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(6), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_type7 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(7), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_type8 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(8), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_type9 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(9), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_type10 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(10), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_userdata_type0 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(0 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_userdata_type1 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(1 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_userdata_type2 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(2 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_userdata_type3 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(3 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_userdata_type4 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(4 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_userdata_type5 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(5 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_userdata_type6 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(6 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_userdata_type7 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(7 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_userdata_type8 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(8 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_userdata_type9 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(9 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(bulkfun_userdata_type10 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(10 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_BULK), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(multfun_type a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(CALLBACK_INTERNAL_VAR_ARGS), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(multfun_userdata_type a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(CALLBACK_INTERNAL_VAR_ARGS | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC), + m_iType(tpDBL), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(strfun_type1 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(0), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_STR), + m_iType(tpSTR), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(strfun_type2 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(1), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_STR), + m_iType(tpSTR), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(strfun_type3 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(2), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_STR), + m_iType(tpSTR), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(strfun_type4 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(3), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_STR), + m_iType(tpSTR), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(strfun_type5 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(4), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_STR), + m_iType(tpSTR), + m_bAllowOpti(a_bAllowOpti) { + } + + ParserCallback::ParserCallback(strfun_type6 a_pFun, + bool a_bAllowOpti) : + m_pFun((void*)a_pFun), + m_iArgc(5), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_STR), + m_iType(tpSTR), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(strfun_userdata_type1 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(0 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_STR), + m_iType(tpSTR), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(strfun_userdata_type2 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(1 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_STR), + m_iType(tpSTR), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(strfun_userdata_type3 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(2 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_STR), + m_iType(tpSTR), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(strfun_userdata_type4 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(3 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_STR), + m_iType(tpSTR), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(strfun_userdata_type5 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(4 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_STR), + m_iType(tpSTR), + m_bAllowOpti(a_bAllowOpti) { + } + + + ParserCallback::ParserCallback(strfun_userdata_type6 a_pFun, + void* a_pUserData, + bool a_bAllowOpti) : + m_pFun(new CbWithUserData{reinterpret_cast(a_pFun), + a_pUserData}), + m_iArgc(5 | CALLBACK_INTERNAL_WITH_USER_DATA), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmFUNC_STR), + m_iType(tpSTR), + m_bAllowOpti(a_bAllowOpti) { + } + + /** \brief Default constructor. + \throw nothrow + */ + ParserCallback::ParserCallback() : + m_pFun(0), + m_iArgc(0), + m_iPri(-1), + m_eOprtAsct(oaNONE), + m_iCode(cmUNKNOWN), + m_iType(tpVOID), + m_bAllowOpti(0) { + } + + + /** \brief Copy constructor. + \throw nothrow + */ + ParserCallback::ParserCallback(const ParserCallback& ref) : ParserCallback() { + Assign(ref); + } + + ParserCallback& + ParserCallback::operator=(const ParserCallback& ref) { + Assign(ref); + return *this; + } + + + ParserCallback::~ParserCallback() { + if (m_iArgc & CALLBACK_INTERNAL_WITH_USER_DATA) + delete reinterpret_cast(m_pFun); + } + + + /** \brief Copy callback from argument. + + \throw nothrow + */ + void + ParserCallback::Assign(const ParserCallback& ref) { + if (this == &ref) + return; + + if (m_iArgc & CALLBACK_INTERNAL_WITH_USER_DATA) { + delete reinterpret_cast(m_pFun); + m_pFun = nullptr; + } + + if (ref.m_iArgc & CALLBACK_INTERNAL_WITH_USER_DATA) + m_pFun = new CbWithUserData(*reinterpret_cast(ref.m_pFun)); + else + m_pFun = ref.m_pFun; + m_iArgc = ref.m_iArgc; + m_bAllowOpti = ref.m_bAllowOpti; + m_iCode = ref.m_iCode; + m_iType = ref.m_iType; + m_iPri = ref.m_iPri; + m_eOprtAsct = ref.m_eOprtAsct; + } + + + /** \brief Clone this instance and return a pointer to the new instance. */ + ParserCallback* + ParserCallback::Clone() const { + return new ParserCallback(*this); + } + + + /** \brief Return tru if the function is conservative. + + Conservative functions return always the same result for the same argument. + \throw nothrow + */ + bool + ParserCallback::IsOptimizable() const { + return m_bAllowOpti; + } + + + /** \brief Get the callback address for the parser function. + + The type of the address is void. It needs to be recasted according to the + argument number to the right type. + + \throw nothrow + */ + void* + ParserCallback::GetAddr() const { + if (m_iArgc & CALLBACK_INTERNAL_WITH_USER_DATA) + return reinterpret_cast(m_pFun)->pFun; + else + return m_pFun; + } + + + /** \brief Get the user data if present, else nullptr + + \throw nothrow + */ + void* + ParserCallback::GetUserData() const { + if (m_iArgc & CALLBACK_INTERNAL_WITH_USER_DATA) + return reinterpret_cast(m_pFun)->pUserData; + else + return nullptr; + } + + + /** \brief Check that the callback looks valid + \throw nothrow + + Check that the function pointer is not null, + and if there are user data that they are not null. + */ + bool + ParserCallback::IsValid() const { + return GetAddr() != nullptr && !((m_iArgc & CALLBACK_INTERNAL_WITH_USER_DATA) && GetUserData() == nullptr); + } + + + /** \brief Return the callback code. */ + ECmdCode + ParserCallback::GetCode() const { + return m_iCode; + } + + + ETypeCode + ParserCallback::GetType() const { + return m_iType; + } + + + /** \brief Return the operator precedence. + \throw nothrown + + Only valid if the callback token is an operator token (binary or infix). + */ + int + ParserCallback::GetPri() const { + return m_iPri; + } + + + /** \brief Return the operators associativity. + \throw nothrown + + Only valid if the callback token is a binary operator token. + */ + EOprtAssociativity + ParserCallback::GetAssociativity() const { + return m_eOprtAsct; + } - /** \brief Returns the number of numeric function Arguments. + /** \brief Returns the number of numeric function Arguments. - This number is negative for functions with variable number of arguments. - */ - int ParserCallback::GetArgc() const - { - return (m_iArgc & CALLBACK_INTERNAL_VAR_ARGS) ? -1 : (m_iArgc & CALLBACK_INTERNAL_FIXED_ARGS_MASK); - } + This number is negative for functions with variable number of arguments. + */ + int + ParserCallback::GetArgc() const { + return (m_iArgc & CALLBACK_INTERNAL_VAR_ARGS) ? -1 : (m_iArgc & CALLBACK_INTERNAL_FIXED_ARGS_MASK); + } } // namespace mu #if defined(_MSC_VER) - #pragma warning(pop) +#pragma warning(pop) #endif diff --git a/libsrc/spatialdata/muparser/muParserCallback.h b/libsrc/spatialdata/muparser/muParserCallback.h index 1e53f14c..2676a333 100644 --- a/libsrc/spatialdata/muparser/muParserCallback.h +++ b/libsrc/spatialdata/muparser/muParserCallback.h @@ -1,30 +1,30 @@ /* - - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2022 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #ifndef MU_PARSER_CALLBACK_H @@ -33,129 +33,219 @@ #include "muParserDef.h" /** \file - \brief Definition of the parser callback class. + \brief Definition of the parser callback class. */ -namespace mu -{ - - /** \brief Encapsulation of prototypes for a numerical parser function. - - Encapsulates the prototyp for numerical parser functions. The class - stores the number of arguments for parser functions as well - as additional flags indication the function is non optimizeable. - The pointer to the callback function pointer is stored as void* - and needs to be casted according to the argument count. - Negative argument counts indicate a parser function with a variable number - of arguments. - */ - class API_EXPORT_CXX ParserCallback final - { - public: - ParserCallback(fun_type0 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec, ECmdCode a_iCode); - ParserCallback(fun_type1 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type2 a_pFun, bool a_bAllowOpti, int a_iPrec, EOprtAssociativity a_eAssociativity); - ParserCallback(fun_type2 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type3 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type4 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type5 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type6 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type7 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type8 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type9 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type10 a_pFun, bool a_bAllowOpti); - - ParserCallback(bulkfun_type0 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type1 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type2 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type3 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type4 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type5 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type6 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type7 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type8 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type9 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type10 a_pFun, bool a_bAllowOpti); - - ParserCallback(multfun_type a_pFun, bool a_bAllowOpti); - - ParserCallback(strfun_type1 a_pFun, bool a_bAllowOpti); - ParserCallback(strfun_type2 a_pFun, bool a_bAllowOpti); - ParserCallback(strfun_type3 a_pFun, bool a_bAllowOpti); - ParserCallback(strfun_type4 a_pFun, bool a_bAllowOpti); - ParserCallback(strfun_type5 a_pFun, bool a_bAllowOpti); - ParserCallback(strfun_type6 a_pFun, bool a_bAllowOpti); - - // note: a_pUserData shall not be nullptr - ParserCallback(fun_userdata_type0 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(fun_userdata_type1 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(fun_userdata_type2 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(fun_userdata_type3 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(fun_userdata_type4 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(fun_userdata_type5 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(fun_userdata_type6 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(fun_userdata_type7 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(fun_userdata_type8 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(fun_userdata_type9 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(fun_userdata_type10 a_pFun, void* a_pUserData, bool a_bAllowOpti); - - ParserCallback(bulkfun_userdata_type0 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(bulkfun_userdata_type1 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(bulkfun_userdata_type2 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(bulkfun_userdata_type3 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(bulkfun_userdata_type4 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(bulkfun_userdata_type5 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(bulkfun_userdata_type6 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(bulkfun_userdata_type7 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(bulkfun_userdata_type8 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(bulkfun_userdata_type9 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(bulkfun_userdata_type10 a_pFun, void* a_pUserData, bool a_bAllowOpti); - - ParserCallback(multfun_userdata_type a_pFun, void* a_pUserData, bool a_bAllowOpti); - - ParserCallback(strfun_userdata_type1 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(strfun_userdata_type2 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(strfun_userdata_type3 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(strfun_userdata_type4 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(strfun_userdata_type5 a_pFun, void* a_pUserData, bool a_bAllowOpti); - ParserCallback(strfun_userdata_type6 a_pFun, void* a_pUserData, bool a_bAllowOpti); - - ParserCallback(); - ParserCallback(const ParserCallback& a_Fun); - ParserCallback & operator=(const ParserCallback& a_Fun); - ~ParserCallback(); - - ParserCallback* Clone() const; - - bool IsOptimizable() const; - bool IsValid() const; - void* GetAddr() const; - void* GetUserData() const; - ECmdCode GetCode() const; - ETypeCode GetType() const; - int GetPri() const; - EOprtAssociativity GetAssociativity() const; - int GetArgc() const; - - private: - void Assign(const ParserCallback& ref); - - void* m_pFun; ///< Pointer to the callback function or internal data, casted to void - - int m_iArgc; ///< Internal representation of number of numeric function arguments - int m_iPri; ///< Valid only for binary and infix operators; Operator precedence. - EOprtAssociativity m_eOprtAsct; ///< Operator associativity; Valid only for binary operators - ECmdCode m_iCode; - ETypeCode m_iType; - bool m_bAllowOpti; ///< Flag indication optimizeability - }; - - - /** \brief Container for Callback objects. */ - typedef std::map funmap_type; +namespace mu { + + /** \brief Encapsulation of prototypes for a numerical parser function. + + Encapsulates the prototyp for numerical parser functions. The class + stores the number of arguments for parser functions as well + as additional flags indication the function is non optimizeable. + The pointer to the callback function pointer is stored as void* + and needs to be casted according to the argument count. + Negative argument counts indicate a parser function with a variable number + of arguments. + */ + class API_EXPORT_CXX ParserCallback final { + public: + ParserCallback(fun_type0 a_pFun, + bool a_bAllowOpti); + ParserCallback(fun_type1 a_pFun, + bool a_bAllowOpti, + int a_iPrec, + ECmdCode a_iCode); + ParserCallback(fun_type1 a_pFun, + bool a_bAllowOpti); + ParserCallback(fun_type2 a_pFun, + bool a_bAllowOpti, + int a_iPrec, + EOprtAssociativity a_eAssociativity); + ParserCallback(fun_type2 a_pFun, + bool a_bAllowOpti); + ParserCallback(fun_type3 a_pFun, + bool a_bAllowOpti); + ParserCallback(fun_type4 a_pFun, + bool a_bAllowOpti); + ParserCallback(fun_type5 a_pFun, + bool a_bAllowOpti); + ParserCallback(fun_type6 a_pFun, + bool a_bAllowOpti); + ParserCallback(fun_type7 a_pFun, + bool a_bAllowOpti); + ParserCallback(fun_type8 a_pFun, + bool a_bAllowOpti); + ParserCallback(fun_type9 a_pFun, + bool a_bAllowOpti); + ParserCallback(fun_type10 a_pFun, + bool a_bAllowOpti); + + ParserCallback(bulkfun_type0 a_pFun, + bool a_bAllowOpti); + ParserCallback(bulkfun_type1 a_pFun, + bool a_bAllowOpti); + ParserCallback(bulkfun_type2 a_pFun, + bool a_bAllowOpti); + ParserCallback(bulkfun_type3 a_pFun, + bool a_bAllowOpti); + ParserCallback(bulkfun_type4 a_pFun, + bool a_bAllowOpti); + ParserCallback(bulkfun_type5 a_pFun, + bool a_bAllowOpti); + ParserCallback(bulkfun_type6 a_pFun, + bool a_bAllowOpti); + ParserCallback(bulkfun_type7 a_pFun, + bool a_bAllowOpti); + ParserCallback(bulkfun_type8 a_pFun, + bool a_bAllowOpti); + ParserCallback(bulkfun_type9 a_pFun, + bool a_bAllowOpti); + ParserCallback(bulkfun_type10 a_pFun, + bool a_bAllowOpti); + + ParserCallback(multfun_type a_pFun, + bool a_bAllowOpti); + + ParserCallback(strfun_type1 a_pFun, + bool a_bAllowOpti); + ParserCallback(strfun_type2 a_pFun, + bool a_bAllowOpti); + ParserCallback(strfun_type3 a_pFun, + bool a_bAllowOpti); + ParserCallback(strfun_type4 a_pFun, + bool a_bAllowOpti); + ParserCallback(strfun_type5 a_pFun, + bool a_bAllowOpti); + ParserCallback(strfun_type6 a_pFun, + bool a_bAllowOpti); + + // note: a_pUserData shall not be nullptr + ParserCallback(fun_userdata_type0 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(fun_userdata_type1 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(fun_userdata_type2 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(fun_userdata_type3 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(fun_userdata_type4 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(fun_userdata_type5 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(fun_userdata_type6 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(fun_userdata_type7 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(fun_userdata_type8 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(fun_userdata_type9 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(fun_userdata_type10 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + + ParserCallback(bulkfun_userdata_type0 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(bulkfun_userdata_type1 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(bulkfun_userdata_type2 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(bulkfun_userdata_type3 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(bulkfun_userdata_type4 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(bulkfun_userdata_type5 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(bulkfun_userdata_type6 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(bulkfun_userdata_type7 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(bulkfun_userdata_type8 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(bulkfun_userdata_type9 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(bulkfun_userdata_type10 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + + ParserCallback(multfun_userdata_type a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + + ParserCallback(strfun_userdata_type1 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(strfun_userdata_type2 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(strfun_userdata_type3 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(strfun_userdata_type4 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(strfun_userdata_type5 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + ParserCallback(strfun_userdata_type6 a_pFun, + void* a_pUserData, + bool a_bAllowOpti); + + ParserCallback(); + ParserCallback(const ParserCallback& a_Fun); + ParserCallback& operator=(const ParserCallback& a_Fun); + ~ParserCallback(); + + ParserCallback* Clone() const; + + bool IsOptimizable() const; + bool IsValid() const; + void* GetAddr() const; + void* GetUserData() const; + ECmdCode GetCode() const; + ETypeCode GetType() const; + int GetPri() const; + EOprtAssociativity GetAssociativity() const; + int GetArgc() const; + + private: + void Assign(const ParserCallback& ref); + + void* m_pFun; ///< Pointer to the callback function or internal data, casted to void + + int m_iArgc; ///< Internal representation of number of numeric function arguments + int m_iPri; ///< Valid only for binary and infix operators; Operator precedence. + EOprtAssociativity m_eOprtAsct; ///< Operator associativity; Valid only for binary operators + ECmdCode m_iCode; + ETypeCode m_iType; + bool m_bAllowOpti; ///< Flag indication optimizeability + }; + + + /** \brief Container for Callback objects. */ + typedef std::map funmap_type; } // namespace mu #endif - diff --git a/libsrc/spatialdata/muparser/muParserDef.h b/libsrc/spatialdata/muparser/muParserDef.h index 13a15c87..a4532014 100644 --- a/libsrc/spatialdata/muparser/muParserDef.h +++ b/libsrc/spatialdata/muparser/muParserDef.h @@ -1,43 +1,43 @@ /* - - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2004 - 2021 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #ifndef MUP_DEF_H #define MUP_DEF_H #include -#include -#include #include +#include +#include #include "muParserFixes.h" /** \file - \brief This file contains standard definitions used by the parser. + \brief This file contains standard definitions used by the parser. */ /** \brief Define the base datatype for values. @@ -55,464 +55,743 @@ use the cmake option instead! */ -//#define MUP_USE_OPENMP +// #define MUP_USE_OPENMP #if defined(_UNICODE) - /** \brief Definition of the basic parser string type. */ - #define MUP_STRING_TYPE std::wstring +/** \brief Definition of the basic parser string type. */ +#define MUP_STRING_TYPE std::wstring - #if !defined(_T) - #define _T(x) L##x - #endif // not defined _T +#if !defined(_T) +#define _T(x) L##x +#endif // not defined _T #else - #ifndef _T - #define _T(x) x - #endif +#ifndef _T +#define _T(x) x +#endif - /** \brief Definition of the basic parser string type. */ - #define MUP_STRING_TYPE std::string +/** \brief Definition of the basic parser string type. */ +#define MUP_STRING_TYPE std::string #endif /** \brief An assertion that does not kill the program. */ -#define MUP_ASSERT(COND) \ - if (!(COND)) \ - { \ - stringstream_type ss; \ - ss << _T("Assertion \"") _T(#COND) _T("\" failed: ") \ - << __FILE__ << _T(" line ") \ - << __LINE__ << _T("."); \ - throw ParserError( ecINTERNAL_ERROR, -1, ss.str()); \ - } +#define MUP_ASSERT(COND) \ + if (!(COND)) { \ + stringstream_type ss; \ + ss << _T("Assertion \"") _T(#COND) _T("\" failed: ") << __FILE__ << _T(" line ") << __LINE__ << _T("."); \ + throw ParserError(ecINTERNAL_ERROR, -1, ss.str()); \ + } #if defined(_MSC_VER) - #pragma warning(push) - #pragma warning(disable : 26812) +#pragma warning(push) +#pragma warning(disable : 26812) #endif -namespace mu -{ +namespace mu { #if defined(_UNICODE) - /** \brief Encapsulate wcout. */ - inline std::wostream& console() - { - return std::wcout; - } + /** \brief Encapsulate wcout. */ + inline std::wostream& + console() { + return std::wcout; + } - /** \brief Encapsulate cin. */ - inline std::wistream& console_in() - { - return std::wcin; - } + /** \brief Encapsulate cin. */ + inline std::wistream& + console_in() { + return std::wcin; + } #else - /** \brief Encapsulate cout. + /** \brief Encapsulate cout. - Used for supporting UNICODE more easily. - */ - inline std::ostream& console() - { - return std::cout; - } + Used for supporting UNICODE more easily. + */ + inline std::ostream& + console() { + return std::cout; + } - /** \brief Encapsulate cin. + /** \brief Encapsulate cin. - Used for supporting UNICODE more easily. - */ - inline std::istream& console_in() - { - return std::cin; - } + Used for supporting UNICODE more easily. + */ + inline std::istream& + console_in() { + return std::cin; + } #endif - /** \brief Bytecode values. - - \attention The order of the operator entries must match the order in ParserBase::c_DefaultOprt! - */ - enum ECmdCode - { - // The following are codes for built in binary operators - // apart from built in operators the user has the opportunity to - // add user defined operators. - cmLE = 0, ///< Operator item: less or equal - cmGE = 1, ///< Operator item: greater or equal - cmNEQ = 2, ///< Operator item: not equal - cmEQ = 3, ///< Operator item: equals - cmLT = 4, ///< Operator item: less than - cmGT = 5, ///< Operator item: greater than - cmADD = 6, ///< Operator item: add - cmSUB = 7, ///< Operator item: subtract - cmMUL = 8, ///< Operator item: multiply - cmDIV = 9, ///< Operator item: division - cmPOW = 10, ///< Operator item: y to the power of ... - cmLAND = 11, - cmLOR = 12, - cmASSIGN = 13, ///< Operator item: Assignment operator - cmBO = 14, ///< Operator item: opening bracket - cmBC = 15, ///< Operator item: closing bracket - cmIF = 16, ///< For use in the ternary if-then-else operator - cmELSE = 17, ///< For use in the ternary if-then-else operator - cmENDIF = 18, ///< For use in the ternary if-then-else operator - cmARG_SEP = 19, ///< function argument separator - cmVAR = 20, ///< variable item - cmVAL = 21, ///< value item - - // For optimization purposes - cmVARPOW2 = 22, - cmVARPOW3 = 23, - cmVARPOW4 = 24, - cmVARMUL = 25, - - // operators and functions - cmFUNC = 26, ///< Code for a generic function item - cmFUNC_STR, ///< Code for a function with a string parameter - cmFUNC_BULK, ///< Special callbacks for Bulk mode with an additional parameter for the bulk index - cmSTRING, ///< Code for a string token - cmOPRT_BIN, ///< user defined binary operator - cmOPRT_POSTFIX, ///< code for postfix operators - cmOPRT_INFIX, ///< code for infix operators - cmEND, ///< end of formula - cmUNKNOWN ///< uninitialized item - }; - - /** \brief Types internally used by the parser. - */ - enum ETypeCode - { - tpSTR = 0, ///< String type (Function arguments and constants only, no string variables) - tpDBL = 1, ///< Floating point variables - tpVOID = 2 ///< Undefined type. - }; - - - enum EParserVersionInfo - { - pviBRIEF, - pviFULL - }; - - - /** \brief Parser operator precedence values. */ - enum EOprtAssociativity - { - oaLEFT = 0, - oaRIGHT = 1, - oaNONE = 2 - }; - - - /** \brief Parser operator precedence values. */ - enum EOprtPrecedence - { - // binary operators - prLOR = 1, - prLAND = 2, - prLOGIC = 3, ///< logic operators - prCMP = 4, ///< comparsion operators - prADD_SUB = 5, ///< addition - prMUL_DIV = 6, ///< multiplication/division - prPOW = 7, ///< power operator priority (highest) - - // infix operators - prINFIX = 6, ///< Signs have a higher priority than ADD_SUB, but lower than power operator - prPOSTFIX = 6 ///< Postfix operator priority (currently unused) - }; - - - /** \brief Error codes. */ - enum EErrorCodes - { - // Formula syntax errors - ecUNEXPECTED_OPERATOR = 0, ///< Unexpected binary operator found - ecUNASSIGNABLE_TOKEN = 1, ///< Token can't be identified. - ecUNEXPECTED_EOF = 2, ///< Unexpected end of formula. (Example: "2+sin(") - ecUNEXPECTED_ARG_SEP = 3, ///< An unexpected comma has been found. (Example: "1,23") - ecUNEXPECTED_ARG = 4, ///< An unexpected argument has been found - ecUNEXPECTED_VAL = 5, ///< An unexpected value token has been found - ecUNEXPECTED_VAR = 6, ///< An unexpected variable token has been found - ecUNEXPECTED_PARENS = 7, ///< Unexpected Parenthesis, opening or closing - ecUNEXPECTED_STR = 8, ///< A string has been found at an inapropriate position - ecSTRING_EXPECTED = 9, ///< A string function has been called with a different type of argument - ecVAL_EXPECTED = 10, ///< A numerical function has been called with a non value type of argument - ecMISSING_PARENS = 11, ///< Missing parens. (Example: "3*sin(3") - ecUNEXPECTED_FUN = 12, ///< Unexpected function found. (Example: "sin(8)cos(9)") - ecUNTERMINATED_STRING = 13, ///< unterminated string constant. (Example: "3*valueof("hello)") - ecTOO_MANY_PARAMS = 14, ///< Too many function parameters - ecTOO_FEW_PARAMS = 15, ///< Too few function parameters. (Example: "ite(1<2,2)") - ecOPRT_TYPE_CONFLICT = 16, ///< binary operators may only be applied to value items of the same type - ecSTR_RESULT = 17, ///< result is a string - - // Invalid Parser input Parameters - ecINVALID_NAME = 18, ///< Invalid function, variable or constant name. - ecINVALID_BINOP_IDENT = 19, ///< Invalid binary operator identifier - ecINVALID_INFIX_IDENT = 20, ///< Invalid function, variable or constant name. - ecINVALID_POSTFIX_IDENT = 21, ///< Invalid function, variable or constant name. - - ecBUILTIN_OVERLOAD = 22, ///< Trying to overload builtin operator - ecINVALID_FUN_PTR = 23, ///< Invalid callback function pointer - ecINVALID_VAR_PTR = 24, ///< Invalid variable pointer - ecEMPTY_EXPRESSION = 25, ///< The Expression is empty - ecNAME_CONFLICT = 26, ///< Name conflict - ecOPT_PRI = 27, ///< Invalid operator priority - // - ecDOMAIN_ERROR = 28, ///< catch division by zero, sqrt(-1), log(0) (currently unused) - ecDIV_BY_ZERO = 29, ///< Division by zero (currently unused) - ecGENERIC = 30, ///< Generic error - ecLOCALE = 31, ///< Conflict with current locale - - ecUNEXPECTED_CONDITIONAL = 32, - ecMISSING_ELSE_CLAUSE = 33, - ecMISPLACED_COLON = 34, - - ecUNREASONABLE_NUMBER_OF_COMPUTATIONS = 35, - - ecIDENTIFIER_TOO_LONG = 36, ///< Thrown when an identifier with more then 255 characters is used. - - ecEXPRESSION_TOO_LONG = 37, ///< Throw an exception if the expression has more than 10000 characters. (an arbitrary limit) - - ecINVALID_CHARACTERS_FOUND = 38,///< The expression or identifier contains invalid non printable characters - - // internal errors - ecINTERNAL_ERROR = 39, ///< Internal error of any kind. - - // The last two are special entries - ecCOUNT, ///< This is no error code, It just stores just the total number of error codes - ecUNDEFINED = -1 ///< Undefined message, placeholder to detect unassigned error messages - }; - - //------------------------------------------------------------------------------ - // Basic Types - //------------------------------------------------------------------------------ - - /** \brief The numeric datatype used by the parser. - - Normally this is a floating point type either single or double precision. - */ - typedef MUP_BASETYPE value_type; - - /** \brief The stringtype used by the parser. - - Depends on whether UNICODE is used or not. - */ - typedef MUP_STRING_TYPE string_type; - - /** \brief The character type used by the parser. - - Depends on whether UNICODE is used or not. - */ - typedef string_type::value_type char_type; - - /** \brief Typedef for easily using stringstream that respect the parser stringtype. */ - typedef std::basic_stringstream, std::allocator > stringstream_type; - - // Data container types - - /** \brief Type used for storing variables. */ - typedef std::map varmap_type; - - /** \brief Type used for storing constants. */ - typedef std::map valmap_type; - - /** \brief Type for assigning a string name to an index in the internal string table. */ - typedef std::map strmap_type; - - // Parser callbacks - - /** \brief Function type used to erase type. Voluntarily needs explicit cast with all other *fun_type*. */ - typedef void(*erased_fun_type)(); - - /** \brief Callback type used for functions without arguments. */ - typedef value_type(*fun_type0)(); - - /** \brief Callback type used for functions with a single arguments. */ - typedef value_type(*fun_type1)(value_type); - - /** \brief Callback type used for functions with two arguments. */ - typedef value_type(*fun_type2)(value_type, value_type); - - /** \brief Callback type used for functions with three arguments. */ - typedef value_type(*fun_type3)(value_type, value_type, value_type); - - /** \brief Callback type used for functions with four arguments. */ - typedef value_type(*fun_type4)(value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with five arguments. */ - typedef value_type(*fun_type5)(value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with six arguments. */ - typedef value_type(*fun_type6)(value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with seven arguments. */ - typedef value_type(*fun_type7)(value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with eight arguments. */ - typedef value_type(*fun_type8)(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with nine arguments. */ - typedef value_type(*fun_type9)(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with ten arguments. */ - typedef value_type(*fun_type10)(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions without arguments. */ - typedef value_type(*fun_userdata_type0)(void*); - - /** \brief Callback type with user data (not null) used for functions with a single arguments. */ - typedef value_type(*fun_userdata_type1)(void*, value_type); - - /** \brief Callback type with user data (not null) used for functions with two arguments. */ - typedef value_type(*fun_userdata_type2)(void*, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions with three arguments. */ - typedef value_type(*fun_userdata_type3)(void*, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions with four arguments. */ - typedef value_type(*fun_userdata_type4)(void*, value_type, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions with five arguments. */ - typedef value_type(*fun_userdata_type5)(void*, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions with six arguments. */ - typedef value_type(*fun_userdata_type6)(void*, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions with seven arguments. */ - typedef value_type(*fun_userdata_type7)(void*, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions with eight arguments. */ - typedef value_type(*fun_userdata_type8)(void*, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions with nine arguments. */ - typedef value_type(*fun_userdata_type9)(void*, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions with ten arguments. */ - typedef value_type(*fun_userdata_type10)(void*, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions without arguments. */ - typedef value_type(*bulkfun_type0)(int, int); - - /** \brief Callback type used for functions with a single arguments. */ - typedef value_type(*bulkfun_type1)(int, int, value_type); - - /** \brief Callback type used for functions with two arguments. */ - typedef value_type(*bulkfun_type2)(int, int, value_type, value_type); - - /** \brief Callback type used for functions with three arguments. */ - typedef value_type(*bulkfun_type3)(int, int, value_type, value_type, value_type); - - /** \brief Callback type used for functions with four arguments. */ - typedef value_type(*bulkfun_type4)(int, int, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with five arguments. */ - typedef value_type(*bulkfun_type5)(int, int, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with six arguments. */ - typedef value_type(*bulkfun_type6)(int, int, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with seven arguments. */ - typedef value_type(*bulkfun_type7)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with eight arguments. */ - typedef value_type(*bulkfun_type8)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with nine arguments. */ - typedef value_type(*bulkfun_type9)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with ten arguments. */ - typedef value_type(*bulkfun_type10)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions without arguments. */ - typedef value_type(*bulkfun_userdata_type0)(void*, int, int); - - /** \brief Callback type with user data (not null) used for functions with a single arguments. */ - typedef value_type(*bulkfun_userdata_type1)(void*, int, int, value_type); - - /** \brief Callback type with user data (not null) used for functions with two arguments. */ - typedef value_type(*bulkfun_userdata_type2)(void*, int, int, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions with three arguments. */ - typedef value_type(*bulkfun_userdata_type3)(void*, int, int, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions with four arguments. */ - typedef value_type(*bulkfun_userdata_type4)(void*, int, int, value_type, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions with five arguments. */ - typedef value_type(*bulkfun_userdata_type5)(void*, int, int, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions with six arguments. */ - typedef value_type(*bulkfun_userdata_type6)(void*, int, int, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions with seven arguments. */ - typedef value_type(*bulkfun_userdata_type7)(void*, int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions with eight arguments. */ - typedef value_type(*bulkfun_userdata_type8)(void*, int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions with nine arguments. */ - typedef value_type(*bulkfun_userdata_type9)(void*, int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions with ten arguments. */ - typedef value_type(*bulkfun_userdata_type10)(void*, int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with a variable argument list. */ - typedef value_type(*multfun_type)(const value_type*, int); - - /** \brief Callback type with user data (not null) used for functions and a variable argument list. */ - typedef value_type(*multfun_userdata_type)(void*, const value_type*, int); - - /** \brief Callback type used for functions taking a string as an argument. */ - typedef value_type(*strfun_type1)(const char_type*); - - /** \brief Callback type used for functions taking a string and a value as arguments. */ - typedef value_type(*strfun_type2)(const char_type*, value_type); - - /** \brief Callback type used for functions taking a string and two values as arguments. */ - typedef value_type(*strfun_type3)(const char_type*, value_type, value_type); - - /** \brief Callback type used for functions taking a string and three values as arguments. */ - typedef value_type(*strfun_type4)(const char_type*, value_type, value_type, value_type); - - /** \brief Callback type used for functions taking a string and four values as arguments. */ - typedef value_type(*strfun_type5)(const char_type*, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions taking a string and five values as arguments. */ - typedef value_type(*strfun_type6)(const char_type*, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions taking a string as an argument. */ - typedef value_type(*strfun_userdata_type1)(void*, const char_type*); - - /** \brief Callback type with user data (not null) used for functions taking a string and a value as arguments. */ - typedef value_type(*strfun_userdata_type2)(void*, const char_type*, value_type); - - /** \brief Callback type with user data (not null) used for functions taking a string and two values as arguments. */ - typedef value_type(*strfun_userdata_type3)(void*, const char_type*, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions taking a string and a value as arguments. */ - typedef value_type(*strfun_userdata_type4)(void*, const char_type*, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions taking a string and two values as arguments. */ - typedef value_type(*strfun_userdata_type5)(void*, const char_type*, value_type, value_type, value_type, value_type); - - /** \brief Callback type with user data (not null) used for functions taking a string and five values as arguments. */ - typedef value_type(*strfun_userdata_type6)(void*, const char_type*, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback used for functions that identify values in a string. */ - typedef int (*identfun_type)(const char_type* sExpr, int* nPos, value_type* fVal); - - /** \brief Callback used for variable creation factory functions. */ - typedef value_type* (*facfun_type)(const char_type*, void*); - - static const int MaxLenExpression = 20000; - static const int MaxLenIdentifier = 100; - static const string_type ParserVersion = string_type(_T("2.3.3 (Release)")); - static const string_type ParserVersionDate = string_type(_T("20220122")); -} // end of namespace + /** \brief Bytecode values. + + \attention The order of the operator entries must match the order in ParserBase::c_DefaultOprt! + */ + enum ECmdCode { + // The following are codes for built in binary operators + // apart from built in operators the user has the opportunity to + // add user defined operators. + cmLE = 0, ///< Operator item: less or equal + cmGE = 1, ///< Operator item: greater or equal + cmNEQ = 2, ///< Operator item: not equal + cmEQ = 3, ///< Operator item: equals + cmLT = 4, ///< Operator item: less than + cmGT = 5, ///< Operator item: greater than + cmADD = 6, ///< Operator item: add + cmSUB = 7, ///< Operator item: subtract + cmMUL = 8, ///< Operator item: multiply + cmDIV = 9, ///< Operator item: division + cmPOW = 10, ///< Operator item: y to the power of ... + cmLAND = 11, + cmLOR = 12, + cmASSIGN = 13, ///< Operator item: Assignment operator + cmBO = 14, ///< Operator item: opening bracket + cmBC = 15, ///< Operator item: closing bracket + cmIF = 16, ///< For use in the ternary if-then-else operator + cmELSE = 17, ///< For use in the ternary if-then-else operator + cmENDIF = 18, ///< For use in the ternary if-then-else operator + cmARG_SEP = 19, ///< function argument separator + cmVAR = 20, ///< variable item + cmVAL = 21, ///< value item + + // For optimization purposes + cmVARPOW2 = 22, + cmVARPOW3 = 23, + cmVARPOW4 = 24, + cmVARMUL = 25, + + // operators and functions + cmFUNC = 26, ///< Code for a generic function item + cmFUNC_STR, ///< Code for a function with a string parameter + cmFUNC_BULK, ///< Special callbacks for Bulk mode with an additional parameter for the bulk index + cmSTRING, ///< Code for a string token + cmOPRT_BIN, ///< user defined binary operator + cmOPRT_POSTFIX, ///< code for postfix operators + cmOPRT_INFIX, ///< code for infix operators + cmEND, ///< end of formula + cmUNKNOWN ///< uninitialized item + }; + + /** \brief Types internally used by the parser. + */ + enum ETypeCode { + tpSTR = 0, ///< String type (Function arguments and constants only, no string variables) + tpDBL = 1, ///< Floating point variables + tpVOID = 2 ///< Undefined type. + }; + + + enum EParserVersionInfo { + pviBRIEF, + pviFULL + }; + + + /** \brief Parser operator precedence values. */ + enum EOprtAssociativity { + oaLEFT = 0, + oaRIGHT = 1, + oaNONE = 2 + }; + + + /** \brief Parser operator precedence values. */ + enum EOprtPrecedence { + // binary operators + prLOR = 1, + prLAND = 2, + prLOGIC = 3, ///< logic operators + prCMP = 4, ///< comparsion operators + prADD_SUB = 5, ///< addition + prMUL_DIV = 6, ///< multiplication/division + prPOW = 7, ///< power operator priority (highest) + + // infix operators + prINFIX = 6, ///< Signs have a higher priority than ADD_SUB, but lower than power operator + prPOSTFIX = 6 ///< Postfix operator priority (currently unused) + }; + + + /** \brief Error codes. */ + enum EErrorCodes { + // Formula syntax errors + ecUNEXPECTED_OPERATOR = 0, ///< Unexpected binary operator found + ecUNASSIGNABLE_TOKEN = 1, ///< Token can't be identified. + ecUNEXPECTED_EOF = 2, ///< Unexpected end of formula. (Example: "2+sin(") + ecUNEXPECTED_ARG_SEP = 3, ///< An unexpected comma has been found. (Example: "1,23") + ecUNEXPECTED_ARG = 4, ///< An unexpected argument has been found + ecUNEXPECTED_VAL = 5, ///< An unexpected value token has been found + ecUNEXPECTED_VAR = 6, ///< An unexpected variable token has been found + ecUNEXPECTED_PARENS = 7, ///< Unexpected Parenthesis, opening or closing + ecUNEXPECTED_STR = 8, ///< A string has been found at an inapropriate position + ecSTRING_EXPECTED = 9, ///< A string function has been called with a different type of argument + ecVAL_EXPECTED = 10, ///< A numerical function has been called with a non value type of argument + ecMISSING_PARENS = 11, ///< Missing parens. (Example: "3*sin(3") + ecUNEXPECTED_FUN = 12, ///< Unexpected function found. (Example: "sin(8)cos(9)") + ecUNTERMINATED_STRING = 13, ///< unterminated string constant. (Example: "3*valueof("hello)") + ecTOO_MANY_PARAMS = 14, ///< Too many function parameters + ecTOO_FEW_PARAMS = 15, ///< Too few function parameters. (Example: "ite(1<2,2)") + ecOPRT_TYPE_CONFLICT = 16, ///< binary operators may only be applied to value items of the same type + ecSTR_RESULT = 17, ///< result is a string + + // Invalid Parser input Parameters + ecINVALID_NAME = 18, ///< Invalid function, variable or constant name. + ecINVALID_BINOP_IDENT = 19, ///< Invalid binary operator identifier + ecINVALID_INFIX_IDENT = 20, ///< Invalid function, variable or constant name. + ecINVALID_POSTFIX_IDENT = 21, ///< Invalid function, variable or constant name. + + ecBUILTIN_OVERLOAD = 22, ///< Trying to overload builtin operator + ecINVALID_FUN_PTR = 23, ///< Invalid callback function pointer + ecINVALID_VAR_PTR = 24, ///< Invalid variable pointer + ecEMPTY_EXPRESSION = 25, ///< The Expression is empty + ecNAME_CONFLICT = 26, ///< Name conflict + ecOPT_PRI = 27, ///< Invalid operator priority + // + ecDOMAIN_ERROR = 28, ///< catch division by zero, sqrt(-1), log(0) (currently unused) + ecDIV_BY_ZERO = 29, ///< Division by zero (currently unused) + ecGENERIC = 30, ///< Generic error + ecLOCALE = 31, ///< Conflict with current locale + + ecUNEXPECTED_CONDITIONAL = 32, + ecMISSING_ELSE_CLAUSE = 33, + ecMISPLACED_COLON = 34, + + ecUNREASONABLE_NUMBER_OF_COMPUTATIONS = 35, + + ecIDENTIFIER_TOO_LONG = 36, ///< Thrown when an identifier with more then 255 characters is used. + + ecEXPRESSION_TOO_LONG = + 37, ///< Throw an exception if the expression has more than 10000 characters. (an arbitrary limit) + + ecINVALID_CHARACTERS_FOUND = 38, ///< The expression or identifier contains invalid non printable characters + + // internal errors + ecINTERNAL_ERROR = 39, ///< Internal error of any kind. + + // The last two are special entries + ecCOUNT, ///< This is no error code, It just stores just the total number of error codes + ecUNDEFINED = -1 ///< Undefined message, placeholder to detect unassigned error messages + }; + + //------------------------------------------------------------------------------ + // Basic Types + //------------------------------------------------------------------------------ + + /** \brief The numeric datatype used by the parser. + + Normally this is a floating point type either single or double precision. + */ + typedef MUP_BASETYPE value_type; + + /** \brief The stringtype used by the parser. + + Depends on whether UNICODE is used or not. + */ + typedef MUP_STRING_TYPE string_type; + + /** \brief The character type used by the parser. + + Depends on whether UNICODE is used or not. + */ + typedef string_type::value_type char_type; + + /** \brief Typedef for easily using stringstream that respect the parser stringtype. */ + typedef std::basic_stringstream, std::allocator> + stringstream_type; + + // Data container types + + /** \brief Type used for storing variables. */ + typedef std::map varmap_type; + + /** \brief Type used for storing constants. */ + typedef std::map valmap_type; + + /** \brief Type for assigning a string name to an index in the internal string table. */ + typedef std::map strmap_type; + + // Parser callbacks + + /** \brief Function type used to erase type. Voluntarily needs explicit cast with all other *fun_type*. */ + typedef void (*erased_fun_type)(); + + /** \brief Callback type used for functions without arguments. */ + typedef value_type (*fun_type0)(); + + /** \brief Callback type used for functions with a single arguments. */ + typedef value_type (*fun_type1)(value_type); + + /** \brief Callback type used for functions with two arguments. */ + typedef value_type (*fun_type2)(value_type, + value_type); + + /** \brief Callback type used for functions with three arguments. */ + typedef value_type (*fun_type3)(value_type, + value_type, + value_type); + + /** \brief Callback type used for functions with four arguments. */ + typedef value_type (*fun_type4)(value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions with five arguments. */ + typedef value_type (*fun_type5)(value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions with six arguments. */ + typedef value_type (*fun_type6)(value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions with seven arguments. */ + typedef value_type (*fun_type7)(value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions with eight arguments. */ + typedef value_type (*fun_type8)(value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions with nine arguments. */ + typedef value_type (*fun_type9)(value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions with ten arguments. */ + typedef value_type (*fun_type10)(value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions without arguments. */ + typedef value_type (*fun_userdata_type0)(void*); + + /** \brief Callback type with user data (not null) used for functions with a single arguments. */ + typedef value_type (*fun_userdata_type1)(void*, + value_type); + + /** \brief Callback type with user data (not null) used for functions with two arguments. */ + typedef value_type (*fun_userdata_type2)(void*, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions with three arguments. */ + typedef value_type (*fun_userdata_type3)(void*, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions with four arguments. */ + typedef value_type (*fun_userdata_type4)(void*, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions with five arguments. */ + typedef value_type (*fun_userdata_type5)(void*, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions with six arguments. */ + typedef value_type (*fun_userdata_type6)(void*, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions with seven arguments. */ + typedef value_type (*fun_userdata_type7)(void*, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions with eight arguments. */ + typedef value_type (*fun_userdata_type8)(void*, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions with nine arguments. */ + typedef value_type (*fun_userdata_type9)(void*, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions with ten arguments. */ + typedef value_type (*fun_userdata_type10)(void*, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions without arguments. */ + typedef value_type (*bulkfun_type0)(int, + int); + + /** \brief Callback type used for functions with a single arguments. */ + typedef value_type (*bulkfun_type1)(int, + int, + value_type); + + /** \brief Callback type used for functions with two arguments. */ + typedef value_type (*bulkfun_type2)(int, + int, + value_type, + value_type); + + /** \brief Callback type used for functions with three arguments. */ + typedef value_type (*bulkfun_type3)(int, + int, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions with four arguments. */ + typedef value_type (*bulkfun_type4)(int, + int, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions with five arguments. */ + typedef value_type (*bulkfun_type5)(int, + int, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions with six arguments. */ + typedef value_type (*bulkfun_type6)(int, + int, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions with seven arguments. */ + typedef value_type (*bulkfun_type7)(int, + int, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions with eight arguments. */ + typedef value_type (*bulkfun_type8)(int, + int, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions with nine arguments. */ + typedef value_type (*bulkfun_type9)(int, + int, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions with ten arguments. */ + typedef value_type (*bulkfun_type10)(int, + int, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions without arguments. */ + typedef value_type (*bulkfun_userdata_type0)(void*, + int, + int); + + /** \brief Callback type with user data (not null) used for functions with a single arguments. */ + typedef value_type (*bulkfun_userdata_type1)(void*, + int, + int, + value_type); + + /** \brief Callback type with user data (not null) used for functions with two arguments. */ + typedef value_type (*bulkfun_userdata_type2)(void*, + int, + int, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions with three arguments. */ + typedef value_type (*bulkfun_userdata_type3)(void*, + int, + int, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions with four arguments. */ + typedef value_type (*bulkfun_userdata_type4)(void*, + int, + int, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions with five arguments. */ + typedef value_type (*bulkfun_userdata_type5)(void*, + int, + int, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions with six arguments. */ + typedef value_type (*bulkfun_userdata_type6)(void*, + int, + int, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions with seven arguments. */ + typedef value_type (*bulkfun_userdata_type7)(void*, + int, + int, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions with eight arguments. */ + typedef value_type (*bulkfun_userdata_type8)(void*, + int, + int, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions with nine arguments. */ + typedef value_type (*bulkfun_userdata_type9)(void*, + int, + int, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions with ten arguments. */ + typedef value_type (*bulkfun_userdata_type10)(void*, + int, + int, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions with a variable argument list. */ + typedef value_type (*multfun_type)(const value_type*, + int); + + /** \brief Callback type with user data (not null) used for functions and a variable argument list. */ + typedef value_type (*multfun_userdata_type)(void*, + const value_type*, + int); + + /** \brief Callback type used for functions taking a string as an argument. */ + typedef value_type (*strfun_type1)(const char_type*); + + /** \brief Callback type used for functions taking a string and a value as arguments. */ + typedef value_type (*strfun_type2)(const char_type*, + value_type); + + /** \brief Callback type used for functions taking a string and two values as arguments. */ + typedef value_type (*strfun_type3)(const char_type*, + value_type, + value_type); + + /** \brief Callback type used for functions taking a string and three values as arguments. */ + typedef value_type (*strfun_type4)(const char_type*, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions taking a string and four values as arguments. */ + typedef value_type (*strfun_type5)(const char_type*, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type used for functions taking a string and five values as arguments. */ + typedef value_type (*strfun_type6)(const char_type*, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions taking a string as an argument. */ + typedef value_type (*strfun_userdata_type1)(void*, + const char_type*); + + /** \brief Callback type with user data (not null) used for functions taking a string and a value as arguments. */ + typedef value_type (*strfun_userdata_type2)(void*, + const char_type*, + value_type); + + /** \brief Callback type with user data (not null) used for functions taking a string and two values as arguments. + */ + typedef value_type (*strfun_userdata_type3)(void*, + const char_type*, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions taking a string and a value as arguments. */ + typedef value_type (*strfun_userdata_type4)(void*, + const char_type*, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions taking a string and two values as arguments. + */ + typedef value_type (*strfun_userdata_type5)(void*, + const char_type*, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback type with user data (not null) used for functions taking a string and five values as arguments. + */ + typedef value_type (*strfun_userdata_type6)(void*, + const char_type*, + value_type, + value_type, + value_type, + value_type, + value_type); + + /** \brief Callback used for functions that identify values in a string. */ + typedef int (*identfun_type)(const char_type* sExpr, + int* nPos, + value_type* fVal); + + /** \brief Callback used for variable creation factory functions. */ + typedef value_type* (*facfun_type)(const char_type*, + void*); + + static const int MaxLenExpression = 20000; + static const int MaxLenIdentifier = 100; + static const string_type ParserVersion = string_type(_T("2.3.3 (Release)")); + static const string_type ParserVersionDate = string_type(_T("20220122")); +} // namespace mu #if defined(_MSC_VER) - #pragma warning(pop) +#pragma warning(pop) #endif #endif - diff --git a/libsrc/spatialdata/muparser/muParserError.cpp b/libsrc/spatialdata/muparser/muParserError.cpp index 960e48ab..f10eef53 100644 --- a/libsrc/spatialdata/muparser/muParserError.cpp +++ b/libsrc/spatialdata/muparser/muParserError.cpp @@ -1,335 +1,328 @@ /* - - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2004 - 2021 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include "muParserError.h" #include #if defined(_MSC_VER) - #pragma warning(push) - #pragma warning(disable : 26812) // MSVC wants to force me te use enum classes or bother me with pointless warnings +#pragma warning(push) +#pragma warning(disable : 26812) // MSVC wants to force me te use enum classes or bother me with pointless warnings #endif -namespace mu -{ - //------------------------------------------------------------------------------ - const ParserErrorMsg& ParserErrorMsg::Instance() - { - static const ParserErrorMsg instance; - return instance; - } - - //------------------------------------------------------------------------------ - string_type ParserErrorMsg::operator[](unsigned a_iIdx) const - { - return (a_iIdx < m_vErrMsg.size()) ? m_vErrMsg[a_iIdx] : string_type(); - } - - //--------------------------------------------------------------------------- - ParserErrorMsg::ParserErrorMsg() - :m_vErrMsg(0) - { - m_vErrMsg.resize(ecCOUNT); - - m_vErrMsg[ecUNASSIGNABLE_TOKEN] = _T("Unexpected token \"$TOK$\" found at position $POS$."); - m_vErrMsg[ecINTERNAL_ERROR] = _T("Internal error"); - m_vErrMsg[ecINVALID_NAME] = _T("Invalid function-, variable- or constant name: \"$TOK$\"."); - m_vErrMsg[ecINVALID_BINOP_IDENT] = _T("Invalid binary operator identifier: \"$TOK$\"."); - m_vErrMsg[ecINVALID_INFIX_IDENT] = _T("Invalid infix operator identifier: \"$TOK$\"."); - m_vErrMsg[ecINVALID_POSTFIX_IDENT] = _T("Invalid postfix operator identifier: \"$TOK$\"."); - m_vErrMsg[ecINVALID_FUN_PTR] = _T("Invalid pointer to callback function."); - m_vErrMsg[ecEMPTY_EXPRESSION] = _T("Expression is empty."); - m_vErrMsg[ecINVALID_VAR_PTR] = _T("Invalid pointer to variable."); - m_vErrMsg[ecUNEXPECTED_OPERATOR] = _T("Unexpected operator \"$TOK$\" found at position $POS$"); - m_vErrMsg[ecUNEXPECTED_EOF] = _T("Unexpected end of expression at position $POS$"); - m_vErrMsg[ecUNEXPECTED_ARG_SEP] = _T("Unexpected argument separator at position $POS$"); - m_vErrMsg[ecUNEXPECTED_PARENS] = _T("Unexpected parenthesis \"$TOK$\" at position $POS$"); - m_vErrMsg[ecUNEXPECTED_FUN] = _T("Unexpected function \"$TOK$\" at position $POS$"); - m_vErrMsg[ecUNEXPECTED_VAL] = _T("Unexpected value \"$TOK$\" found at position $POS$"); - m_vErrMsg[ecUNEXPECTED_VAR] = _T("Unexpected variable \"$TOK$\" found at position $POS$"); - m_vErrMsg[ecUNEXPECTED_ARG] = _T("Function arguments used without a function (position: $POS$)"); - m_vErrMsg[ecMISSING_PARENS] = _T("Missing parenthesis"); - m_vErrMsg[ecTOO_MANY_PARAMS] = _T("Too many parameters for function \"$TOK$\" at expression position $POS$"); - m_vErrMsg[ecTOO_FEW_PARAMS] = _T("Too few parameters for function \"$TOK$\" at expression position $POS$"); - m_vErrMsg[ecDIV_BY_ZERO] = _T("Divide by zero"); - m_vErrMsg[ecDOMAIN_ERROR] = _T("Domain error"); - m_vErrMsg[ecNAME_CONFLICT] = _T("Name conflict"); - m_vErrMsg[ecOPT_PRI] = _T("Invalid value for operator priority (must be greater or equal to zero)."); - m_vErrMsg[ecBUILTIN_OVERLOAD] = _T("user defined binary operator \"$TOK$\" conflicts with a built in operator."); - m_vErrMsg[ecUNEXPECTED_STR] = _T("Unexpected string token found at position $POS$."); - m_vErrMsg[ecUNTERMINATED_STRING] = _T("Unterminated string starting at position $POS$."); - m_vErrMsg[ecSTRING_EXPECTED] = _T("String function called with a non string type of argument."); - m_vErrMsg[ecVAL_EXPECTED] = _T("String value used where a numerical argument is expected."); - m_vErrMsg[ecOPRT_TYPE_CONFLICT] = _T("No suitable overload for operator \"$TOK$\" at position $POS$."); - m_vErrMsg[ecSTR_RESULT] = _T("Strings must only be used as function arguments!"); - m_vErrMsg[ecGENERIC] = _T("Parser error."); - m_vErrMsg[ecLOCALE] = _T("Decimal separator is identic to function argument separator."); - m_vErrMsg[ecUNEXPECTED_CONDITIONAL] = _T("The \"$TOK$\" operator must be preceded by a closing bracket."); - m_vErrMsg[ecMISSING_ELSE_CLAUSE] = _T("If-then-else operator is missing an else clause"); - m_vErrMsg[ecMISPLACED_COLON] = _T("Misplaced colon at position $POS$"); - m_vErrMsg[ecUNREASONABLE_NUMBER_OF_COMPUTATIONS] = _T("Number of computations to small for bulk mode. (Vectorisation overhead too costly)"); - m_vErrMsg[ecIDENTIFIER_TOO_LONG] = _T("Identifier too long."); - m_vErrMsg[ecEXPRESSION_TOO_LONG] = _T("Expression too long."); - m_vErrMsg[ecINVALID_CHARACTERS_FOUND] = _T("Invalid non printable characters found in expression/identifer!"); - - for (int i = 0; i < ecCOUNT; ++i) - { - if (!m_vErrMsg[i].length()) - throw std::runtime_error("Error definitions are incomplete!"); - } - } - - //--------------------------------------------------------------------------- - // - // ParserError class - // - //--------------------------------------------------------------------------- - - /** \brief Default constructor. */ - ParserError::ParserError() - :m_strMsg() - , m_strFormula() - , m_strTok() - , m_iPos(-1) - , m_iErrc(ecUNDEFINED) - , m_ErrMsg(ParserErrorMsg::Instance()) - { - } - - //------------------------------------------------------------------------------ - /** \brief This Constructor is used for internal exceptions only. - - It does not contain any information but the error code. - */ - ParserError::ParserError(EErrorCodes a_iErrc) - :m_strMsg() - , m_strFormula() - , m_strTok() - , m_iPos(-1) - , m_iErrc(a_iErrc) - , m_ErrMsg(ParserErrorMsg::Instance()) - { - m_strMsg = m_ErrMsg[m_iErrc]; - stringstream_type stream; - stream << (int)m_iPos; - ReplaceSubString(m_strMsg, _T("$POS$"), stream.str()); - ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok); - } - - //------------------------------------------------------------------------------ - /** \brief Construct an error from a message text. */ - ParserError::ParserError(const string_type& sMsg) - :m_ErrMsg(ParserErrorMsg::Instance()) - { - Reset(); - m_strMsg = sMsg; - } - - //------------------------------------------------------------------------------ - /** \brief Construct an error object. - \param [in] a_iErrc the error code. - \param [in] sTok The token string related to this error. - \param [in] sExpr The expression related to the error. - \param [in] a_iPos the position in the expression where the error occurred. - */ - ParserError::ParserError(EErrorCodes iErrc, - const string_type& sTok, - const string_type& sExpr, - int iPos) - :m_strMsg() - , m_strFormula(sExpr) - , m_strTok(sTok) - , m_iPos(iPos) - , m_iErrc(iErrc) - , m_ErrMsg(ParserErrorMsg::Instance()) - { - m_strMsg = m_ErrMsg[m_iErrc]; - stringstream_type stream; - stream << (int)m_iPos; - ReplaceSubString(m_strMsg, _T("$POS$"), stream.str()); - ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok); - } - - //------------------------------------------------------------------------------ - /** \brief Construct an error object. - \param [in] iErrc the error code. - \param [in] iPos the position in the expression where the error occurred. - \param [in] sTok The token string related to this error. - */ - ParserError::ParserError(EErrorCodes iErrc, int iPos, const string_type& sTok) - :m_strMsg() - , m_strFormula() - , m_strTok(sTok) - , m_iPos(iPos) - , m_iErrc(iErrc) - , m_ErrMsg(ParserErrorMsg::Instance()) - { - m_strMsg = m_ErrMsg[m_iErrc]; - stringstream_type stream; - stream << (int)m_iPos; - ReplaceSubString(m_strMsg, _T("$POS$"), stream.str()); - ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok); - } - - //------------------------------------------------------------------------------ - /** \brief Construct an error object. - \param [in] szMsg The error message text. - \param [in] iPos the position related to the error. - \param [in] sTok The token string related to this error. - */ - ParserError::ParserError(const char_type* szMsg, int iPos, const string_type& sTok) - :m_strMsg(szMsg) - , m_strFormula() - , m_strTok(sTok) - , m_iPos(iPos) - , m_iErrc(ecGENERIC) - , m_ErrMsg(ParserErrorMsg::Instance()) - { - stringstream_type stream; - stream << (int)m_iPos; - ReplaceSubString(m_strMsg, _T("$POS$"), stream.str()); - ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok); - } - - //------------------------------------------------------------------------------ - /** \brief Copy constructor. */ - ParserError::ParserError(const ParserError& a_Obj) - :m_strMsg(a_Obj.m_strMsg) - , m_strFormula(a_Obj.m_strFormula) - , m_strTok(a_Obj.m_strTok) - , m_iPos(a_Obj.m_iPos) - , m_iErrc(a_Obj.m_iErrc) - , m_ErrMsg(ParserErrorMsg::Instance()) - { - } - - //------------------------------------------------------------------------------ - /** \brief Assignment operator. */ - ParserError& ParserError::operator=(const ParserError& a_Obj) - { - if (this == &a_Obj) - return *this; - - m_strMsg = a_Obj.m_strMsg; - m_strFormula = a_Obj.m_strFormula; - m_strTok = a_Obj.m_strTok; - m_iPos = a_Obj.m_iPos; - m_iErrc = a_Obj.m_iErrc; - return *this; - } - - //------------------------------------------------------------------------------ - ParserError::~ParserError() - {} - - //------------------------------------------------------------------------------ - /** \brief Replace all occurrences of a substring with another string. - \param strFind The string that shall be replaced. - \param strReplaceWith The string that should be inserted instead of strFind - */ - void ParserError::ReplaceSubString(string_type& strSource, - const string_type& strFind, - const string_type& strReplaceWith) - { - string_type strResult; - string_type::size_type iPos(0), iNext(0); - - for (;;) - { - iNext = strSource.find(strFind, iPos); - strResult.append(strSource, iPos, iNext - iPos); - - if (iNext == string_type::npos) - break; - - strResult.append(strReplaceWith); - iPos = iNext + strFind.length(); - } - - strSource.swap(strResult); - } - - //------------------------------------------------------------------------------ - /** \brief Reset the error object. */ - void ParserError::Reset() - { - m_strMsg = _T(""); - m_strFormula = _T(""); - m_strTok = _T(""); - m_iPos = -1; - m_iErrc = ecUNDEFINED; - } - - //------------------------------------------------------------------------------ - /** \brief Set the expression related to this error. */ - void ParserError::SetFormula(const string_type& a_strFormula) - { - m_strFormula = a_strFormula; - } - - //------------------------------------------------------------------------------ - /** \brief gets the expression related tp this error.*/ - const string_type& ParserError::GetExpr() const - { - return m_strFormula; - } - - //------------------------------------------------------------------------------ - /** \brief Returns the message string for this error. */ - const string_type& ParserError::GetMsg() const - { - return m_strMsg; - } - - //------------------------------------------------------------------------------ - /** \brief Return the formula position related to the error. - - If the error is not related to a distinct position this will return -1 - */ - int ParserError::GetPos() const - { - return m_iPos; - } - - //------------------------------------------------------------------------------ - /** \brief Return string related with this token (if available). */ - const string_type& ParserError::GetToken() const - { - return m_strTok; - } - - //------------------------------------------------------------------------------ - /** \brief Return the error code. */ - EErrorCodes ParserError::GetCode() const - { - return m_iErrc; - } +namespace mu { + //------------------------------------------------------------------------------ + const ParserErrorMsg& + ParserErrorMsg::Instance() { + static const ParserErrorMsg instance; + return instance; + } + + //------------------------------------------------------------------------------ + string_type + ParserErrorMsg::operator[](unsigned a_iIdx) const { + return (a_iIdx < m_vErrMsg.size()) ? m_vErrMsg[a_iIdx] : string_type(); + } + + //--------------------------------------------------------------------------- + ParserErrorMsg::ParserErrorMsg() : m_vErrMsg(0) { + m_vErrMsg.resize(ecCOUNT); + + m_vErrMsg[ecUNASSIGNABLE_TOKEN] = _T("Unexpected token \"$TOK$\" found at position $POS$."); + m_vErrMsg[ecINTERNAL_ERROR] = _T("Internal error"); + m_vErrMsg[ecINVALID_NAME] = _T("Invalid function-, variable- or constant name: \"$TOK$\"."); + m_vErrMsg[ecINVALID_BINOP_IDENT] = _T("Invalid binary operator identifier: \"$TOK$\"."); + m_vErrMsg[ecINVALID_INFIX_IDENT] = _T("Invalid infix operator identifier: \"$TOK$\"."); + m_vErrMsg[ecINVALID_POSTFIX_IDENT] = _T("Invalid postfix operator identifier: \"$TOK$\"."); + m_vErrMsg[ecINVALID_FUN_PTR] = _T("Invalid pointer to callback function."); + m_vErrMsg[ecEMPTY_EXPRESSION] = _T("Expression is empty."); + m_vErrMsg[ecINVALID_VAR_PTR] = _T("Invalid pointer to variable."); + m_vErrMsg[ecUNEXPECTED_OPERATOR] = _T("Unexpected operator \"$TOK$\" found at position $POS$"); + m_vErrMsg[ecUNEXPECTED_EOF] = _T("Unexpected end of expression at position $POS$"); + m_vErrMsg[ecUNEXPECTED_ARG_SEP] = _T("Unexpected argument separator at position $POS$"); + m_vErrMsg[ecUNEXPECTED_PARENS] = _T("Unexpected parenthesis \"$TOK$\" at position $POS$"); + m_vErrMsg[ecUNEXPECTED_FUN] = _T("Unexpected function \"$TOK$\" at position $POS$"); + m_vErrMsg[ecUNEXPECTED_VAL] = _T("Unexpected value \"$TOK$\" found at position $POS$"); + m_vErrMsg[ecUNEXPECTED_VAR] = _T("Unexpected variable \"$TOK$\" found at position $POS$"); + m_vErrMsg[ecUNEXPECTED_ARG] = _T("Function arguments used without a function (position: $POS$)"); + m_vErrMsg[ecMISSING_PARENS] = _T("Missing parenthesis"); + m_vErrMsg[ecTOO_MANY_PARAMS] = _T("Too many parameters for function \"$TOK$\" at expression position $POS$"); + m_vErrMsg[ecTOO_FEW_PARAMS] = _T("Too few parameters for function \"$TOK$\" at expression position $POS$"); + m_vErrMsg[ecDIV_BY_ZERO] = _T("Divide by zero"); + m_vErrMsg[ecDOMAIN_ERROR] = _T("Domain error"); + m_vErrMsg[ecNAME_CONFLICT] = _T("Name conflict"); + m_vErrMsg[ecOPT_PRI] = _T("Invalid value for operator priority (must be greater or equal to zero)."); + m_vErrMsg[ecBUILTIN_OVERLOAD] = + _T("user defined binary operator \"$TOK$\" conflicts with a built in operator."); + m_vErrMsg[ecUNEXPECTED_STR] = _T("Unexpected string token found at position $POS$."); + m_vErrMsg[ecUNTERMINATED_STRING] = _T("Unterminated string starting at position $POS$."); + m_vErrMsg[ecSTRING_EXPECTED] = _T("String function called with a non string type of argument."); + m_vErrMsg[ecVAL_EXPECTED] = _T("String value used where a numerical argument is expected."); + m_vErrMsg[ecOPRT_TYPE_CONFLICT] = _T("No suitable overload for operator \"$TOK$\" at position $POS$."); + m_vErrMsg[ecSTR_RESULT] = _T("Strings must only be used as function arguments!"); + m_vErrMsg[ecGENERIC] = _T("Parser error."); + m_vErrMsg[ecLOCALE] = _T("Decimal separator is identic to function argument separator."); + m_vErrMsg[ecUNEXPECTED_CONDITIONAL] = _T("The \"$TOK$\" operator must be preceded by a closing bracket."); + m_vErrMsg[ecMISSING_ELSE_CLAUSE] = _T("If-then-else operator is missing an else clause"); + m_vErrMsg[ecMISPLACED_COLON] = _T("Misplaced colon at position $POS$"); + m_vErrMsg[ecUNREASONABLE_NUMBER_OF_COMPUTATIONS] = + _T("Number of computations to small for bulk mode. (Vectorisation overhead too costly)"); + m_vErrMsg[ecIDENTIFIER_TOO_LONG] = _T("Identifier too long."); + m_vErrMsg[ecEXPRESSION_TOO_LONG] = _T("Expression too long."); + m_vErrMsg[ecINVALID_CHARACTERS_FOUND] = _T("Invalid non printable characters found in expression/identifer!"); + + for (int i = 0; i < ecCOUNT; ++i) { + if (!m_vErrMsg[i].length()) + throw std::runtime_error("Error definitions are incomplete!"); + } + } + + //--------------------------------------------------------------------------- + // + // ParserError class + // + //--------------------------------------------------------------------------- + + /** \brief Default constructor. */ + ParserError::ParserError() : + m_strMsg(), + m_strFormula(), + m_strTok(), + m_iPos(-1), + m_iErrc(ecUNDEFINED), + m_ErrMsg(ParserErrorMsg::Instance()) { + } + + //------------------------------------------------------------------------------ + /** \brief This Constructor is used for internal exceptions only. + + It does not contain any information but the error code. + */ + ParserError::ParserError(EErrorCodes a_iErrc) : + m_strMsg(), + m_strFormula(), + m_strTok(), + m_iPos(-1), + m_iErrc(a_iErrc), + m_ErrMsg(ParserErrorMsg::Instance()) { + m_strMsg = m_ErrMsg[m_iErrc]; + stringstream_type stream; + stream << (int)m_iPos; + ReplaceSubString(m_strMsg, _T("$POS$"), stream.str()); + ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok); + } + + //------------------------------------------------------------------------------ + /** \brief Construct an error from a message text. */ + ParserError::ParserError(const string_type& sMsg) : m_ErrMsg(ParserErrorMsg::Instance()) { + Reset(); + m_strMsg = sMsg; + } + + //------------------------------------------------------------------------------ + /** \brief Construct an error object. + \param [in] a_iErrc the error code. + \param [in] sTok The token string related to this error. + \param [in] sExpr The expression related to the error. + \param [in] a_iPos the position in the expression where the error occurred. + */ + ParserError::ParserError(EErrorCodes iErrc, + const string_type& sTok, + const string_type& sExpr, + int iPos) : + m_strMsg(), + m_strFormula(sExpr), + m_strTok(sTok), + m_iPos(iPos), + m_iErrc(iErrc), + m_ErrMsg(ParserErrorMsg::Instance()) { + m_strMsg = m_ErrMsg[m_iErrc]; + stringstream_type stream; + stream << (int)m_iPos; + ReplaceSubString(m_strMsg, _T("$POS$"), stream.str()); + ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok); + } + + //------------------------------------------------------------------------------ + /** \brief Construct an error object. + \param [in] iErrc the error code. + \param [in] iPos the position in the expression where the error occurred. + \param [in] sTok The token string related to this error. + */ + ParserError::ParserError(EErrorCodes iErrc, + int iPos, + const string_type& sTok) : + m_strMsg(), + m_strFormula(), + m_strTok(sTok), + m_iPos(iPos), + m_iErrc(iErrc), + m_ErrMsg(ParserErrorMsg::Instance()) { + m_strMsg = m_ErrMsg[m_iErrc]; + stringstream_type stream; + stream << (int)m_iPos; + ReplaceSubString(m_strMsg, _T("$POS$"), stream.str()); + ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok); + } + + //------------------------------------------------------------------------------ + /** \brief Construct an error object. + \param [in] szMsg The error message text. + \param [in] iPos the position related to the error. + \param [in] sTok The token string related to this error. + */ + ParserError::ParserError(const char_type* szMsg, + int iPos, + const string_type& sTok) : + m_strMsg(szMsg), + m_strFormula(), + m_strTok(sTok), + m_iPos(iPos), + m_iErrc(ecGENERIC), + m_ErrMsg(ParserErrorMsg::Instance()) { + stringstream_type stream; + stream << (int)m_iPos; + ReplaceSubString(m_strMsg, _T("$POS$"), stream.str()); + ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok); + } + + //------------------------------------------------------------------------------ + /** \brief Copy constructor. */ + ParserError::ParserError(const ParserError& a_Obj) : + m_strMsg(a_Obj.m_strMsg), + m_strFormula(a_Obj.m_strFormula), + m_strTok(a_Obj.m_strTok), + m_iPos(a_Obj.m_iPos), + m_iErrc(a_Obj.m_iErrc), + m_ErrMsg(ParserErrorMsg::Instance()) { + } + + //------------------------------------------------------------------------------ + /** \brief Assignment operator. */ + ParserError& + ParserError::operator=(const ParserError& a_Obj) { + if (this == &a_Obj) + return *this; + + m_strMsg = a_Obj.m_strMsg; + m_strFormula = a_Obj.m_strFormula; + m_strTok = a_Obj.m_strTok; + m_iPos = a_Obj.m_iPos; + m_iErrc = a_Obj.m_iErrc; + return *this; + } + + //------------------------------------------------------------------------------ + ParserError::~ParserError() { + } + + //------------------------------------------------------------------------------ + /** \brief Replace all occurrences of a substring with another string. + \param strFind The string that shall be replaced. + \param strReplaceWith The string that should be inserted instead of strFind + */ + void + ParserError::ReplaceSubString(string_type& strSource, + const string_type& strFind, + const string_type& strReplaceWith) { + string_type strResult; + string_type::size_type iPos(0), iNext(0); + + for (;;) { + iNext = strSource.find(strFind, iPos); + strResult.append(strSource, iPos, iNext - iPos); + + if (iNext == string_type::npos) + break; + + strResult.append(strReplaceWith); + iPos = iNext + strFind.length(); + } + + strSource.swap(strResult); + } + + //------------------------------------------------------------------------------ + /** \brief Reset the error object. */ + void + ParserError::Reset() { + m_strMsg = _T(""); + m_strFormula = _T(""); + m_strTok = _T(""); + m_iPos = -1; + m_iErrc = ecUNDEFINED; + } + + //------------------------------------------------------------------------------ + /** \brief Set the expression related to this error. */ + void + ParserError::SetFormula(const string_type& a_strFormula) { + m_strFormula = a_strFormula; + } + + //------------------------------------------------------------------------------ + /** \brief gets the expression related tp this error.*/ + const string_type& + ParserError::GetExpr() const { + return m_strFormula; + } + + //------------------------------------------------------------------------------ + /** \brief Returns the message string for this error. */ + const string_type& + ParserError::GetMsg() const { + return m_strMsg; + } + + //------------------------------------------------------------------------------ + /** \brief Return the formula position related to the error. + + If the error is not related to a distinct position this will return -1 + */ + int + ParserError::GetPos() const { + return m_iPos; + } + + //------------------------------------------------------------------------------ + /** \brief Return string related with this token (if available). */ + const string_type& + ParserError::GetToken() const { + return m_strTok; + } + + //------------------------------------------------------------------------------ + /** \brief Return the error code. */ + EErrorCodes + ParserError::GetCode() const { + return m_iErrc; + } } // namespace mu #if defined(_MSC_VER) - #pragma warning(pop) +#pragma warning(pop) #endif diff --git a/libsrc/spatialdata/muparser/muParserError.h b/libsrc/spatialdata/muparser/muParserError.h index 90fbfdfa..44271658 100644 --- a/libsrc/spatialdata/muparser/muParserError.h +++ b/libsrc/spatialdata/muparser/muParserError.h @@ -1,117 +1,120 @@ /* - - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2004 - 2021 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #ifndef MU_PARSER_ERROR_H #define MU_PARSER_ERROR_H +#include +#include #include #include -#include #include -#include #include "muParserDef.h" #if defined(_MSC_VER) - #pragma warning(push) - #pragma warning(disable : 4251) // ...needs to have dll-interface to be used by clients of class ... +#pragma warning(push) +#pragma warning(disable : 4251) // ...needs to have dll-interface to be used by clients of class ... #endif /** \file - \brief This file defines the error class used by the parser. + \brief This file defines the error class used by the parser. */ -namespace mu -{ - /** \brief A class that handles the error messages. */ - class ParserErrorMsg final - { - public: - static const ParserErrorMsg& Instance(); - string_type operator[](unsigned a_iIdx) const; - - private: - ParserErrorMsg& operator=(const ParserErrorMsg&) = delete; - ParserErrorMsg(const ParserErrorMsg&) = delete; - ParserErrorMsg(); - - ~ParserErrorMsg() = default; - - std::vector m_vErrMsg; ///< A vector with the predefined error messages - }; - - - /** \brief Error class of the parser. - - Part of the math parser package. - */ - class API_EXPORT_CXX ParserError - { - private: - - /** \brief Replace all ocuurences of a substring with another string. */ - void ReplaceSubString(string_type& strSource, const string_type& strFind, const string_type& strReplaceWith); - void Reset(); - - public: - - ParserError(); - explicit ParserError(EErrorCodes a_iErrc); - explicit ParserError(const string_type& sMsg); - ParserError(EErrorCodes a_iErrc, const string_type& sTok, const string_type& sFormula = string_type(), int a_iPos = -1); - ParserError(EErrorCodes a_iErrc, int a_iPos, const string_type& sTok); - ParserError(const char_type* a_szMsg, int a_iPos = -1, const string_type& sTok = string_type()); - ParserError(const ParserError& a_Obj); - - ParserError& operator=(const ParserError& a_Obj); - ~ParserError(); - - void SetFormula(const string_type& a_strFormula); - const string_type& GetExpr() const; - const string_type& GetMsg() const; - int GetPos() const; - const string_type& GetToken() const; - EErrorCodes GetCode() const; - - private: - string_type m_strMsg; ///< The message string - string_type m_strFormula; ///< Formula string - string_type m_strTok; ///< Token related with the error - int m_iPos; ///< Formula position related to the error - EErrorCodes m_iErrc; ///< Error code - const ParserErrorMsg& m_ErrMsg; - }; +namespace mu { + /** \brief A class that handles the error messages. */ + class ParserErrorMsg final { + public: + static const ParserErrorMsg& Instance(); + string_type operator[](unsigned a_iIdx) const; + + private: + ParserErrorMsg& operator=(const ParserErrorMsg&) = delete; + ParserErrorMsg(const ParserErrorMsg&) = delete; + ParserErrorMsg(); + + ~ParserErrorMsg() = default; + + std::vector m_vErrMsg; ///< A vector with the predefined error messages + }; + + + /** \brief Error class of the parser. + + Part of the math parser package. + */ + class API_EXPORT_CXX ParserError { + private: + /** \brief Replace all ocuurences of a substring with another string. */ + void ReplaceSubString(string_type& strSource, + const string_type& strFind, + const string_type& strReplaceWith); + void Reset(); + + public: + ParserError(); + explicit ParserError(EErrorCodes a_iErrc); + explicit ParserError(const string_type& sMsg); + ParserError(EErrorCodes a_iErrc, + const string_type& sTok, + const string_type& sFormula = string_type(), + int a_iPos = -1); + ParserError(EErrorCodes a_iErrc, + int a_iPos, + const string_type& sTok); + ParserError(const char_type* a_szMsg, + int a_iPos = -1, + const string_type& sTok = string_type()); + ParserError(const ParserError& a_Obj); + + ParserError& operator=(const ParserError& a_Obj); + ~ParserError(); + + void SetFormula(const string_type& a_strFormula); + const string_type& GetExpr() const; + const string_type& GetMsg() const; + int GetPos() const; + const string_type& GetToken() const; + EErrorCodes GetCode() const; + + private: + string_type m_strMsg; ///< The message string + string_type m_strFormula; ///< Formula string + string_type m_strTok; ///< Token related with the error + int m_iPos; ///< Formula position related to the error + EErrorCodes m_iErrc; ///< Error code + const ParserErrorMsg& m_ErrMsg; + }; } // namespace mu #if defined(_MSC_VER) - #pragma warning(pop) +#pragma warning(pop) #endif #endif - diff --git a/libsrc/spatialdata/muparser/muParserFixes.h b/libsrc/spatialdata/muparser/muParserFixes.h index 8042d281..4909a0cd 100644 --- a/libsrc/spatialdata/muparser/muParserFixes.h +++ b/libsrc/spatialdata/muparser/muParserFixes.h @@ -1,36 +1,36 @@ /* - - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2004 - 2021 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #ifndef MU_PARSER_FIXES_H #define MU_PARSER_FIXES_H /** \file - \brief This file contains compatibility fixes for some platforms. + \brief This file contains compatibility fixes for some platforms. */ // @@ -40,51 +40,49 @@ /* From http://gcc.gnu.org/wiki/Visibility */ /* Generic helper definitions for shared library support */ #if defined _WIN32 || defined __CYGWIN__ - #define MUPARSER_HELPER_DLL_IMPORT __declspec(dllimport) - #define MUPARSER_HELPER_DLL_EXPORT __declspec(dllexport) - #define MUPARSER_HELPER_DLL_LOCAL +#define MUPARSER_HELPER_DLL_IMPORT __declspec(dllimport) +#define MUPARSER_HELPER_DLL_EXPORT __declspec(dllexport) +#define MUPARSER_HELPER_DLL_LOCAL +#else +#if __GNUC__ >= 4 +#define MUPARSER_HELPER_DLL_IMPORT __attribute__((visibility("default"))) +#define MUPARSER_HELPER_DLL_EXPORT __attribute__((visibility("default"))) +#define MUPARSER_HELPER_DLL_LOCAL __attribute__((visibility("hidden"))) #else - #if __GNUC__ >= 4 - #define MUPARSER_HELPER_DLL_IMPORT __attribute__ ((visibility ("default"))) - #define MUPARSER_HELPER_DLL_EXPORT __attribute__ ((visibility ("default"))) - #define MUPARSER_HELPER_DLL_LOCAL __attribute__ ((visibility ("hidden"))) - #else - #define MUPARSER_HELPER_DLL_IMPORT - #define MUPARSER_HELPER_DLL_EXPORT - #define MUPARSER_HELPER_DLL_LOCAL - #endif +#define MUPARSER_HELPER_DLL_IMPORT +#define MUPARSER_HELPER_DLL_EXPORT +#define MUPARSER_HELPER_DLL_LOCAL +#endif #endif -/* - Now we use the generic helper definitions above to define API_EXPORT_CXX and MUPARSER_LOCAL. - API_EXPORT_CXX is used for the public API symbols. It either DLL imports or DLL exports (or does nothing for static build) - MUPARSER_LOCAL is used for non-api symbols. +/* + Now we use the generic helper definitions above to define API_EXPORT_CXX and MUPARSER_LOCAL. + API_EXPORT_CXX is used for the public API symbols. It either DLL imports or DLL exports (or does nothing for + static build) MUPARSER_LOCAL is used for non-api symbols. */ #ifndef MUPARSER_STATIC /* defined if muParser is compiled as a DLL */ - #ifdef MUPARSERLIB_EXPORTS /* defined if we are building the muParser DLL (instead of using it) */ - #define API_EXPORT_CXX MUPARSER_HELPER_DLL_EXPORT - #else - #define API_EXPORT_CXX MUPARSER_HELPER_DLL_IMPORT - #endif /* MUPARSER_DLL_EXPORTS */ - #define MUPARSER_LOCAL MUPARSER_HELPER_DLL_LOCAL +#ifdef MUPARSERLIB_EXPORTS /* defined if we are building the muParser DLL (instead of using it) */ +#define API_EXPORT_CXX MUPARSER_HELPER_DLL_EXPORT +#else +#define API_EXPORT_CXX MUPARSER_HELPER_DLL_IMPORT +#endif /* MUPARSER_DLL_EXPORTS */ +#define MUPARSER_LOCAL MUPARSER_HELPER_DLL_LOCAL #else /* MUPARSER_STATIC is defined: this means muParser is a static lib. */ - #define API_EXPORT_CXX - #define MUPARSER_LOCAL +#define API_EXPORT_CXX +#define MUPARSER_LOCAL #endif /* !MUPARSER_STATIC */ #ifdef _WIN32 - #define API_EXPORT(TYPE) API_EXPORT_CXX TYPE __cdecl +#define API_EXPORT(TYPE) API_EXPORT_CXX TYPE __cdecl #else - #define API_EXPORT(TYPE) TYPE +#define API_EXPORT(TYPE) TYPE #endif #endif // include guard - - diff --git a/libsrc/spatialdata/muparser/muParserInt.cpp b/libsrc/spatialdata/muparser/muParserInt.cpp index 76189e91..c08cc74d 100644 --- a/libsrc/spatialdata/muparser/muParserInt.cpp +++ b/libsrc/spatialdata/muparser/muParserInt.cpp @@ -1,279 +1,366 @@ /* - - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2004 - 2021 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include "muParserInt.h" -#include #include +#include #include using namespace std; /** \file - \brief Implementation of a parser using integer value. + \brief Implementation of a parser using integer value. */ /** \brief Namespace for mathematical applications. */ -namespace mu -{ - value_type ParserInt::Abs(value_type v) { return (value_type)Round(fabs((double)v)); } - value_type ParserInt::Sign(value_type v) { return (Round(v) < 0) ? -1 : (Round(v) > 0) ? 1 : 0; } - value_type ParserInt::Ite(value_type v1, value_type v2, value_type v3) { return (Round(v1) == 1) ? Round(v2) : Round(v3); } - value_type ParserInt::Add(value_type v1, value_type v2) { return Round(v1) + Round(v2); } - value_type ParserInt::Sub(value_type v1, value_type v2) { return Round(v1) - Round(v2); } - value_type ParserInt::Mul(value_type v1, value_type v2) { return Round(v1) * Round(v2); } - value_type ParserInt::Div(value_type v1, value_type v2) { return Round(v1) / Round(v2); } - value_type ParserInt::Mod(value_type v1, value_type v2) { return Round(v1) % Round(v2); } - value_type ParserInt::Shr(value_type v1, value_type v2) { return Round(v1) >> Round(v2); } - value_type ParserInt::Shl(value_type v1, value_type v2) { return Round(v1) << Round(v2); } - value_type ParserInt::LogAnd(value_type v1, value_type v2) { return Round(v1) & Round(v2); } - value_type ParserInt::LogOr(value_type v1, value_type v2) { return Round(v1) | Round(v2); } - value_type ParserInt::And(value_type v1, value_type v2) { return Round(v1) && Round(v2); } - value_type ParserInt::Or(value_type v1, value_type v2) { return Round(v1) || Round(v2); } - value_type ParserInt::Less(value_type v1, value_type v2) { return Round(v1) < Round(v2); } - value_type ParserInt::Greater(value_type v1, value_type v2) { return Round(v1) > Round(v2); } - value_type ParserInt::LessEq(value_type v1, value_type v2) { return Round(v1) <= Round(v2); } - value_type ParserInt::GreaterEq(value_type v1, value_type v2) { return Round(v1) >= Round(v2); } - value_type ParserInt::Equal(value_type v1, value_type v2) { return Round(v1) == Round(v2); } - value_type ParserInt::NotEqual(value_type v1, value_type v2) { return Round(v1) != Round(v2); } - value_type ParserInt::Not(value_type v) { return !Round(v); } - - value_type ParserInt::Pow(value_type v1, value_type v2) - { - return std::pow((double)Round(v1), (double)Round(v2)); - } - - - value_type ParserInt::UnaryMinus(value_type v) - { - return -Round(v); - } - - - value_type ParserInt::Sum(const value_type* a_afArg, int a_iArgc) - { - if (!a_iArgc) - throw ParserError(_T("too few arguments for function sum.")); - - value_type fRes = 0; - for (int i = 0; i < a_iArgc; ++i) - fRes += a_afArg[i]; - - return fRes; - } - - - value_type ParserInt::Min(const value_type* a_afArg, int a_iArgc) - { - if (!a_iArgc) - throw ParserError(_T("too few arguments for function min.")); - - value_type fRes = a_afArg[0]; - for (int i = 0; i < a_iArgc; ++i) - fRes = std::min(fRes, a_afArg[i]); - - return fRes; - } - - - value_type ParserInt::Max(const value_type* a_afArg, int a_iArgc) - { - if (!a_iArgc) - throw ParserError(_T("too few arguments for function min.")); - - value_type fRes = a_afArg[0]; - for (int i = 0; i < a_iArgc; ++i) - fRes = std::max(fRes, a_afArg[i]); - - return fRes; - } - - - int ParserInt::IsVal(const char_type* a_szExpr, int* a_iPos, value_type* a_fVal) - { - string_type buf(a_szExpr); - std::size_t pos = buf.find_first_not_of(_T("0123456789")); - - if (pos == std::string::npos) - return 0; - - stringstream_type stream(buf.substr(0, pos)); - int iVal(0); - - stream >> iVal; - if (stream.fail()) - return 0; - - stringstream_type::pos_type iEnd = stream.tellg(); // Position after reading - if (stream.fail()) - iEnd = stream.str().length(); - - if (iEnd == (stringstream_type::pos_type) - 1) - return 0; - - *a_iPos += (int)iEnd; - *a_fVal = (value_type)iVal; - return 1; - } - - - /** \brief Check a given position in the expression for the presence of - a hex value. - \param a_szExpr Pointer to the expression string - \param [in/out] a_iPos Pointer to an integer value holding the current parsing - position in the expression. - \param [out] a_fVal Pointer to the position where the detected value shall be stored. - - Hey values must be prefixed with "0x" in order to be detected properly. - */ - int ParserInt::IsHexVal(const char_type* a_szExpr, int* a_iPos, value_type* a_fVal) - { - if (a_szExpr[1] == 0 || (a_szExpr[0] != '0' || a_szExpr[1] != 'x')) - return 0; +namespace mu { + value_type + ParserInt::Abs(value_type v) { + return (value_type)Round(fabs((double)v)); + } + value_type + ParserInt::Sign(value_type v) { + return (Round(v) < 0) ? -1 : (Round(v) > 0) ? 1 : 0; + } + value_type + ParserInt::Ite(value_type v1, + value_type v2, + value_type v3) { + return (Round(v1) == 1) ? Round(v2) : Round(v3); + } + value_type + ParserInt::Add(value_type v1, + value_type v2) { + return Round(v1) + Round(v2); + } + value_type + ParserInt::Sub(value_type v1, + value_type v2) { + return Round(v1) - Round(v2); + } + value_type + ParserInt::Mul(value_type v1, + value_type v2) { + return Round(v1) * Round(v2); + } + value_type + ParserInt::Div(value_type v1, + value_type v2) { + return Round(v1) / Round(v2); + } + value_type + ParserInt::Mod(value_type v1, + value_type v2) { + return Round(v1) % Round(v2); + } + value_type + ParserInt::Shr(value_type v1, + value_type v2) { + return Round(v1) >> Round(v2); + } + value_type + ParserInt::Shl(value_type v1, + value_type v2) { + return Round(v1) << Round(v2); + } + value_type + ParserInt::LogAnd(value_type v1, + value_type v2) { + return Round(v1) & Round(v2); + } + value_type + ParserInt::LogOr(value_type v1, + value_type v2) { + return Round(v1) | Round(v2); + } + value_type + ParserInt::And(value_type v1, + value_type v2) { + return Round(v1) && Round(v2); + } + value_type + ParserInt::Or(value_type v1, + value_type v2) { + return Round(v1) || Round(v2); + } + value_type + ParserInt::Less(value_type v1, + value_type v2) { + return Round(v1) < Round(v2); + } + value_type + ParserInt::Greater(value_type v1, + value_type v2) { + return Round(v1) > Round(v2); + } + value_type + ParserInt::LessEq(value_type v1, + value_type v2) { + return Round(v1) <= Round(v2); + } + value_type + ParserInt::GreaterEq(value_type v1, + value_type v2) { + return Round(v1) >= Round(v2); + } + value_type + ParserInt::Equal(value_type v1, + value_type v2) { + return Round(v1) == Round(v2); + } + value_type + ParserInt::NotEqual(value_type v1, + value_type v2) { + return Round(v1) != Round(v2); + } + value_type + ParserInt::Not(value_type v) { + return !Round(v); + } + + value_type + ParserInt::Pow(value_type v1, + value_type v2) { + return std::pow((double)Round(v1), (double)Round(v2)); + } + + + value_type + ParserInt::UnaryMinus(value_type v) { + return -Round(v); + } + + + value_type + ParserInt::Sum(const value_type* a_afArg, + int a_iArgc) { + if (!a_iArgc) + throw ParserError(_T("too few arguments for function sum.")); + + value_type fRes = 0; + for (int i = 0; i < a_iArgc; ++i) + fRes += a_afArg[i]; + + return fRes; + } + + + value_type + ParserInt::Min(const value_type* a_afArg, + int a_iArgc) { + if (!a_iArgc) + throw ParserError(_T("too few arguments for function min.")); + + value_type fRes = a_afArg[0]; + for (int i = 0; i < a_iArgc; ++i) + fRes = std::min(fRes, a_afArg[i]); + + return fRes; + } + + + value_type + ParserInt::Max(const value_type* a_afArg, + int a_iArgc) { + if (!a_iArgc) + throw ParserError(_T("too few arguments for function min.")); + + value_type fRes = a_afArg[0]; + for (int i = 0; i < a_iArgc; ++i) + fRes = std::max(fRes, a_afArg[i]); + + return fRes; + } + + + int + ParserInt::IsVal(const char_type* a_szExpr, + int* a_iPos, + value_type* a_fVal) { + string_type buf(a_szExpr); + std::size_t pos = buf.find_first_not_of(_T("0123456789")); + + if (pos == std::string::npos) + return 0; + + stringstream_type stream(buf.substr(0, pos)); + int iVal(0); + + stream >> iVal; + if (stream.fail()) + return 0; + + stringstream_type::pos_type iEnd = stream.tellg(); // Position after reading + if (stream.fail()) + iEnd = stream.str().length(); + + if (iEnd == (stringstream_type::pos_type)-1) + return 0; + + *a_iPos += (int)iEnd; + *a_fVal = (value_type)iVal; + return 1; + } - unsigned iVal(0); - // New code based on streams for UNICODE compliance: - stringstream_type::pos_type nPos(0); - stringstream_type ss(a_szExpr + 2); - ss >> std::hex >> iVal; - nPos = ss.tellg(); + /** \brief Check a given position in the expression for the presence of + a hex value. + \param a_szExpr Pointer to the expression string + \param [in/out] a_iPos Pointer to an integer value holding the current parsing + position in the expression. + \param [out] a_fVal Pointer to the position where the detected value shall be stored. - if (nPos == (stringstream_type::pos_type)0) - return 1; + Hey values must be prefixed with "0x" in order to be detected properly. + */ + int + ParserInt::IsHexVal(const char_type* a_szExpr, + int* a_iPos, + value_type* a_fVal) { + if (a_szExpr[1] == 0 || (a_szExpr[0] != '0' || a_szExpr[1] != 'x')) + return 0; - *a_iPos += (int)(2 + nPos); - *a_fVal = (value_type)iVal; - return 1; - } + unsigned iVal(0); + // New code based on streams for UNICODE compliance: + stringstream_type::pos_type nPos(0); + stringstream_type ss(a_szExpr + 2); + ss >> std::hex >> iVal; + nPos = ss.tellg(); - int ParserInt::IsBinVal(const char_type* a_szExpr, int* a_iPos, value_type* a_fVal) - { - if (a_szExpr[0] != '#') - return 0; + if (nPos == (stringstream_type::pos_type)0) + return 1; - unsigned iVal(0), - iBits(sizeof(iVal) * 8), - i(0); + *a_iPos += (int)(2 + nPos); + *a_fVal = (value_type)iVal; + return 1; + } - for (i = 0; (a_szExpr[i + 1] == '0' || a_szExpr[i + 1] == '1') && i < iBits; ++i) - iVal |= (int)(a_szExpr[i + 1] == '1') << ((iBits - 1) - i); - if (i == 0) - return 0; + int + ParserInt::IsBinVal(const char_type* a_szExpr, + int* a_iPos, + value_type* a_fVal) { + if (a_szExpr[0] != '#') + return 0; - if (i == iBits) - throw exception_type(_T("Binary to integer conversion error (overflow).")); + unsigned iVal(0), iBits(sizeof(iVal) * 8), i(0); - *a_fVal = (unsigned)(iVal >> (iBits - i)); - *a_iPos += i + 1; + for (i = 0; (a_szExpr[i + 1] == '0' || a_szExpr[i + 1] == '1') && i < iBits; ++i) + iVal |= (int)(a_szExpr[i + 1] == '1') << ((iBits - 1) - i); - return 1; - } + if (i == 0) + return 0; + if (i == iBits) + throw exception_type(_T("Binary to integer conversion error (overflow).")); - /** \brief Constructor. + *a_fVal = (unsigned)(iVal >> (iBits - i)); + *a_iPos += i + 1; - Call ParserBase class constructor and trigger Function, Operator and Constant initialization. - */ - ParserInt::ParserInt() - :ParserBase() - { - AddValIdent(IsVal); // lowest priority - AddValIdent(IsBinVal); - AddValIdent(IsHexVal); // highest priority + return 1; + } + + + /** \brief Constructor. - InitCharSets(); - InitFun(); - InitOprt(); - } + Call ParserBase class constructor and trigger Function, Operator and Constant initialization. + */ + ParserInt::ParserInt() : ParserBase() { + AddValIdent(IsVal); // lowest priority + AddValIdent(IsBinVal); + AddValIdent(IsHexVal); // highest priority + InitCharSets(); + InitFun(); + InitOprt(); + } + + + void + ParserInt::InitConst() { + } - void ParserInt::InitConst() - { - } - - - void ParserInt::InitCharSets() - { - DefineNameChars(_T("0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")); - DefineOprtChars(_T("+-*^/?<>=!%&|~'_")); - DefineInfixOprtChars(_T("/+-*^?<>=!%&|~'_")); - } - - - /** \brief Initialize the default functions. */ - void ParserInt::InitFun() - { - DefineFun(_T("sign"), Sign); - DefineFun(_T("abs"), Abs); - DefineFun(_T("if"), Ite); - DefineFun(_T("sum"), Sum); - DefineFun(_T("min"), Min); - DefineFun(_T("max"), Max); - } - - - /** \brief Initialize operators. */ - void ParserInt::InitOprt() - { - // disable all built in operators, not all of them useful for integer numbers - // (they don't do rounding of values) - EnableBuiltInOprt(false); - - // Disable all built in operators, they won't work with integer numbers - // since they are designed for floating point numbers - DefineInfixOprt(_T("-"), UnaryMinus); - DefineInfixOprt(_T("!"), Not); - - DefineOprt(_T("&"), LogAnd, prLOGIC); - DefineOprt(_T("|"), LogOr, prLOGIC); - DefineOprt(_T("&&"), And, prLOGIC); - DefineOprt(_T("||"), Or, prLOGIC); - DefineOprt(_T("<"), Less, prCMP); - DefineOprt(_T(">"), Greater, prCMP); - DefineOprt(_T("<="), LessEq, prCMP); - DefineOprt(_T(">="), GreaterEq, prCMP); - DefineOprt(_T("=="), Equal, prCMP); - DefineOprt(_T("!="), NotEqual, prCMP); + void + ParserInt::InitCharSets() { + DefineNameChars(_T("0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")); + DefineOprtChars(_T("+-*^/?<>=!%&|~'_")); + DefineInfixOprtChars(_T("/+-*^?<>=!%&|~'_")); + } + + + /** \brief Initialize the default functions. */ + void + ParserInt::InitFun() { + DefineFun(_T("sign"), Sign); + DefineFun(_T("abs"), Abs); + DefineFun(_T("if"), Ite); + DefineFun(_T("sum"), Sum); + DefineFun(_T("min"), Min); + DefineFun(_T("max"), Max); + } + + + /** \brief Initialize operators. */ + void + ParserInt::InitOprt() { + // disable all built in operators, not all of them useful for integer numbers + // (they don't do rounding of values) + EnableBuiltInOprt(false); + + // Disable all built in operators, they won't work with integer numbers + // since they are designed for floating point numbers + DefineInfixOprt(_T("-"), UnaryMinus); + DefineInfixOprt(_T("!"), Not); + + DefineOprt(_T("&"), LogAnd, prLOGIC); + DefineOprt(_T("|"), LogOr, prLOGIC); + DefineOprt(_T("&&"), And, prLOGIC); + DefineOprt(_T("||"), Or, prLOGIC); + + DefineOprt(_T("<"), Less, prCMP); + DefineOprt(_T(">"), Greater, prCMP); + DefineOprt(_T("<="), LessEq, prCMP); + DefineOprt(_T(">="), GreaterEq, prCMP); + DefineOprt(_T("=="), Equal, prCMP); + DefineOprt(_T("!="), NotEqual, prCMP); - DefineOprt(_T("+"), Add, prADD_SUB); - DefineOprt(_T("-"), Sub, prADD_SUB); + DefineOprt(_T("+"), Add, prADD_SUB); + DefineOprt(_T("-"), Sub, prADD_SUB); - DefineOprt(_T("*"), Mul, prMUL_DIV); - DefineOprt(_T("/"), Div, prMUL_DIV); - DefineOprt(_T("%"), Mod, prMUL_DIV); + DefineOprt(_T("*"), Mul, prMUL_DIV); + DefineOprt(_T("/"), Div, prMUL_DIV); + DefineOprt(_T("%"), Mod, prMUL_DIV); - DefineOprt(_T("^"), Pow, prPOW, oaRIGHT); - DefineOprt(_T(">>"), Shr, prMUL_DIV + 1); - DefineOprt(_T("<<"), Shl, prMUL_DIV + 1); - } + DefineOprt(_T("^"), Pow, prPOW, oaRIGHT); + DefineOprt(_T(">>"), Shr, prMUL_DIV + 1); + DefineOprt(_T("<<"), Shl, prMUL_DIV + 1); + } } // namespace mu diff --git a/libsrc/spatialdata/muparser/muParserInt.h b/libsrc/spatialdata/muparser/muParserInt.h index 513f0926..99191e13 100644 --- a/libsrc/spatialdata/muparser/muParserInt.h +++ b/libsrc/spatialdata/muparser/muParserInt.h @@ -1,30 +1,30 @@ /* - - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2004 - 2021 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #ifndef MU_PARSER_INT_H #define MU_PARSER_INT_H @@ -34,110 +34,137 @@ /** \file - \brief Definition of a parser using integer value. + \brief Definition of a parser using integer value. */ -namespace mu -{ - - /** \brief Mathematical expressions parser. - - This version of the parser handles only integer numbers. It disables the built in operators thus it is - slower than muParser. Integer values are stored in the double value_type and converted if needed. - */ - class ParserInt : public ParserBase - { - private: - static int Round(value_type v) { return (int)(v + ((v >= 0) ? 0.5 : -0.5)); }; - - static value_type Abs(value_type); - static value_type Sign(value_type); - static value_type Ite(value_type, value_type, value_type); - // !! The unary Minus is a MUST, otherwise you can't use negative signs !! - static value_type UnaryMinus(value_type); - // Functions with variable number of arguments - static value_type Sum(const value_type* a_afArg, int a_iArgc); // sum - static value_type Min(const value_type* a_afArg, int a_iArgc); // minimum - static value_type Max(const value_type* a_afArg, int a_iArgc); // maximum - // binary operator callbacks - static value_type Add(value_type v1, value_type v2); - static value_type Sub(value_type v1, value_type v2); - static value_type Mul(value_type v1, value_type v2); - static value_type Div(value_type v1, value_type v2); - static value_type Mod(value_type v1, value_type v2); - static value_type Pow(value_type v1, value_type v2); - static value_type Shr(value_type v1, value_type v2); - static value_type Shl(value_type v1, value_type v2); - static value_type LogAnd(value_type v1, value_type v2); - static value_type LogOr(value_type v1, value_type v2); - static value_type And(value_type v1, value_type v2); - static value_type Or(value_type v1, value_type v2); - static value_type Xor(value_type v1, value_type v2); - static value_type Less(value_type v1, value_type v2); - static value_type Greater(value_type v1, value_type v2); - static value_type LessEq(value_type v1, value_type v2); - static value_type GreaterEq(value_type v1, value_type v2); - static value_type Equal(value_type v1, value_type v2); - static value_type NotEqual(value_type v1, value_type v2); - static value_type Not(value_type v1); - - static int IsHexVal(const char_type* a_szExpr, int* a_iPos, value_type* a_iVal); - static int IsBinVal(const char_type* a_szExpr, int* a_iPos, value_type* a_iVal); - static int IsVal(const char_type* a_szExpr, int* a_iPos, value_type* a_iVal); - - /** \brief A facet class used to change decimal and thousands separator. */ - template - class change_dec_sep : public std::numpunct - { - public: - - explicit change_dec_sep(char_type cDecSep, char_type cThousandsSep = 0, int nGroup = 3) - :std::numpunct() - , m_cDecPoint(cDecSep) - , m_cThousandsSep(cThousandsSep) - , m_nGroup(nGroup) - {} - - protected: - - virtual char_type do_decimal_point() const - { - return m_cDecPoint; - } - - virtual char_type do_thousands_sep() const - { - return m_cThousandsSep; - } - - virtual std::string do_grouping() const - { - // fix for issue 4: https://code.google.com/p/muparser/issues/detail?id=4 - // courtesy of Jens Bartsch - // original code: - // return std::string(1, (char)m_nGroup); - // new code: - return std::string(1, (char)(m_cThousandsSep > 0 ? m_nGroup : CHAR_MAX)); - } - - private: - - int m_nGroup; - char_type m_cDecPoint; - char_type m_cThousandsSep; - }; - - public: - ParserInt(); - - void InitFun() override; - void InitOprt() override; - void InitConst() override; - void InitCharSets() override; - }; +namespace mu { + + /** \brief Mathematical expressions parser. + + This version of the parser handles only integer numbers. It disables the built in operators thus it is + slower than muParser. Integer values are stored in the double value_type and converted if needed. + */ + class ParserInt : public ParserBase { + private: + static int + Round(value_type v) { + return (int)(v + ((v >= 0) ? 0.5 : -0.5)); + }; + + static value_type Abs(value_type); + static value_type Sign(value_type); + static value_type Ite(value_type, + value_type, + value_type); + // !! The unary Minus is a MUST, otherwise you can't use negative signs !! + static value_type UnaryMinus(value_type); + // Functions with variable number of arguments + static value_type Sum(const value_type* a_afArg, + int a_iArgc); // sum + static value_type Min(const value_type* a_afArg, + int a_iArgc); // minimum + static value_type Max(const value_type* a_afArg, + int a_iArgc); // maximum + // binary operator callbacks + static value_type Add(value_type v1, + value_type v2); + static value_type Sub(value_type v1, + value_type v2); + static value_type Mul(value_type v1, + value_type v2); + static value_type Div(value_type v1, + value_type v2); + static value_type Mod(value_type v1, + value_type v2); + static value_type Pow(value_type v1, + value_type v2); + static value_type Shr(value_type v1, + value_type v2); + static value_type Shl(value_type v1, + value_type v2); + static value_type LogAnd(value_type v1, + value_type v2); + static value_type LogOr(value_type v1, + value_type v2); + static value_type And(value_type v1, + value_type v2); + static value_type Or(value_type v1, + value_type v2); + static value_type Xor(value_type v1, + value_type v2); + static value_type Less(value_type v1, + value_type v2); + static value_type Greater(value_type v1, + value_type v2); + static value_type LessEq(value_type v1, + value_type v2); + static value_type GreaterEq(value_type v1, + value_type v2); + static value_type Equal(value_type v1, + value_type v2); + static value_type NotEqual(value_type v1, + value_type v2); + static value_type Not(value_type v1); + + static int IsHexVal(const char_type* a_szExpr, + int* a_iPos, + value_type* a_iVal); + static int IsBinVal(const char_type* a_szExpr, + int* a_iPos, + value_type* a_iVal); + static int IsVal(const char_type* a_szExpr, + int* a_iPos, + value_type* a_iVal); + + /** \brief A facet class used to change decimal and thousands separator. */ + template class change_dec_sep : public std::numpunct { + public: + explicit change_dec_sep(char_type cDecSep, + char_type cThousandsSep = 0, + int nGroup = 3) : + std::numpunct(), + m_cDecPoint(cDecSep), + m_cThousandsSep(cThousandsSep), + m_nGroup(nGroup) { + } + + protected: + virtual char_type + do_decimal_point() const { + return m_cDecPoint; + } + + virtual char_type + do_thousands_sep() const { + return m_cThousandsSep; + } + + virtual std::string + do_grouping() const { + // fix for issue 4: https://code.google.com/p/muparser/issues/detail?id=4 + // courtesy of Jens Bartsch + // original code: + // return std::string(1, (char)m_nGroup); + // new code: + return std::string(1, (char)(m_cThousandsSep > 0 ? m_nGroup : CHAR_MAX)); + } + + private: + int m_nGroup; + char_type m_cDecPoint; + char_type m_cThousandsSep; + }; + + public: + ParserInt(); + + void InitFun() override; + void InitOprt() override; + void InitConst() override; + void InitCharSets() override; + }; } // namespace mu #endif - diff --git a/libsrc/spatialdata/muparser/muParserTemplateMagic.h b/libsrc/spatialdata/muparser/muParserTemplateMagic.h index 77fe5493..26446580 100644 --- a/libsrc/spatialdata/muparser/muParserTemplateMagic.h +++ b/libsrc/spatialdata/muparser/muParserTemplateMagic.h @@ -1,198 +1,285 @@ /* - - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2004 - 2021 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #ifndef MU_PARSER_TEMPLATE_MAGIC_H #define MU_PARSER_TEMPLATE_MAGIC_H -#include #include "muParserError.h" +#include -namespace mu -{ - //----------------------------------------------------------------------------------------------- - // - // Compile time type detection - // - //----------------------------------------------------------------------------------------------- - - /** \brief A class singling out integer types at compile time using - template meta programming. - */ - template - struct TypeInfo - { - static bool IsInteger() { return false; } - }; - - template<> - struct TypeInfo - { - static bool IsInteger() { return true; } - }; - - template<> - struct TypeInfo - { - static bool IsInteger() { return true; } - }; - - template<> - struct TypeInfo - { - static bool IsInteger() { return true; } - }; - - template<> - struct TypeInfo - { - static bool IsInteger() { return true; } - }; - - template<> - struct TypeInfo - { - static bool IsInteger() { return true; } - }; - - template<> - struct TypeInfo - { - static bool IsInteger() { return true; } - }; - - template<> - struct TypeInfo - { - static bool IsInteger() { return true; } - }; - - template<> - struct TypeInfo - { - static bool IsInteger() { return true; } - }; - - - //----------------------------------------------------------------------------------------------- - // - // Standard math functions with dummy overload for integer types - // - //----------------------------------------------------------------------------------------------- - - /** \brief A template class for providing wrappers for essential math functions. - - This template is spezialized for several types in order to provide a unified interface - for parser internal math function calls regardless of the data type. - */ - template - struct MathImpl - { - static T Sin(T v) { return sin(v); } - static T Cos(T v) { return cos(v); } - static T Tan(T v) { return tan(v); } - static T ASin(T v) { return asin(v); } - static T ACos(T v) { return acos(v); } - static T ATan(T v) { return atan(v); } - static T ATan2(T v1, T v2) { return atan2(v1, v2); } - static T Sinh(T v) { return sinh(v); } - static T Cosh(T v) { return cosh(v); } - static T Tanh(T v) { return tanh(v); } - static T ASinh(T v) { return log(v + sqrt(v * v + 1)); } - static T ACosh(T v) { return log(v + sqrt(v * v - 1)); } - static T ATanh(T v) { return ((T)0.5 * log((1 + v) / (1 - v))); } - static T Log(T v) { return log(v); } - static T Log2(T v) { return log(v) / log((T)2); } // Logarithm base 2 - static T Log10(T v) { return log10(v); } // Logarithm base 10 - static T Exp(T v) { return exp(v); } - static T Abs(T v) { return (v >= 0) ? v : -v; } - static T Sqrt(T v) { return sqrt(v); } - static T Rint(T v) { return floor(v + (T)0.5); } - static T Sign(T v) { return (T)((v < 0) ? -1 : (v > 0) ? 1 : 0); } - static T Pow(T v1, T v2) { return std::pow(v1, v2); } - - static T UnaryMinus(T v) { return -v; } - static T UnaryPlus(T v) { return v; } - - static T Sum(const T *a_afArg, int a_iArgc) - { - if (!a_iArgc) - throw ParserError(_T("too few arguments for function sum.")); - - T fRes = 0; - for (int i = 0; i < a_iArgc; ++i) fRes += a_afArg[i]; - return fRes; - } - - static T Avg(const T *a_afArg, int a_iArgc) - { - if (!a_iArgc) - throw ParserError(_T("too few arguments for function avg.")); - - T fRes = 0; - for (int i = 0; i < a_iArgc; ++i) fRes += a_afArg[i]; - return fRes / (T)a_iArgc; - } - - static T Min(const T *a_afArg, int a_iArgc) - { - if (!a_iArgc) - throw ParserError(_T("too few arguments for function min.")); - - T fRes = a_afArg[0]; - for (int i = 0; i < a_iArgc; ++i) - fRes = std::min(fRes, a_afArg[i]); - - return fRes; - } - - static T Max(const T *a_afArg, int a_iArgc) - { - if (!a_iArgc) - throw ParserError(_T("too few arguments for function max.")); - - T fRes = a_afArg[0]; - for (int i = 0; i < a_iArgc; ++i) fRes = std::max(fRes, a_afArg[i]); - - return fRes; - } - - -#if defined (__GNUG__) - // Bei zu genauer definition von pi kann die Berechnung von - // sin(pi*a) mit a=1 10 x langsamer sein! - static constexpr T CONST_PI = (T)3.141592653589; +namespace mu { + //----------------------------------------------------------------------------------------------- + // + // Compile time type detection + // + //----------------------------------------------------------------------------------------------- + + /** \brief A class singling out integer types at compile time using + template meta programming. + */ + template struct TypeInfo { + static bool + IsInteger() { + return false; + } + }; + + template <> struct TypeInfo { + static bool + IsInteger() { + return true; + } + }; + + template <> struct TypeInfo { + static bool + IsInteger() { + return true; + } + }; + + template <> struct TypeInfo { + static bool + IsInteger() { + return true; + } + }; + + template <> struct TypeInfo { + static bool + IsInteger() { + return true; + } + }; + + template <> struct TypeInfo { + static bool + IsInteger() { + return true; + } + }; + + template <> struct TypeInfo { + static bool + IsInteger() { + return true; + } + }; + + template <> struct TypeInfo { + static bool + IsInteger() { + return true; + } + }; + + template <> struct TypeInfo { + static bool + IsInteger() { + return true; + } + }; + + + //----------------------------------------------------------------------------------------------- + // + // Standard math functions with dummy overload for integer types + // + //----------------------------------------------------------------------------------------------- + + /** \brief A template class for providing wrappers for essential math functions. + + This template is spezialized for several types in order to provide a unified interface + for parser internal math function calls regardless of the data type. + */ + template struct MathImpl { + static T + Sin(T v) { + return sin(v); + } + static T + Cos(T v) { + return cos(v); + } + static T + Tan(T v) { + return tan(v); + } + static T + ASin(T v) { + return asin(v); + } + static T + ACos(T v) { + return acos(v); + } + static T + ATan(T v) { + return atan(v); + } + static T + ATan2(T v1, + T v2) { + return atan2(v1, v2); + } + static T + Sinh(T v) { + return sinh(v); + } + static T + Cosh(T v) { + return cosh(v); + } + static T + Tanh(T v) { + return tanh(v); + } + static T + ASinh(T v) { + return log(v + sqrt(v * v + 1)); + } + static T + ACosh(T v) { + return log(v + sqrt(v * v - 1)); + } + static T + ATanh(T v) { + return ((T)0.5 * log((1 + v) / (1 - v))); + } + static T + Log(T v) { + return log(v); + } + static T + Log2(T v) { + return log(v) / log((T)2); + } // Logarithm base 2 + static T + Log10(T v) { + return log10(v); + } // Logarithm base 10 + static T + Exp(T v) { + return exp(v); + } + static T + Abs(T v) { + return (v >= 0) ? v : -v; + } + static T + Sqrt(T v) { + return sqrt(v); + } + static T + Rint(T v) { + return floor(v + (T)0.5); + } + static T + Sign(T v) { + return (T)((v < 0) ? -1 : (v > 0) ? 1 : 0); + } + static T + Pow(T v1, + T v2) { + return std::pow(v1, v2); + } + + static T + UnaryMinus(T v) { + return -v; + } + static T + UnaryPlus(T v) { + return v; + } + + static T + Sum(const T* a_afArg, + int a_iArgc) { + if (!a_iArgc) + throw ParserError(_T("too few arguments for function sum.")); + + T fRes = 0; + for (int i = 0; i < a_iArgc; ++i) + fRes += a_afArg[i]; + return fRes; + } + + static T + Avg(const T* a_afArg, + int a_iArgc) { + if (!a_iArgc) + throw ParserError(_T("too few arguments for function avg.")); + + T fRes = 0; + for (int i = 0; i < a_iArgc; ++i) + fRes += a_afArg[i]; + return fRes / (T)a_iArgc; + } + + static T + Min(const T* a_afArg, + int a_iArgc) { + if (!a_iArgc) + throw ParserError(_T("too few arguments for function min.")); + + T fRes = a_afArg[0]; + for (int i = 0; i < a_iArgc; ++i) + fRes = std::min(fRes, a_afArg[i]); + + return fRes; + } + + static T + Max(const T* a_afArg, + int a_iArgc) { + if (!a_iArgc) + throw ParserError(_T("too few arguments for function max.")); + + T fRes = a_afArg[0]; + for (int i = 0; i < a_iArgc; ++i) + fRes = std::max(fRes, a_afArg[i]); + + return fRes; + } + + +#if defined(__GNUG__) + // Bei zu genauer definition von pi kann die Berechnung von + // sin(pi*a) mit a=1 10 x langsamer sein! + static constexpr T CONST_PI = (T)3.141592653589; #else - static constexpr T CONST_PI = (T)3.141592653589793238462643; + static constexpr T CONST_PI = (T)3.141592653589793238462643; #endif - static constexpr T CONST_E = (T)2.718281828459045235360287; - }; -} + static constexpr T CONST_E = (T)2.718281828459045235360287; + }; +} // namespace mu #endif diff --git a/libsrc/spatialdata/muparser/muParserToken.h b/libsrc/spatialdata/muparser/muParserToken.h index 7410a65e..c9ec53d3 100644 --- a/libsrc/spatialdata/muparser/muParserToken.h +++ b/libsrc/spatialdata/muparser/muParserToken.h @@ -1,524 +1,588 @@ /* - - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2004 - 2021 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #ifndef MU_PARSER_TOKEN_H #define MU_PARSER_TOKEN_H -#include -#include -#include +#include #include -#include +#include +#include #include -#include +#include +#include #if defined(_MSC_VER) - #pragma warning(push) - #pragma warning(disable : 26812) +#pragma warning(push) +#pragma warning(disable : 26812) #endif -#include "muParserError.h" #include "muParserCallback.h" +#include "muParserError.h" /** \file - \brief This file contains the parser token definition. + \brief This file contains the parser token definition. */ -namespace mu -{ - template struct TplCallType; - template <> struct TplCallType<0> { using fun_type = fun_type0; using fun_userdata_type = fun_userdata_type0; using bulkfun_type = bulkfun_type0; using bulkfun_userdata_type = bulkfun_userdata_type0; }; - template <> struct TplCallType<1> { using fun_type = fun_type1; using fun_userdata_type = fun_userdata_type1; using bulkfun_type = bulkfun_type1; using bulkfun_userdata_type = bulkfun_userdata_type1; using strfun_type = strfun_type1; using strfun_userdata_type = strfun_userdata_type1; }; - template <> struct TplCallType<2> { using fun_type = fun_type2; using fun_userdata_type = fun_userdata_type2; using bulkfun_type = bulkfun_type2; using bulkfun_userdata_type = bulkfun_userdata_type2; using strfun_type = strfun_type2; using strfun_userdata_type = strfun_userdata_type2; }; - template <> struct TplCallType<3> { using fun_type = fun_type3; using fun_userdata_type = fun_userdata_type3; using bulkfun_type = bulkfun_type3; using bulkfun_userdata_type = bulkfun_userdata_type3; using strfun_type = strfun_type3; using strfun_userdata_type = strfun_userdata_type3; }; - template <> struct TplCallType<4> { using fun_type = fun_type4; using fun_userdata_type = fun_userdata_type4; using bulkfun_type = bulkfun_type4; using bulkfun_userdata_type = bulkfun_userdata_type4; using strfun_type = strfun_type4; using strfun_userdata_type = strfun_userdata_type4; }; - template <> struct TplCallType<5> { using fun_type = fun_type5; using fun_userdata_type = fun_userdata_type5; using bulkfun_type = bulkfun_type5; using bulkfun_userdata_type = bulkfun_userdata_type5; using strfun_type = strfun_type5; using strfun_userdata_type = strfun_userdata_type5; }; - template <> struct TplCallType<6> { using fun_type = fun_type6; using fun_userdata_type = fun_userdata_type6; using bulkfun_type = bulkfun_type6; using bulkfun_userdata_type = bulkfun_userdata_type6; using strfun_type = strfun_type6; using strfun_userdata_type = strfun_userdata_type6; }; - template <> struct TplCallType<7> { using fun_type = fun_type7; using fun_userdata_type = fun_userdata_type7; using bulkfun_type = bulkfun_type7; using bulkfun_userdata_type = bulkfun_userdata_type7; }; - template <> struct TplCallType<8> { using fun_type = fun_type8; using fun_userdata_type = fun_userdata_type8; using bulkfun_type = bulkfun_type8; using bulkfun_userdata_type = bulkfun_userdata_type8; }; - template <> struct TplCallType<9> { using fun_type = fun_type9; using fun_userdata_type = fun_userdata_type9; using bulkfun_type = bulkfun_type9; using bulkfun_userdata_type = bulkfun_userdata_type9; }; - template <> struct TplCallType<10> { using fun_type = fun_type10; using fun_userdata_type = fun_userdata_type10; using bulkfun_type = bulkfun_type10; using bulkfun_userdata_type = bulkfun_userdata_type10; }; - - struct generic_callable_type - { - // Note: we keep generic_callable_type a pod for the purpose of layout - - erased_fun_type _pRawFun; - void* _pUserData; - - template - value_type call_fun(Args&&... args) const - { - static_assert(NbParams == sizeof...(Args), "mismatch between NbParams and Args"); - if (_pUserData == nullptr) - { - auto fun_typed_ptr = reinterpret_cast::fun_type>(_pRawFun); - return (*fun_typed_ptr)(std::forward(args)...); - } - else - { - auto fun_userdata_typed_ptr = reinterpret_cast::fun_userdata_type>(_pRawFun); - return (*fun_userdata_typed_ptr)(_pUserData, std::forward(args)...); - } - } - - template - value_type call_bulkfun(Args&&... args) const - { - static_assert(NbParams == sizeof...(Args) - 2, "mismatch between NbParams and Args"); - if (_pUserData == nullptr) { - auto bulkfun_typed_ptr = reinterpret_cast::bulkfun_type>(_pRawFun); - return (*bulkfun_typed_ptr)(std::forward(args)...); - } else { - auto bulkfun_userdata_typed_ptr = reinterpret_cast::bulkfun_userdata_type>(_pRawFun); - return (*bulkfun_userdata_typed_ptr)(_pUserData, std::forward(args)...); - } - } - - value_type call_multfun(const value_type* a_afArg, int a_iArgc) const - { - if (_pUserData == nullptr) { - auto multfun_typed_ptr = reinterpret_cast(_pRawFun); - return (*multfun_typed_ptr)(a_afArg, a_iArgc); - } else { - auto multfun_userdata_typed_ptr = reinterpret_cast(_pRawFun); - return (*multfun_userdata_typed_ptr)(_pUserData, a_afArg, a_iArgc); - } - } - - template - value_type call_strfun(Args&&... args) const - { - static_assert(NbParams == sizeof...(Args), "mismatch between NbParams and Args"); - if (_pUserData == nullptr) - { - auto strfun_typed_ptr = reinterpret_cast::strfun_type>(_pRawFun); - return (*strfun_typed_ptr)(std::forward(args)...); - } - else - { - auto strfun_userdata_typed_ptr = reinterpret_cast::strfun_userdata_type>(_pRawFun); - return (*strfun_userdata_typed_ptr)(_pUserData, std::forward(args)...); - } - } - - bool operator==(generic_callable_type other) const - { - return _pRawFun == other._pRawFun && _pUserData == other._pUserData; - } - - explicit operator bool() const - { - return _pRawFun != nullptr; - } - - bool operator==(std::nullptr_t) const - { - return _pRawFun == nullptr; - } - - bool operator!=(std::nullptr_t) const - { - return _pRawFun != nullptr; - } - }; - - static_assert(std::is_trivial::value, "generic_callable_type shall be trivial"); - static_assert(std::is_standard_layout::value, "generic_callable_type shall have standard layout"); - // C++17: static_assert(std::is_aggregate::value, "generic_callable_type shall be an aggregate"); - - /** \brief Encapsulation of the data for a single formula token. - - Formula token implementation. Part of the Math Parser Package. - Formula tokens can be either one of the following: -
    -
  • value
  • -
  • variable
  • -
  • function with numerical arguments
  • -
  • functions with a string as argument
  • -
  • prefix operators
  • -
  • infix operators
  • -
  • binary operator
  • -
- */ - template - class ParserToken final - { - private: - - ECmdCode m_iCode; ///< Type of the token; The token type is a constant of type #ECmdCode. - ETypeCode m_iType; - void* m_pTok; ///< Stores Token pointer; not applicable for all tokens - int m_iIdx; ///< An otional index to an external buffer storing the token data - TString m_strTok; ///< Token string - TString m_strVal; ///< Value for string variables - value_type m_fVal; ///< the value - std::unique_ptr m_pCallback; - - public: - - /** \brief Constructor (default). - - Sets token to an neutral state of type cmUNKNOWN. - \throw nothrow - \sa ECmdCode - */ - ParserToken() - :m_iCode(cmUNKNOWN) - , m_iType(tpVOID) - , m_pTok(0) - , m_iIdx(-1) - , m_strTok() - , m_strVal() - , m_fVal(0) - , m_pCallback() - {} - - //------------------------------------------------------------------------------ - /** \brief Create token from another one. - - Implemented by calling Assign(...) - \throw nothrow - \post m_iType==cmUNKNOWN - \sa #Assign - */ - ParserToken(const ParserToken& a_Tok) - { - Assign(a_Tok); - } - - - /** \brief Assignment operator. - - Copy token state from another token and return this. - Implemented by calling Assign(...). - \throw nothrow - */ - ParserToken& operator=(const ParserToken& a_Tok) - { - Assign(a_Tok); - return *this; - } - - - /** \brief Copy token information from argument. - - \throw nothrow - */ - void Assign(const ParserToken& a_Tok) - { - m_iCode = a_Tok.m_iCode; - m_pTok = a_Tok.m_pTok; - m_strTok = a_Tok.m_strTok; - m_iIdx = a_Tok.m_iIdx; - m_strVal = a_Tok.m_strVal; - m_iType = a_Tok.m_iType; - m_fVal = a_Tok.m_fVal; - // create new callback object if a_Tok has one - m_pCallback.reset(a_Tok.m_pCallback.get() ? a_Tok.m_pCallback->Clone() : 0); - } - - //------------------------------------------------------------------------------ - /** \brief Assign a token type. - - Token may not be of type value, variable or function. Those have separate set functions. - - \pre [assert] a_iType!=cmVAR - \pre [assert] a_iType!=cmVAL - \pre [assert] a_iType!=cmFUNC - \post m_fVal = 0 - \post m_pTok = 0 - */ - ParserToken& Set(ECmdCode a_iType, const TString& a_strTok = TString()) - { - // The following types can't be set this way, they have special Set functions - MUP_ASSERT(a_iType != cmVAR); - MUP_ASSERT(a_iType != cmVAL); - MUP_ASSERT(a_iType != cmFUNC); - - m_iCode = a_iType; - m_iType = tpVOID; - m_pTok = 0; - m_strTok = a_strTok; - m_iIdx = -1; - - return *this; - } - - //------------------------------------------------------------------------------ - /** \brief Set Callback type. */ - ParserToken& Set(const ParserCallback& a_pCallback, const TString& a_sTok) - { - MUP_ASSERT(a_pCallback.IsValid()); - - m_iCode = a_pCallback.GetCode(); - m_iType = tpVOID; - m_strTok = a_sTok; - m_pCallback.reset(new ParserCallback(a_pCallback)); - - m_pTok = 0; - m_iIdx = -1; - - return *this; - } - - //------------------------------------------------------------------------------ - /** \brief Make this token a value token. - - Member variables not necessary for value tokens will be invalidated. - \throw nothrow - */ - ParserToken& SetVal(TBase a_fVal, const TString& a_strTok = TString()) - { - m_iCode = cmVAL; - m_iType = tpDBL; - m_fVal = a_fVal; - m_strTok = a_strTok; - m_iIdx = -1; - - m_pTok = 0; - m_pCallback.reset(0); - - return *this; - } - - //------------------------------------------------------------------------------ - /** \brief make this token a variable token. - - Member variables not necessary for variable tokens will be invalidated. - \throw nothrow - */ - ParserToken& SetVar(TBase* a_pVar, const TString& a_strTok) - { - m_iCode = cmVAR; - m_iType = tpDBL; - m_strTok = a_strTok; - m_iIdx = -1; - m_pTok = (void*)a_pVar; - m_pCallback.reset(0); - return *this; - } - - //------------------------------------------------------------------------------ - /** \brief Make this token a variable token. - - Member variables not necessary for variable tokens will be invalidated. - \throw nothrow - */ - ParserToken& SetString(const TString& a_strTok, std::size_t a_iSize) - { - m_iCode = cmSTRING; - m_iType = tpSTR; - m_strTok = a_strTok; - m_iIdx = static_cast(a_iSize); - - m_pTok = 0; - m_pCallback.reset(0); - return *this; - } - - //------------------------------------------------------------------------------ - /** \brief Set an index associated with the token related data. - - In cmSTRFUNC - This is the index to a string table in the main parser. - \param a_iIdx The index the string function result will take in the bytecode parser. - \throw exception_type if #a_iIdx<0 or #m_iType!=cmSTRING - */ - void SetIdx(int a_iIdx) - { - if (m_iCode != cmSTRING || a_iIdx < 0) - throw ParserError(ecINTERNAL_ERROR); - - m_iIdx = a_iIdx; - } - - //------------------------------------------------------------------------------ - /** \brief Return Index associated with the token related data. - - In cmSTRFUNC - This is the index to a string table in the main parser. - - \throw exception_type if #m_iIdx<0 or #m_iType!=cmSTRING - \return The index the result will take in the Bytecode calculatin array (#m_iIdx). - */ - int GetIdx() const - { - if (m_iIdx < 0 || m_iCode != cmSTRING) - throw ParserError(ecINTERNAL_ERROR); - - return m_iIdx; - } - - //------------------------------------------------------------------------------ - /** \brief Return the token type. - - \return #m_iType - \throw nothrow - */ - ECmdCode GetCode() const - { - if (m_pCallback.get()) - { - return m_pCallback->GetCode(); - } - else - { - return m_iCode; - } - } - - //------------------------------------------------------------------------------ - ETypeCode GetType() const - { - if (m_pCallback.get()) - { - return m_pCallback->GetType(); - } - else - { - return m_iType; - } - } - - //------------------------------------------------------------------------------ - int GetPri() const - { - if (!m_pCallback.get()) - throw ParserError(ecINTERNAL_ERROR); - - if (m_pCallback->GetCode() != cmOPRT_BIN && m_pCallback->GetCode() != cmOPRT_INFIX) - throw ParserError(ecINTERNAL_ERROR); - - return m_pCallback->GetPri(); - } - - //------------------------------------------------------------------------------ - EOprtAssociativity GetAssociativity() const - { - if (m_pCallback.get() == nullptr || m_pCallback->GetCode() != cmOPRT_BIN) - throw ParserError(ecINTERNAL_ERROR); - - return m_pCallback->GetAssociativity(); - } - - //------------------------------------------------------------------------------ - /** \brief Return the address of the callback function assoziated with - function and operator tokens. - - \return The pointer stored in #m_pTok. - \throw exception_type if token type is non of: -
    -
  • cmFUNC
  • -
  • cmSTRFUNC
  • -
  • cmPOSTOP
  • -
  • cmINFIXOP
  • -
  • cmOPRT_BIN
  • -
- \sa ECmdCode - */ - generic_callable_type GetFuncAddr() const - { - return (m_pCallback.get()) - ? generic_callable_type{(erased_fun_type)m_pCallback->GetAddr(), - m_pCallback->GetUserData()} - : generic_callable_type{}; - } - - //------------------------------------------------------------------------------ - /** \biref Get value of the token. - - Only applicable to variable and value tokens. - \throw exception_type if token is no value/variable token. - */ - TBase GetVal() const - { - switch (m_iCode) - { - case cmVAL: return m_fVal; - case cmVAR: return *((TBase*)m_pTok); - default: throw ParserError(ecVAL_EXPECTED); - } - } - - //------------------------------------------------------------------------------ - /** \brief Get address of a variable token. - - Valid only if m_iType==CmdVar. - \throw exception_type if token is no variable token. - */ - TBase* GetVar() const - { - if (m_iCode != cmVAR) - throw ParserError(ecINTERNAL_ERROR); - - return (TBase*)m_pTok; - } - - //------------------------------------------------------------------------------ - /** \brief Return the number of function arguments. - - Valid only if m_iType==CmdFUNC. - */ - int GetArgCount() const - { - MUP_ASSERT(m_pCallback.get()); - - if (!m_pCallback->IsValid()) - throw ParserError(ecINTERNAL_ERROR); - - return m_pCallback->GetArgc(); - } - - //------------------------------------------------------------------------------ - /** \brief Return true if the token is a function token that can be optimized. - */ - bool IsOptimizable() const - { - return m_pCallback->IsValid() && m_pCallback->IsOptimizable(); - } - - //------------------------------------------------------------------------------ - /** \brief Return the token identifier. - - If #m_iType is cmSTRING the token identifier is the value of the string argument - for a string function. - \return #m_strTok - \throw nothrow - \sa m_strTok - */ - const TString& GetAsString() const - { - return m_strTok; - } - }; +namespace mu { + template struct TplCallType; + template <> struct TplCallType<0> { + using fun_type = fun_type0; + using fun_userdata_type = fun_userdata_type0; + using bulkfun_type = bulkfun_type0; + using bulkfun_userdata_type = bulkfun_userdata_type0; + }; + template <> struct TplCallType<1> { + using fun_type = fun_type1; + using fun_userdata_type = fun_userdata_type1; + using bulkfun_type = bulkfun_type1; + using bulkfun_userdata_type = bulkfun_userdata_type1; + using strfun_type = strfun_type1; + using strfun_userdata_type = strfun_userdata_type1; + }; + template <> struct TplCallType<2> { + using fun_type = fun_type2; + using fun_userdata_type = fun_userdata_type2; + using bulkfun_type = bulkfun_type2; + using bulkfun_userdata_type = bulkfun_userdata_type2; + using strfun_type = strfun_type2; + using strfun_userdata_type = strfun_userdata_type2; + }; + template <> struct TplCallType<3> { + using fun_type = fun_type3; + using fun_userdata_type = fun_userdata_type3; + using bulkfun_type = bulkfun_type3; + using bulkfun_userdata_type = bulkfun_userdata_type3; + using strfun_type = strfun_type3; + using strfun_userdata_type = strfun_userdata_type3; + }; + template <> struct TplCallType<4> { + using fun_type = fun_type4; + using fun_userdata_type = fun_userdata_type4; + using bulkfun_type = bulkfun_type4; + using bulkfun_userdata_type = bulkfun_userdata_type4; + using strfun_type = strfun_type4; + using strfun_userdata_type = strfun_userdata_type4; + }; + template <> struct TplCallType<5> { + using fun_type = fun_type5; + using fun_userdata_type = fun_userdata_type5; + using bulkfun_type = bulkfun_type5; + using bulkfun_userdata_type = bulkfun_userdata_type5; + using strfun_type = strfun_type5; + using strfun_userdata_type = strfun_userdata_type5; + }; + template <> struct TplCallType<6> { + using fun_type = fun_type6; + using fun_userdata_type = fun_userdata_type6; + using bulkfun_type = bulkfun_type6; + using bulkfun_userdata_type = bulkfun_userdata_type6; + using strfun_type = strfun_type6; + using strfun_userdata_type = strfun_userdata_type6; + }; + template <> struct TplCallType<7> { + using fun_type = fun_type7; + using fun_userdata_type = fun_userdata_type7; + using bulkfun_type = bulkfun_type7; + using bulkfun_userdata_type = bulkfun_userdata_type7; + }; + template <> struct TplCallType<8> { + using fun_type = fun_type8; + using fun_userdata_type = fun_userdata_type8; + using bulkfun_type = bulkfun_type8; + using bulkfun_userdata_type = bulkfun_userdata_type8; + }; + template <> struct TplCallType<9> { + using fun_type = fun_type9; + using fun_userdata_type = fun_userdata_type9; + using bulkfun_type = bulkfun_type9; + using bulkfun_userdata_type = bulkfun_userdata_type9; + }; + template <> struct TplCallType<10> { + using fun_type = fun_type10; + using fun_userdata_type = fun_userdata_type10; + using bulkfun_type = bulkfun_type10; + using bulkfun_userdata_type = bulkfun_userdata_type10; + }; + + struct generic_callable_type { + // Note: we keep generic_callable_type a pod for the purpose of layout + + erased_fun_type _pRawFun; + void* _pUserData; + + template + value_type + call_fun(Args&&... args) const { + static_assert(NbParams == sizeof...(Args), "mismatch between NbParams and Args"); + if (_pUserData == nullptr) { + auto fun_typed_ptr = reinterpret_cast::fun_type>(_pRawFun); + return (*fun_typed_ptr)(std::forward(args)...); + } else { + auto fun_userdata_typed_ptr = + reinterpret_cast::fun_userdata_type>(_pRawFun); + return (*fun_userdata_typed_ptr)(_pUserData, std::forward(args)...); + } + } + + template + value_type + call_bulkfun(Args&&... args) const { + static_assert(NbParams == sizeof...(Args) - 2, "mismatch between NbParams and Args"); + if (_pUserData == nullptr) { + auto bulkfun_typed_ptr = reinterpret_cast::bulkfun_type>(_pRawFun); + return (*bulkfun_typed_ptr)(std::forward(args)...); + } else { + auto bulkfun_userdata_typed_ptr = + reinterpret_cast::bulkfun_userdata_type>(_pRawFun); + return (*bulkfun_userdata_typed_ptr)(_pUserData, std::forward(args)...); + } + } + + value_type + call_multfun(const value_type* a_afArg, + int a_iArgc) const { + if (_pUserData == nullptr) { + auto multfun_typed_ptr = reinterpret_cast(_pRawFun); + return (*multfun_typed_ptr)(a_afArg, a_iArgc); + } else { + auto multfun_userdata_typed_ptr = reinterpret_cast(_pRawFun); + return (*multfun_userdata_typed_ptr)(_pUserData, a_afArg, a_iArgc); + } + } + + template + value_type + call_strfun(Args&&... args) const { + static_assert(NbParams == sizeof...(Args), "mismatch between NbParams and Args"); + if (_pUserData == nullptr) { + auto strfun_typed_ptr = reinterpret_cast::strfun_type>(_pRawFun); + return (*strfun_typed_ptr)(std::forward(args)...); + } else { + auto strfun_userdata_typed_ptr = + reinterpret_cast::strfun_userdata_type>(_pRawFun); + return (*strfun_userdata_typed_ptr)(_pUserData, std::forward(args)...); + } + } + + bool + operator==(generic_callable_type other) const { + return _pRawFun == other._pRawFun && _pUserData == other._pUserData; + } + + explicit + operator bool() const { + return _pRawFun != nullptr; + } + + bool + operator==(std::nullptr_t) const { + return _pRawFun == nullptr; + } + + bool + operator!=(std::nullptr_t) const { + return _pRawFun != nullptr; + } + }; + + static_assert(std::is_trivial::value, + "generic_callable_type shall be trivial"); + static_assert(std::is_standard_layout::value, + "generic_callable_type shall have standard layout"); + // C++17: static_assert(std::is_aggregate::value, "generic_callable_type shall be an + // aggregate"); + + /** \brief Encapsulation of the data for a single formula token. + + Formula token implementation. Part of the Math Parser Package. + Formula tokens can be either one of the following: +
    +
  • value
  • +
  • variable
  • +
  • function with numerical arguments
  • +
  • functions with a string as argument
  • +
  • prefix operators
  • +
  • infix operators
  • +
  • binary operator
  • +
+ */ + template class ParserToken final { + private: + ECmdCode m_iCode; ///< Type of the token; The token type is a constant of type #ECmdCode. + ETypeCode m_iType; + void* m_pTok; ///< Stores Token pointer; not applicable for all tokens + int m_iIdx; ///< An otional index to an external buffer storing the token data + TString m_strTok; ///< Token string + TString m_strVal; ///< Value for string variables + value_type m_fVal; ///< the value + std::unique_ptr m_pCallback; + + public: + /** \brief Constructor (default). + + Sets token to an neutral state of type cmUNKNOWN. + \throw nothrow + \sa ECmdCode + */ + ParserToken() : + m_iCode(cmUNKNOWN), + m_iType(tpVOID), + m_pTok(0), + m_iIdx(-1), + m_strTok(), + m_strVal(), + m_fVal(0), + m_pCallback() { + } + + //------------------------------------------------------------------------------ + /** \brief Create token from another one. + + Implemented by calling Assign(...) + \throw nothrow + \post m_iType==cmUNKNOWN + \sa #Assign + */ + ParserToken(const ParserToken& a_Tok) { + Assign(a_Tok); + } + + + /** \brief Assignment operator. + + Copy token state from another token and return this. + Implemented by calling Assign(...). + \throw nothrow + */ + ParserToken& + operator=(const ParserToken& a_Tok) { + Assign(a_Tok); + return *this; + } + + + /** \brief Copy token information from argument. + + \throw nothrow + */ + void + Assign(const ParserToken& a_Tok) { + m_iCode = a_Tok.m_iCode; + m_pTok = a_Tok.m_pTok; + m_strTok = a_Tok.m_strTok; + m_iIdx = a_Tok.m_iIdx; + m_strVal = a_Tok.m_strVal; + m_iType = a_Tok.m_iType; + m_fVal = a_Tok.m_fVal; + // create new callback object if a_Tok has one + m_pCallback.reset(a_Tok.m_pCallback.get() ? a_Tok.m_pCallback->Clone() : 0); + } + + //------------------------------------------------------------------------------ + /** \brief Assign a token type. + + Token may not be of type value, variable or function. Those have separate set functions. + + \pre [assert] a_iType!=cmVAR + \pre [assert] a_iType!=cmVAL + \pre [assert] a_iType!=cmFUNC + \post m_fVal = 0 + \post m_pTok = 0 + */ + ParserToken& + Set(ECmdCode a_iType, + const TString& a_strTok = TString()) { + // The following types can't be set this way, they have special Set functions + MUP_ASSERT(a_iType != cmVAR); + MUP_ASSERT(a_iType != cmVAL); + MUP_ASSERT(a_iType != cmFUNC); + + m_iCode = a_iType; + m_iType = tpVOID; + m_pTok = 0; + m_strTok = a_strTok; + m_iIdx = -1; + + return *this; + } + + //------------------------------------------------------------------------------ + /** \brief Set Callback type. */ + ParserToken& + Set(const ParserCallback& a_pCallback, + const TString& a_sTok) { + MUP_ASSERT(a_pCallback.IsValid()); + + m_iCode = a_pCallback.GetCode(); + m_iType = tpVOID; + m_strTok = a_sTok; + m_pCallback.reset(new ParserCallback(a_pCallback)); + + m_pTok = 0; + m_iIdx = -1; + + return *this; + } + + //------------------------------------------------------------------------------ + /** \brief Make this token a value token. + + Member variables not necessary for value tokens will be invalidated. + \throw nothrow + */ + ParserToken& + SetVal(TBase a_fVal, + const TString& a_strTok = TString()) { + m_iCode = cmVAL; + m_iType = tpDBL; + m_fVal = a_fVal; + m_strTok = a_strTok; + m_iIdx = -1; + + m_pTok = 0; + m_pCallback.reset(0); + + return *this; + } + + //------------------------------------------------------------------------------ + /** \brief make this token a variable token. + + Member variables not necessary for variable tokens will be invalidated. + \throw nothrow + */ + ParserToken& + SetVar(TBase* a_pVar, + const TString& a_strTok) { + m_iCode = cmVAR; + m_iType = tpDBL; + m_strTok = a_strTok; + m_iIdx = -1; + m_pTok = (void*)a_pVar; + m_pCallback.reset(0); + return *this; + } + + //------------------------------------------------------------------------------ + /** \brief Make this token a variable token. + + Member variables not necessary for variable tokens will be invalidated. + \throw nothrow + */ + ParserToken& + SetString(const TString& a_strTok, + std::size_t a_iSize) { + m_iCode = cmSTRING; + m_iType = tpSTR; + m_strTok = a_strTok; + m_iIdx = static_cast(a_iSize); + + m_pTok = 0; + m_pCallback.reset(0); + return *this; + } + + //------------------------------------------------------------------------------ + /** \brief Set an index associated with the token related data. + + In cmSTRFUNC - This is the index to a string table in the main parser. + \param a_iIdx The index the string function result will take in the bytecode parser. + \throw exception_type if #a_iIdx<0 or #m_iType!=cmSTRING + */ + void + SetIdx(int a_iIdx) { + if (m_iCode != cmSTRING || a_iIdx < 0) + throw ParserError(ecINTERNAL_ERROR); + + m_iIdx = a_iIdx; + } + + //------------------------------------------------------------------------------ + /** \brief Return Index associated with the token related data. + + In cmSTRFUNC - This is the index to a string table in the main parser. + + \throw exception_type if #m_iIdx<0 or #m_iType!=cmSTRING + \return The index the result will take in the Bytecode calculatin array (#m_iIdx). + */ + int + GetIdx() const { + if (m_iIdx < 0 || m_iCode != cmSTRING) + throw ParserError(ecINTERNAL_ERROR); + + return m_iIdx; + } + + //------------------------------------------------------------------------------ + /** \brief Return the token type. + + \return #m_iType + \throw nothrow + */ + ECmdCode + GetCode() const { + if (m_pCallback.get()) { + return m_pCallback->GetCode(); + } else { + return m_iCode; + } + } + + //------------------------------------------------------------------------------ + ETypeCode + GetType() const { + if (m_pCallback.get()) { + return m_pCallback->GetType(); + } else { + return m_iType; + } + } + + //------------------------------------------------------------------------------ + int + GetPri() const { + if (!m_pCallback.get()) + throw ParserError(ecINTERNAL_ERROR); + + if (m_pCallback->GetCode() != cmOPRT_BIN && m_pCallback->GetCode() != cmOPRT_INFIX) + throw ParserError(ecINTERNAL_ERROR); + + return m_pCallback->GetPri(); + } + + //------------------------------------------------------------------------------ + EOprtAssociativity + GetAssociativity() const { + if (m_pCallback.get() == nullptr || m_pCallback->GetCode() != cmOPRT_BIN) + throw ParserError(ecINTERNAL_ERROR); + + return m_pCallback->GetAssociativity(); + } + + //------------------------------------------------------------------------------ + /** \brief Return the address of the callback function assoziated with + function and operator tokens. + + \return The pointer stored in #m_pTok. + \throw exception_type if token type is non of: +
    +
  • cmFUNC
  • +
  • cmSTRFUNC
  • +
  • cmPOSTOP
  • +
  • cmINFIXOP
  • +
  • cmOPRT_BIN
  • +
+ \sa ECmdCode + */ + generic_callable_type + GetFuncAddr() const { + return (m_pCallback.get()) + ? generic_callable_type{(erased_fun_type)m_pCallback->GetAddr(), m_pCallback->GetUserData()} + : generic_callable_type{}; + } + + //------------------------------------------------------------------------------ + /** \biref Get value of the token. + + Only applicable to variable and value tokens. + \throw exception_type if token is no value/variable token. + */ + TBase + GetVal() const { + switch (m_iCode) { + case cmVAL: + return m_fVal; + case cmVAR: + return *((TBase*)m_pTok); + default: + throw ParserError(ecVAL_EXPECTED); + } + } + + //------------------------------------------------------------------------------ + /** \brief Get address of a variable token. + + Valid only if m_iType==CmdVar. + \throw exception_type if token is no variable token. + */ + TBase* + GetVar() const { + if (m_iCode != cmVAR) + throw ParserError(ecINTERNAL_ERROR); + + return (TBase*)m_pTok; + } + + //------------------------------------------------------------------------------ + /** \brief Return the number of function arguments. + + Valid only if m_iType==CmdFUNC. + */ + int + GetArgCount() const { + MUP_ASSERT(m_pCallback.get()); + + if (!m_pCallback->IsValid()) + throw ParserError(ecINTERNAL_ERROR); + + return m_pCallback->GetArgc(); + } + + //------------------------------------------------------------------------------ + /** \brief Return true if the token is a function token that can be optimized. + */ + bool + IsOptimizable() const { + return m_pCallback->IsValid() && m_pCallback->IsOptimizable(); + } + + //------------------------------------------------------------------------------ + /** \brief Return the token identifier. + + If #m_iType is cmSTRING the token identifier is the value of the string argument + for a string function. + \return #m_strTok + \throw nothrow + \sa m_strTok + */ + const TString& + GetAsString() const { + return m_strTok; + } + }; } // namespace mu #if defined(_MSC_VER) - #pragma warning(pop) +#pragma warning(pop) #endif #endif diff --git a/libsrc/spatialdata/muparser/muParserTokenReader.cpp b/libsrc/spatialdata/muparser/muParserTokenReader.cpp index 312a0c5f..bc25e99f 100644 --- a/libsrc/spatialdata/muparser/muParserTokenReader.cpp +++ b/libsrc/spatialdata/muparser/muParserTokenReader.cpp @@ -1,30 +1,31 @@ /* + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2004 - 2021 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ #include #include @@ -32,966 +33,946 @@ #include #include -#include "muParserTokenReader.h" #include "muParserBase.h" +#include "muParserTokenReader.h" #if defined(_MSC_VER) - #pragma warning(push) - #pragma warning(disable : 26812) +#pragma warning(push) +#pragma warning(disable : 26812) #endif /** \file - \brief This file contains the parser token reader implementation. + \brief This file contains the parser token reader implementation. */ -namespace mu -{ - - // Forward declaration - class ParserBase; - - /** \brief Copy constructor. - - \sa Assign - \throw nothrow - */ - ParserTokenReader::ParserTokenReader(const ParserTokenReader& a_Reader) - { - Assign(a_Reader); - } - - - /** \brief Assignment operator. - - Self assignment will be suppressed otherwise #Assign is called. - - \param a_Reader Object to copy to this token reader. - \throw nothrow - */ - ParserTokenReader& ParserTokenReader::operator=(const ParserTokenReader& a_Reader) - { - if (&a_Reader != this) - Assign(a_Reader); - - return *this; - } - - - /** \brief Assign state of a token reader to this token reader. - - \param a_Reader Object from which the state should be copied. - \throw nothrow - */ - void ParserTokenReader::Assign(const ParserTokenReader& a_Reader) - { - m_pParser = a_Reader.m_pParser; - m_strFormula = a_Reader.m_strFormula; - m_iPos = a_Reader.m_iPos; - m_iSynFlags = a_Reader.m_iSynFlags; - - m_UsedVar = a_Reader.m_UsedVar; - m_pFunDef = a_Reader.m_pFunDef; - m_pConstDef = a_Reader.m_pConstDef; - m_pVarDef = a_Reader.m_pVarDef; - m_pStrVarDef = a_Reader.m_pStrVarDef; - m_pPostOprtDef = a_Reader.m_pPostOprtDef; - m_pInfixOprtDef = a_Reader.m_pInfixOprtDef; - m_pOprtDef = a_Reader.m_pOprtDef; - m_bIgnoreUndefVar = a_Reader.m_bIgnoreUndefVar; - m_vIdentFun = a_Reader.m_vIdentFun; - m_pFactory = a_Reader.m_pFactory; - m_pFactoryData = a_Reader.m_pFactoryData; - m_bracketStack = a_Reader.m_bracketStack; - m_cArgSep = a_Reader.m_cArgSep; - m_fZero = a_Reader.m_fZero; - m_lastTok = a_Reader.m_lastTok; - } - - - /** \brief Constructor. - - Create a Token reader and bind it to a parser object. - - \pre [assert] a_pParser may not be NULL - \post #m_pParser==a_pParser - \param a_pParent Parent parser object of the token reader. - */ - ParserTokenReader::ParserTokenReader(ParserBase* a_pParent) - :m_pParser(a_pParent) - , m_strFormula() - , m_iPos(0) - , m_iSynFlags(0) - , m_bIgnoreUndefVar(false) - , m_pFunDef(nullptr) - , m_pPostOprtDef(nullptr) - , m_pInfixOprtDef(nullptr) - , m_pOprtDef(nullptr) - , m_pConstDef(nullptr) - , m_pStrVarDef(nullptr) - , m_pVarDef(nullptr) - , m_pFactory(nullptr) - , m_pFactoryData(nullptr) - , m_vIdentFun() - , m_UsedVar() - , m_fZero(0) - , m_bracketStack() - , m_lastTok() - , m_cArgSep(',') - { - MUP_ASSERT(m_pParser != nullptr); - SetParent(m_pParser); - } - - - /** \brief Create instance of a ParserTokenReader identical with this - and return its pointer. - - This is a factory method the calling function must take care of the object destruction. - - \return A new ParserTokenReader object. - \throw nothrow - */ - ParserTokenReader* ParserTokenReader::Clone(ParserBase* a_pParent) const - { - std::unique_ptr ptr(new ParserTokenReader(*this)); - ptr->SetParent(a_pParent); - return ptr.release(); - } - - - ParserTokenReader::token_type& ParserTokenReader::SaveBeforeReturn(const token_type& tok) - { - m_lastTok = tok; - return m_lastTok; - } - - - void ParserTokenReader::AddValIdent(identfun_type a_pCallback) - { - // Use push_front is used to give user defined callbacks a higher priority than - // the built in ones. Otherwise reading hex numbers would not work - // since the "0" in "0xff" would always be read first making parsing of - // the rest impossible. - // reference: - // http://sourceforge.net/projects/muparser/forums/forum/462843/topic/4824956 - m_vIdentFun.push_front(a_pCallback); - } - - - void ParserTokenReader::SetVarCreator(facfun_type a_pFactory, void* pUserData) - { - m_pFactory = a_pFactory; - m_pFactoryData = pUserData; - } - - - /** \brief Return the current position of the token reader in the formula string. - - \return #m_iPos - \throw nothrow - */ - int ParserTokenReader::GetPos() const - { - return m_iPos; - } - - - /** \brief Return a reference to the formula. - - \return #m_strFormula - \throw nothrow - */ - const string_type& ParserTokenReader::GetExpr() const - { - return m_strFormula; - } - - - /** \brief Return a map containing the used variables only. */ - varmap_type& ParserTokenReader::GetUsedVar() - { - return m_UsedVar; - } - - - /** \brief Initialize the token Reader. - - Sets the formula position index to zero and set Syntax flags to default for initial formula parsing. - \pre [assert] triggered if a_szFormula==0 - */ - void ParserTokenReader::SetFormula(const string_type& a_strFormula) - { - m_strFormula = a_strFormula; - ReInit(); - } - - - /** \brief Set Flag that controls behaviour in case of undefined variables being found. - - If true, the parser does not throw an exception if an undefined variable is found. - otherwise it does. This variable is used internally only! - It suppresses a "undefined variable" exception in GetUsedVar(). - Those function should return a complete list of variables including - those the are not defined by the time of it's call. - */ - void ParserTokenReader::IgnoreUndefVar(bool bIgnore) - { - m_bIgnoreUndefVar = bIgnore; - } - - - /** \brief Reset the token reader to the start of the formula. - - The syntax flags will be reset to a value appropriate for the - start of a formula. - \post #m_iPos==0, #m_iSynFlags = noOPT | noBC | noPOSTOP | noSTR - \throw nothrow - \sa ESynCodes - */ - void ParserTokenReader::ReInit() - { - m_iPos = 0; - m_iSynFlags = sfSTART_OF_LINE; - m_bracketStack = std::stack(); - m_UsedVar.clear(); - m_lastTok = token_type(); - } - - - /** \brief Read the next token from the string. */ - ParserTokenReader::token_type ParserTokenReader::ReadNextToken() - { - MUP_ASSERT(m_pParser != nullptr); - - const char_type* szExpr = m_strFormula.c_str(); - token_type tok; - - // Ignore all non printable characters when reading the expression - while (szExpr[m_iPos] > 0 && szExpr[m_iPos] <= 0x20) - { - // 14-31 are control characters. I donÄt want to have to deal with such strings at all! - // (see https://en.cppreference.com/w/cpp/string/byte/isprint) - if (szExpr[m_iPos] >= 14 && szExpr[m_iPos] <= 31) - Error(ecINVALID_CHARACTERS_FOUND, m_iPos); - - ++m_iPos; - } - - // Check for end of formula - if (IsEOF(tok)) - return SaveBeforeReturn(tok); - - // Check for user defined binary operator - if (IsOprt(tok)) - return SaveBeforeReturn(tok); - - // Check for function token - if (IsFunTok(tok)) - return SaveBeforeReturn(tok); - - // Check built in operators / tokens - if (IsBuiltIn(tok)) - return SaveBeforeReturn(tok); - - // Check for function argument separators - if (IsArgSep(tok)) - return SaveBeforeReturn(tok); - - // Check for values / constant tokens - if (IsValTok(tok)) - return SaveBeforeReturn(tok); - - // Check for variable tokens - if (IsVarTok(tok)) - return SaveBeforeReturn(tok); - - // Check for string variables - if (IsStrVarTok(tok)) - return SaveBeforeReturn(tok); - - // Check for String tokens - if (IsString(tok)) - return SaveBeforeReturn(tok); - - // Check for unary operators - if (IsInfixOpTok(tok)) - return SaveBeforeReturn(tok); - - // Check for unary operators - if (IsPostOpTok(tok)) - return SaveBeforeReturn(tok); - - // Check String for undefined variable token. Done only if a - // flag is set indicating to ignore undefined variables. - // This is a way to conditionally avoid an error if - // undefined variables occur. - // (The GetUsedVar function must suppress the error for - // undefined variables in order to collect all variable - // names including the undefined ones.) - if ((m_bIgnoreUndefVar || m_pFactory) && IsUndefVarTok(tok)) - return SaveBeforeReturn(tok); - - // Check for unknown token - // - // !!! From this point on there is no exit without an exception possible... - // - string_type strTok; - auto iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, (std::size_t)m_iPos); - if (iEnd != m_iPos) - Error(ecUNASSIGNABLE_TOKEN, m_iPos, strTok); - - Error(ecUNASSIGNABLE_TOKEN, m_iPos, m_strFormula.substr(m_iPos)); - return token_type(); // never reached - } - - - void ParserTokenReader::SetParent(ParserBase* a_pParent) - { - m_pParser = a_pParent; - m_pFunDef = &a_pParent->m_FunDef; - m_pOprtDef = &a_pParent->m_OprtDef; - m_pInfixOprtDef = &a_pParent->m_InfixOprtDef; - m_pPostOprtDef = &a_pParent->m_PostOprtDef; - m_pVarDef = &a_pParent->m_VarDef; - m_pStrVarDef = &a_pParent->m_StrVarDef; - m_pConstDef = &a_pParent->m_ConstDef; - } - - - /** \brief Extract all characters that belong to a certain charset. - - \param a_szCharSet [in] Const char array of the characters allowed in the token. - \param a_strTok [out] The string that consists entirely of characters listed in a_szCharSet. - \param a_iPos [in] Position in the string from where to start reading. - \return The Position of the first character not listed in a_szCharSet. - \throw nothrow - */ - int ParserTokenReader::ExtractToken(const char_type* a_szCharSet, string_type& a_sTok, std::size_t a_iPos) const - { - auto iEnd = m_strFormula.find_first_not_of(a_szCharSet, a_iPos); - - if (iEnd == string_type::npos) - iEnd = m_strFormula.length(); - - // Assign token string if there was something found - if (a_iPos != iEnd) - a_sTok = string_type(m_strFormula.begin() + a_iPos, m_strFormula.begin() + iEnd); - - return static_cast(iEnd); - } - - - /** \brief Check Expression for the presence of a binary operator token. - - Userdefined binary operator "++" gives inconsistent parsing result for - the equations "a++b" and "a ++ b" if alphabetic characters are allowed - in operator tokens. To avoid this this function checks specifically - for operator tokens. - */ - int ParserTokenReader::ExtractOperatorToken(string_type& a_sTok, std::size_t a_iPos) const - { - // Changed as per Issue 6: https://code.google.com/p/muparser/issues/detail?id=6 - auto iEnd = m_strFormula.find_first_not_of(m_pParser->ValidOprtChars(), a_iPos); - if (iEnd == string_type::npos) - iEnd = m_strFormula.length(); - - // Assign token string if there was something found - if (a_iPos != iEnd) - { - a_sTok = string_type(m_strFormula.begin() + a_iPos, m_strFormula.begin() + iEnd); - return static_cast(iEnd); - } - else - { - // There is still the chance of having to deal with an operator consisting exclusively - // of alphabetic characters. - return ExtractToken(_T("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), a_sTok, (std::size_t)a_iPos); - } - } - - - /** \brief Check if a built in operator or other token can be found - \param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token. - \return true if an operator token has been found. - */ - bool ParserTokenReader::IsBuiltIn(token_type& a_Tok) - { - const char_type** const pOprtDef = m_pParser->GetOprtDef(), - * const szFormula = m_strFormula.c_str(); - - // Compare token with function and operator strings - // check string for operator/function - for (int i = 0; pOprtDef[i]; i++) - { - std::size_t len(std::char_traits::length(pOprtDef[i])); - if (string_type(pOprtDef[i]) == string_type(szFormula + m_iPos, szFormula + m_iPos + len)) - { - switch (i) - { - case cmLAND: - case cmLOR: - case cmLT: - case cmGT: - case cmLE: - case cmGE: - case cmNEQ: - case cmEQ: - case cmADD: - case cmSUB: - case cmMUL: - case cmDIV: - case cmPOW: - case cmASSIGN: - // The assignment operator need special treatment - if (i == cmASSIGN && m_iSynFlags & noASSIGN) - Error(ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef[i]); - - if (!m_pParser->HasBuiltInOprt()) continue; - if (m_iSynFlags & noOPT) - { - // Maybe its an infix operator not an operator - // Both operator types can share characters in - // their identifiers - if (IsInfixOpTok(a_Tok)) - return true; - - Error(ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef[i]); - } - - m_iSynFlags = noBC | noOPT | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE | noEND; - break; - - case cmBO: - if (m_iSynFlags & noBO) - Error(ecUNEXPECTED_PARENS, m_iPos, pOprtDef[i]); - - if (m_lastTok.GetCode() == cmFUNC) - m_iSynFlags = noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; - else - m_iSynFlags = noBC | noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; - - m_bracketStack.push(cmBO); - break; - - case cmBC: - if (m_iSynFlags & noBC) - Error(ecUNEXPECTED_PARENS, m_iPos, pOprtDef[i]); - - m_iSynFlags = noBO | noVAR | noVAL | noFUN | noINFIXOP | noSTR | noASSIGN; - - if (!m_bracketStack.empty()) - m_bracketStack.pop(); - else - Error(ecUNEXPECTED_PARENS, m_iPos, pOprtDef[i]); - break; - - case cmELSE: - if (m_iSynFlags & noELSE) - Error(ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef[i]); - - m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE | noSTR; - break; - - case cmIF: - if (m_iSynFlags & noIF) - Error(ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef[i]); - - m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE | noSTR; - break; - - default: // The operator is listed in c_DefaultOprt, but not here. This is a bad thing... - Error(ecINTERNAL_ERROR); - } // switch operator id - - m_iPos += (int)len; - a_Tok.Set((ECmdCode)i, pOprtDef[i]); - return true; - } // if operator string found - } // end of for all operator strings - - return false; - } - - - bool ParserTokenReader::IsArgSep(token_type& a_Tok) - { - const char_type* szFormula = m_strFormula.c_str(); - - if (szFormula[m_iPos] == m_cArgSep) - { - // copy the separator into null terminated string - char_type szSep[2]; - szSep[0] = m_cArgSep; - szSep[1] = 0; - - if (m_iSynFlags & noARG_SEP) - Error(ecUNEXPECTED_ARG_SEP, m_iPos, szSep); - - m_iSynFlags = noBC | noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN; - m_iPos++; - a_Tok.Set(cmARG_SEP, szSep); - return true; - } - - return false; - } - - - /** \brief Check for End of Formula. - - \return true if an end of formula is found false otherwise. - \param a_Tok [out] If an eof is found the corresponding token will be stored there. - \throw nothrow - \sa IsOprt, IsFunTok, IsStrFunTok, IsValTok, IsVarTok, IsString, IsInfixOpTok, IsPostOpTok - */ - bool ParserTokenReader::IsEOF(token_type& a_Tok) - { - const char_type* szFormula = m_strFormula.c_str(); - - // check for EOF - if (!szFormula[m_iPos] /*|| szFormula[m_iPos] == '\n'*/) - { - if (m_iSynFlags & noEND) - Error(ecUNEXPECTED_EOF, m_iPos); - - if (!m_bracketStack.empty()) - Error(ecMISSING_PARENS, m_iPos, _T(")")); - - m_iSynFlags = 0; - a_Tok.Set(cmEND); - return true; - } - - return false; - } - - - /** \brief Check if a string position contains a unary infix operator. - \return true if a function token has been found false otherwise. - */ - bool ParserTokenReader::IsInfixOpTok(token_type& a_Tok) - { - string_type sTok; - auto iEnd = ExtractToken(m_pParser->ValidInfixOprtChars(), sTok, (std::size_t)m_iPos); - if (iEnd == m_iPos) - return false; - - // iterate over all postfix operator strings - funmap_type::const_reverse_iterator it = m_pInfixOprtDef->rbegin(); - for (; it != m_pInfixOprtDef->rend(); ++it) - { - if (sTok.find(it->first) != 0) - continue; - - a_Tok.Set(it->second, it->first); - m_iPos += (int)it->first.length(); - - if (m_iSynFlags & noINFIXOP) - Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString()); - - m_iSynFlags = noPOSTOP | noINFIXOP | noOPT | noBC | noSTR | noASSIGN | noARG_SEP; - return true; - } - - return false; - - /* - a_Tok.Set(item->second, sTok); - m_iPos = (int)iEnd; - - if (m_iSynFlags & noINFIXOP) - Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString()); - - m_iSynFlags = noPOSTOP | noINFIXOP | noOPT | noBC | noSTR | noASSIGN; - return true; - */ - } - - - /** \brief Check whether the token at a given position is a function token. - \param a_Tok [out] If a value token is found it will be placed here. - \throw ParserException if Syntaxflags do not allow a function at a_iPos - \return true if a function token has been found false otherwise. - \pre [assert] m_pParser!=0 - */ - bool ParserTokenReader::IsFunTok(token_type& a_Tok) - { - string_type strTok; - auto iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, (std::size_t)m_iPos); - if (iEnd == m_iPos) - return false; - - funmap_type::const_iterator item = m_pFunDef->find(strTok); - if (item == m_pFunDef->end()) - return false; - - // Check if the next sign is an opening bracket - const char_type* szFormula = m_strFormula.c_str(); - if (szFormula[iEnd] != '(') - return false; - - a_Tok.Set(item->second, strTok); - - m_iPos = (int)iEnd; - if (m_iSynFlags & noFUN) - Error(ecUNEXPECTED_FUN, m_iPos - (int)a_Tok.GetAsString().length(), a_Tok.GetAsString()); - - m_iSynFlags = noANY ^ noBO; - return true; - } - - - /** \brief Check if a string position contains a binary operator. - \param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token. - \return true if an operator token has been found. - */ - bool ParserTokenReader::IsOprt(token_type& a_Tok) - { - const char_type* const szExpr = m_strFormula.c_str(); - string_type strTok; - - auto iEnd = ExtractOperatorToken(strTok, (std::size_t)m_iPos); - if (iEnd == m_iPos) - return false; - - // Check if the operator is a built in operator, if so ignore it here - const char_type** const pOprtDef = m_pParser->GetOprtDef(); - for (int i = 0; m_pParser->HasBuiltInOprt() && pOprtDef[i]; ++i) - { - if (string_type(pOprtDef[i]) == strTok) - return false; - } - - // Note: - // All tokens in oprt_bin_maptype are have been sorted by their length - // Long operators must come first! Otherwise short names (like: "add") that - // are part of long token names (like: "add123") will be found instead - // of the long ones. - // Length sorting is done with ascending length so we use a reverse iterator here. - funmap_type::const_reverse_iterator it = m_pOprtDef->rbegin(); - for (; it != m_pOprtDef->rend(); ++it) - { - const string_type& sID = it->first; - if (sID == string_type(szExpr + m_iPos, szExpr + m_iPos + sID.length())) - { - a_Tok.Set(it->second, strTok); - - // operator was found - if (m_iSynFlags & noOPT) - { - // An operator was found but is not expected to occur at - // this position of the formula, maybe it is an infix - // operator, not a binary operator. Both operator types - // can share characters in their identifiers. - if (IsInfixOpTok(a_Tok)) - return true; - else - { - // nope, no infix operator - return false; - //Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString()); - } - - } - - m_iPos += (int)sID.length(); - m_iSynFlags = noBC | noOPT | noARG_SEP | noPOSTOP | noEND | noASSIGN; - return true; - } - } - - return false; - } - - - /** \brief Check if a string position contains a unary post value operator. */ - bool ParserTokenReader::IsPostOpTok(token_type& a_Tok) - { - // Do not check for postfix operators if they are not allowed at - // the current expression index. - // - // This will fix the bug reported here: - // - // http://sourceforge.net/tracker/index.php?func=detail&aid=3343891&group_id=137191&atid=737979 - // - if (m_iSynFlags & noPOSTOP) - return false; - // - - // Tricky problem with equations like "3m+5": - // m is a postfix operator, + is a valid sign for postfix operators and - // for binary operators parser detects "m+" as operator string and - // finds no matching postfix operator. - // - // This is a special case so this routine slightly differs from the other - // token readers. - - // Test if there could be a postfix operator - string_type sTok; - auto iEnd = ExtractToken(m_pParser->ValidOprtChars(), sTok, (std::size_t)m_iPos); - if (iEnd == m_iPos) - return false; - - // iterate over all postfix operator strings - funmap_type::const_reverse_iterator it = m_pPostOprtDef->rbegin(); - for (; it != m_pPostOprtDef->rend(); ++it) - { - if (sTok.find(it->first) != 0) - continue; - - a_Tok.Set(it->second, sTok); - m_iPos += (int)it->first.length(); - - m_iSynFlags = noVAL | noVAR | noFUN | noBO | noPOSTOP | noSTR | noASSIGN; - return true; - } - - return false; - } - - - /** \brief Check whether the token at a given position is a value token. - - Value tokens are either values or constants. - - \param a_Tok [out] If a value token is found it will be placed here. - \return true if a value token has been found. - */ - bool ParserTokenReader::IsValTok(token_type& a_Tok) - { - MUP_ASSERT(m_pConstDef != nullptr); - MUP_ASSERT(m_pParser != nullptr); - - string_type strTok; - value_type fVal(0); - - // 2.) Check for user defined constant - // Read everything that could be a constant name - auto iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, (std::size_t)m_iPos); - if (iEnd != m_iPos) - { - valmap_type::const_iterator item = m_pConstDef->find(strTok); - if (item != m_pConstDef->end()) - { - m_iPos = iEnd; - a_Tok.SetVal(item->second, strTok); - - if (m_iSynFlags & noVAL) - Error(ecUNEXPECTED_VAL, m_iPos - (int)strTok.length(), strTok); - - m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; - return true; - } - } - - // 3.call the value recognition functions provided by the user - // Call user defined value recognition functions - std::list::const_iterator item = m_vIdentFun.begin(); - for (item = m_vIdentFun.begin(); item != m_vIdentFun.end(); ++item) - { - int iStart = m_iPos; - if ((*item)(m_strFormula.c_str() + m_iPos, &m_iPos, &fVal) == 1) - { - // 2013-11-27 Issue 2: https://code.google.com/p/muparser/issues/detail?id=2 - strTok.assign(m_strFormula.c_str(), iStart, (std::size_t)m_iPos - iStart); - - if (m_iSynFlags & noVAL) - Error(ecUNEXPECTED_VAL, m_iPos - (int)strTok.length(), strTok); - - a_Tok.SetVal(fVal, strTok); - m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; - return true; - } - } - - return false; - } - - - /** \brief Check wheter a token at a given position is a variable token. - \param a_Tok [out] If a variable token has been found it will be placed here. - \return true if a variable token has been found. - */ - bool ParserTokenReader::IsVarTok(token_type& a_Tok) - { - if (m_pVarDef->empty()) - return false; - - string_type strTok; - auto iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, (std::size_t)m_iPos); - if (iEnd == m_iPos) - return false; - - varmap_type::const_iterator item = m_pVarDef->find(strTok); - if (item == m_pVarDef->end()) - return false; - - if (m_iSynFlags & noVAR) - Error(ecUNEXPECTED_VAR, m_iPos, strTok); - - m_pParser->OnDetectVar(&m_strFormula, m_iPos, iEnd); - - m_iPos = iEnd; - a_Tok.SetVar(item->second, strTok); - m_UsedVar[item->first] = item->second; // Add variable to used-var-list - - m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR; - - // Zur Info hier die SynFlags von IsVal(): - // m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; - return true; - } - - - bool ParserTokenReader::IsStrVarTok(token_type& a_Tok) - { - if (!m_pStrVarDef || m_pStrVarDef->empty()) - return false; - - string_type strTok; - auto iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, (std::size_t)m_iPos); - if (iEnd == m_iPos) - return false; - - strmap_type::const_iterator item = m_pStrVarDef->find(strTok); - if (item == m_pStrVarDef->end()) - return false; - - if (m_iSynFlags & noSTR) - Error(ecUNEXPECTED_VAR, m_iPos, strTok); - - m_iPos = iEnd; - if (!m_pParser->m_vStringVarBuf.size()) - Error(ecINTERNAL_ERROR); - - a_Tok.SetString(m_pParser->m_vStringVarBuf[item->second], m_pParser->m_vStringVarBuf.size()); - - m_iSynFlags = noANY ^ (noBC | noOPT | noEND | noARG_SEP); - return true; - } - - - - /** \brief Check wheter a token at a given position is an undefined variable. - - \param a_Tok [out] If a variable tom_pParser->m_vStringBufken has been found it will be placed here. - \return true if a variable token has been found. - \throw nothrow - */ - bool ParserTokenReader::IsUndefVarTok(token_type& a_Tok) - { - string_type strTok; - auto iEnd(ExtractToken(m_pParser->ValidNameChars(), strTok, (std::size_t)m_iPos)); - if (iEnd == m_iPos) - return false; - - if (m_iSynFlags & noVAR) - { - // 20061021 added token string strTok instead of a_Tok.GetAsString() as the - // token identifier. - // related bug report: - // http://sourceforge.net/tracker/index.php?func=detail&aid=1578779&group_id=137191&atid=737979 - Error(ecUNEXPECTED_VAR, m_iPos - (int)a_Tok.GetAsString().length(), strTok); - } - - // If a factory is available implicitely create new variables - if (m_pFactory) - { - value_type* fVar = m_pFactory(strTok.c_str(), m_pFactoryData); - a_Tok.SetVar(fVar, strTok); - - // Do not use m_pParser->DefineVar( strTok, fVar ); - // in order to define the new variable, it will clear the - // m_UsedVar array which will kill previously defined variables - // from the list - // This is safe because the new variable can never override an existing one - // because they are checked first! - (*m_pVarDef)[strTok] = fVar; - m_UsedVar[strTok] = fVar; // Add variable to used-var-list - } - else - { - a_Tok.SetVar((value_type*)&m_fZero, strTok); - m_UsedVar[strTok] = 0; // Add variable to used-var-list - } - - m_iPos = iEnd; - - // Call the variable factory in order to let it define a new parser variable - m_iSynFlags = noVAL | noVAR | noFUN | noBO | noPOSTOP | noINFIXOP | noSTR; - return true; - } - - - - /** \brief Check wheter a token at a given position is a string. - \param a_Tok [out] If a variable token has been found it will be placed here. - \return true if a string token has been found. - \sa IsOprt, IsFunTok, IsStrFunTok, IsValTok, IsVarTok, IsEOF, IsInfixOpTok, IsPostOpTok - \throw nothrow - */ - bool ParserTokenReader::IsString(token_type& a_Tok) - { - if (m_strFormula[m_iPos] != '"') - return false; - - string_type strBuf(&m_strFormula[(std::size_t)m_iPos + 1]); - std::size_t iEnd(0), iSkip(0); - - // parser over escaped '\"' end replace them with '"' - for (iEnd = (int)strBuf.find(_T('\"')); iEnd != 0 && iEnd != string_type::npos; iEnd = (int)strBuf.find(_T('\"'), iEnd)) - { - if (strBuf[iEnd - 1] != '\\') break; - strBuf.replace(iEnd - 1, 2, _T("\"")); - iSkip++; - } - - if (iEnd == string_type::npos) - Error(ecUNTERMINATED_STRING, m_iPos, _T("\"")); - - string_type strTok(strBuf.begin(), strBuf.begin() + iEnd); - - if (m_iSynFlags & noSTR) - Error(ecUNEXPECTED_STR, m_iPos, strTok); - - m_pParser->m_vStringBuf.push_back(strTok); // Store string in internal buffer - a_Tok.SetString(strTok, m_pParser->m_vStringBuf.size()); - - m_iPos += (int)strTok.length() + 2 + (int)iSkip; // +2 for quotes; +iSkip for escape characters - m_iSynFlags = noANY ^ (noARG_SEP | noBC | noOPT | noEND); - - return true; - } - - - /** \brief Create an error containing the parse error position. - - This function will create an Parser Exception object containing the error text and its position. - - \param a_iErrc [in] The error code of type #EErrorCodes. - \param a_iPos [in] The position where the error was detected. - \param a_strTok [in] The token string representation associated with the error. - \throw ParserException always throws thats the only purpose of this function. - */ - void ParserTokenReader::Error(EErrorCodes a_iErrc, int a_iPos, const string_type& a_sTok) const - { - m_pParser->Error(a_iErrc, a_iPos, a_sTok); - } - - - void ParserTokenReader::SetArgSep(char_type cArgSep) - { - m_cArgSep = cArgSep; - } - - - char_type ParserTokenReader::GetArgSep() const - { - return m_cArgSep; - } +namespace mu { + + // Forward declaration + class ParserBase; + + /** \brief Copy constructor. + + \sa Assign + \throw nothrow + */ + ParserTokenReader::ParserTokenReader(const ParserTokenReader& a_Reader) { + Assign(a_Reader); + } + + + /** \brief Assignment operator. + + Self assignment will be suppressed otherwise #Assign is called. + + \param a_Reader Object to copy to this token reader. + \throw nothrow + */ + ParserTokenReader& + ParserTokenReader::operator=(const ParserTokenReader& a_Reader) { + if (&a_Reader != this) + Assign(a_Reader); + + return *this; + } + + + /** \brief Assign state of a token reader to this token reader. + + \param a_Reader Object from which the state should be copied. + \throw nothrow + */ + void + ParserTokenReader::Assign(const ParserTokenReader& a_Reader) { + m_pParser = a_Reader.m_pParser; + m_strFormula = a_Reader.m_strFormula; + m_iPos = a_Reader.m_iPos; + m_iSynFlags = a_Reader.m_iSynFlags; + + m_UsedVar = a_Reader.m_UsedVar; + m_pFunDef = a_Reader.m_pFunDef; + m_pConstDef = a_Reader.m_pConstDef; + m_pVarDef = a_Reader.m_pVarDef; + m_pStrVarDef = a_Reader.m_pStrVarDef; + m_pPostOprtDef = a_Reader.m_pPostOprtDef; + m_pInfixOprtDef = a_Reader.m_pInfixOprtDef; + m_pOprtDef = a_Reader.m_pOprtDef; + m_bIgnoreUndefVar = a_Reader.m_bIgnoreUndefVar; + m_vIdentFun = a_Reader.m_vIdentFun; + m_pFactory = a_Reader.m_pFactory; + m_pFactoryData = a_Reader.m_pFactoryData; + m_bracketStack = a_Reader.m_bracketStack; + m_cArgSep = a_Reader.m_cArgSep; + m_fZero = a_Reader.m_fZero; + m_lastTok = a_Reader.m_lastTok; + } + + + /** \brief Constructor. + + Create a Token reader and bind it to a parser object. + + \pre [assert] a_pParser may not be NULL + \post #m_pParser==a_pParser + \param a_pParent Parent parser object of the token reader. + */ + ParserTokenReader::ParserTokenReader(ParserBase* a_pParent) : + m_pParser(a_pParent), + m_strFormula(), + m_iPos(0), + m_iSynFlags(0), + m_bIgnoreUndefVar(false), + m_pFunDef(nullptr), + m_pPostOprtDef(nullptr), + m_pInfixOprtDef(nullptr), + m_pOprtDef(nullptr), + m_pConstDef(nullptr), + m_pStrVarDef(nullptr), + m_pVarDef(nullptr), + m_pFactory(nullptr), + m_pFactoryData(nullptr), + m_vIdentFun(), + m_UsedVar(), + m_fZero(0), + m_bracketStack(), + m_lastTok(), + m_cArgSep(',') { + MUP_ASSERT(m_pParser != nullptr); + SetParent(m_pParser); + } + + + /** \brief Create instance of a ParserTokenReader identical with this + and return its pointer. + + This is a factory method the calling function must take care of the object destruction. + + \return A new ParserTokenReader object. + \throw nothrow + */ + ParserTokenReader* + ParserTokenReader::Clone(ParserBase* a_pParent) const { + std::unique_ptr ptr(new ParserTokenReader(*this)); + ptr->SetParent(a_pParent); + return ptr.release(); + } + + + ParserTokenReader::token_type& + ParserTokenReader::SaveBeforeReturn(const token_type& tok) { + m_lastTok = tok; + return m_lastTok; + } + + + void + ParserTokenReader::AddValIdent(identfun_type a_pCallback) { + // Use push_front is used to give user defined callbacks a higher priority than + // the built in ones. Otherwise reading hex numbers would not work + // since the "0" in "0xff" would always be read first making parsing of + // the rest impossible. + // reference: + // http://sourceforge.net/projects/muparser/forums/forum/462843/topic/4824956 + m_vIdentFun.push_front(a_pCallback); + } + + + void + ParserTokenReader::SetVarCreator(facfun_type a_pFactory, + void* pUserData) { + m_pFactory = a_pFactory; + m_pFactoryData = pUserData; + } + + + /** \brief Return the current position of the token reader in the formula string. + + \return #m_iPos + \throw nothrow + */ + int + ParserTokenReader::GetPos() const { + return m_iPos; + } + + + /** \brief Return a reference to the formula. + + \return #m_strFormula + \throw nothrow + */ + const string_type& + ParserTokenReader::GetExpr() const { + return m_strFormula; + } + + + /** \brief Return a map containing the used variables only. */ + varmap_type& + ParserTokenReader::GetUsedVar() { + return m_UsedVar; + } + + + /** \brief Initialize the token Reader. + + Sets the formula position index to zero and set Syntax flags to default for initial formula parsing. + \pre [assert] triggered if a_szFormula==0 + */ + void + ParserTokenReader::SetFormula(const string_type& a_strFormula) { + m_strFormula = a_strFormula; + ReInit(); + } + + + /** \brief Set Flag that controls behaviour in case of undefined variables being found. + + If true, the parser does not throw an exception if an undefined variable is found. + otherwise it does. This variable is used internally only! + It suppresses a "undefined variable" exception in GetUsedVar(). + Those function should return a complete list of variables including + those the are not defined by the time of it's call. + */ + void + ParserTokenReader::IgnoreUndefVar(bool bIgnore) { + m_bIgnoreUndefVar = bIgnore; + } + + + /** \brief Reset the token reader to the start of the formula. + + The syntax flags will be reset to a value appropriate for the + start of a formula. + \post #m_iPos==0, #m_iSynFlags = noOPT | noBC | noPOSTOP | noSTR + \throw nothrow + \sa ESynCodes + */ + void + ParserTokenReader::ReInit() { + m_iPos = 0; + m_iSynFlags = sfSTART_OF_LINE; + m_bracketStack = std::stack(); + m_UsedVar.clear(); + m_lastTok = token_type(); + } + + + /** \brief Read the next token from the string. */ + ParserTokenReader::token_type + ParserTokenReader::ReadNextToken() { + MUP_ASSERT(m_pParser != nullptr); + + const char_type* szExpr = m_strFormula.c_str(); + token_type tok; + + // Ignore all non printable characters when reading the expression + while (szExpr[m_iPos] > 0 && szExpr[m_iPos] <= 0x20) { + // 14-31 are control characters. I don�t want to have to deal with such strings at all! + // (see https://en.cppreference.com/w/cpp/string/byte/isprint) + if (szExpr[m_iPos] >= 14 && szExpr[m_iPos] <= 31) + Error(ecINVALID_CHARACTERS_FOUND, m_iPos); + + ++m_iPos; + } + + // Check for end of formula + if (IsEOF(tok)) + return SaveBeforeReturn(tok); + + // Check for user defined binary operator + if (IsOprt(tok)) + return SaveBeforeReturn(tok); + + // Check for function token + if (IsFunTok(tok)) + return SaveBeforeReturn(tok); + + // Check built in operators / tokens + if (IsBuiltIn(tok)) + return SaveBeforeReturn(tok); + + // Check for function argument separators + if (IsArgSep(tok)) + return SaveBeforeReturn(tok); + + // Check for values / constant tokens + if (IsValTok(tok)) + return SaveBeforeReturn(tok); + + // Check for variable tokens + if (IsVarTok(tok)) + return SaveBeforeReturn(tok); + + // Check for string variables + if (IsStrVarTok(tok)) + return SaveBeforeReturn(tok); + + // Check for String tokens + if (IsString(tok)) + return SaveBeforeReturn(tok); + + // Check for unary operators + if (IsInfixOpTok(tok)) + return SaveBeforeReturn(tok); + + // Check for unary operators + if (IsPostOpTok(tok)) + return SaveBeforeReturn(tok); + + // Check String for undefined variable token. Done only if a + // flag is set indicating to ignore undefined variables. + // This is a way to conditionally avoid an error if + // undefined variables occur. + // (The GetUsedVar function must suppress the error for + // undefined variables in order to collect all variable + // names including the undefined ones.) + if ((m_bIgnoreUndefVar || m_pFactory) && IsUndefVarTok(tok)) + return SaveBeforeReturn(tok); + + // Check for unknown token + // + // !!! From this point on there is no exit without an exception possible... + // + string_type strTok; + auto iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, (std::size_t)m_iPos); + if (iEnd != m_iPos) + Error(ecUNASSIGNABLE_TOKEN, m_iPos, strTok); + + Error(ecUNASSIGNABLE_TOKEN, m_iPos, m_strFormula.substr(m_iPos)); + return token_type(); // never reached + } + + + void + ParserTokenReader::SetParent(ParserBase* a_pParent) { + m_pParser = a_pParent; + m_pFunDef = &a_pParent->m_FunDef; + m_pOprtDef = &a_pParent->m_OprtDef; + m_pInfixOprtDef = &a_pParent->m_InfixOprtDef; + m_pPostOprtDef = &a_pParent->m_PostOprtDef; + m_pVarDef = &a_pParent->m_VarDef; + m_pStrVarDef = &a_pParent->m_StrVarDef; + m_pConstDef = &a_pParent->m_ConstDef; + } + + + /** \brief Extract all characters that belong to a certain charset. + + \param a_szCharSet [in] Const char array of the characters allowed in the token. + \param a_strTok [out] The string that consists entirely of characters listed in a_szCharSet. + \param a_iPos [in] Position in the string from where to start reading. + \return The Position of the first character not listed in a_szCharSet. + \throw nothrow + */ + int + ParserTokenReader::ExtractToken(const char_type* a_szCharSet, + string_type& a_sTok, + std::size_t a_iPos) const { + auto iEnd = m_strFormula.find_first_not_of(a_szCharSet, a_iPos); + + if (iEnd == string_type::npos) + iEnd = m_strFormula.length(); + + // Assign token string if there was something found + if (a_iPos != iEnd) + a_sTok = string_type(m_strFormula.begin() + a_iPos, m_strFormula.begin() + iEnd); + + return static_cast(iEnd); + } + + + /** \brief Check Expression for the presence of a binary operator token. + + Userdefined binary operator "++" gives inconsistent parsing result for + the equations "a++b" and "a ++ b" if alphabetic characters are allowed + in operator tokens. To avoid this this function checks specifically + for operator tokens. + */ + int + ParserTokenReader::ExtractOperatorToken(string_type& a_sTok, + std::size_t a_iPos) const { + // Changed as per Issue 6: https://code.google.com/p/muparser/issues/detail?id=6 + auto iEnd = m_strFormula.find_first_not_of(m_pParser->ValidOprtChars(), a_iPos); + if (iEnd == string_type::npos) + iEnd = m_strFormula.length(); + + // Assign token string if there was something found + if (a_iPos != iEnd) { + a_sTok = string_type(m_strFormula.begin() + a_iPos, m_strFormula.begin() + iEnd); + return static_cast(iEnd); + } else { + // There is still the chance of having to deal with an operator consisting exclusively + // of alphabetic characters. + return ExtractToken(_T("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), + a_sTok, + (std::size_t)a_iPos); + } + } + + + /** \brief Check if a built in operator or other token can be found + \param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix + operator token. + \return true if an operator token has been found. + */ + bool + ParserTokenReader::IsBuiltIn(token_type& a_Tok) { + const char_type **const pOprtDef = m_pParser->GetOprtDef(), *const szFormula = m_strFormula.c_str(); + + // Compare token with function and operator strings + // check string for operator/function + for (int i = 0; pOprtDef[i]; i++) { + std::size_t len(std::char_traits::length(pOprtDef[i])); + if (string_type(pOprtDef[i]) == string_type(szFormula + m_iPos, szFormula + m_iPos + len)) { + switch (i) { + case cmLAND: + case cmLOR: + case cmLT: + case cmGT: + case cmLE: + case cmGE: + case cmNEQ: + case cmEQ: + case cmADD: + case cmSUB: + case cmMUL: + case cmDIV: + case cmPOW: + case cmASSIGN: + // The assignment operator need special treatment + if (i == cmASSIGN && m_iSynFlags & noASSIGN) + Error(ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef[i]); + + if (!m_pParser->HasBuiltInOprt()) + continue; + if (m_iSynFlags & noOPT) { + // Maybe its an infix operator not an operator + // Both operator types can share characters in + // their identifiers + if (IsInfixOpTok(a_Tok)) + return true; + + Error(ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef[i]); + } + + m_iSynFlags = noBC | noOPT | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE | noEND; + break; + + case cmBO: + if (m_iSynFlags & noBO) + Error(ecUNEXPECTED_PARENS, m_iPos, pOprtDef[i]); + + if (m_lastTok.GetCode() == cmFUNC) + m_iSynFlags = noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; + else + m_iSynFlags = noBC | noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; + + m_bracketStack.push(cmBO); + break; + + case cmBC: + if (m_iSynFlags & noBC) + Error(ecUNEXPECTED_PARENS, m_iPos, pOprtDef[i]); + + m_iSynFlags = noBO | noVAR | noVAL | noFUN | noINFIXOP | noSTR | noASSIGN; + + if (!m_bracketStack.empty()) + m_bracketStack.pop(); + else + Error(ecUNEXPECTED_PARENS, m_iPos, pOprtDef[i]); + break; + + case cmELSE: + if (m_iSynFlags & noELSE) + Error(ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef[i]); + + m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE | noSTR; + break; + + case cmIF: + if (m_iSynFlags & noIF) + Error(ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef[i]); + + m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE | noSTR; + break; + + default: // The operator is listed in c_DefaultOprt, but not here. This is a bad thing... + Error(ecINTERNAL_ERROR); + } // switch operator id + + m_iPos += (int)len; + a_Tok.Set((ECmdCode)i, pOprtDef[i]); + return true; + } // if operator string found + } // end of for all operator strings + + return false; + } + + + bool + ParserTokenReader::IsArgSep(token_type& a_Tok) { + const char_type* szFormula = m_strFormula.c_str(); + + if (szFormula[m_iPos] == m_cArgSep) { + // copy the separator into null terminated string + char_type szSep[2]; + szSep[0] = m_cArgSep; + szSep[1] = 0; + + if (m_iSynFlags & noARG_SEP) + Error(ecUNEXPECTED_ARG_SEP, m_iPos, szSep); + + m_iSynFlags = noBC | noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN; + m_iPos++; + a_Tok.Set(cmARG_SEP, szSep); + return true; + } + + return false; + } + + + /** \brief Check for End of Formula. + + \return true if an end of formula is found false otherwise. + \param a_Tok [out] If an eof is found the corresponding token will be stored there. + \throw nothrow + \sa IsOprt, IsFunTok, IsStrFunTok, IsValTok, IsVarTok, IsString, IsInfixOpTok, IsPostOpTok + */ + bool + ParserTokenReader::IsEOF(token_type& a_Tok) { + const char_type* szFormula = m_strFormula.c_str(); + + // check for EOF + if (!szFormula[m_iPos] /*|| szFormula[m_iPos] == '\n'*/) { + if (m_iSynFlags & noEND) + Error(ecUNEXPECTED_EOF, m_iPos); + + if (!m_bracketStack.empty()) + Error(ecMISSING_PARENS, m_iPos, _T(")")); + + m_iSynFlags = 0; + a_Tok.Set(cmEND); + return true; + } + + return false; + } + + + /** \brief Check if a string position contains a unary infix operator. + \return true if a function token has been found false otherwise. + */ + bool + ParserTokenReader::IsInfixOpTok(token_type& a_Tok) { + string_type sTok; + auto iEnd = ExtractToken(m_pParser->ValidInfixOprtChars(), sTok, (std::size_t)m_iPos); + if (iEnd == m_iPos) + return false; + + // iterate over all postfix operator strings + funmap_type::const_reverse_iterator it = m_pInfixOprtDef->rbegin(); + for (; it != m_pInfixOprtDef->rend(); ++it) { + if (sTok.find(it->first) != 0) + continue; + + a_Tok.Set(it->second, it->first); + m_iPos += (int)it->first.length(); + + if (m_iSynFlags & noINFIXOP) + Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString()); + + m_iSynFlags = noPOSTOP | noINFIXOP | noOPT | noBC | noSTR | noASSIGN | noARG_SEP; + return true; + } + + return false; + + /* + a_Tok.Set(item->second, sTok); + m_iPos = (int)iEnd; + + if (m_iSynFlags & noINFIXOP) + Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString()); + + m_iSynFlags = noPOSTOP | noINFIXOP | noOPT | noBC | noSTR | noASSIGN; + return true; + */ + } + + + /** \brief Check whether the token at a given position is a function token. + \param a_Tok [out] If a value token is found it will be placed here. + \throw ParserException if Syntaxflags do not allow a function at a_iPos + \return true if a function token has been found false otherwise. + \pre [assert] m_pParser!=0 + */ + bool + ParserTokenReader::IsFunTok(token_type& a_Tok) { + string_type strTok; + auto iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, (std::size_t)m_iPos); + if (iEnd == m_iPos) + return false; + + funmap_type::const_iterator item = m_pFunDef->find(strTok); + if (item == m_pFunDef->end()) + return false; + + // Check if the next sign is an opening bracket + const char_type* szFormula = m_strFormula.c_str(); + if (szFormula[iEnd] != '(') + return false; + + a_Tok.Set(item->second, strTok); + + m_iPos = (int)iEnd; + if (m_iSynFlags & noFUN) + Error(ecUNEXPECTED_FUN, m_iPos - (int)a_Tok.GetAsString().length(), a_Tok.GetAsString()); + + m_iSynFlags = noANY ^ noBO; + return true; + } + + + /** \brief Check if a string position contains a binary operator. + \param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix + operator token. + \return true if an operator token has been found. + */ + bool + ParserTokenReader::IsOprt(token_type& a_Tok) { + const char_type* const szExpr = m_strFormula.c_str(); + string_type strTok; + + auto iEnd = ExtractOperatorToken(strTok, (std::size_t)m_iPos); + if (iEnd == m_iPos) + return false; + + // Check if the operator is a built in operator, if so ignore it here + const char_type** const pOprtDef = m_pParser->GetOprtDef(); + for (int i = 0; m_pParser->HasBuiltInOprt() && pOprtDef[i]; ++i) { + if (string_type(pOprtDef[i]) == strTok) + return false; + } + + // Note: + // All tokens in oprt_bin_maptype are have been sorted by their length + // Long operators must come first! Otherwise short names (like: "add") that + // are part of long token names (like: "add123") will be found instead + // of the long ones. + // Length sorting is done with ascending length so we use a reverse iterator here. + funmap_type::const_reverse_iterator it = m_pOprtDef->rbegin(); + for (; it != m_pOprtDef->rend(); ++it) { + const string_type& sID = it->first; + if (sID == string_type(szExpr + m_iPos, szExpr + m_iPos + sID.length())) { + a_Tok.Set(it->second, strTok); + + // operator was found + if (m_iSynFlags & noOPT) { + // An operator was found but is not expected to occur at + // this position of the formula, maybe it is an infix + // operator, not a binary operator. Both operator types + // can share characters in their identifiers. + if (IsInfixOpTok(a_Tok)) + return true; + else { + // nope, no infix operator + return false; + // Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString()); + } + } + + m_iPos += (int)sID.length(); + m_iSynFlags = noBC | noOPT | noARG_SEP | noPOSTOP | noEND | noASSIGN; + return true; + } + } + + return false; + } + + + /** \brief Check if a string position contains a unary post value operator. */ + bool + ParserTokenReader::IsPostOpTok(token_type& a_Tok) { + // Do not check for postfix operators if they are not allowed at + // the current expression index. + // + // This will fix the bug reported here: + // + // http://sourceforge.net/tracker/index.php?func=detail&aid=3343891&group_id=137191&atid=737979 + // + if (m_iSynFlags & noPOSTOP) + return false; + // + + // Tricky problem with equations like "3m+5": + // m is a postfix operator, + is a valid sign for postfix operators and + // for binary operators parser detects "m+" as operator string and + // finds no matching postfix operator. + // + // This is a special case so this routine slightly differs from the other + // token readers. + + // Test if there could be a postfix operator + string_type sTok; + auto iEnd = ExtractToken(m_pParser->ValidOprtChars(), sTok, (std::size_t)m_iPos); + if (iEnd == m_iPos) + return false; + + // iterate over all postfix operator strings + funmap_type::const_reverse_iterator it = m_pPostOprtDef->rbegin(); + for (; it != m_pPostOprtDef->rend(); ++it) { + if (sTok.find(it->first) != 0) + continue; + + a_Tok.Set(it->second, sTok); + m_iPos += (int)it->first.length(); + + m_iSynFlags = noVAL | noVAR | noFUN | noBO | noPOSTOP | noSTR | noASSIGN; + return true; + } + + return false; + } + + + /** \brief Check whether the token at a given position is a value token. + + Value tokens are either values or constants. + + \param a_Tok [out] If a value token is found it will be placed here. + \return true if a value token has been found. + */ + bool + ParserTokenReader::IsValTok(token_type& a_Tok) { + MUP_ASSERT(m_pConstDef != nullptr); + MUP_ASSERT(m_pParser != nullptr); + + string_type strTok; + value_type fVal(0); + + // 2.) Check for user defined constant + // Read everything that could be a constant name + auto iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, (std::size_t)m_iPos); + if (iEnd != m_iPos) { + valmap_type::const_iterator item = m_pConstDef->find(strTok); + if (item != m_pConstDef->end()) { + m_iPos = iEnd; + a_Tok.SetVal(item->second, strTok); + + if (m_iSynFlags & noVAL) + Error(ecUNEXPECTED_VAL, m_iPos - (int)strTok.length(), strTok); + + m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; + return true; + } + } + + // 3.call the value recognition functions provided by the user + // Call user defined value recognition functions + std::list::const_iterator item = m_vIdentFun.begin(); + for (item = m_vIdentFun.begin(); item != m_vIdentFun.end(); ++item) { + int iStart = m_iPos; + if ((*item)(m_strFormula.c_str() + m_iPos, &m_iPos, &fVal) == 1) { + // 2013-11-27 Issue 2: https://code.google.com/p/muparser/issues/detail?id=2 + strTok.assign(m_strFormula.c_str(), iStart, (std::size_t)m_iPos - iStart); + + if (m_iSynFlags & noVAL) + Error(ecUNEXPECTED_VAL, m_iPos - (int)strTok.length(), strTok); + + a_Tok.SetVal(fVal, strTok); + m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; + return true; + } + } + + return false; + } + + + /** \brief Check wheter a token at a given position is a variable token. + \param a_Tok [out] If a variable token has been found it will be placed here. + \return true if a variable token has been found. + */ + bool + ParserTokenReader::IsVarTok(token_type& a_Tok) { + if (m_pVarDef->empty()) + return false; + + string_type strTok; + auto iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, (std::size_t)m_iPos); + if (iEnd == m_iPos) + return false; + + varmap_type::const_iterator item = m_pVarDef->find(strTok); + if (item == m_pVarDef->end()) + return false; + + if (m_iSynFlags & noVAR) + Error(ecUNEXPECTED_VAR, m_iPos, strTok); + + m_pParser->OnDetectVar(&m_strFormula, m_iPos, iEnd); + + m_iPos = iEnd; + a_Tok.SetVar(item->second, strTok); + m_UsedVar[item->first] = item->second; // Add variable to used-var-list + + m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR; + + // Zur Info hier die SynFlags von IsVal(): + // m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; + return true; + } + + + bool + ParserTokenReader::IsStrVarTok(token_type& a_Tok) { + if (!m_pStrVarDef || m_pStrVarDef->empty()) + return false; + + string_type strTok; + auto iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, (std::size_t)m_iPos); + if (iEnd == m_iPos) + return false; + + strmap_type::const_iterator item = m_pStrVarDef->find(strTok); + if (item == m_pStrVarDef->end()) + return false; + + if (m_iSynFlags & noSTR) + Error(ecUNEXPECTED_VAR, m_iPos, strTok); + + m_iPos = iEnd; + if (!m_pParser->m_vStringVarBuf.size()) + Error(ecINTERNAL_ERROR); + + a_Tok.SetString(m_pParser->m_vStringVarBuf[item->second], m_pParser->m_vStringVarBuf.size()); + + m_iSynFlags = noANY ^ (noBC | noOPT | noEND | noARG_SEP); + return true; + } + + + /** \brief Check wheter a token at a given position is an undefined variable. + + \param a_Tok [out] If a variable tom_pParser->m_vStringBufken has been found it will be placed here. + \return true if a variable token has been found. + \throw nothrow + */ + bool + ParserTokenReader::IsUndefVarTok(token_type& a_Tok) { + string_type strTok; + auto iEnd(ExtractToken(m_pParser->ValidNameChars(), strTok, (std::size_t)m_iPos)); + if (iEnd == m_iPos) + return false; + + if (m_iSynFlags & noVAR) { + // 20061021 added token string strTok instead of a_Tok.GetAsString() as the + // token identifier. + // related bug report: + // http://sourceforge.net/tracker/index.php?func=detail&aid=1578779&group_id=137191&atid=737979 + Error(ecUNEXPECTED_VAR, m_iPos - (int)a_Tok.GetAsString().length(), strTok); + } + + // If a factory is available implicitely create new variables + if (m_pFactory) { + value_type* fVar = m_pFactory(strTok.c_str(), m_pFactoryData); + a_Tok.SetVar(fVar, strTok); + + // Do not use m_pParser->DefineVar( strTok, fVar ); + // in order to define the new variable, it will clear the + // m_UsedVar array which will kill previously defined variables + // from the list + // This is safe because the new variable can never override an existing one + // because they are checked first! + (*m_pVarDef)[strTok] = fVar; + m_UsedVar[strTok] = fVar; // Add variable to used-var-list + } else { + a_Tok.SetVar((value_type*)&m_fZero, strTok); + m_UsedVar[strTok] = 0; // Add variable to used-var-list + } + + m_iPos = iEnd; + + // Call the variable factory in order to let it define a new parser variable + m_iSynFlags = noVAL | noVAR | noFUN | noBO | noPOSTOP | noINFIXOP | noSTR; + return true; + } + + + /** \brief Check wheter a token at a given position is a string. + \param a_Tok [out] If a variable token has been found it will be placed here. + \return true if a string token has been found. + \sa IsOprt, IsFunTok, IsStrFunTok, IsValTok, IsVarTok, IsEOF, IsInfixOpTok, IsPostOpTok + \throw nothrow + */ + bool + ParserTokenReader::IsString(token_type& a_Tok) { + if (m_strFormula[m_iPos] != '"') + return false; + + string_type strBuf(&m_strFormula[(std::size_t)m_iPos + 1]); + std::size_t iEnd(0), iSkip(0); + + // parser over escaped '\"' end replace them with '"' + for (iEnd = (int)strBuf.find(_T('\"')); iEnd != 0 && iEnd != string_type::npos; + iEnd = (int)strBuf.find(_T('\"'), iEnd)) { + if (strBuf[iEnd - 1] != '\\') + break; + strBuf.replace(iEnd - 1, 2, _T("\"")); + iSkip++; + } + + if (iEnd == string_type::npos) + Error(ecUNTERMINATED_STRING, m_iPos, _T("\"")); + + string_type strTok(strBuf.begin(), strBuf.begin() + iEnd); + + if (m_iSynFlags & noSTR) + Error(ecUNEXPECTED_STR, m_iPos, strTok); + + m_pParser->m_vStringBuf.push_back(strTok); // Store string in internal buffer + a_Tok.SetString(strTok, m_pParser->m_vStringBuf.size()); + + m_iPos += (int)strTok.length() + 2 + (int)iSkip; // +2 for quotes; +iSkip for escape characters + m_iSynFlags = noANY ^ (noARG_SEP | noBC | noOPT | noEND); + + return true; + } + + + /** \brief Create an error containing the parse error position. + + This function will create an Parser Exception object containing the error text and its position. + + \param a_iErrc [in] The error code of type #EErrorCodes. + \param a_iPos [in] The position where the error was detected. + \param a_strTok [in] The token string representation associated with the error. + \throw ParserException always throws thats the only purpose of this function. + */ + void + ParserTokenReader::Error(EErrorCodes a_iErrc, + int a_iPos, + const string_type& a_sTok) const { + m_pParser->Error(a_iErrc, a_iPos, a_sTok); + } + + + void + ParserTokenReader::SetArgSep(char_type cArgSep) { + m_cArgSep = cArgSep; + } + + + char_type + ParserTokenReader::GetArgSep() const { + return m_cArgSep; + } } // namespace mu #if defined(_MSC_VER) - #pragma warning(pop) +#pragma warning(pop) #endif diff --git a/libsrc/spatialdata/muparser/muParserTokenReader.h b/libsrc/spatialdata/muparser/muParserTokenReader.h index 0ea19f53..f099e4bc 100644 --- a/libsrc/spatialdata/muparser/muParserTokenReader.h +++ b/libsrc/spatialdata/muparser/muParserTokenReader.h @@ -1,30 +1,31 @@ /* + * + * _____ __ _____________ _______ ______ ___________ + * / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ + * | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ + * |__|_| /____/| __(____ /__| /____ >\___ >__| + * \/ |__| \/ \/ \/ + * Copyright (C) 2022 Ingo Berg + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ - _____ __ _____________ _______ ______ ___________ - / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \ - | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/ - |__|_| /____/| __(____ /__| /____ >\___ >__| - \/ |__| \/ \/ \/ - Copyright (C) 2004 - 2021 Ingo Berg - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ #ifndef MU_PARSER_TOKEN_READER_H #define MU_PARSER_TOKEN_READER_H @@ -41,120 +42,118 @@ #include "muParserToken.h" /** \file - \brief This file contains the parser token reader definition. + \brief This file contains the parser token reader definition. */ -namespace mu -{ - // Forward declaration - class ParserBase; - - /** \brief Token reader for the ParserBase class. */ - class ParserTokenReader final - { - private: - - typedef ParserToken token_type; - - public: - - ParserTokenReader(ParserBase* a_pParent); - ParserTokenReader* Clone(ParserBase* a_pParent) const; - - void AddValIdent(identfun_type a_pCallback); - void SetVarCreator(facfun_type a_pFactory, void* pUserData); - void SetFormula(const string_type& a_strFormula); - void SetArgSep(char_type cArgSep); - - int GetPos() const; - const string_type& GetExpr() const; - varmap_type& GetUsedVar(); - char_type GetArgSep() const; - - void IgnoreUndefVar(bool bIgnore); - void ReInit(); - token_type ReadNextToken(); - - private: - - /** \brief Syntax codes. - - The syntax codes control the syntax check done during the first time parsing of - the expression string. They are flags that indicate which tokens are allowed next - if certain tokens are identified. - */ - enum ESynCodes - { - noBO = 1 << 0, ///< to avoid i.e. "cos(7)(" - noBC = 1 << 1, ///< to avoid i.e. "sin)" or "()" - noVAL = 1 << 2, ///< to avoid i.e. "tan 2" or "sin(8)3.14" - noVAR = 1 << 3, ///< to avoid i.e. "sin a" or "sin(8)a" - noARG_SEP = 1 << 4, ///< to avoid i.e. ",," or "+," ... - noFUN = 1 << 5, ///< to avoid i.e. "sqrt cos" or "(1)sin" - noOPT = 1 << 6, ///< to avoid i.e. "(+)" - noPOSTOP = 1 << 7, ///< to avoid i.e. "(5!!)" "sin!" - noINFIXOP = 1 << 8, ///< to avoid i.e. "++4" "!!4" - noEND = 1 << 9, ///< to avoid unexpected end of formula - noSTR = 1 << 10, ///< to block numeric arguments on string functions - noASSIGN = 1 << 11, ///< to block assignment to constant i.e. "4=7" - noIF = 1 << 12, - noELSE = 1 << 13, - sfSTART_OF_LINE = noOPT | noBC | noPOSTOP | noASSIGN | noIF | noELSE | noARG_SEP, - noANY = ~0 ///< All of he above flags set - }; - - ParserTokenReader(const ParserTokenReader& a_Reader); - ParserTokenReader& operator=(const ParserTokenReader& a_Reader); - void Assign(const ParserTokenReader& a_Reader); - - void SetParent(ParserBase* a_pParent); - int ExtractToken(const char_type* a_szCharSet, string_type& a_strTok, std::size_t a_iPos) const; - int ExtractOperatorToken(string_type& a_sTok, std::size_t a_iPos) const; - - bool IsBuiltIn(token_type& a_Tok); - bool IsArgSep(token_type& a_Tok); - bool IsEOF(token_type& a_Tok); - bool IsInfixOpTok(token_type& a_Tok); - bool IsFunTok(token_type& a_Tok); - bool IsPostOpTok(token_type& a_Tok); - bool IsOprt(token_type& a_Tok); - bool IsValTok(token_type& a_Tok); - bool IsVarTok(token_type& a_Tok); - bool IsStrVarTok(token_type& a_Tok); - bool IsUndefVarTok(token_type& a_Tok); - bool IsString(token_type& a_Tok); - void Error(EErrorCodes a_iErrc, int a_iPos = -1, const string_type& a_sTok = string_type()) const; - - token_type& SaveBeforeReturn(const token_type& tok); - - ParserBase* m_pParser; - string_type m_strFormula; - int m_iPos; - int m_iSynFlags; - bool m_bIgnoreUndefVar; - - const funmap_type* m_pFunDef; - const funmap_type* m_pPostOprtDef; - const funmap_type* m_pInfixOprtDef; - const funmap_type* m_pOprtDef; - const valmap_type* m_pConstDef; - const strmap_type* m_pStrVarDef; - - varmap_type* m_pVarDef; ///< The only non const pointer to parser internals - facfun_type m_pFactory; - void* m_pFactoryData; - std::list m_vIdentFun; ///< Value token identification function - varmap_type m_UsedVar; - value_type m_fZero; ///< Dummy value of zero, referenced by undefined variables - - std::stack m_bracketStack; - - token_type m_lastTok; - char_type m_cArgSep; ///< The character used for separating function arguments - }; +namespace mu { + // Forward declaration + class ParserBase; + + /** \brief Token reader for the ParserBase class. */ + class ParserTokenReader final { + private: + typedef ParserToken token_type; + + public: + ParserTokenReader(ParserBase* a_pParent); + ParserTokenReader* Clone(ParserBase* a_pParent) const; + + void AddValIdent(identfun_type a_pCallback); + void SetVarCreator(facfun_type a_pFactory, + void* pUserData); + void SetFormula(const string_type& a_strFormula); + void SetArgSep(char_type cArgSep); + + int GetPos() const; + const string_type& GetExpr() const; + varmap_type& GetUsedVar(); + char_type GetArgSep() const; + + void IgnoreUndefVar(bool bIgnore); + void ReInit(); + token_type ReadNextToken(); + + private: + /** \brief Syntax codes. + + The syntax codes control the syntax check done during the first time parsing of + the expression string. They are flags that indicate which tokens are allowed next + if certain tokens are identified. + */ + enum ESynCodes { + noBO = 1 << 0, ///< to avoid i.e. "cos(7)(" + noBC = 1 << 1, ///< to avoid i.e. "sin)" or "()" + noVAL = 1 << 2, ///< to avoid i.e. "tan 2" or "sin(8)3.14" + noVAR = 1 << 3, ///< to avoid i.e. "sin a" or "sin(8)a" + noARG_SEP = 1 << 4, ///< to avoid i.e. ",," or "+," ... + noFUN = 1 << 5, ///< to avoid i.e. "sqrt cos" or "(1)sin" + noOPT = 1 << 6, ///< to avoid i.e. "(+)" + noPOSTOP = 1 << 7, ///< to avoid i.e. "(5!!)" "sin!" + noINFIXOP = 1 << 8, ///< to avoid i.e. "++4" "!!4" + noEND = 1 << 9, ///< to avoid unexpected end of formula + noSTR = 1 << 10, ///< to block numeric arguments on string functions + noASSIGN = 1 << 11, ///< to block assignment to constant i.e. "4=7" + noIF = 1 << 12, + noELSE = 1 << 13, + sfSTART_OF_LINE = noOPT | noBC | noPOSTOP | noASSIGN | noIF | noELSE | noARG_SEP, + noANY = ~0 ///< All of he above flags set + }; + + ParserTokenReader(const ParserTokenReader& a_Reader); + ParserTokenReader& operator=(const ParserTokenReader& a_Reader); + void Assign(const ParserTokenReader& a_Reader); + + void SetParent(ParserBase* a_pParent); + int ExtractToken(const char_type* a_szCharSet, + string_type& a_strTok, + std::size_t a_iPos) const; + int ExtractOperatorToken(string_type& a_sTok, + std::size_t a_iPos) const; + + bool IsBuiltIn(token_type& a_Tok); + bool IsArgSep(token_type& a_Tok); + bool IsEOF(token_type& a_Tok); + bool IsInfixOpTok(token_type& a_Tok); + bool IsFunTok(token_type& a_Tok); + bool IsPostOpTok(token_type& a_Tok); + bool IsOprt(token_type& a_Tok); + bool IsValTok(token_type& a_Tok); + bool IsVarTok(token_type& a_Tok); + bool IsStrVarTok(token_type& a_Tok); + bool IsUndefVarTok(token_type& a_Tok); + bool IsString(token_type& a_Tok); + void Error(EErrorCodes a_iErrc, + int a_iPos = -1, + const string_type& a_sTok = string_type()) const; + + token_type& SaveBeforeReturn(const token_type& tok); + + ParserBase* m_pParser; + string_type m_strFormula; + int m_iPos; + int m_iSynFlags; + bool m_bIgnoreUndefVar; + + const funmap_type* m_pFunDef; + const funmap_type* m_pPostOprtDef; + const funmap_type* m_pInfixOprtDef; + const funmap_type* m_pOprtDef; + const valmap_type* m_pConstDef; + const strmap_type* m_pStrVarDef; + + varmap_type* m_pVarDef; ///< The only non const pointer to parser internals + facfun_type m_pFactory; + void* m_pFactoryData; + std::list m_vIdentFun; ///< Value token identification function + varmap_type m_UsedVar; + value_type m_fZero; ///< Dummy value of zero, referenced by undefined variables + + std::stack m_bracketStack; + + token_type m_lastTok; + char_type m_cArgSep; ///< The character used for separating function arguments + }; } // namespace mu #endif - - diff --git a/libsrc/spatialdata/muparser/muparserfwd.hh b/libsrc/spatialdata/muparser/muparserfwd.hh index d5808fac..a2d16a04 100644 --- a/libsrc/spatialdata/muparser/muparserfwd.hh +++ b/libsrc/spatialdata/muparser/muparserfwd.hh @@ -16,6 +16,6 @@ namespace mu { typedef MUP_BASETYPE value_type; -} // mu +} // namespace mu // End of file diff --git a/libsrc/spatialdata/spatialdb/AnalyticDB.cc b/libsrc/spatialdata/spatialdb/AnalyticDB.cc index 8338c0d7..8e48c7bf 100644 --- a/libsrc/spatialdata/spatialdb/AnalyticDB.cc +++ b/libsrc/spatialdata/spatialdb/AnalyticDB.cc @@ -15,17 +15,17 @@ // Include ios here to avoid some Python/gcc issues #include -#include "spatialdata/units/Parser.hh" // USES Parser #include "spatialdata/geocoords/CSCart.hh" // HASA CoordSys #include "spatialdata/geocoords/Converter.hh" // USES Converter #include "spatialdata/muparser/muParser.h" // USES mu::parser +#include "spatialdata/units/Parser.hh" // USES Parser -#include // USES std::vector #include // USES std::runtime_error +#include // USES std::vector +#include // USES assert() #include // USES std::ostringsgream #include // USES strcasecmp() -#include // USES assert() // ---------------------------------------------------------------------- /// Default constructor @@ -38,7 +38,8 @@ spatialdata::spatialdb::AnalyticDB::AnalyticDB(void) : _converter(new spatialdata::geocoords::Converter), _queryValues(NULL), _numValues(0), - _querySize(0) {} + _querySize(0) { +} // ---------------------------------------------------------------------- @@ -53,15 +54,18 @@ spatialdata::spatialdb::AnalyticDB::AnalyticDB(const char* label) : _converter(new spatialdata::geocoords::Converter), _queryValues(NULL), _numValues(0), - _querySize(0) {} + _querySize(0) { +} // ---------------------------------------------------------------------- /// Default destructor spatialdata::spatialdb::AnalyticDB::~AnalyticDB(void) { clear(); - delete _cs;_cs = NULL; - delete _converter;_converter = NULL; + delete _cs; + _cs = NULL; + delete _converter; + _converter = NULL; } // destructor @@ -69,11 +73,16 @@ spatialdata::spatialdb::AnalyticDB::~AnalyticDB(void) { /// Clear database values. void spatialdata::spatialdb::AnalyticDB::clear(void) { - delete[] _names;_names = NULL; - delete[] _scales;_scales = NULL; - delete[] _expressions;_expressions = NULL; - delete[] _parsers;_parsers = NULL; - delete[] _queryValues;_queryValues = NULL; + delete[] _names; + _names = NULL; + delete[] _scales; + _scales = NULL; + delete[] _expressions; + _expressions = NULL; + delete[] _parsers; + _parsers = NULL; + delete[] _queryValues; + _queryValues = NULL; _querySize = 0; _numValues = 0; } // destructor @@ -86,8 +95,7 @@ spatialdata::spatialdb::AnalyticDB::setData(const char* const* names, const char* const* units, const char* const* expressions, const size_t numValues) { - assert( (0 < numValues && names && units && expressions) || - (0 == numValues && !names && !units && !expressions) ); + assert((0 < numValues && names && units && expressions) || (0 == numValues && !names && !units && !expressions)); clear(); @@ -129,7 +137,8 @@ spatialdata::spatialdb::AnalyticDB::setData(const char* const* names, // Default query values is all values. _querySize = _numValues; - delete[] _queryValues;_queryValues = (_querySize > 0) ? new size_t[_querySize] : NULL; + delete[] _queryValues; + _queryValues = (_querySize > 0) ? new size_t[_querySize] : NULL; for (size_t i = 0; i < _querySize; ++i) { _queryValues[i] = i; } // for @@ -141,7 +150,9 @@ spatialdata::spatialdb::AnalyticDB::setData(const char* const* names, // Set filename containing data. void spatialdata::spatialdb::AnalyticDB::setCoordSys(const geocoords::CoordSys& cs) { - delete _cs;_cs = cs.clone();assert(_cs); + delete _cs; + _cs = cs.clone(); + assert(_cs); } // setCoordSys @@ -169,14 +180,15 @@ spatialdata::spatialdb::AnalyticDB::setQueryValues(const char* const* names, const size_t numVals) { if (0 == numVals) { std::ostringstream msg; - msg << "Number of values for query in spatial database " << getDescription() - << "\n must be positive.\n"; + msg << "Number of values for query in spatial database " << getDescription() << "\n must be positive.\n"; throw std::invalid_argument(msg.str()); } // if assert(names && 0 < numVals); _querySize = numVals; - delete[] _queryValues;_queryValues = new size_t[numVals];assert(_queryValues); + delete[] _queryValues; + _queryValues = new size_t[numVals]; + assert(_queryValues); for (size_t iVal = 0; iVal < numVals; ++iVal) { size_t iName = 0; while (iName < _numValues) { @@ -187,8 +199,8 @@ spatialdata::spatialdb::AnalyticDB::setQueryValues(const char* const* names, } // while if (iName >= _numValues) { std::ostringstream msg; - msg << "Could not find value '" << names[iVal] << "' in spatial database '" - << getDescription() << "'. Available values are:"; + msg << "Could not find value '" << names[iVal] << "' in spatial database '" << getDescription() + << "'. Available values are:"; for (size_t iName = 0; iName < _numValues; ++iName) { msg << "\n " << _names[iName]; msg << "\n"; @@ -216,10 +228,8 @@ spatialdata::spatialdb::AnalyticDB::query(double* vals, } // if else if (numVals != _querySize) { std::ostringstream msg; - msg << "Number of values to be returned by spatial database " - << getDescription() << "\n" - << "(" << _querySize << ") does not match size of array provided (" - << numVals << ").\n"; + msg << "Number of values to be returned by spatial database " << getDescription() << "\n" + << "(" << _querySize << ") does not match size of array provided (" << numVals << ").\n"; throw std::invalid_argument(msg.str()); } // if diff --git a/libsrc/spatialdata/spatialdb/AnalyticDB.hh b/libsrc/spatialdata/spatialdb/AnalyticDB.hh index 3892a08c..dfec3f07 100644 --- a/libsrc/spatialdata/spatialdb/AnalyticDB.hh +++ b/libsrc/spatialdata/spatialdb/AnalyticDB.hh @@ -19,8 +19,7 @@ class spatialdata::spatialdb::AnalyticDB : public SpatialDB { friend class TestAnalyticDB; // unit testing -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /// Default constructor. @@ -100,15 +99,13 @@ public: const size_t numDims, const spatialdata::geocoords::CoordSys* csQuery); -private: - + private: // PRIVATE METHODS //////////////////////////////////////////////////// AnalyticDB(const AnalyticDB& data); ///< Not implemented const AnalyticDB& operator=(const AnalyticDB& data); ///< Not implemented -private: - + private: // PRIVATE MEMBERS ///////////////////////////////////////////////////// mu::value_type _expVars[3]; ///< Storage for default expression variables diff --git a/libsrc/spatialdata/spatialdb/AnalyticDB.icc b/libsrc/spatialdata/spatialdb/AnalyticDB.icc index 959ffe97..b6d2024a 100644 --- a/libsrc/spatialdata/spatialdb/AnalyticDB.icc +++ b/libsrc/spatialdata/spatialdb/AnalyticDB.icc @@ -10,15 +10,13 @@ #pragma once // Open the database and prepare for querying. -inline -void +inline void spatialdata::spatialdb::AnalyticDB::open(void) { } // Close the database. -inline -void +inline void spatialdata::spatialdb::AnalyticDB::close(void) { } diff --git a/libsrc/spatialdata/spatialdb/CompositeDB.cc b/libsrc/spatialdata/spatialdb/CompositeDB.cc index 09aba92b..599a4761 100644 --- a/libsrc/spatialdata/spatialdb/CompositeDB.cc +++ b/libsrc/spatialdata/spatialdb/CompositeDB.cc @@ -12,10 +12,10 @@ #include "CompositeDB.hh" // Implementation of class methods -#include // USES std::runtime_error +#include // USES assert() #include // USES std::ostringsgream +#include // USES std::runtime_error #include // USES strcasecmp() -#include // USES assert() // ---------------------------------------------------------------------- /// Default constructor @@ -23,7 +23,8 @@ spatialdata::spatialdb::CompositeDB::CompositeDB(void) : _dbA(NULL), _dbB(NULL), _infoA(NULL), - _infoB(NULL) {} + _infoB(NULL) { +} // ---------------------------------------------------------------------- @@ -33,7 +34,8 @@ spatialdata::spatialdb::CompositeDB::CompositeDB(const char* label) : _dbA(NULL), _dbB(NULL), _infoA(NULL), - _infoB(NULL) {} + _infoB(NULL) { +} // ---------------------------------------------------------------------- @@ -41,8 +43,10 @@ spatialdata::spatialdb::CompositeDB::CompositeDB(const char* label) : spatialdata::spatialdb::CompositeDB::~CompositeDB(void) { // Don't manage memory for dbA and dbB - delete _infoA;_infoA = NULL; - delete _infoB;_infoB = NULL; + delete _infoA; + _infoA = NULL; + delete _infoB; + _infoB = NULL; } // destructor @@ -57,7 +61,8 @@ spatialdata::spatialdb::CompositeDB::setDBA(SpatialDB* db, assert(numNames > 0); // Clear out old data - delete _infoA;_infoA = new DBInfo; + delete _infoA; + _infoA = new DBInfo; _dbA = db; // Set data @@ -82,7 +87,8 @@ spatialdata::spatialdb::CompositeDB::setDBB(SpatialDB* db, assert(numNames > 0); // Clear out old data - delete _infoB;_infoB = new DBInfo; + delete _infoB; + _infoB = new DBInfo; _dbB = db; // Set data @@ -114,8 +120,10 @@ spatialdata::spatialdb::CompositeDB::open(void) { _infoA->query_size = _infoA->num_names; const size_t qsizeA = _infoA->query_size; char** queryValuesA = (qsizeA > 0) ? new char*[qsizeA] : NULL; - delete[] _infoA->query_indices;_infoA->query_indices = (qsizeA > 0) ? new size_t[qsizeA] : NULL; - delete[] _infoA->query_buffer;_infoA->query_buffer = (qsizeA > 0) ? new double[qsizeA] : NULL; + delete[] _infoA->query_indices; + _infoA->query_indices = (qsizeA > 0) ? new size_t[qsizeA] : NULL; + delete[] _infoA->query_buffer; + _infoA->query_buffer = (qsizeA > 0) ? new double[qsizeA] : NULL; for (size_t i = 0; i < qsizeA; ++i) { _infoA->query_indices[i] = i; queryValuesA[i] = const_cast(_infoA->names_values[i].c_str()); @@ -126,16 +134,20 @@ spatialdata::spatialdb::CompositeDB::open(void) { _infoB->query_size = _infoB->num_names; const size_t qsizeB = _infoB->query_size; char** queryValuesB = (qsizeB > 0) ? new char*[qsizeB] : NULL; - delete[] _infoB->query_indices;_infoB->query_indices = (qsizeB > 0) ? new size_t[qsizeB] : NULL; - delete[] _infoB->query_buffer;_infoB->query_buffer = (qsizeB > 0) ? new double[qsizeB] : NULL; + delete[] _infoB->query_indices; + _infoB->query_indices = (qsizeB > 0) ? new size_t[qsizeB] : NULL; + delete[] _infoB->query_buffer; + _infoB->query_buffer = (qsizeB > 0) ? new double[qsizeB] : NULL; for (size_t i = 0; i < qsizeB; ++i) { _infoB->query_indices[i] = qsizeA + i; queryValuesB[i] = const_cast(_infoB->names_values[i].c_str()); } // for _dbB->setQueryValues(const_cast(queryValuesB), qsizeB); - delete[] queryValuesA;queryValuesA = NULL; - delete[] queryValuesB;queryValuesB = NULL; + delete[] queryValuesA; + queryValuesA = NULL; + delete[] queryValuesB; + queryValuesB = NULL; } // open @@ -192,8 +204,7 @@ spatialdata::spatialdb::CompositeDB::setQueryValues(const char* const* names, if (0 == numVals) { std::ostringstream msg; - msg << "Number of values for query in spatial database " << getDescription() - << " must be positive.\n"; + msg << "Number of values for query in spatial database " << getDescription() << " must be positive.\n"; throw std::invalid_argument(msg.str()); } // if assert(names && 0 < numVals); @@ -290,8 +301,10 @@ spatialdata::spatialdb::CompositeDB::setQueryValues(const char* const* names, _dbB->setQueryValues(const_cast(queryValsB), qsizeB); } // if - delete[] queryValsA;queryValsA = NULL; - delete[] queryValsB;queryValsB = NULL; + delete[] queryValsA; + queryValsA = NULL; + delete[] queryValsB; + queryValsB = NULL; } // queryVals @@ -319,10 +332,8 @@ spatialdata::spatialdb::CompositeDB::query(double* vals, } // if else if (numVals != querySize) { std::ostringstream msg; - msg << "Number of values to be returned by spatial database " - << getDescription() - << "(" << querySize << ") does not match size of array provided (" - << numVals << ").\n"; + msg << "Number of values to be returned by spatial database " << getDescription() << "(" << querySize + << ") does not match size of array provided (" << numVals << ").\n"; throw std::logic_error(msg.str()); } // if diff --git a/libsrc/spatialdata/spatialdb/CompositeDB.hh b/libsrc/spatialdata/spatialdb/CompositeDB.hh index 93964803..54229855 100644 --- a/libsrc/spatialdata/spatialdb/CompositeDB.hh +++ b/libsrc/spatialdata/spatialdb/CompositeDB.hh @@ -17,8 +17,7 @@ class spatialdata::spatialdb::CompositeDB : public SpatialDB { // class CompositeDB friend class TestCompositeDB; // unit testing -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /// Default constructor. @@ -97,15 +96,13 @@ public: const size_t numDims, const spatialdata::geocoords::CoordSys* pCSQuery); -private: - + private: // NOT IMPLEMENTED //////////////////////////////////////////////////// CompositeDB(const CompositeDB& data); ///< Not implemented const CompositeDB& operator=(const CompositeDB& data); ///< Not implemented -private: - + private: // PRIVATE STRUCTS //////////////////////////////////////////////////// struct DBInfo { @@ -120,21 +117,24 @@ private: query_indices(NULL), names_values(NULL), query_size(0), - num_names(0) {} + num_names(0) { + } ~DBInfo(void) { - delete[] query_buffer;query_buffer = NULL; - delete[] query_indices;query_indices = NULL; - delete[] names_values;names_values = NULL; + delete[] query_buffer; + query_buffer = NULL; + delete[] query_indices; + query_indices = NULL; + delete[] names_values; + names_values = NULL; query_size = 0; num_names = 0; } // destructor }; // DBInfo -private: - + private: // PRIVATE MEMBERS ///////////////////////////////////////////////////// SpatialDB* _dbA; ///< Spatial database A diff --git a/libsrc/spatialdata/spatialdb/Exception.hh b/libsrc/spatialdata/spatialdb/Exception.hh index 68be1268..becf3bae 100644 --- a/libsrc/spatialdata/spatialdb/Exception.hh +++ b/libsrc/spatialdata/spatialdb/Exception.hh @@ -15,8 +15,7 @@ /// C++ exceptions for spatial database. class spatialdata::spatialdb::OutOfBounds : public std::runtime_error { // class OutOfBounds -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /** Constructor. diff --git a/libsrc/spatialdata/spatialdb/Exception.icc b/libsrc/spatialdata/spatialdb/Exception.icc index f643a204..4ce7cb86 100644 --- a/libsrc/spatialdata/spatialdb/Exception.icc +++ b/libsrc/spatialdata/spatialdb/Exception.icc @@ -10,9 +10,8 @@ #pragma once // Constructor. -inline -spatialdata::spatialdb::OutOfBounds::OutOfBounds(const std::string& msg) : - std::runtime_error(msg) {} +inline spatialdata::spatialdb::OutOfBounds::OutOfBounds(const std::string& msg) : std::runtime_error(msg) { +} // version diff --git a/libsrc/spatialdata/spatialdb/GocadVoxet.cc b/libsrc/spatialdata/spatialdb/GocadVoxet.cc index db40eb12..986c9487 100644 --- a/libsrc/spatialdata/spatialdb/GocadVoxet.cc +++ b/libsrc/spatialdata/spatialdb/GocadVoxet.cc @@ -17,10 +17,10 @@ #include // USES std::ifstream #include // USES round() -#include // USES std::runtime_error -#include // USES std::ostringsgream -#include // USES memcpy() and strcmp() #include // USES assert() +#include // USES memcpy() and strcmp() +#include // USES std::ostringsgream +#include // USES std::runtime_error #if defined(WORDS_BIGENDIAN) #define NATIVE_BIG_ENDIAN @@ -30,14 +30,15 @@ // ---------------------------------------------------------------------- // Constructor -spatialdata::spatialdb::GocadVoxet::GocadVoxet(void) : - _data(NULL) {} +spatialdata::spatialdb::GocadVoxet::GocadVoxet(void) : _data(NULL) { +} // ---------------------------------------------------------------------- // Destructor spatialdata::spatialdb::GocadVoxet::~GocadVoxet(void) { - delete[] _data;_data = NULL; + delete[] _data; + _data = NULL; } // destructor @@ -51,8 +52,7 @@ spatialdata::spatialdb::GocadVoxet::read(const char* dir, fullname = std::string(dir) + std::string("/") + std::string(filename); _readVoxetFile(fullname.c_str(), property); - fullname = std::string(dir) + std::string("/") - + std::string(_property.filename); + fullname = std::string(dir) + std::string("/") + std::string(_property.filename); _readPropertyFile(fullname.c_str()); } // read @@ -66,31 +66,26 @@ spatialdata::spatialdb::GocadVoxet::query(double* value, const int numX = _geometry.n[0]; const int numY = _geometry.n[1]; const int numZ = _geometry.n[2]; - const int indexX = - round( (pt[0] - (_geometry.o[0]+_geometry.min[0]))*_geometry.scale[0]); - const int indexY = - round( (pt[1] - (_geometry.o[1]+_geometry.min[1]))*_geometry.scale[1]); - const int indexZ = - round( (pt[2] - (_geometry.o[2]+_geometry.min[2]))*_geometry.scale[2]); + const int indexX = round((pt[0] - (_geometry.o[0] + _geometry.min[0])) * _geometry.scale[0]); + const int indexY = round((pt[1] - (_geometry.o[1] + _geometry.min[1])) * _geometry.scale[1]); + const int indexZ = round((pt[2] - (_geometry.o[2] + _geometry.min[2])) * _geometry.scale[2]); // Check if voxet is in range int flag = 0; - if (( indexX >= 0) && ( indexX < numX) && - ( indexY >= 0) && ( indexY < numY) && - ( indexZ >= 0) && ( indexZ < numZ) ) { - int indexV = indexZ*numY*numX + indexY*numX + indexX; + if ((indexX >= 0) && (indexX < numX) && (indexY >= 0) && (indexY < numY) && (indexZ >= 0) && (indexZ < numZ)) { + int indexV = indexZ * numY * numX + indexY * numX + indexX; *value = _data[indexV]; // If voxet value is "no data value" if (fabs(1.0 - *value / _property.noDataValue) < 1.0e-6) { // If near indexZ=0, retry with indexZ+1, otherwise if near // indexZ=numZ, retry with indexZ-1. - const int dz = (indexZ < numZ/2) ? +1 : -1; + const int dz = (indexZ < numZ / 2) ? +1 : -1; const int maxRetries = 32; for (int iTry = 0; iTry < maxRetries; ++iTry) { - const int indexZNew = indexZ + dz*iTry; + const int indexZNew = indexZ + dz * iTry; assert(indexZNew >= 0 && indexZNew < numZ); - indexV = indexZNew*numY*numX + indexY*numX + indexX; + indexV = indexZNew * numY * numX + indexY * numX + indexX; *value = _data[indexV]; if (fabs(1.0 - *value / _property.noDataValue) > 1.0e-6) { break; @@ -115,12 +110,9 @@ spatialdata::spatialdb::GocadVoxet::queryNearest(double* value, const int numX = _geometry.n[0]; const int numY = _geometry.n[1]; const int numZ = _geometry.n[2]; - int indexX = - round( (pt[0] - (_geometry.o[0]+_geometry.min[0]))*_geometry.scale[0]); - int indexY = - round( (pt[1] - (_geometry.o[1]+_geometry.min[1]))*_geometry.scale[1]); - int indexZ = - round( (pt[2] - (_geometry.o[2]+_geometry.min[2]))*_geometry.scale[2]); + int indexX = round((pt[0] - (_geometry.o[0] + _geometry.min[0])) * _geometry.scale[0]); + int indexY = round((pt[1] - (_geometry.o[1] + _geometry.min[1])) * _geometry.scale[1]); + int indexZ = round((pt[2] - (_geometry.o[2] + _geometry.min[2])) * _geometry.scale[2]); // Correct to range of voxet, if necessary. int flag = 0; @@ -145,7 +137,7 @@ spatialdata::spatialdb::GocadVoxet::queryNearest(double* value, assert(indexY >= 0 && indexY < numY); assert(indexZ >= 0 && indexZ < numZ); - int indexV = indexZ*numY*numX + indexY*numX + indexX; + int indexV = indexZ * numY * numX + indexY * numX + indexX; *value = _data[indexV]; #if 0 @@ -195,13 +187,13 @@ spatialdata::spatialdb::GocadVoxet::_readVoxetFile(const char* filename, const char* headerE = "GOCAD Voxet 1"; const int headerLen = strlen(headerE); std::string hbuffer; - hbuffer.resize(headerLen+1); - buffer.read((char*) hbuffer.c_str(), sizeof(char)*headerLen); + hbuffer.resize(headerLen + 1); + buffer.read((char*)hbuffer.c_str(), sizeof(char) * headerLen); hbuffer[headerLen] = '\0'; if (0 != strcmp(headerE, hbuffer.c_str())) { std::ostringstream msg; - msg << "Header '" << hbuffer << "' does not match expected header '" - << headerE << "' in Gocad Voxet file '" << filename << "'.\n"; + msg << "Header '" << hbuffer << "' does not match expected header '" << headerE << "' in Gocad Voxet file '" + << filename << "'.\n"; throw std::runtime_error(msg.str()); } // if @@ -292,19 +284,16 @@ spatialdata::spatialdb::GocadVoxet::_readVoxetFile(const char* filename, buffer.clear(); buffer >> token; } // while - if (( token != "END") || !vfile.good()) { + if ((token != "END") || !vfile.good()) { throw std::runtime_error("I/O error while parsing Gocad Voxet tokens."); } } catch (const std::exception& err) { std::ostringstream msg; - msg << "Error occurred while reading Gocad Voxet file '" - << filename << "'.\n" - << err.what(); + msg << "Error occurred while reading Gocad Voxet file '" << filename << "'.\n" << err.what(); throw std::runtime_error(msg.str()); } catch (...) { std::ostringstream msg; - msg << "Unknown error occurred while reading Gocad Voxet file '" - << filename << "'.\n"; + msg << "Unknown error occurred while reading Gocad Voxet file '" << filename << "'.\n"; throw std::runtime_error(msg.str()); } // try/catch @@ -312,12 +301,12 @@ spatialdata::spatialdb::GocadVoxet::_readVoxetFile(const char* filename, assert(0 == _geometry.u[1] && 0 == _geometry.u[2]); assert(0 == _geometry.v[0] && 0 == _geometry.v[2]); assert(0 == _geometry.w[0] && 0 == _geometry.w[1]); - const double lenX = _geometry.max[0]*_geometry.u[0] - _geometry.min[0]; - const double lenY = _geometry.max[1]*_geometry.v[1] - _geometry.min[1]; - const double lenZ = _geometry.max[2]*_geometry.w[2] - _geometry.min[2]; - _geometry.scale[0] = (lenX != 0.0) ? (_geometry.n[0]-1) / lenX : 1.0e+30; - _geometry.scale[1] = (lenY != 0.0) ? (_geometry.n[1]-1) / lenY : 1.0e+30; - _geometry.scale[2] = (lenZ != 0.0) ? (_geometry.n[2]-1) / lenZ : 1.0e+30; + const double lenX = _geometry.max[0] * _geometry.u[0] - _geometry.min[0]; + const double lenY = _geometry.max[1] * _geometry.v[1] - _geometry.min[1]; + const double lenZ = _geometry.max[2] * _geometry.w[2] - _geometry.min[2]; + _geometry.scale[0] = (lenX != 0.0) ? (_geometry.n[0] - 1) / lenX : 1.0e+30; + _geometry.scale[1] = (lenY != 0.0) ? (_geometry.n[1] - 1) / lenY : 1.0e+30; + _geometry.scale[2] = (lenZ != 0.0) ? (_geometry.n[2] - 1) / lenZ : 1.0e+30; } // _readVoxetFile @@ -327,29 +316,26 @@ void spatialdata::spatialdb::GocadVoxet::_readPropertyFile(const char* filename) { assert(sizeof(float) == _property.esize); const int nvals = _geometry.n[0] * _geometry.n[1] * _geometry.n[2]; - delete[] _data;_data = new float[nvals]; + delete[] _data; + _data = new float[nvals]; try { std::ifstream pfile(filename); if (!pfile.is_open() || !pfile.good()) { std::ostringstream msg; - msg << "Could not open Gocad Voxet property file '" << filename - << "' for reading.\n"; + msg << "Could not open Gocad Voxet property file '" << filename << "' for reading.\n"; throw std::runtime_error(msg.str()); } // if - pfile.read((char*) _data, sizeof(float)*nvals); + pfile.read((char*)_data, sizeof(float) * nvals); _endianBigToNative(_data, nvals); } catch (const std::exception& err) { std::ostringstream msg; - msg << "Error occurred while reading Gocad Voxet property file '" - << filename << "'.\n" - << err.what(); + msg << "Error occurred while reading Gocad Voxet property file '" << filename << "'.\n" << err.what(); throw std::runtime_error(msg.str()); } catch (...) { std::ostringstream msg; - msg << "Unknown error occurred while reading Gocad Voxet property file '" - << filename << "'.\n"; + msg << "Unknown error occurred while reading Gocad Voxet property file '" << filename << "'.\n"; throw std::runtime_error(msg.str()); } // try/catch } // _readPropertyFile @@ -363,7 +349,7 @@ spatialdata::spatialdb::GocadVoxet::_endianBigToNative(float* vals, assert(0 != vals); #if defined(NATIVE_LITTLE_ENDIAN) for (int i = 0; i < nvals; ++i) { - char* buf = (char*) (vals + i); + char* buf = (char*)(vals + i); char tmp = buf[3]; buf[3] = buf[0]; buf[0] = tmp; @@ -379,15 +365,15 @@ spatialdata::spatialdb::GocadVoxet::_endianBigToNative(float* vals, // Reset class data. void spatialdata::spatialdb::GocadVoxet::_resetData(void) { - const float zero[] = { 0.0, 0.0, 0.0 }; - const float one[] = { 1.0, 1.0, 1.0 }; - - memcpy(_geometry.o, zero, 3*sizeof(float)); - memcpy(_geometry.u, zero, 3*sizeof(float)); - memcpy(_geometry.v, zero, 3*sizeof(float)); - memcpy(_geometry.w, zero, 3*sizeof(float)); - memcpy(_geometry.min, zero, 3*sizeof(float)); - memcpy(_geometry.max, one, 3*sizeof(float)); + const float zero[] = {0.0, 0.0, 0.0}; + const float one[] = {1.0, 1.0, 1.0}; + + memcpy(_geometry.o, zero, 3 * sizeof(float)); + memcpy(_geometry.u, zero, 3 * sizeof(float)); + memcpy(_geometry.v, zero, 3 * sizeof(float)); + memcpy(_geometry.w, zero, 3 * sizeof(float)); + memcpy(_geometry.min, zero, 3 * sizeof(float)); + memcpy(_geometry.max, one, 3 * sizeof(float)); _geometry.name[0] = ""; _geometry.name[1] = ""; _geometry.name[2] = ""; @@ -403,7 +389,8 @@ spatialdata::spatialdb::GocadVoxet::_resetData(void) { _property.offset = 0; _property.filename = ""; - delete[] _data;_data = 0; + delete[] _data; + _data = 0; } // _resetData diff --git a/libsrc/spatialdata/spatialdb/GocadVoxet.hh b/libsrc/spatialdata/spatialdb/GocadVoxet.hh index 1cad7a5d..b0d7cab7 100644 --- a/libsrc/spatialdata/spatialdb/GocadVoxet.hh +++ b/libsrc/spatialdata/spatialdb/GocadVoxet.hh @@ -17,8 +17,7 @@ class spatialdata::spatialdb::GocadVoxet { // GocadVoxet friend class TestGocadVOxet; // unit testing // PUBLIC MEMBERS /////////////////////////////////////////////////////// -public: - + public: /// Constructor GocadVoxet(void); @@ -54,14 +53,12 @@ public: const double pt[3]) const; // NOT IMPLEMENTED ////////////////////////////////////////////////////// -private: - + private: GocadVoxet(const GocadVoxet&); ///< Not implemented const GocadVoxet& operator=(const GocadVoxet&); ///< Not implemented // PRIVATE STRUCTS ////////////////////////////////////////////////////// -private: - + private: struct Geometry { float o[3]; float u[3]; @@ -86,8 +83,7 @@ private: }; // property // PRIVATE METHODS ////////////////////////////////////////////////////// -private: - + private: /** Read voxet file. * * @param filename Name of Gocad voxet file. @@ -114,8 +110,7 @@ private: void _resetData(void); // PRIVATE MEMBERS ////////////////////////////////////////////////////// -private: - + private: Geometry _geometry; ///< Geometry of voxet data. Property _property; ///< Voxet properties. float* _data; ///< Array with data values diff --git a/libsrc/spatialdata/spatialdb/GravityField.cc b/libsrc/spatialdata/spatialdb/GravityField.cc index 19a3659b..8ae626dd 100644 --- a/libsrc/spatialdata/spatialdb/GravityField.cc +++ b/libsrc/spatialdata/spatialdb/GravityField.cc @@ -12,24 +12,23 @@ #include "GravityField.hh" // Implementation of class methods -#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys #include "spatialdata/geocoords/CSGeo.hh" // USES CSGeo +#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys +#include // USES assert() #include // USES sqrt() -#include // USES strcasecmp() -#include // USES std::runtime_error #include // USES std::ostringsgream -#include // USES assert() +#include // USES std::runtime_error +#include // USES strcasecmp() namespace spatialdata { namespace spatialdb { class _GravityField; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata class spatialdata::spatialdb::_GravityField { -public: - + public: static const size_t numValues; static const char* valueNames[3]; }; @@ -69,7 +68,7 @@ void spatialdata::spatialdb::GravityField::setGravityDir(const double x, const double y, const double z) { - const double mag = std::max(1.0e-8, sqrt(x*x + y*y + z*z)); + const double mag = std::max(1.0e-8, sqrt(x * x + y * y + z * z)); _gravityDir[0] = x / mag; _gravityDir[1] = y / mag; _gravityDir[2] = z / mag; @@ -143,8 +142,8 @@ spatialdata::spatialdb::GravityField::setQueryValues(const char* const* names, _queryValues[iVal] = 2; } else { std::ostringstream msg; - msg << "Could not find value '" << names[iVal] << "' in spatial database '" - << getDescription() << "'. Available values are: " + msg << "Could not find value '" << names[iVal] << "' in spatial database '" << getDescription() + << "'. Available values are: " << "'" << _GravityField::valueNames[0] << "', " << "'" << _GravityField::valueNames[1] << "', " << "'" << _GravityField::valueNames[2] << "'."; @@ -171,16 +170,14 @@ spatialdata::spatialdb::GravityField::query(double* vals, throw std::logic_error(msg.str()); } else if (numVals != _querySize) { std::ostringstream msg; - msg << "Number of values to be returned by spatial database " - << getDescription() << "\n" - << "(" << _querySize << ") does not match size of array provided (" - << numVals << ").\n"; + msg << "Number of values to be returned by spatial database " << getDescription() << "\n" + << "(" << _querySize << ") does not match size of array provided (" << numVals << ").\n"; throw std::logic_error(msg.str()); } // if if (geocoords::CoordSys::CARTESIAN == cs->getCSType()) { for (size_t i = 0; i < _querySize; ++i) { - vals[i] = _acceleration*_gravityDir[_queryValues[i]]; + vals[i] = _acceleration * _gravityDir[_queryValues[i]]; } // for } else { const geocoords::CSGeo* csGeo = dynamic_cast(cs); diff --git a/libsrc/spatialdata/spatialdb/GravityField.hh b/libsrc/spatialdata/spatialdb/GravityField.hh index 71908fc5..57adadff 100644 --- a/libsrc/spatialdata/spatialdb/GravityField.hh +++ b/libsrc/spatialdata/spatialdb/GravityField.hh @@ -15,8 +15,7 @@ class spatialdata::spatialdb::GravityField : public SpatialDB { friend class TestGravityField; // unit testing -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /// Default constructor. @@ -88,15 +87,13 @@ public: const size_t numDims, const spatialdata::geocoords::CoordSys* cs); -private: - + private: // PRIVATE METHODS //////////////////////////////////////////////////// GravityField(const GravityField& data); ///< Not implemented const GravityField& operator=(const GravityField& data); ///< Not implemented -private: - + private: // PRIVATE MEMBERS ///////////////////////////////////////////////////// double _gravityDir[3]; ///< Direction of gravitational body force. diff --git a/libsrc/spatialdata/spatialdb/SCECCVMH.cc b/libsrc/spatialdata/spatialdb/SCECCVMH.cc index acf8f200..f5f4ed8b 100644 --- a/libsrc/spatialdata/spatialdb/SCECCVMH.cc +++ b/libsrc/spatialdata/spatialdb/SCECCVMH.cc @@ -17,12 +17,12 @@ #include "spatialdata/geocoords/CSGeo.hh" // USES CSGeo #include "spatialdata/geocoords/Converter.hh" // USES Converter +#include // USES assert() +#include // USES memcpy() #include // USES pow() #include // USES std::ostringstream #include // USES std::logic_error -#include // USES memcpy() #include // USES strcasecmp() -#include // USES assert() // ---------------------------------------------------------------------- // Constructor @@ -59,25 +59,38 @@ spatialdata::spatialdb::SCECCVMH::SCECCVMH(void) : // ---------------------------------------------------------------------- // Destructor spatialdata::spatialdb::SCECCVMH::~SCECCVMH(void) { - delete _laLowResVp;_laLowResVp = NULL; - delete _laLowResTag;_laLowResTag = NULL; - delete _laHighResVp;_laHighResVp = NULL; - delete _laHighResTag;_laHighResTag = NULL; - delete _crustMantleVp;_crustMantleVp = NULL; - delete _crustMantleVs;_crustMantleVs = NULL; - delete _crustMantleTag;_crustMantleTag = NULL; - delete _topoElev;_topoElev = NULL; - delete _baseDepth;_baseDepth = NULL; - delete _mohoDepth;_mohoDepth = NULL; - delete _csUTM;_csUTM = NULL; + delete _laLowResVp; + _laLowResVp = NULL; + delete _laLowResTag; + _laLowResTag = NULL; + delete _laHighResVp; + _laHighResVp = NULL; + delete _laHighResTag; + _laHighResTag = NULL; + delete _crustMantleVp; + _crustMantleVp = NULL; + delete _crustMantleVs; + _crustMantleVs = NULL; + delete _crustMantleTag; + _crustMantleTag = NULL; + delete _topoElev; + _topoElev = NULL; + delete _baseDepth; + _baseDepth = NULL; + delete _mohoDepth; + _mohoDepth = NULL; + delete _csUTM; + _csUTM = NULL; _squashLimit = 0.0; _minVs = 0.0; - delete[] _queryValues;_queryValues = NULL; + delete[] _queryValues; + _queryValues = NULL; _querySize = 0; _squashTopo = 0; - delete _converter;_converter = NULL; + delete _converter; + _converter = NULL; } // destructor @@ -151,16 +164,26 @@ spatialdata::spatialdb::SCECCVMH::open(void) { // Close the database. void spatialdata::spatialdb::SCECCVMH::close(void) { - delete _laLowResVp;_laLowResVp = NULL; - delete _laLowResTag;_laLowResTag = NULL; - delete _laHighResVp;_laHighResVp = NULL; - delete _laHighResTag;_laHighResTag = NULL; - delete _crustMantleVp;_crustMantleVp = NULL; - delete _crustMantleVs;_crustMantleVs = NULL; - delete _crustMantleTag;_crustMantleTag = NULL; - delete _topoElev;_topoElev = NULL; - delete _baseDepth;_baseDepth = NULL; - delete _mohoDepth;_mohoDepth = NULL; + delete _laLowResVp; + _laLowResVp = NULL; + delete _laLowResTag; + _laLowResTag = NULL; + delete _laHighResVp; + _laHighResVp = NULL; + delete _laHighResTag; + _laHighResTag = NULL; + delete _crustMantleVp; + _crustMantleVp = NULL; + delete _crustMantleVs; + _crustMantleVs = NULL; + delete _crustMantleTag; + _crustMantleTag = NULL; + delete _topoElev; + _topoElev = NULL; + delete _baseDepth; + _baseDepth = NULL; + delete _mohoDepth; + _mohoDepth = NULL; } // close @@ -198,14 +221,14 @@ spatialdata::spatialdb::SCECCVMH::setQueryValues(const char* const* names, const size_t numVals) { if (0 == numVals) { std::ostringstream msg; - msg << "Number of values for query in spatial database " << getDescription() - << "\n must be positive.\n"; + msg << "Number of values for query in spatial database " << getDescription() << "\n must be positive.\n"; throw std::invalid_argument(msg.str()); } // if assert(names && 0 < numVals); _querySize = numVals; - delete[] _queryValues;_queryValues = new size_t[numVals]; + delete[] _queryValues; + _queryValues = new size_t[numVals]; for (size_t iVal = 0; iVal < numVals; ++iVal) { if (0 == strcasecmp(names[iVal], "vp")) { _queryValues[iVal] = QUERY_VP; @@ -223,8 +246,8 @@ spatialdata::spatialdb::SCECCVMH::setQueryValues(const char* const* names, _queryValues[iVal] = QUERY_VPTAG; } else { std::ostringstream msg; - msg << "Could not find value '" << names[iVal] << "' in spatial database '" - << getDescription() << "'. Available values are:\n" + msg << "Could not find value '" << names[iVal] << "' in spatial database '" << getDescription() + << "'. Available values are:\n" << "vp, vs, density, topo-elev, basement-depth, moho-depth, vp-tag."; throw std::out_of_range(msg.str()); } // else @@ -247,10 +270,8 @@ spatialdata::spatialdb::SCECCVMH::query(double* vals, throw std::logic_error(msg.str()); } else if (numVals != _querySize) { std::ostringstream msg; - msg << "Number of values to be returned by spatial database " - << getDescription() << "\n" - << "(" << _querySize << ") does not match size of array provided (" - << numVals << ").\n"; + msg << "Number of values to be returned by spatial database " << getDescription() << "\n" + << "(" << _querySize << ") does not match size of array provided (" << numVals << ").\n"; throw std::invalid_argument(msg.str()); } else if (3 != numDims) { std::ostringstream msg; @@ -259,13 +280,13 @@ spatialdata::spatialdb::SCECCVMH::query(double* vals, } // if // Convert coordinates to UTM - memcpy(_xyzUTM, coords, numDims*sizeof(double)); + memcpy(_xyzUTM, coords, numDims * sizeof(double)); assert(_converter); _converter->convert(_xyzUTM, 1, numDims, _csUTM, csQuery); bool haveTopo = false; double topoElev = 0; - if (_squashTopo && ( _xyzUTM[2] > _squashLimit) ) { + if (_squashTopo && (_xyzUTM[2] > _squashLimit)) { _topoElev->queryNearest(&topoElev, _xyzUTM); haveTopo = true; _xyzUTM[2] += topoElev; @@ -339,7 +360,6 @@ spatialdata::spatialdb::SCECCVMH::query(double* vals, default: assert(0); } // switch - } return queryFlag; } // query @@ -424,13 +444,12 @@ spatialdata::spatialdb::SCECCVMH::_calcDensity(const double vp) const { // Compute density from Vp. double spatialdata::spatialdb::SCECCVMH::_calcVs(const double vp) const { - double vs = (vp < 4250.0) ? - (vp - 1360.0) / 1.16 : - 785.8 - 1.2344*vp + 794.9 * pow(vp/1000.0,2) - - 123.8 * pow(vp/1000.0,3) + 6.4 * pow(vp/1000.0,4); + double vs = (vp < 4250.0) ? (vp - 1360.0) / 1.16 + : 785.8 - 1.2344 * vp + 794.9 * pow(vp / 1000.0, 2) - 123.8 * pow(vp / 1000.0, 3) + + 6.4 * pow(vp / 1000.0, 4); if (vp < 1500.0) { if (vp != 1480.0) { // if not water - vs = (1500.0-1360.0)/1.16; + vs = (1500.0 - 1360.0) / 1.16; } else { vs = 0.0; // water } // if/else diff --git a/libsrc/spatialdata/spatialdb/SCECCVMH.hh b/libsrc/spatialdata/spatialdb/SCECCVMH.hh index 387368b4..5fb52b65 100644 --- a/libsrc/spatialdata/spatialdb/SCECCVMH.hh +++ b/libsrc/spatialdata/spatialdb/SCECCVMH.hh @@ -17,8 +17,7 @@ class spatialdata::spatialdb::SCECCVMH : SpatialDB { friend class TestSCECCVMH; // unit testing // PUBLIC MEMBERS /////////////////////////////////////////////////////// -public: - + public: /// Constructor SCECCVMH(void); @@ -46,7 +45,7 @@ public: * @param limit Minimum elevation for squashing. */ void setSquashFlag(const bool flag, - const double limit=-2000.0); + const double limit = -2000.0); /// Open the database and prepare for querying. void open(void); @@ -94,27 +93,24 @@ public: const spatialdata::geocoords::CoordSys* pCSQuery); // NOT IMPLEMENTED ////////////////////////////////////////////////////// -private: - + private: SCECCVMH(const SCECCVMH&); ///< Not implemented const SCECCVMH& operator=(const SCECCVMH&); ///< Not implemented // PRIVATE ENUMS //////////////////////////////////////////////////////// -private: - + private: enum QueryValsEnum { - QUERY_VP=0, // vp - QUERY_VS=1, // vs - QUERY_DENSITY=2, // density - QUERY_TOPOELEV=3, // Elevation of topography - QUERY_BASEDEPTH=4, // Depth of basement - QUERY_MOHODEPTH=5, // Depth of Moho - QUERY_VPTAG=6 // Tag for Vp + QUERY_VP = 0, // vp + QUERY_VS = 1, // vs + QUERY_DENSITY = 2, // density + QUERY_TOPOELEV = 3, // Elevation of topography + QUERY_BASEDEPTH = 4, // Depth of basement + QUERY_MOHODEPTH = 5, // Depth of Moho + QUERY_VPTAG = 6 // Tag for Vp }; // ValsEnum // PRIVATE METHODS ////////////////////////////////////////////////////// -private: - + private: /** Perform query for Vp. * * @param vp Result of query @@ -150,8 +146,7 @@ private: double _minVp(void) const; // PRIVATE MEMBERS ////////////////////////////////////////////////////// -private: - + private: double _xyzUTM[3]; std::string _dataDir; GocadVoxet* _laLowResVp; diff --git a/libsrc/spatialdata/spatialdb/SCECCVMH.icc b/libsrc/spatialdata/spatialdb/SCECCVMH.icc index 780af8e3..a9914605 100644 --- a/libsrc/spatialdata/spatialdb/SCECCVMH.icc +++ b/libsrc/spatialdata/spatialdb/SCECCVMH.icc @@ -10,16 +10,14 @@ #pragma once // Set directory containing SCEC CVM-H data files. -inline -void +inline void spatialdata::spatialdb::SCECCVMH::setDataDir(const char* dir) { _dataDir = dir; } // Set squashed topography/bathymetry flag and minimum elevation of -inline -void +inline void spatialdata::spatialdb::SCECCVMH::setSquashFlag(const bool flag, const double limit) { _squashTopo = flag; @@ -28,8 +26,7 @@ spatialdata::spatialdb::SCECCVMH::setSquashFlag(const bool flag, // Compute minimum Vp from minimum Vs. -inline -double +inline double spatialdata::spatialdb::SCECCVMH::_minVp(void) const { // Use inverse of nominal Vp->Vs relation to compute minimum Vp. const double minVp = 1360.0 + 1.16 * _minVs; diff --git a/libsrc/spatialdata/spatialdb/SimpleDB.cc b/libsrc/spatialdata/spatialdb/SimpleDB.cc index 61b0d6fa..88470706 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDB.cc +++ b/libsrc/spatialdata/spatialdb/SimpleDB.cc @@ -10,19 +10,19 @@ #include -#include "SpatialDB.hh" // ISA SpatialDB object #include "SimpleDB.hh" // Implementation of class methods +#include "SpatialDB.hh" // ISA SpatialDB object -#include "SimpleIO.hh" // USES SimpleIO #include "SimpleDBData.hh" // USES SimpleDBData #include "SimpleDBQuery.hh" // USES SimpleDBQuery +#include "SimpleIO.hh" // USES SimpleIO #include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys -#include // USES std::ostringsgream +#include "Exception.hh" // USES OutOfBounds #include // USES assert() +#include // USES std::ostringsgream #include // USES std::runtime_error -#include "Exception.hh" // USES OutOfBounds // ---------------------------------------------------------------------- /// Default constructor @@ -30,7 +30,8 @@ spatialdata::spatialdb::SimpleDB::SimpleDB(void) : _data(NULL), _iohandler(NULL), _query(NULL), - _cs(NULL) {} + _cs(NULL) { +} // ---------------------------------------------------------------------- @@ -40,16 +41,21 @@ spatialdata::spatialdb::SimpleDB::SimpleDB(const char* label) : _data(NULL), _iohandler(NULL), _query(NULL), - _cs(NULL) {} + _cs(NULL) { +} // ---------------------------------------------------------------------- /// Default destructor spatialdata::spatialdb::SimpleDB::~SimpleDB(void) { - delete _data;_data = NULL; - delete _iohandler;_iohandler = NULL; - delete _query;_query = NULL; - delete _cs;_cs = NULL; + delete _data; + _data = NULL; + delete _iohandler; + _iohandler = NULL; + delete _query; + _query = NULL; + delete _cs; + _cs = NULL; } // destructor @@ -69,7 +75,8 @@ spatialdata::spatialdb::SimpleDB::setQueryType(const SimpleDB::QueryEnum queryTy // Set the I/O handler. void spatialdata::spatialdb::SimpleDB::setIOHandler(const SimpleIO* iohandler) { - delete _iohandler;_iohandler = iohandler ? iohandler->clone() : NULL; + delete _iohandler; + _iohandler = iohandler ? iohandler->clone() : NULL; } // setIOHandler @@ -97,7 +104,8 @@ spatialdata::spatialdb::SimpleDB::open(void) { queryValues[i] = _data->getName(i); } // for _query->setQueryValues(queryValues, numValues); - delete[] queryValues;queryValues = NULL; + delete[] queryValues; + queryValues = NULL; } // open @@ -105,7 +113,8 @@ spatialdata::spatialdb::SimpleDB::open(void) { /// Close the database. void spatialdata::spatialdb::SimpleDB::close(void) { - delete _data;_data = 0; + delete _data; + _data = 0; if (_query) { _query->deallocate(); @@ -169,7 +178,7 @@ spatialdata::spatialdb::SimpleDB::query(double* vals, } // if _query->query(vals, numVals, coords, numDims, pCSQuery); } catch (const OutOfBounds& err) { - std::fill(vals, vals+numVals, 0); + std::fill(vals, vals + numVals, 0); return 1; } catch (const std::exception& err) { throw; diff --git a/libsrc/spatialdata/spatialdb/SimpleDB.hh b/libsrc/spatialdata/spatialdb/SimpleDB.hh index 3a4d87c0..c764ba39 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDB.hh +++ b/libsrc/spatialdata/spatialdb/SimpleDB.hh @@ -17,26 +17,24 @@ class spatialdata::spatialdb::SimpleDB : public SpatialDB { // class SimpleDB friend class TestSimpleDB; // unit testing friend class TestSimpleDBQuery; // unit testing -public: - + public: // PUBLIC ENUM //////////////////////////////////////////////////////// /** Topology of spatial data */ enum TopoEnum { - POINT=0, - LINE=1, - AREA=2, - VOLUME=3 + POINT = 0, + LINE = 1, + AREA = 2, + VOLUME = 3 }; /** Type of query */ enum QueryEnum { - NEAREST=0, - LINEAR=1 + NEAREST = 0, + LINEAR = 1 }; -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /// Default constructor. @@ -109,15 +107,13 @@ public: const size_t numDims, const spatialdata::geocoords::CoordSys* pCSQuery); -private: - + private: // PRIVATE METHODS //////////////////////////////////////////////////// SimpleDB(const SimpleDB& data); ///< Not implemented const SimpleDB& operator=(const SimpleDB& data); ///< Not implemented -private: - + private: // PRIVATE MEMBERS ///////////////////////////////////////////////////// SimpleDBData* _data; ///< Pointer to data diff --git a/libsrc/spatialdata/spatialdb/SimpleDBData.cc b/libsrc/spatialdata/spatialdb/SimpleDBData.cc index d410809a..7dedfd72 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBData.cc +++ b/libsrc/spatialdata/spatialdb/SimpleDBData.cc @@ -14,8 +14,8 @@ #include // USES memcpy() -#include // USES std::runtime_error #include // USES std::ostringsgream +#include // USES std::runtime_error // ---------------------------------------------------------------------- // Default constructor @@ -27,16 +27,21 @@ spatialdata::spatialdb::SimpleDBData::SimpleDBData(void) : _numLocs(0), _numValues(0), _dataDim(0), - _spaceDim(0) {} + _spaceDim(0) { +} // ---------------------------------------------------------------------- // Default destructor spatialdata::spatialdb::SimpleDBData::~SimpleDBData(void) { - delete[] _data;_data = 0; - delete[] _coordinates;_coordinates = 0; - delete[] _names;_names = 0; - delete[] _units;_units = 0; + delete[] _data; + _data = 0; + delete[] _coordinates; + _coordinates = 0; + delete[] _names; + _names = 0; + delete[] _units; + _units = 0; _numLocs = 0; _numValues = 0; _dataDim = 0; @@ -51,10 +56,14 @@ spatialdata::spatialdb::SimpleDBData::allocate(const size_t numLocs, const size_t numValues, const size_t spaceDim, const size_t dataDim) { - delete[] _data;_data = 0; - delete[] _coordinates;_coordinates = 0; - delete[] _names;_names = 0; - delete[] _units;_units = 0; + delete[] _data; + _data = 0; + delete[] _coordinates; + _coordinates = 0; + delete[] _names; + _names = 0; + delete[] _units; + _units = 0; if (numLocs <= 0) { std::ostringstream msg; @@ -71,16 +80,16 @@ spatialdata::spatialdb::SimpleDBData::allocate(const size_t numLocs, msg << "Number of spatial dimensions (" << spaceDim << ") must be positive."; throw std::invalid_argument(msg.str()); } // if - if (( dataDim < 0) || ( dataDim > 3) ) { + if ((dataDim < 0) || (dataDim > 3)) { std::ostringstream msg; msg << "Spatial dimension of data (" << dataDim << ") must be in the range [0,3]."; throw std::out_of_range(msg.str()); } // if - size_t size = numLocs*numValues; + size_t size = numLocs * numValues; _data = (size > 0) ? new double[size] : NULL; - size = numLocs*spaceDim; + size = numLocs * spaceDim; _coordinates = (size > 0) ? new double[size] : NULL; size = numValues; @@ -104,7 +113,7 @@ spatialdata::spatialdb::SimpleDBData::setData(const double* values, assert(numLocs == _numLocs); assert(numValues == _numValues); - memcpy(_data, values, numLocs*numValues*sizeof(double)); + memcpy(_data, values, numLocs * numValues * sizeof(double)); } // data @@ -118,7 +127,7 @@ spatialdata::spatialdb::SimpleDBData::setCoordinates(const double* values, assert(numLocs == _numLocs); assert(spaceDim == _spaceDim); - memcpy(_coordinates, values, numLocs*spaceDim*sizeof(double)); + memcpy(_coordinates, values, numLocs * spaceDim * sizeof(double)); } // coordinates diff --git a/libsrc/spatialdata/spatialdb/SimpleDBData.hh b/libsrc/spatialdata/spatialdb/SimpleDBData.hh index 29c22bdd..226650c0 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBData.hh +++ b/libsrc/spatialdata/spatialdb/SimpleDBData.hh @@ -16,8 +16,7 @@ class spatialdata::spatialdb::SimpleDBData { // SimpleDBData friend class TestSimpleDBData; // unit testing -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /// Default constructor @@ -148,8 +147,7 @@ public: */ const char* getUnits(const size_t index) const; -private: - + private: // PRIVATE METHODS //////////////////////////////////////////////////// double* _data; ///< Array of data values. diff --git a/libsrc/spatialdata/spatialdb/SimpleDBData.icc b/libsrc/spatialdata/spatialdb/SimpleDBData.icc index 4fb396c2..4fb35be3 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBData.icc +++ b/libsrc/spatialdata/spatialdb/SimpleDBData.icc @@ -12,76 +12,67 @@ #include // USES assert() // Get number of locations for data. -inline -size_t +inline size_t spatialdata::spatialdb::SimpleDBData::getNumLocs(void) const { return _numLocs; } // Get number of values for data. -inline -size_t +inline size_t spatialdata::spatialdb::SimpleDBData::getNumValues(void) const { return _numValues; } // Get spatial dimension of data distribution. -inline -size_t +inline size_t spatialdata::spatialdb::SimpleDBData::getDataDim(void) const { return _dataDim; } // Get spatial dimension of locations. -inline -size_t +inline size_t spatialdata::spatialdb::SimpleDBData::getSpaceDim(void) const { return _spaceDim; } // Get coordinates of location in database. -inline -const double* +inline const double* spatialdata::spatialdb::SimpleDBData::getCoordinates(const size_t index) const { assert(index >= 0 && index < _numLocs); - return &_coordinates[index*_spaceDim]; + return &_coordinates[index * _spaceDim]; } // Get coordinates of location in database. -inline -double* +inline double* spatialdata::spatialdb::SimpleDBData::getCoordinates(const size_t index) { assert(index >= 0 && index < _numLocs); - return &_coordinates[index*_spaceDim]; + return &_coordinates[index * _spaceDim]; } // Get data values at location in database. -inline -const double* +inline const double* spatialdata::spatialdb::SimpleDBData::getData(const size_t index) const { assert(index >= 0 && index < _numLocs); - return &_data[index*_numValues]; + return &_data[index * _numValues]; } // Get data values at location in database. -inline -double* +inline double* spatialdata::spatialdb::SimpleDBData::getData(const size_t index) { assert(index >= 0 && index < _numLocs); - return &_data[index*_numValues]; + return &_data[index * _numValues]; } // Get name of value. -inline -const char* +inline const char* spatialdata::spatialdb::SimpleDBData::getName(const size_t index) const { assert(index >= 0 && index < _numValues); return _names[index].c_str(); @@ -89,8 +80,7 @@ spatialdata::spatialdb::SimpleDBData::getName(const size_t index) const { // Get units of value. -inline -const char* +inline const char* spatialdata::spatialdb::SimpleDBData::getUnits(const size_t index) const { assert(index >= 0 && index < _numValues); return _units[index].c_str(); diff --git a/libsrc/spatialdata/spatialdb/SimpleDBQuery.cc b/libsrc/spatialdata/spatialdb/SimpleDBQuery.cc index 8b830742..a8e822c1 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBQuery.cc +++ b/libsrc/spatialdata/spatialdb/SimpleDBQuery.cc @@ -10,9 +10,9 @@ #include -#include "SpatialDB.hh" // USES SimpleDB #include "SimpleDB.hh" // USES SimpleDB #include "SimpleDBQuery.hh" // implementation of class methods +#include "SpatialDB.hh" // USES SimpleDB #include "SimpleDBData.hh" // USEs SimpleDBData @@ -25,11 +25,11 @@ #define MAXFLOAT 1e+30 #endif -#include // USES memcpy() -#include // USES strcasecmp() +#include // USES std::fill(), std::lower_bound(), std::distance() #include // USES assert() +#include // USES memcpy() #include // USES std::ostringsgream -#include // USES std::fill(), std::lower_bound(), std::distance() +#include // USES strcasecmp() // ---------------------------------------------------------------------- // Default constructor. @@ -38,14 +38,16 @@ spatialdata::spatialdb::SimpleDBQuery::SimpleDBQuery(const SimpleDB& db) : _db(db), _converter(new spatialdata::geocoords::Converter), _queryValues(NULL), - _querySize(0) {} + _querySize(0) { +} // ---------------------------------------------------------------------- // Default destructor. spatialdata::spatialdb::SimpleDBQuery::~SimpleDBQuery(void) { deallocate(); - delete _converter;_converter = NULL; + delete _converter; + _converter = NULL; } // destructor @@ -53,7 +55,8 @@ spatialdata::spatialdb::SimpleDBQuery::~SimpleDBQuery(void) { // Deallocate data structures. void spatialdata::spatialdb::SimpleDBQuery::deallocate(void) { - delete[] _queryValues;_queryValues = NULL; + delete[] _queryValues; + _queryValues = NULL; _querySize = 0; _nearest.resize(0); } // deallocate @@ -75,14 +78,14 @@ spatialdata::spatialdb::SimpleDBQuery::setQueryValues(const char* const* names, assert(_db._data); if (0 == numVals) { std::ostringstream msg; - msg << "Number of values for query in spatial database " << _db.getDescription() - << "\n must be positive.\n"; + msg << "Number of values for query in spatial database " << _db.getDescription() << "\n must be positive.\n"; throw std::invalid_argument(msg.str()); } // if assert(names && 0 < numVals); _querySize = numVals; - delete[] _queryValues;_queryValues = new size_t[numVals]; + delete[] _queryValues; + _queryValues = new size_t[numVals]; for (size_t iVal = 0; iVal < numVals; ++iVal) { size_t iName = 0; const size_t numNames = _db._data->getNumValues(); @@ -94,8 +97,8 @@ spatialdata::spatialdb::SimpleDBQuery::setQueryValues(const char* const* names, } // while if (iName >= numNames) { std::ostringstream msg; - msg << "Could not find value '" << names[iVal] << "' in spatial database '" - << _db.getDescription() << "'. Available values are:"; + msg << "Could not find value '" << names[iVal] << "' in spatial database '" << _db.getDescription() + << "'. Available values are:"; for (size_t iName = 0; iName < numNames; ++iName) { msg << "\n " << _db._data->getName(iName); } @@ -125,10 +128,8 @@ spatialdata::spatialdb::SimpleDBQuery::query(double* vals, } // if else if (numVals != _querySize) { std::ostringstream msg; - msg << "Number of values to be returned by spatial database " - << _db.getDescription() << "\n" - << "(" << _querySize << ") does not match size of array provided (" - << numVals << ").\n"; + msg << "Number of values to be returned by spatial database " << _db.getDescription() << "\n" + << "(" << _querySize << ") does not match size of array provided (" << numVals << ").\n"; throw std::invalid_argument(msg.str()); } // if @@ -160,8 +161,7 @@ spatialdata::spatialdb::SimpleDBQuery::query(double* vals, void spatialdata::spatialdb::SimpleDBQuery::_queryNearest(double* vals, const size_t numVals) { - assert( (0 < numVals && vals) || - (0 == numVals && !vals) ); + assert((0 < numVals && vals) || (0 == numVals && !vals)); assert(_db._data); assert(numVals == _querySize); @@ -194,8 +194,7 @@ spatialdata::spatialdb::SimpleDBQuery::_queryNearest(double* vals, void spatialdata::spatialdb::SimpleDBQuery::_queryLinear(double* vals, const size_t numVals) { - assert( (0 < numVals && vals) || - (0 == numVals && !vals) ); + assert((0 < numVals && vals) || (0 == numVals && !vals)); assert(_db._data); assert(numVals == _querySize); @@ -253,8 +252,7 @@ spatialdata::spatialdb::SimpleDBQuery::_findNearest(void) { const double dist2 = _distSquared(_q, pt); // find place in nearest list if it exists - const std::vector::iterator pNearDist = - std::lower_bound(nearestDist.begin(), nearestDist.end(), dist2); + const std::vector::iterator pNearDist = std::lower_bound(nearestDist.begin(), nearestDist.end(), dist2); if (dist2 <= *pNearDist) { // if found place in nearest list #if !defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) size_t index = std::distance(nearestDist.begin(), pNearDist); @@ -264,9 +262,9 @@ spatialdata::spatialdb::SimpleDBQuery::_findNearest(void) { #endif // move values to allow insertion of current - for (size_t moveIndex = nearSize-1; moveIndex > index; --moveIndex) { - nearestDist[moveIndex] = nearestDist[moveIndex-1]; - _nearest[moveIndex] = _nearest[moveIndex-1]; + for (size_t moveIndex = nearSize - 1; moveIndex > index; --moveIndex) { + nearestDist[moveIndex] = nearestDist[moveIndex - 1]; + _nearest[moveIndex] = _nearest[moveIndex - 1]; } // for if (index < nearSize) { // insert current @@ -361,15 +359,14 @@ spatialdata::spatialdb::SimpleDBQuery::_findLinePt(std::vector* pWeigh const double abX = ptB[0] - ptA[0]; const double abY = ptB[1] - ptA[1]; const double abZ = ptB[2] - ptA[2]; - const double abdotab = abX*abX + abY*abY + abZ*abZ; - const double pbdotab = (ptB[0]-_q[0])*abX + (ptB[1]-_q[1])*abY + (ptB[2]-_q[2])*abZ; - const double apdotab = (_q[0]-ptA[0])*abX + (_q[1]-ptA[1])*abY + (_q[2]-ptA[2])*abZ; + const double abdotab = abX * abX + abY * abY + abZ * abZ; + const double pbdotab = (ptB[0] - _q[0]) * abX + (ptB[1] - _q[1]) * abY + (ptB[2] - _q[2]) * abZ; + const double apdotab = (_q[0] - ptA[0]) * abX + (_q[1] - ptA[1]) * abY + (_q[2] - ptA[2]) * abZ; wtA = pbdotab / abdotab; wtB = apdotab / abdotab; const double tolerance = 1e-06; - if (( wtA >= -tolerance) && - ( wtB >= -tolerance) ) { + if ((wtA >= -tolerance) && (wtB >= -tolerance)) { // found 2nd point if weights are positive within tolerance level // (i.e. interpolation, not extrapolation) break; @@ -449,49 +446,38 @@ spatialdata::spatialdb::SimpleDBQuery::_findAreaPt(std::vector* pWeigh // triangle ABC is not a tiny fraction of the distance AB // length(ab)^2 - const double ab2 = - pow(ptA[0]-ptB[0], 2) + - pow(ptA[1]-ptB[1], 2) + - pow(ptA[2]-ptB[2], 2); + const double ab2 = pow(ptA[0] - ptB[0], 2) + pow(ptA[1] - ptB[1], 2) + pow(ptA[2] - ptB[2], 2); const double tolerance = 1.0e-06; - if (areaABC > tolerance*ab2) { + if (areaABC > tolerance * ab2) { #endif // project P onto abc plane double qProj[3]; - const double qmod = dirABC[0]*_q[0] + dirABC[1]*_q[1] + dirABC[2]*_q[2]; - qProj[0] = _q[0] - dirABC[0]*qmod; - qProj[1] = _q[1] - dirABC[1]*qmod; - qProj[2] = _q[2] - dirABC[2]*qmod; + const double qmod = dirABC[0] * _q[0] + dirABC[1] * _q[1] + dirABC[2] * _q[2]; + qProj[0] = _q[0] - dirABC[0] * qmod; + qProj[1] = _q[1] - dirABC[1] * qmod; + qProj[2] = _q[2] - dirABC[2] * qmod; // wtA = areaBCQ / areaABC * DotProduct(dirBCQ, dirABC); double areaBCQ = 0; double dirBCQ[3]; _area(&areaBCQ, dirBCQ, ptB, ptC, qProj); - wtA = areaBCQ/areaABC * (dirBCQ[0]*dirABC[0] + - dirBCQ[1]*dirABC[1] + - dirBCQ[2]*dirABC[2]); + wtA = areaBCQ / areaABC * (dirBCQ[0] * dirABC[0] + dirBCQ[1] * dirABC[1] + dirBCQ[2] * dirABC[2]); // wtB = areaCAQ / areaABC * DotProduct(dirCAQ, dirABC); double areaCAQ = 0; double dirCAQ[3]; _area(&areaCAQ, dirCAQ, ptC, ptA, qProj); - wtB = areaCAQ/areaABC * (dirCAQ[0]*dirABC[0] + - dirCAQ[1]*dirABC[1] + - dirCAQ[2]*dirABC[2]); + wtB = areaCAQ / areaABC * (dirCAQ[0] * dirABC[0] + dirCAQ[1] * dirABC[1] + dirCAQ[2] * dirABC[2]); // wtC = areaABQ / areaABC * DotProduct(dirABQ, dirABC); double areaABQ = 0; double dirABQ[3]; _area(&areaABQ, dirABQ, ptA, ptB, qProj); - wtC = areaABQ/areaABC * (dirABQ[0]*dirABC[0] + - dirABQ[1]*dirABC[1] + - dirABQ[2]*dirABC[2]); + wtC = areaABQ / areaABC * (dirABQ[0] * dirABC[0] + dirABQ[1] * dirABC[1] + dirABQ[2] * dirABC[2]); const double tolerance = 1e-06; - if (( wtA >= -tolerance) && - ( wtB >= -tolerance) && - ( wtC >= -tolerance) ) { + if ((wtA >= -tolerance) && (wtB >= -tolerance) && (wtC >= -tolerance)) { // found 3rd point if weights are positive within tolerance level // (i.e. interpolation, not extrapolation) break; @@ -554,13 +540,10 @@ spatialdata::spatialdb::SimpleDBQuery::_findVolumePt(std::vector* pWei const double abcd = _volume(ptA, ptB, ptC, ptD); // ab = length(ab) - const double ab3 = - pow(pow(ptA[0] - ptB[0], 2) + - pow(ptA[1] - ptB[1], 2) + - pow(ptA[2] - ptB[2], 2), 3); + const double ab3 = pow(pow(ptA[0] - ptB[0], 2) + pow(ptA[1] - ptB[1], 2) + pow(ptA[2] - ptB[2], 2), 3); const double tolerance = 1.0e-06; - if (fabs(abcd) > tolerance*ab3) { + if (fabs(abcd) > tolerance * ab3) { // volume pbcd const double pbcd = _volume(_q, ptB, ptC, ptD); // wtA = vol(pbcd)/vol(abcd) @@ -582,10 +565,7 @@ spatialdata::spatialdb::SimpleDBQuery::_findVolumePt(std::vector* pWei wtD = abcp / abcd; const double tolerance = 1e-06; - if (( wtA >= -tolerance) && - ( wtB >= -tolerance) && - ( wtC >= -tolerance) && - ( wtD >= -tolerance) ) { + if ((wtA >= -tolerance) && (wtB >= -tolerance) && (wtC >= -tolerance) && (wtD >= -tolerance)) { // found 4th point if weights are positive within tolerance level // (i.e. interpolation, not extrapolation) break; @@ -614,7 +594,7 @@ spatialdata::spatialdb::SimpleDBQuery::_setPoint3(double pt3[3], pt3[0] = 0.0; pt3[1] = 0.0; pt3[2] = 0.0; - memcpy(pt3, pt, spaceDim*sizeof(double)); + memcpy(pt3, pt, spaceDim * sizeof(double)); } // _setPoint3 @@ -623,10 +603,10 @@ spatialdata::spatialdb::SimpleDBQuery::_setPoint3(double pt3[3], double spatialdata::spatialdb::SimpleDBQuery::_distSquared(const double a[3], const double b[3]) { - const double abX = b[0]-a[0]; - const double abY = b[1]-a[1]; - const double abZ = b[2]-a[2]; - const double dist2 = abX*abX + abY*abY + abZ*abZ; + const double abX = b[0] - a[0]; + const double abY = b[1] - a[1]; + const double abZ = b[2] - a[2]; + const double dist2 = abX * abX + abY * abY + abZ * abZ; return dist2; } // _distSquared @@ -654,11 +634,11 @@ spatialdata::spatialdb::SimpleDBQuery::_area(double* pArea, const double acY = c[1] - a[1]; const double acZ = c[2] - a[2]; - dir[0] = abY*acZ - abZ*acY; - dir[1] = abZ*acX - abX*acZ; - dir[2] = abX*acY - abY*acX; + dir[0] = abY * acZ - abZ * acY; + dir[1] = abZ * acX - abX * acZ; + dir[2] = abX * acY - abY * acX; - *pArea = sqrt(dir[0]*dir[0] + dir[1]*dir[1] + dir[2]*dir[2]); + *pArea = sqrt(dir[0] * dir[0] + dir[1] * dir[1] + dir[2] * dir[2]); if (0 != *pArea) { dir[0] /= *pArea; dir[1] /= *pArea; @@ -677,21 +657,13 @@ spatialdata::spatialdb::SimpleDBQuery::_volume(const double a[3], /* Compute volume of tetrahedral defined by four points. */ // _volume const double det1 = - b[0] * (c[1]*d[2] - c[2]*d[1]) + - b[1] * (c[2]*d[0] - c[0]*d[2]) + - b[2] * (c[0]*d[1] - c[1]*d[0]); + b[0] * (c[1] * d[2] - c[2] * d[1]) + b[1] * (c[2] * d[0] - c[0] * d[2]) + b[2] * (c[0] * d[1] - c[1] * d[0]); const double det2 = - -c[0] * (d[1]*a[2] - d[2]*a[1]) - - c[1] * (d[2]*a[0] - d[0]*a[2]) - - c[2] * (d[0]*a[1] - d[1]*a[0]); + -c[0] * (d[1] * a[2] - d[2] * a[1]) - c[1] * (d[2] * a[0] - d[0] * a[2]) - c[2] * (d[0] * a[1] - d[1] * a[0]); const double det3 = - d[0] * (a[1]*b[2] - a[2]*b[1]) + - d[1] * (a[2]*b[0] - a[0]*b[2]) + - d[2] * (a[0]*b[1] - a[1]*b[0]); + d[0] * (a[1] * b[2] - a[2] * b[1]) + d[1] * (a[2] * b[0] - a[0] * b[2]) + d[2] * (a[0] * b[1] - a[1] * b[0]); const double det4 = - -a[0] * (b[1]*c[2] - b[2]*c[1]) - - a[1] * (b[2]*c[0] - b[0]*c[2]) - - a[2] * (b[0]*c[1] - b[1]*c[0]); + -a[0] * (b[1] * c[2] - b[2] * c[1]) - a[1] * (b[2] * c[0] - b[0] * c[2]) - a[2] * (b[0] * c[1] - b[1] * c[0]); return (det1 + det2 + det3 + det4) / 6.0; } // _volume diff --git a/libsrc/spatialdata/spatialdb/SimpleDBQuery.hh b/libsrc/spatialdata/spatialdb/SimpleDBQuery.hh index 5b6c89a7..7e4fd018 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBQuery.hh +++ b/libsrc/spatialdata/spatialdb/SimpleDBQuery.hh @@ -9,8 +9,8 @@ // ================================================================================================= #pragma once -#include "spatialdbfwd.hh" // forward declarations #include "SimpleDB.hh" // USES SimpleDB +#include "spatialdbfwd.hh" // forward declarations #include "spatialdata/geocoords/geocoordsfwd.hh" // HOLDSA Converter @@ -20,8 +20,7 @@ class spatialdata::spatialdb::SimpleDBQuery { // class SimpleDBQuery friend class TestSimpleDBQuery; -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /** Default constructor. @@ -64,8 +63,7 @@ public: const size_t numDims, const spatialdata::geocoords::CoordSys* pCSQuery); -private: - + private: // PRIVATE STRUCT ///////////////////////////////////////////////////// /** Interpolation weighting information */ @@ -74,8 +72,7 @@ private: size_t nearIndex; ///< Index into nearest }; // struct WtStruct -private: - + private: // PRIVATE METHODS //////////////////////////////////////////////////// /** Query database using nearest neighbor algorithm. @@ -143,10 +140,9 @@ private: * @param pt Cooridinates of point in current coordinate sytem. * @param spaceDim Spatial dimension of current coordinate system. */ - static - void _setPoint3(double* const pt3, - const double* pt, - const size_t spaceDim); + static void _setPoint3(double* const pt3, + const double* pt, + const size_t spaceDim); /** Compute square of distance between points A and B. * @@ -181,8 +177,7 @@ private: const double c[3], const double d[3]); -private: - + private: // PRIVATE MEMBERS //////////////////////////////////////////////////// double _q[3]; ///< Location of query. diff --git a/libsrc/spatialdata/spatialdb/SimpleGridAscii.cc b/libsrc/spatialdata/spatialdb/SimpleGridAscii.cc index 4506f3ef..e5823b8b 100644 --- a/libsrc/spatialdata/spatialdb/SimpleGridAscii.cc +++ b/libsrc/spatialdata/spatialdb/SimpleGridAscii.cc @@ -12,28 +12,28 @@ #include "SimpleGridAscii.hh" // implementation of class methods -#include "SpatialDB.hh" // USES SimpleDB #include "SimpleDB.hh" // USES SimpleDB +#include "SpatialDB.hh" // USES SimpleDB #include "SimpleDBData.hh" // USES SimpleDBData -#include "spatialdata/geocoords/CoordSys.hh" // USES CSCart #include "spatialdata/geocoords/CSCart.hh" // USES CSCart #include "spatialdata/geocoords/CSPicklerAscii.hh" // USES CSPicklerAscii +#include "spatialdata/geocoords/CoordSys.hh" // USES CSCart #include "spatialdata/utils/LineParser.hh" // USES LineParser +#include // USES std::sort() +#include // USES pow() #include // USES std::ofstream, std::ifstream #include // USES setw(), setiosflags(), resetiosflags() -#include // USES pow() -#include // USES std::sort() #include // USES std::vector -#include // USES std::runtime_error +#include // USES assert() +#include // USES strlen() #include // USES std::cout #include // USES std::ostringsgream +#include // USES std::runtime_error #include // USES strcasecmp() -#include // USES strlen() -#include // USES assert() // ---------------------------------------------------------------------- const char* spatialdata::spatialdb::SimpleGridAscii::FILEHEADER = "#SPATIAL_GRID.ascii"; @@ -48,8 +48,7 @@ spatialdata::spatialdb::SimpleGridAscii::read(SimpleGridDB* db) { // read std::ifstream filein(db->_filename.c_str()); if (!filein.is_open() || !filein.good()) { std::ostringstream msg; - msg << "Could not open spatial database file '" << db->_filename - << "' for reading.\n"; + msg << "Could not open spatial database file '" << db->_filename << "' for reading.\n"; throw std::runtime_error(msg.str()); } // if @@ -63,8 +62,7 @@ spatialdata::spatialdb::SimpleGridAscii::read(SimpleGridDB* db) { // read filein.close(); } catch (const std::exception& err) { std::ostringstream msg; - msg << "Error occurred while reading spatial database file '" << db->_filename << "'.\n" - << err.what(); + msg << "Error occurred while reading spatial database file '" << db->_filename << "'.\n" << err.what(); throw std::runtime_error(msg.str()); } catch (...) { std::ostringstream msg; @@ -82,8 +80,7 @@ spatialdata::spatialdb::SimpleGridAscii::write(const SimpleGridDB& db) { // writ std::ofstream fileout(db._filename.c_str()); if (!fileout.is_open() || !fileout.good()) { std::ostringstream msg; - msg << "Could not open spatial database file '" << db._filename - << "' for writing.\n"; + msg << "Could not open spatial database file '" << db._filename << "' for writing.\n"; throw std::runtime_error(msg.str()); } // if @@ -97,8 +94,7 @@ spatialdata::spatialdb::SimpleGridAscii::write(const SimpleGridDB& db) { // writ fileout.close(); } catch (const std::exception& err) { std::ostringstream msg; - msg << "Error occurred while writing spatial database file '" << db._filename << "'.\n" - << err.what(); + msg << "Error occurred while writing spatial database file '" << db._filename << "'.\n" << err.what(); throw std::runtime_error(msg.str()); } catch (...) { std::ostringstream msg; @@ -125,14 +121,13 @@ spatialdata::spatialdb::SimpleGridAscii::_readHeader(std::istream& filein, const int headerLen = strlen(FILEHEADER); std::string hbuffer; - hbuffer.resize(headerLen+1); - buffer.read((char*) hbuffer.c_str(), sizeof(char)*headerLen); + hbuffer.resize(headerLen + 1); + buffer.read((char*)hbuffer.c_str(), sizeof(char) * headerLen); hbuffer[headerLen] = '\0'; if (0 != strcasecmp(FILEHEADER, hbuffer.c_str())) { std::ostringstream msg; - msg - << "Magic header '" << buffer.str() << "' does not match expected header '" - << FILEHEADER << "' in spatial database file '" << db->_filename << "'.\n"; + msg << "Magic header '" << buffer.str() << "' does not match expected header '" << FILEHEADER + << "' in spatial database file '" << db->_filename << "'.\n"; throw std::runtime_error(msg.str()); } // if @@ -151,13 +146,18 @@ spatialdata::spatialdb::SimpleGridAscii::_readHeader(std::istream& filein, db->_numX = 0; db->_numY = 0; db->_numZ = 0; - delete[] db->_x;db->_x = NULL; - delete[] db->_y;db->_y = NULL; - delete[] db->_z;db->_z = NULL; + delete[] db->_x; + db->_x = NULL; + delete[] db->_y; + db->_y = NULL; + delete[] db->_z; + db->_z = NULL; db->_numValues = 0; - delete[] db->_names;db->_names = NULL; - delete[] db->_units;db->_units = NULL; + delete[] db->_names; + db->_names = NULL; + delete[] db->_units; + db->_units = NULL; buffer.str(parser.next()); buffer.clear(); @@ -182,8 +182,9 @@ spatialdata::spatialdb::SimpleGridAscii::_readHeader(std::istream& filein, if (db->_numValues > 0) { db->_names = new std::string[db->_numValues]; } else { - throw std::runtime_error("Number of values must be specified BEFORE " - "names of values in SimpleGridDB file."); + throw std::runtime_error( + "Number of values must be specified BEFORE " + "names of values in SimpleGridDB file."); } buffer.ignore(maxIgnore, '='); for (size_t iVal = 0; iVal < db->_numValues; ++iVal) { @@ -193,8 +194,9 @@ spatialdata::spatialdb::SimpleGridAscii::_readHeader(std::istream& filein, if (db->_numValues > 0) { db->_units = new std::string[db->_numValues]; } else { - throw std::runtime_error("Number of values must be specified BEFORE " - "units of values in SimpleGridDB file."); + throw std::runtime_error( + "Number of values must be specified BEFORE " + "units of values in SimpleGridDB file."); } // if/else buffer.ignore(maxIgnore, '='); for (size_t iVal = 0; iVal < db->_numValues; ++iVal) { @@ -205,7 +207,7 @@ spatialdata::spatialdb::SimpleGridAscii::_readHeader(std::istream& filein, std::string rbuffer(buffer.str()); filein.putback('\n'); filein.clear(); - int i = rbuffer.length()-1; + int i = rbuffer.length() - 1; while (i >= 0) { filein.putback(rbuffer[i]); if ('=' == rbuffer[i--]) { @@ -224,7 +226,7 @@ spatialdata::spatialdb::SimpleGridAscii::_readHeader(std::istream& filein, buffer.clear(); buffer >> token; } // while - if (( token != "}") || !filein.good()) { + if ((token != "}") || !filein.good()) { throw std::runtime_error("I/O error while parsing SimpleGridDB settings."); } @@ -239,15 +241,15 @@ spatialdata::spatialdb::SimpleGridAscii::_readHeader(std::istream& filein, msg << "SimpleGridDB settings must include positive 'space-dim'.\n"; } // if - if (( db->_spaceDim > 0) && ( db->_numX <= 0) ) { + if ((db->_spaceDim > 0) && (db->_numX <= 0)) { ok = false; msg << "SimpleGridDB settings must include 'num-x'.\n"; } // if - if (( db->_spaceDim > 1) && ( db->_numY <= 0) ) { + if ((db->_spaceDim > 1) && (db->_numY <= 0)) { ok = false; msg << "SimpleGridDB settings must include 'num-y' with 2-D and 3-D data.\n"; } // if - if (( db->_spaceDim > 2) && ( db->_numZ <= 0) ) { + if ((db->_spaceDim > 2) && (db->_numZ <= 0)) { ok = false; msg << "SimpleGridDB settings must include 'num-z' with 3-D data.\n"; } // if @@ -282,10 +284,14 @@ spatialdata::spatialdb::SimpleGridAscii::_readHeader(std::istream& filein, void spatialdata::spatialdb::SimpleGridAscii::_readData(std::istream& filein, SimpleGridDB* const db) { - delete[] db->_x;db->_x = 0; - delete[] db->_y;db->_y = 0; - delete[] db->_z;db->_z = 0; - delete[] db->_data;db->_data = 0; + delete[] db->_x; + db->_x = 0; + delete[] db->_y; + db->_y = 0; + delete[] db->_z; + db->_z = 0; + delete[] db->_data; + db->_data = 0; const int numX = db->_numX; const int numY = db->_numY; @@ -382,7 +388,7 @@ spatialdata::spatialdb::SimpleGridAscii::_readData(std::istream& filein, assert(numLocs > 0); assert(numValues > 0); - db->_data = new double[numLocs*db->_numValues]; + db->_data = new double[numLocs * db->_numValues]; assert(spaceDim > 0); double* coords = new double[spaceDim]; int count = 0; @@ -407,10 +413,11 @@ spatialdata::spatialdb::SimpleGridAscii::_readData(std::istream& filein, << "Error reading data from buffer '" << buffer.str() << "'."; throw std::runtime_error(msg.str()); } // if - buffer >> db->_data[indexData+iVal]; + buffer >> db->_data[indexData + iVal]; } // for } // for - delete[] coords;coords = 0; + delete[] coords; + coords = 0; if (_verbose) { std::cout << "Read " << count << " lines of data.\n"; } // if @@ -452,15 +459,14 @@ spatialdata::spatialdb::SimpleGridAscii::_writeHeader(std::ostream& fileout, const int numValues = db._numValues; const int spaceDim = db._spaceDim; - fileout - << FILEHEADER << " " << version << "\n" - << "SimpleGridDB {\n" - << " num-x = " << db._numX << "\n" - << " num-y = " << db._numY << "\n" - << " num-z = " << db._numZ << "\n" - << " space-dim = " << spaceDim << "\n" - << " num-values = " << numValues << "\n" - << " value-names ="; + fileout << FILEHEADER << " " << version << "\n" + << "SimpleGridDB {\n" + << " num-x = " << db._numX << "\n" + << " num-y = " << db._numY << "\n" + << " num-z = " << db._numZ << "\n" + << " space-dim = " << spaceDim << "\n" + << " num-values = " << numValues << "\n" + << " value-names ="; assert(db._names); for (int iVal = 0; iVal < numValues; ++iVal) { @@ -489,10 +495,7 @@ spatialdata::spatialdb::SimpleGridAscii::_writeHeader(std::ostream& fileout, void spatialdata::spatialdb::SimpleGridAscii::_writeData(std::ostream& fileout, const SimpleGridDB& db) { // _writeData - fileout - << std::resetiosflags(std::ios::fixed) - << std::setiosflags(std::ios::scientific) - << std::setprecision(6); + fileout << std::resetiosflags(std::ios::fixed) << std::setiosflags(std::ios::scientific) << std::setprecision(6); const int numX = db._numX; const int numY = db._numY; @@ -523,12 +526,9 @@ spatialdata::spatialdb::SimpleGridAscii::_writeData(std::ostream& fileout, for (int iY = 0; iY < numY; ++iY) { for (int iX = 0; iX < numX; ++iX) { const int iD = db._getDataIndex(iX, numX, iY, numY, iZ, numZ); - fileout - << std::setw(14) << db._x[iX] - << std::setw(14) << db._y[iY] - << std::setw(14) << db._z[iZ]; + fileout << std::setw(14) << db._x[iX] << std::setw(14) << db._y[iY] << std::setw(14) << db._z[iZ]; for (int iV = 0; iV < numValues; ++iV) { - fileout << std::setw(14) << db._data[iD+iV]; + fileout << std::setw(14) << db._data[iD + iV]; } // for fileout << "\n"; } // for @@ -539,11 +539,9 @@ spatialdata::spatialdb::SimpleGridAscii::_writeData(std::ostream& fileout, for (int iY = 0; iY < numY; ++iY) { for (int iX = 0; iX < numX; ++iX) { const int iD = db._getDataIndex(iX, numX, iY, numY, iZ, numZ); - fileout - << std::setw(14) << db._x[iX] - << std::setw(14) << db._y[iY]; + fileout << std::setw(14) << db._x[iX] << std::setw(14) << db._y[iY]; for (int iV = 0; iV < numValues; ++iV) { - fileout << std::setw(14) << db._data[iD+iV]; + fileout << std::setw(14) << db._data[iD + iV]; } // for fileout << "\n"; } // for @@ -553,10 +551,9 @@ spatialdata::spatialdb::SimpleGridAscii::_writeData(std::ostream& fileout, const int iZ = 0; for (int iX = 0; iX < numX; ++iX) { const int iD = db._getDataIndex(iX, numX, iY, numY, iZ, numZ); - fileout - << std::setw(14) << db._x[iX]; + fileout << std::setw(14) << db._x[iX]; for (int iV = 0; iV < numValues; ++iV) { - fileout << std::setw(14) << db._data[iD+iV]; + fileout << std::setw(14) << db._data[iD + iV]; } // for fileout << "\n"; } // for diff --git a/libsrc/spatialdata/spatialdb/SimpleGridAscii.hh b/libsrc/spatialdata/spatialdb/SimpleGridAscii.hh index c4c135a7..26b0e8e6 100644 --- a/libsrc/spatialdata/spatialdb/SimpleGridAscii.hh +++ b/libsrc/spatialdata/spatialdb/SimpleGridAscii.hh @@ -15,8 +15,7 @@ // ---------------------------------------------------------------------- class spatialdata::spatialdb::SimpleGridAscii { // SimpleGridAscii -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// // Using default constructor. @@ -29,18 +28,15 @@ public: * * @param db Spatial database. */ - static - void read(SimpleGridDB* db); + static void read(SimpleGridDB* db); /** Write the database. * * @param db Spatial database. */ - static - void write(const SimpleGridDB& db); - -private: + static void write(const SimpleGridDB& db); + private: // PRIVATE METHODS //////////////////////////////////////////////////// /** Read data file header. @@ -48,39 +44,34 @@ private: * @param filein Input stream. * @param db Spatial database. */ - static - void _readHeader(std::istream& filein, - SimpleGridDB* const db); + static void _readHeader(std::istream& filein, + SimpleGridDB* const db); /** Read data values. * * @param filein Input stream. * @param db Spatial database. */ - static - void _readData(std::istream& filein, - SimpleGridDB* const db); + static void _readData(std::istream& filein, + SimpleGridDB* const db); /** Write the data file header. * * @param fileout Output stream. * @param db Spatial database. */ - static - void _writeHeader(std::ostream& fileout, - const SimpleGridDB& db); + static void _writeHeader(std::ostream& fileout, + const SimpleGridDB& db); /** Write data values. * * @param fileout Output stream. * @param db Spatial database. */ - static - void _writeData(std::ostream& fileout, - const SimpleGridDB& db); - -private: + static void _writeData(std::ostream& fileout, + const SimpleGridDB& db); + private: // PRIVATE MEMBERS //////////////////////////////////////////////////// /** Magic header in ascii files */ diff --git a/libsrc/spatialdata/spatialdb/SimpleGridDB.cc b/libsrc/spatialdata/spatialdb/SimpleGridDB.cc index e35e00bf..98e9c819 100644 --- a/libsrc/spatialdata/spatialdb/SimpleGridDB.cc +++ b/libsrc/spatialdata/spatialdb/SimpleGridDB.cc @@ -14,18 +14,18 @@ #include "SimpleGridAscii.hh" // USES SimpleGridAscii -#include "spatialdata/geocoords/CoordSys.hh" // HASA CoordSys #include "spatialdata/geocoords/Converter.hh" // USES Converter +#include "spatialdata/geocoords/CoordSys.hh" // HASA CoordSys #include "spatialdata/utils/LineParser.hh" // USES LineParser #include // USES std::floor() +#include // USES assert() +#include // USES memcpy() #include // USES std::ifstream #include // USES std::ostringstream #include // USES std::logic_error -#include // USES memcpy() #include // USES strcasecmp() -#include // USES assert() // ---------------------------------------------------------------------- // Constructor @@ -47,27 +47,37 @@ spatialdata::spatialdb::SimpleGridDB::SimpleGridDB(void) : _filename(""), _cs(NULL), _converter(new spatialdata::geocoords::Converter), - _queryType(NEAREST) {} + _queryType(NEAREST) { +} // ---------------------------------------------------------------------- // Destructor spatialdata::spatialdb::SimpleGridDB::~SimpleGridDB(void) { - delete[] _data;_data = NULL; - delete[] _x;_x = NULL; - delete[] _y;_y = NULL; - delete[] _z;_z = NULL; + delete[] _data; + _data = NULL; + delete[] _x; + _x = NULL; + delete[] _y; + _y = NULL; + delete[] _z; + _z = NULL; _numX = 0; _numY = 0; _numZ = 0; _numValues = 0; - delete[] _names;_names = NULL; - delete[] _units;_units = NULL; - delete[] _queryValues;_queryValues = NULL; + delete[] _names; + _names = NULL; + delete[] _units; + _units = NULL; + delete[] _queryValues; + _queryValues = NULL; _querySize = 0; - delete _cs;_cs = NULL; - delete _converter;_converter = NULL; + delete _cs; + _cs = NULL; + delete _converter; + _converter = NULL; } // destructor @@ -91,14 +101,14 @@ spatialdata::spatialdb::SimpleGridDB::open(void) { SpatialDB::_convertToSI(_data, _units, numLocs, _numValues); } catch (const std::exception& err) { std::ostringstream msg; - msg << "Error parsing units for spatial database '" << getDescription() << "':\n" - << err.what(); + msg << "Error parsing units for spatial database '" << getDescription() << "':\n" << err.what(); throw std::runtime_error(msg.str().c_str()); } // try/catch // Default query values is all values. _querySize = _numValues; - delete[] _queryValues;_queryValues = (_querySize > 0) ? new size_t[_querySize] : NULL; + delete[] _queryValues; + _queryValues = (_querySize > 0) ? new size_t[_querySize] : NULL; for (size_t i = 0; i < _querySize; ++i) { _queryValues[i] = i; } // for @@ -109,20 +119,27 @@ spatialdata::spatialdb::SimpleGridDB::open(void) { // Close the database. void spatialdata::spatialdb::SimpleGridDB::close(void) { - delete[] _data;_data = NULL; - delete[] _x;_x = NULL; - delete[] _y;_y = NULL; - delete[] _z;_z = NULL; + delete[] _data; + _data = NULL; + delete[] _x; + _x = NULL; + delete[] _y; + _y = NULL; + delete[] _z; + _z = NULL; _numX = 0; _numY = 0; _numZ = 0; _numValues = 0; - delete[] _names;_names = NULL; - delete[] _units;_units = NULL; + delete[] _names; + _names = NULL; + delete[] _units; + _units = NULL; _querySize = 0; - delete[] _queryValues;_queryValues = NULL; + delete[] _queryValues; + _queryValues = NULL; } // close @@ -159,15 +176,14 @@ spatialdata::spatialdb::SimpleGridDB::setQueryValues(const char* const* names, assert(_data); if (0 == numVals) { std::ostringstream msg; - msg - << "Number of values for query in spatial database " << getDescription() - << "\n must be positive.\n"; + msg << "Number of values for query in spatial database " << getDescription() << "\n must be positive.\n"; throw std::invalid_argument(msg.str()); } // if assert(names && 0 < numVals); _querySize = numVals; - delete[] _queryValues;_queryValues = new size_t[numVals]; + delete[] _queryValues; + _queryValues = new size_t[numVals]; for (size_t iVal = 0; iVal < numVals; ++iVal) { size_t iName = 0; const size_t numNames = _numValues; @@ -179,8 +195,8 @@ spatialdata::spatialdb::SimpleGridDB::setQueryValues(const char* const* names, } // while if (iName >= numNames) { std::ostringstream msg; - msg << "Could not find value '" << names[iVal] << "' in spatial database '" - << getDescription() << "'. Available values are:"; + msg << "Could not find value '" << names[iVal] << "' in spatial database '" << getDescription() + << "'. Available values are:"; for (size_t iName = 0; iName < numNames; ++iName) { msg << "\n " << _names[iName]; } // for @@ -209,21 +225,19 @@ spatialdata::spatialdb::SimpleGridDB::query(double* vals, throw std::logic_error(msg.str()); } else if (numVals != querySize) { std::ostringstream msg; - msg << "Number of values to be returned by spatial database " - << getDescription() << "\n" - << "(" << querySize << ") does not match size of array provided (" - << numVals << ").\n"; + msg << "Number of values to be returned by spatial database " << getDescription() << "\n" + << "(" << querySize << ") does not match size of array provided (" << numVals << ").\n"; throw std::invalid_argument(msg.str()); } else if (numDims != _spaceDim) { std::ostringstream msg; - msg << "Spatial dimension (" << numDims - << ") does not match spatial dimension of spatial database (" << _spaceDim << ")."; + msg << "Spatial dimension (" << numDims << ") does not match spatial dimension of spatial database (" + << _spaceDim << ")."; throw std::invalid_argument(msg.str()); } // if // Convert coordinates assert(numDims <= 3); - memcpy(_xyz, coords, numDims*sizeof(double)); + memcpy(_xyz, coords, numDims * sizeof(double)); assert(_converter); _converter->convert(_xyz, 1, numDims, _cs, csQuery); @@ -253,9 +267,8 @@ spatialdata::spatialdb::SimpleGridDB::query(double* vals, switch (_queryType) { case LINEAR: - if (( index0 < 0.0) || (( index0 > 0) && ( index0 > size0-1.0) ) || - ( index1 < 0.0) || (( index1 > 0) && ( index1 > size1-1.0) ) || - ( index2 < 0.0) || (( index2 > 0) && ( index2 > size2-1.0) )) { + if ((index0 < 0.0) || ((index0 > 0) && (index0 > size0 - 1.0)) || (index1 < 0.0) || + ((index1 > 0) && (index1 > size1 - 1.0)) || (index2 < 0.0) || ((index2 > 0) && (index2 > size2 - 1.0))) { queryFlag = 1; return queryFlag; } // if @@ -276,19 +289,19 @@ spatialdata::spatialdb::SimpleGridDB::query(double* vals, } // switch break; case NEAREST: { - index0 = std::min(index0, size0-1.0); + index0 = std::min(index0, size0 - 1.0); index0 = std::max(index0, 0.0); - index1 = std::min(index1, size1-1.0); + index1 = std::min(index1, size1 - 1.0); index1 = std::max(index1, 0.0); - index2 = std::min(index2, size2-1.0); + index2 = std::min(index2, size2 - 1.0); index2 = std::max(index2, 0.0); - const size_t indexNearest0 = size_t(std::floor(index0+0.5)); - const size_t indexNearest1 = size_t(std::floor(index1+0.5)); - const size_t indexNearest2 = size_t(std::floor(index2+0.5)); + const size_t indexNearest0 = size_t(std::floor(index0 + 0.5)); + const size_t indexNearest1 = size_t(std::floor(index1 + 0.5)); + const size_t indexNearest2 = size_t(std::floor(index2 + 0.5)); const size_t indexData = _getDataIndex(indexNearest0, size0, indexNearest1, size1, indexNearest2, size2); for (size_t iVal = 0; iVal < querySize; ++iVal) { - vals[iVal] = _data[indexData+_queryValues[iVal]]; + vals[iVal] = _data[indexData + _queryValues[iVal]]; #if 0 // DEBUGGING std::cout << "val["< 0) ? new double[numLocs*numValues] : NULL; - - delete[] _x;_x = (numX > 0) ? new double[numX] : NULL; - delete[] _y;_y = (numY > 0) ? new double[numY] : NULL; - delete[] _z;_z = (numZ > 0) ? new double[numZ] : NULL; + delete[] _data; + _data = (numLocs * numValues > 0) ? new double[numLocs * numValues] : NULL; + + delete[] _x; + _x = (numX > 0) ? new double[numX] : NULL; + delete[] _y; + _y = (numY > 0) ? new double[numY] : NULL; + delete[] _z; + _z = (numZ > 0) ? new double[numZ] : NULL; } // allocate @@ -431,16 +448,16 @@ spatialdata::spatialdb::SimpleGridDB::setData(const double* coords, } // if if (!_data) { - const size_t size = numLocs*numValues; + const size_t size = numLocs * numValues; _data = (size > 0) ? new double[size] : NULL; } // if assert(_data); for (size_t iLoc = 0; iLoc < numLocs; ++iLoc) { - const size_t indexData = _getDataIndex(&coords[iLoc*spaceDim], spaceDim); - const size_t jj = iLoc*numValues; + const size_t indexData = _getDataIndex(&coords[iLoc * spaceDim], spaceDim); + const size_t jj = iLoc * numValues; for (size_t iV = 0; iV < numValues; ++iV) { - _data[indexData+iV] = values[jj+iV]; + _data[indexData + iV] = values[jj + iV]; } // for } // for } // setData @@ -458,7 +475,8 @@ spatialdata::spatialdb::SimpleGridDB::setNames(const char* const* values, << ") for names of values in simple grid spatial database."; throw std::invalid_argument(msg.str()); } // if - delete[] _names;_names = (numValues > 0) ? new std::string[numValues] : NULL; + delete[] _names; + _names = (numValues > 0) ? new std::string[numValues] : NULL; for (size_t i = 0; i < numValues; ++i) { _names[i] = values[i]; } // for @@ -477,7 +495,8 @@ spatialdata::spatialdb::SimpleGridDB::setUnits(const char* const* values, << ") for units of values in simple grid spatial database."; throw std::invalid_argument(msg.str()); } // if - delete[] _units;_units = (numValues > 0) ? new std::string[numValues] : NULL; + delete[] _units; + _units = (numValues > 0) ? new std::string[numValues] : NULL; for (size_t i = 0; i < numValues; ++i) { _units[i] = values[i]; } // for @@ -488,7 +507,9 @@ spatialdata::spatialdb::SimpleGridDB::setUnits(const char* const* values, // Set filename containing data. void spatialdata::spatialdb::SimpleGridDB::setCoordSys(const geocoords::CoordSys& cs) { - delete _cs;_cs = cs.clone();assert(_cs); + delete _cs; + _cs = cs.clone(); + assert(_cs); } // setCoordSys @@ -505,52 +526,47 @@ spatialdata::spatialdb::SimpleGridDB::_checkCompatibility(void) const { const size_t numZ = _numZ; int count1 = 0; - if (( 0 == numX) || ( 1 == numX) ) { + if ((0 == numX) || (1 == numX)) { count1 += 1; } // if - if (( 0 == numY) || ( 1 == numY) ) { + if ((0 == numY) || (1 == numY)) { count1 += 1; } // if - if (( 0 == numZ) || ( 1 == numZ) ) { + if ((0 == numZ) || (1 == numZ)) { count1 += 1; } // if - if (( 0 == dataDim) && ( 3 != count1) ) { + if ((0 == dataDim) && (3 != count1)) { msg << "Dimension of data in spatial distribution (" << dataDim - << ") is incompatible with dimensions of a 0-D grid (" - << numX << "," << numY << "," << numZ << ")."; + << ") is incompatible with dimensions of a 0-D grid (" << numX << "," << numY << "," << numZ << ")."; throw std::domain_error(msg.str()); - } else if (( 1 == dataDim) && ( 2 != count1) ) { + } else if ((1 == dataDim) && (2 != count1)) { msg << "Dimension of data in spatial distribution (" << dataDim - << ") is incompatible with dimensions of a 1-D grid (" - << numX << "," << numY << "," << numZ << ")."; + << ") is incompatible with dimensions of a 1-D grid (" << numX << "," << numY << "," << numZ << ")."; throw std::domain_error(msg.str()); - } else if (( 2 == dataDim) && ( 1 != count1) ) { + } else if ((2 == dataDim) && (1 != count1)) { msg << "Dimension of data in spatial distribution (" << dataDim - << ") is incompatible with dimensions of a 2-D grid (" - << numX << "," << numY << "," << numZ << ")."; + << ") is incompatible with dimensions of a 2-D grid (" << numX << "," << numY << "," << numZ << ")."; throw std::domain_error(msg.str()); - } else if (( 3 == dataDim) && ( 0 != count1) ) { + } else if ((3 == dataDim) && (0 != count1)) { msg << "Dimension of data in spatial distribution (" << dataDim - << ") is incompatible with dimensions of a 3-D grid (" - << numX << "," << numY << "," << numZ << ")."; + << ") is incompatible with dimensions of a 3-D grid (" << numX << "," << numY << "," << numZ << ")."; throw std::domain_error(msg.str()); } // if/else if (dataDim > spaceDim) { msg << "Dimension of data in spatial distribution (" << dataDim - << ") exceeds the number of dimensions of the coordinates (" - << spaceDim << ")."; + << ") exceeds the number of dimensions of the coordinates (" << spaceDim << ")."; throw std::domain_error(msg.str()); } // if assert(_cs); if (spaceDim != _cs->getSpaceDim()) { - msg << "Number of dimensions in coordinates of spatial distribution (" - << spaceDim << ") does not match number of dimensions in coordinate " + msg << "Number of dimensions in coordinates of spatial distribution (" << spaceDim + << ") does not match number of dimensions in coordinate " << "system (" << _cs->getSpaceDim() << ")"; throw std::domain_error(msg.str()); } // if @@ -574,23 +590,23 @@ spatialdata::spatialdb::SimpleGridDB::_search(const double target, size_t indexL = 0; size_t indexR = nvals - 1; const double tolerance = 1.0e-6; - if (( target >= vals[indexL]-tolerance) && ( target <= vals[indexR]+tolerance) ) { + if ((target >= vals[indexL] - tolerance) && (target <= vals[indexR] + tolerance)) { while (indexR - indexL > 1) { - size_t indexM = indexL + (indexR-indexL) / 2; + size_t indexM = indexL + (indexR - indexL) / 2; if (target < vals[indexM]) { indexR = indexM; } else { indexL = indexM; } // if/else } // while - assert(target >= vals[indexL]-tolerance); + assert(target >= vals[indexL] - tolerance); assert(vals[indexR] > vals[indexL]); index = double(indexL) + (target - vals[indexL]) / (vals[indexR] - vals[indexL]); } else if (_queryType == NEAREST) { if (target <= vals[indexL]) { index = 0.0; } else { - index = double(nvals-1); + index = double(nvals - 1); } // if/else } // if/else @@ -606,7 +622,7 @@ spatialdata::spatialdb::SimpleGridDB::_interpolate1D(double* vals, const double indexX, const size_t numX) const { assert(numX >= 2); - const size_t indexX0 = std::min(numX-2, size_t(std::floor(indexX))); + const size_t indexX0 = std::min(numX - 2, size_t(std::floor(indexX))); const double wtX0 = 1.0 - (indexX - indexX0); const size_t indexX1 = indexX0 + 1; const double wtX1 = 1.0 - wtX0; @@ -622,9 +638,7 @@ spatialdata::spatialdb::SimpleGridDB::_interpolate1D(double* vals, const size_t querySize = _querySize; for (size_t iVal = 0; iVal < querySize; ++iVal) { const size_t qVal = _queryValues[iVal]; - vals[iVal] = - wt000 * _data[index000+qVal] + - wt100 * _data[index100+qVal]; + vals[iVal] = wt000 * _data[index000 + qVal] + wt100 * _data[index100 + qVal]; #if 0 // DEBUGGING std::cout << "val["<= 2); - const size_t indexX0 = std::min(numX-2, size_t(std::floor(indexX))); + const size_t indexX0 = std::min(numX - 2, size_t(std::floor(indexX))); const double wtX0 = 1.0 - (indexX - indexX0); const size_t indexX1 = indexX0 + 1; const double wtX1 = 1.0 - wtX0; @@ -654,7 +668,7 @@ spatialdata::spatialdb::SimpleGridDB::_interpolate2D(double* vals, assert(0 <= indexX1 && indexX1 < numX); assert(numY >= 2); - const size_t indexY0 = std::min(numY-2, size_t(std::floor(indexY))); + const size_t indexY0 = std::min(numY - 2, size_t(std::floor(indexY))); const double wtY0 = 1.0 - (indexY - indexY0); const size_t indexY1 = indexY0 + 1; const double wtY1 = 1.0 - wtY0; @@ -674,11 +688,8 @@ spatialdata::spatialdb::SimpleGridDB::_interpolate2D(double* vals, const size_t querySize = _querySize; for (size_t iVal = 0; iVal < querySize; ++iVal) { const size_t qVal = _queryValues[iVal]; - vals[iVal] = - wt000 * _data[index000+qVal] + - wt010 * _data[index010+qVal] + - wt100 * _data[index100+qVal] + - wt110 * _data[index110+qVal]; + vals[iVal] = wt000 * _data[index000 + qVal] + wt010 * _data[index010 + qVal] + wt100 * _data[index100 + qVal] + + wt110 * _data[index110 + qVal]; #if 0 // DEBUGGING std::cout << "val["<= 2); - const size_t indexX0 = std::min(numX-2, size_t(std::floor(indexX))); + const size_t indexX0 = std::min(numX - 2, size_t(std::floor(indexX))); const double wtX0 = 1.0 - (indexX - indexX0); const size_t indexX1 = indexX0 + 1; const double wtX1 = 1.0 - wtX0; @@ -713,7 +724,7 @@ spatialdata::spatialdb::SimpleGridDB::_interpolate3D(double* vals, assert(0 <= indexX1 && indexX1 < numX); assert(numY >= 2); - const size_t indexY0 = std::min(numY-2, size_t(std::floor(indexY))); + const size_t indexY0 = std::min(numY - 2, size_t(std::floor(indexY))); const double wtY0 = 1.0 - (indexY - indexY0); const size_t indexY1 = indexY0 + 1; const double wtY1 = 1.0 - wtY0; @@ -721,7 +732,7 @@ spatialdata::spatialdb::SimpleGridDB::_interpolate3D(double* vals, assert(0 <= indexY1 && indexY1 < numY); assert(numZ >= 2); - const size_t indexZ0 = std::min(numZ-2, size_t(std::floor(indexZ))); + const size_t indexZ0 = std::min(numZ - 2, size_t(std::floor(indexZ))); const double wtZ0 = 1.0 - (indexZ - indexZ0); const size_t indexZ1 = indexZ0 + 1; const double wtZ1 = 1.0 - wtZ0; @@ -749,15 +760,9 @@ spatialdata::spatialdb::SimpleGridDB::_interpolate3D(double* vals, const size_t querySize = _querySize; for (size_t iVal = 0; iVal < querySize; ++iVal) { const size_t qVal = _queryValues[iVal]; - vals[iVal] = - wt000 * _data[index000+qVal] + - wt001 * _data[index001+qVal] + - wt010 * _data[index010+qVal] + - wt011 * _data[index011+qVal] + - wt100 * _data[index100+qVal] + - wt101 * _data[index101+qVal] + - wt110 * _data[index110+qVal] + - wt111 * _data[index111+qVal]; + vals[iVal] = wt000 * _data[index000 + qVal] + wt001 * _data[index001 + qVal] + wt010 * _data[index010 + qVal] + + wt011 * _data[index011 + qVal] + wt100 * _data[index100 + qVal] + wt101 * _data[index101 + qVal] + + wt110 * _data[index110 + qVal] + wt111 * _data[index111 + qVal]; #if 0 // DEBUGGING std::cout << "val["< 2) { - index0 = std::floor(_search(coords[0], _x, _numX)+0.5); - index1 = std::floor(_search(coords[1], _y, _numY)+0.5); - index2 = std::floor(_search(coords[2], _z, _numZ)+0.5); + index0 = std::floor(_search(coords[0], _x, _numX) + 0.5); + index1 = std::floor(_search(coords[1], _y, _numY) + 0.5); + index2 = std::floor(_search(coords[2], _z, _numZ) + 0.5); _reindex3d(&index0, &size0, &index1, &size1, &index2, &size2); } else if (spaceDim > 1) { - index0 = std::floor(_search(coords[0], _x, _numX)+0.5); - index1 = std::floor(_search(coords[1], _y, _numY)+0.5); + index0 = std::floor(_search(coords[0], _x, _numX) + 0.5); + index1 = std::floor(_search(coords[1], _y, _numY) + 0.5); _reindex2d(&index0, &size0, &index1, &size1); } else { assert(1 == spaceDim); - index0 = std::floor(_search(coords[0], _x, _numX)+0.5); + index0 = std::floor(_search(coords[0], _x, _numX) + 0.5); } // if const size_t indexData = _getDataIndex(size_t(index0), size0, size_t(index1), size1, size_t(index2), size2); diff --git a/libsrc/spatialdata/spatialdb/SimpleGridDB.hh b/libsrc/spatialdata/spatialdb/SimpleGridDB.hh index 8fffc8fd..18598ee9 100644 --- a/libsrc/spatialdata/spatialdb/SimpleGridDB.hh +++ b/libsrc/spatialdata/spatialdb/SimpleGridDB.hh @@ -18,19 +18,17 @@ class spatialdata::spatialdb::SimpleGridDB : public SpatialDB { // SimpleGridDB friend class TestSimpleGridAscii; friend class SimpleGridAscii; // reader -public: - + public: // PUBLIC ENUM //////////////////////////////////////////////////////// /** Type of query */ enum QueryEnum { - NEAREST=0, ///< Nearest interpolation. - LINEAR=1, ///< Linear interpolation. + NEAREST = 0, ///< Nearest interpolation. + LINEAR = 1, ///< Linear interpolation. }; // PUBLIC MEMBERS /////////////////////////////////////////////////////// -public: - + public: /// Constructor SimpleGridDB(void); @@ -175,8 +173,7 @@ public: void setCoordSys(const geocoords::CoordSys& cs); // PRIVATE METHODS ////////////////////////////////////////////////////// -private: - + private: /// Check compatibility of spatial database parameters. void _checkCompatibility(void) const; @@ -299,8 +296,7 @@ private: const size_t spaceDim) const; // PRIVATE MEMBERS ////////////////////////////////////////////////////// -private: - + private: double* _data; ///< Array of data values. double* _x; ///< Array of x coordinates. double* _y; ///< Array of y coordinates. @@ -330,8 +326,7 @@ private: static const char* FILEHEADER; // NOT IMPLEMENTED ////////////////////////////////////////////////////// -private: - + private: SimpleGridDB(const SimpleGridDB&); ///< Not implemented const SimpleGridDB& operator=(const SimpleGridDB&); ///< Not implemented diff --git a/libsrc/spatialdata/spatialdb/SimpleGridDB.icc b/libsrc/spatialdata/spatialdb/SimpleGridDB.icc index e2bb1b98..340a5aa9 100644 --- a/libsrc/spatialdata/spatialdb/SimpleGridDB.icc +++ b/libsrc/spatialdata/spatialdb/SimpleGridDB.icc @@ -13,8 +13,7 @@ // ---------------------------------------------------------------------- // Get index into data array. -inline -size_t +inline size_t spatialdata::spatialdb::SimpleGridDB::_getDataIndex(const size_t index0, const size_t size0, const size_t index1, @@ -22,8 +21,8 @@ spatialdata::spatialdb::SimpleGridDB::_getDataIndex(const size_t index0, const size_t index2, const size_t size2) const { // Order points so indexing works in any dimension. - const size_t locIndex = index2*size1*size0 + index1*size0 + index0; - return locIndex*_numValues; + const size_t locIndex = index2 * size1 * size0 + index1 * size0 + index0; + return locIndex * _numValues; } // _dataIndex diff --git a/libsrc/spatialdata/spatialdb/SimpleIO.cc b/libsrc/spatialdata/spatialdb/SimpleIO.cc index dc7b49ab..26b36164 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIO.cc +++ b/libsrc/spatialdata/spatialdb/SimpleIO.cc @@ -14,34 +14,35 @@ // Include ios here to avoid some Python/gcc issues #include -#include "SpatialDB.hh" // USES SimpleDB #include "SimpleDB.hh" // USES SimpleDB #include "SimpleDBData.hh" // USES SimpleDBData +#include "SpatialDB.hh" // USES SimpleDB #include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys #include "spatialdata/units/Parser.hh" // USES Parser +#include // USES assert() #include // USES std::ostringstream +#include // USES std::runtime_error, std::exception #include // USES std::string #include // USES std::vector -#include // USES std::runtime_error, std::exception -#include // USES assert() // ---------------------------------------------------------------------- /// Default constructor -spatialdata::spatialdb::SimpleIO::SimpleIO(void) {} +spatialdata::spatialdb::SimpleIO::SimpleIO(void) { +} // ---------------------------------------------------------------------- /// Default destructor -spatialdata::spatialdb::SimpleIO::~SimpleIO(void) {} +spatialdata::spatialdb::SimpleIO::~SimpleIO(void) { +} // ---------------------------------------------------------------------- void -spatialdata::spatialdb::SimpleIO::checkCompatibility( - const SimpleDBData& data, - const spatialdata::geocoords::CoordSys* cs) { +spatialdata::spatialdb::SimpleIO::checkCompatibility(const SimpleDBData& data, + const spatialdata::geocoords::CoordSys* cs) { assert(cs); const size_t numLocs = data.getNumLocs(); @@ -49,26 +50,24 @@ spatialdata::spatialdb::SimpleIO::checkCompatibility( const size_t dataDim = data.getDataDim(); std::ostringstream msg; if (numLocs < 1 + dataDim) { - msg << "Spatial distribution with data dimensions of " << dataDim - << " must have at least " << 1+dataDim << " points.\n" + msg << "Spatial distribution with data dimensions of " << dataDim << " must have at least " << 1 + dataDim + << " points.\n" << "Found " << numLocs << " points in distribution."; throw std::domain_error(msg.str()); } // if - if (( 0 == dataDim) && ( numLocs > 1) ) { - msg << "Spatial distribution with data dimensions of " << dataDim - << " cannot have more than one point.\n" + if ((0 == dataDim) && (numLocs > 1)) { + msg << "Spatial distribution with data dimensions of " << dataDim << " cannot have more than one point.\n" << "Found " << numLocs << " points in distribution."; throw std::domain_error(msg.str()); } // if if (dataDim > spaceDim) { msg << "Dimension of data in spatial distribution (" << dataDim - << ") exceeds the number of dimensions of the coordinates (" - << spaceDim << ")."; + << ") exceeds the number of dimensions of the coordinates (" << spaceDim << ")."; throw std::domain_error(msg.str()); } // if if (spaceDim != cs->getSpaceDim()) { - msg << "Number of dimensions in coordinates of spatial distribution (" - << spaceDim << ") does not match number of dimensions in coordinate " + msg << "Number of dimensions in coordinates of spatial distribution (" << spaceDim + << ") does not match number of dimensions in coordinate " << "system (" << cs->getSpaceDim() << ")"; throw std::domain_error(msg.str()); } // if diff --git a/libsrc/spatialdata/spatialdb/SimpleIO.hh b/libsrc/spatialdata/spatialdb/SimpleIO.hh index 1535e8c8..c4205b7c 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIO.hh +++ b/libsrc/spatialdata/spatialdb/SimpleIO.hh @@ -9,15 +9,14 @@ // ================================================================================================= #pragma once -#include "spatialdbfwd.hh" // forward declarations #include "spatialdata/geocoords/geocoordsfwd.hh" // forward declarations +#include "spatialdbfwd.hh" // forward declarations #include // HASA std::string /// C++ manager for simple spatial database. class spatialdata::spatialdb::SimpleIO { // class SimpleIO -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /// Default constructor. @@ -62,8 +61,7 @@ public: virtual void write(const SimpleDBData& data, const spatialdata::geocoords::CoordSys* pCS) = 0; -protected: - + protected: // PROTECTED METHODS ////////////////////////////////////////////////// /** Check compatibility of topology and spatial distribution. @@ -85,14 +83,12 @@ protected: */ static void convertToSI(SimpleDBData* const data); -private: - + private: // PRIVATE METHODS //////////////////////////////////////////////////// const SimpleIO& operator=(const SimpleIO& data); ///< Not implemented -private: - + private: // PRIVATE MEMBERS //////////////////////////////////////////////////// /** Filename of database */ diff --git a/libsrc/spatialdata/spatialdb/SimpleIO.icc b/libsrc/spatialdata/spatialdb/SimpleIO.icc index 1c777c06..e0a86378 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIO.icc +++ b/libsrc/spatialdata/spatialdb/SimpleIO.icc @@ -10,16 +10,14 @@ #pragma once // Set filename for database. -inline -void +inline void spatialdata::spatialdb::SimpleIO::setFilename(const char* filename) { _filename = filename; } // Get filename for database. -inline -const char* +inline const char* spatialdata::spatialdb::SimpleIO::getFilename(void) const { return _filename.c_str(); } diff --git a/libsrc/spatialdata/spatialdb/SimpleIOAscii.cc b/libsrc/spatialdata/spatialdb/SimpleIOAscii.cc index 1598e062..1ef2cdb7 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIOAscii.cc +++ b/libsrc/spatialdata/spatialdb/SimpleIOAscii.cc @@ -12,29 +12,28 @@ #include "SimpleIOAscii.hh" // implementation of class methods -#include "SpatialDB.hh" // USES SimpleDB #include "SimpleDB.hh" // USES SimpleDB +#include "SpatialDB.hh" // USES SimpleDB #include "SimpleDBData.hh" // USES SimpleDBData -#include "spatialdata/geocoords/CoordSys.hh" // USES CSCart #include "spatialdata/geocoords/CSCart.hh" // USES CSCart #include "spatialdata/geocoords/CSPicklerAscii.hh" // USES CSPicklerAscii +#include "spatialdata/geocoords/CoordSys.hh" // USES CSCart #include "spatialdata/utils/LineParser.hh" // USES LineParser #include // USES std::ofstream, std::ifstream #include // USES setw(), setiosflags(), resetiosflags() -#include // USES std::runtime_error +#include // USES assert() +#include // USES strlen() #include // USES std::ostringsgream +#include // USES std::runtime_error #include // USES strcasecmp() -#include // USES strlen() -#include // USES assert() #include // ---------------------------------------------------------------------- -const char* spatialdata::spatialdb::SimpleIOAscii::HEADER = - "#SPATIAL.ascii"; +const char* spatialdata::spatialdb::SimpleIOAscii::HEADER = "#SPATIAL.ascii"; // ---------------------------------------------------------------------- // Read ascii database file. @@ -47,8 +46,7 @@ spatialdata::spatialdb::SimpleIOAscii::read(SimpleDBData* pData, std::ifstream filein(getFilename()); if (!filein.is_open() || !filein.good()) { std::ostringstream msg; - msg << "Could not open spatial database file '" << getFilename() - << "' for reading."; + msg << "Could not open spatial database file '" << getFilename() << "' for reading."; throw std::runtime_error(msg.str()); } // if @@ -62,14 +60,13 @@ spatialdata::spatialdb::SimpleIOAscii::read(SimpleDBData* pData, const int headerLen = strlen(HEADER); std::string hbuffer; - hbuffer.resize(headerLen+1); - buffer.read((char*) hbuffer.c_str(), sizeof(char)*headerLen); + hbuffer.resize(headerLen + 1); + buffer.read((char*)hbuffer.c_str(), sizeof(char) * headerLen); hbuffer[headerLen] = '\0'; if (0 != strcasecmp(HEADER, hbuffer.c_str())) { std::ostringstream msg; - msg - << "Magic header '" << buffer.str() << "' does not match expected header '" - << HEADER << "' in spatial database file '" << getFilename() << "'."; + msg << "Magic header '" << buffer.str() << "' does not match expected header '" << HEADER + << "' in spatial database file '" << getFilename() << "'."; throw std::runtime_error(msg.str()); } // if int version = 0; @@ -78,12 +75,10 @@ spatialdata::spatialdb::SimpleIOAscii::read(SimpleDBData* pData, case 1: _readV1(pData, ppCS, filein); break; - default: - { // default + default: { // default std::ostringstream msg; - msg - << "Did not recognize format version " << version - << " of spatial database file '" << getFilename() << "'."; + msg << "Did not recognize format version " << version << " of spatial database file '" << getFilename() + << "'."; throw std::runtime_error(msg.str()); } // default } // switch @@ -92,14 +87,11 @@ spatialdata::spatialdb::SimpleIOAscii::read(SimpleDBData* pData, } } catch (const std::exception& err) { std::ostringstream msg; - msg << "Error occurred while reading spatial database file '" - << getFilename() << "'.\n" - << err.what(); + msg << "Error occurred while reading spatial database file '" << getFilename() << "'.\n" << err.what(); throw std::runtime_error(msg.str()); } catch (...) { std::ostringstream msg; - msg << "Unknown error occurred while reading spatial database file '" - << getFilename() << "'."; + msg << "Unknown error occurred while reading spatial database file '" << getFilename() << "'."; throw std::runtime_error(msg.str()); } // try/catch @@ -150,10 +142,12 @@ spatialdata::spatialdb::SimpleIOAscii::_readV1(SimpleDBData* pData, buffer >> numLocs; } else if (0 == strcasecmp(token.c_str(), "value-names")) { if (numValues > 0) { - delete[] names;names = new std::string[numValues]; + delete[] names; + names = new std::string[numValues]; } else { - throw std::runtime_error("Number of values must be specified BEFORE " - "names of values in SimpleDB file."); + throw std::runtime_error( + "Number of values must be specified BEFORE " + "names of values in SimpleDB file."); } buffer.ignore(maxIgnore, '='); for (int iVal = 0; iVal < numValues; ++iVal) { @@ -161,10 +155,12 @@ spatialdata::spatialdb::SimpleIOAscii::_readV1(SimpleDBData* pData, } } else if (0 == strcasecmp(token.c_str(), "value-units")) { if (numValues > 0) { - delete[] units;units = new std::string[numValues]; + delete[] units; + units = new std::string[numValues]; } else { - throw std::runtime_error("Number of values must be specified BEFORE " - "units of values in SimpleDB file."); + throw std::runtime_error( + "Number of values must be specified BEFORE " + "units of values in SimpleDB file."); } buffer.ignore(maxIgnore, '='); for (int iVal = 0; iVal < numValues; ++iVal) { @@ -181,7 +177,7 @@ spatialdata::spatialdb::SimpleIOAscii::_readV1(SimpleDBData* pData, std::string rbuffer(buffer.str()); filein.putback('\n'); filein.clear(); - int i = rbuffer.length()-1; + int i = rbuffer.length() - 1; while (i >= 0) { filein.putback(rbuffer[i]); if ('=' == rbuffer[i--]) { @@ -200,7 +196,7 @@ spatialdata::spatialdb::SimpleIOAscii::_readV1(SimpleDBData* pData, buffer.clear(); buffer >> token; } // while - if (( token != "}") || !filein.good()) { + if ((token != "}") || !filein.good()) { throw std::runtime_error("I/O error while parsing SimpleDB settings."); } @@ -235,10 +231,14 @@ spatialdata::spatialdb::SimpleIOAscii::_readV1(SimpleDBData* pData, } // for pData->setNames(const_cast(cnames), numValues); pData->setUnits(const_cast(cunits), numValues); - delete[] names;names = NULL; - delete[] units;units = NULL; - delete[] cnames;cnames = NULL; - delete[] cunits;cunits = NULL; + delete[] names; + names = NULL; + delete[] units; + units = NULL; + delete[] cnames; + cnames = NULL; + delete[] cunits; + cunits = NULL; int count = 0; for (int iLoc = 0; iLoc < numLocs; ++iLoc, ++count) { @@ -289,15 +289,13 @@ spatialdata::spatialdb::SimpleIOAscii::_readV1(SimpleDBData* pData, // ---------------------------------------------------------------------- // Write ascii database file. void -spatialdata::spatialdb::SimpleIOAscii::write( - const SimpleDBData& data, - const spatialdata::geocoords::CoordSys* pCS) { // write +spatialdata::spatialdb::SimpleIOAscii::write(const SimpleDBData& data, + const spatialdata::geocoords::CoordSys* pCS) { // write try { std::ofstream fileout(getFilename()); if (!fileout.is_open() || !fileout.good()) { std::ostringstream msg; - msg << "Could not open spatial database file " << getFilename() - << "for writing.\n"; + msg << "Could not open spatial database file " << getFilename() << "for writing.\n"; throw std::runtime_error(msg.str()); } // if @@ -307,11 +305,10 @@ spatialdata::spatialdb::SimpleIOAscii::write( const int spaceDim = data.getSpaceDim(); const int dataDim = data.getDataDim(); - fileout - << HEADER << " " << version << "\n" - << "SimpleDB {\n" - << " num-values = " << std::setw(6) << numValues << "\n" - << " value-names ="; + fileout << HEADER << " " << version << "\n" + << "SimpleDB {\n" + << " num-values = " << std::setw(6) << numValues << "\n" + << " value-names ="; for (int iVal = 0; iVal < numValues; ++iVal) { fileout << " " << data.getName(iVal); } @@ -321,21 +318,18 @@ spatialdata::spatialdb::SimpleIOAscii::write( fileout << " " << data.getUnits(iVal); } fileout << "\n"; - fileout - << " num-locs = " << std::setw(6) << numLocs << "\n" - << " data-dim = " << std::setw(4) << dataDim << "\n" - << " space-dim = " << std::setw(4) << spaceDim << "\n" - << " cs-data = "; + fileout << " num-locs = " << std::setw(6) << numLocs << "\n" + << " data-dim = " << std::setw(4) << dataDim << "\n" + << " space-dim = " << std::setw(4) << spaceDim << "\n" + << " cs-data = "; spatialdata::geocoords::CSPicklerAscii::pickle(fileout, pCS); fileout << "}\n"; if (!fileout.good()) { throw std::runtime_error("I/O error while writing SimpleDB header."); } - fileout - << std::resetiosflags(std::ios::fixed) - << std::setiosflags(std::ios::scientific) - << std::setprecision(6); + fileout << std::resetiosflags(std::ios::fixed) << std::setiosflags(std::ios::scientific) + << std::setprecision(6); for (int iLoc = 0; iLoc < numLocs; ++iLoc) { const double* coordinates = data.getCoordinates(iLoc); for (int iCoord = 0; iCoord < spaceDim; ++iCoord) { @@ -348,18 +342,17 @@ spatialdata::spatialdb::SimpleIOAscii::write( fileout << "\n"; } // for if (!fileout.good()) { - throw std::runtime_error("I/O error while writing SimpleDB data. Make sure num-locs is correct and your last line of data contains a line feed."); + throw std::runtime_error( + "I/O error while writing SimpleDB data. Make sure num-locs is correct and your last line of data " + "contains a line feed."); } } catch (const std::exception& err) { std::ostringstream msg; - msg << "Error occurred while writing spatial database file '" - << getFilename() << "'.\n" - << err.what(); + msg << "Error occurred while writing spatial database file '" << getFilename() << "'.\n" << err.what(); throw std::runtime_error(msg.str()); } catch (...) { std::ostringstream msg; - msg << "Unknown error occurred while writing spatial database file '" - << getFilename() << "'."; + msg << "Unknown error occurred while writing spatial database file '" << getFilename() << "'."; throw std::runtime_error(msg.str()); } // try/catch } // write diff --git a/libsrc/spatialdata/spatialdb/SimpleIOAscii.hh b/libsrc/spatialdata/spatialdb/SimpleIOAscii.hh index 564d38fb..e802aa68 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIOAscii.hh +++ b/libsrc/spatialdata/spatialdb/SimpleIOAscii.hh @@ -15,8 +15,7 @@ // ---------------------------------------------------------------------- class spatialdata::spatialdb::SimpleIOAscii : public SimpleIO { // SimpleIOAscii -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// // Using default constructor. @@ -47,8 +46,7 @@ public: void write(const SimpleDBData& data, const spatialdata::geocoords::CoordSys* pCS); -private: - + private: // PRIVATE METHODS //////////////////////////////////////////////////// /** Read database version 1 file. @@ -61,8 +59,7 @@ private: spatialdata::geocoords::CoordSys** ppCS, std::istream& filein); -private: - + private: // PRIVATE MEMBERS //////////////////////////////////////////////////// /** Magic header in ascii files */ diff --git a/libsrc/spatialdata/spatialdb/SimpleIOAscii.icc b/libsrc/spatialdata/spatialdb/SimpleIOAscii.icc index 6a072b34..b87c541a 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIOAscii.icc +++ b/libsrc/spatialdata/spatialdb/SimpleIOAscii.icc @@ -11,8 +11,7 @@ // ---------------------------------------------------------------------- // Clone object. -inline -spatialdata::spatialdb::SimpleIO* +inline spatialdata::spatialdb::SimpleIO* spatialdata::spatialdb::SimpleIOAscii::clone(void) const { return new SimpleIOAscii(*this); } diff --git a/libsrc/spatialdata/spatialdb/SpatialDB.cc b/libsrc/spatialdata/spatialdb/SpatialDB.cc index 8d46bd1b..3df86ae4 100644 --- a/libsrc/spatialdata/spatialdb/SpatialDB.cc +++ b/libsrc/spatialdata/spatialdb/SpatialDB.cc @@ -22,19 +22,20 @@ // ---------------------------------------------------------------------- /// Default constructor -spatialdata::spatialdb::SpatialDB::SpatialDB(void) : - _description("") {} +spatialdata::spatialdb::SpatialDB::SpatialDB(void) : _description("") { +} // ---------------------------------------------------------------------- /// Constructor with label -spatialdata::spatialdb::SpatialDB::SpatialDB(const char* label) : - _description(label) {} +spatialdata::spatialdb::SpatialDB::SpatialDB(const char* label) : _description(label) { +} // ---------------------------------------------------------------------- /// Default destructor -spatialdata::spatialdb::SpatialDB::~SpatialDB(void) {} +spatialdata::spatialdb::SpatialDB::~SpatialDB(void) { +} // ---------------------------------------------------------------------- @@ -58,8 +59,10 @@ spatialdata::spatialdb::SpatialDB::query(float* vals, vals[i] = valsD[i]; } // for - delete[] valsD;valsD = NULL; - delete[] coordsD;coordsD = NULL; + delete[] valsD; + valsD = NULL; + delete[] coordsD; + coordsD = NULL; return err; } // query @@ -79,16 +82,11 @@ spatialdata::spatialdb::SpatialDB::multiquery(double* vals, const spatialdata::geocoords::CoordSys* csQuery) { assert(numLocsV == numLocsE); assert(numLocsC == numLocsE); - assert( (!vals && 0 == numLocsV && 0 == numValsV) || - (vals && numLocsV > 0 && numValsV > 0) ); - assert( (!err && 0 == numLocsE) || - (err && numLocsE > 0) ); - assert( (!coords && 0 == numLocsC && 0 == numDimsC) || - (coords && numLocsC > 0 && numDimsC > 0) ); - - for (size_t i = 0, indexV = 0, indexC = 0; - i < numLocsV; - ++i, indexV += numValsV, indexC += numDimsC) { + assert((!vals && 0 == numLocsV && 0 == numValsV) || (vals && numLocsV > 0 && numValsV > 0)); + assert((!err && 0 == numLocsE) || (err && numLocsE > 0)); + assert((!coords && 0 == numLocsC && 0 == numDimsC) || (coords && numLocsC > 0 && numDimsC > 0)); + + for (size_t i = 0, indexV = 0, indexC = 0; i < numLocsV; ++i, indexV += numValsV, indexC += numDimsC) { err[i] = query(&vals[indexV], numValsV, &coords[indexC], numDimsC, csQuery); } // for } // multiquery @@ -108,16 +106,11 @@ spatialdata::spatialdb::SpatialDB::multiquery(float* vals, const spatialdata::geocoords::CoordSys* csQuery) { assert(numLocsV == numLocsE); assert(numLocsC == numLocsE); - assert( (!vals && 0 == numLocsV && 0 == numValsV) || - (vals && numLocsV > 0 && numValsV > 0) ); - assert( (!err && 0 == numLocsE) || - (err && numLocsE > 0) ); - assert( (!coords && 0 == numLocsC && 0 == numDimsC) || - (coords && numLocsC > 0 && numDimsC > 0) ); - - for (size_t i = 0, indexV = 0, indexC = 0; - i < numLocsV; - ++i, indexV += numValsV, indexC += numDimsC) { + assert((!vals && 0 == numLocsV && 0 == numValsV) || (vals && numLocsV > 0 && numValsV > 0)); + assert((!err && 0 == numLocsE) || (err && numLocsE > 0)); + assert((!coords && 0 == numLocsC && 0 == numDimsC) || (coords && numLocsC > 0 && numDimsC > 0)); + + for (size_t i = 0, indexV = 0, indexC = 0; i < numLocsV; ++i, indexV += numValsV, indexC += numDimsC) { err[i] = query(&vals[indexV], numValsV, &coords[indexC], numDimsC, csQuery); } // for } // multiquery @@ -148,7 +141,7 @@ spatialdata::spatialdb::SpatialDB::_convertToSI(double* vals, for (size_t iLoc = 0; iLoc < numLocs; ++iLoc) { for (size_t iVal = 0; iVal < numVals; ++iVal) { - vals[iLoc*numVals+iVal] *= scales[iVal]; + vals[iLoc * numVals + iVal] *= scales[iVal]; } // for } // for } // _convertToSI diff --git a/libsrc/spatialdata/spatialdb/SpatialDB.hh b/libsrc/spatialdata/spatialdb/SpatialDB.hh index 0fa2b31d..e8db0151 100644 --- a/libsrc/spatialdata/spatialdb/SpatialDB.hh +++ b/libsrc/spatialdata/spatialdb/SpatialDB.hh @@ -9,15 +9,14 @@ // ================================================================================================= #pragma once -#include "spatialdbfwd.hh" #include "spatialdata/geocoords/geocoordsfwd.hh" +#include "spatialdbfwd.hh" #include // USES std::string /// C++ manager for spatial database. class spatialdata::spatialdb::SpatialDB { -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /// Default constructor. @@ -45,21 +44,18 @@ public: const char* getDescription(void) const; /// Open the database and prepare for querying. - virtual - void open(void) = 0; + virtual void open(void) = 0; /// Close the database. - virtual - void close(void) = 0; + virtual void close(void) = 0; /** Get names of values in spatial database. * * @param[out] valueNames Array of names of values. * @param[out] numValues Size of array. */ - virtual - void getNamesDBValues(const char*** valueNames, - size_t* numValues) const = 0; + virtual void getNamesDBValues(const char*** valueNames, + size_t* numValues) const = 0; /** Set values to be returned by queries. * @@ -68,9 +64,8 @@ public: * @param names Names of values to be returned in queries * @param numVals Number of values to be returned in queries */ - virtual - void setQueryValues(const char* const* names, - const size_t numVals) = 0; + virtual void setQueryValues(const char* const* names, + const size_t numVals) = 0; /** Query the database. * @@ -87,12 +82,11 @@ public: * * @returns 0 on success, 1 on failure (i.e., could not interpolate) */ - virtual - int query(double* vals, - const size_t numVals, - const double* coords, - const size_t numDims, - const spatialdata::geocoords::CoordSys* csQuery) = 0; + virtual int query(double* vals, + const size_t numVals, + const double* coords, + const size_t numDims, + const spatialdata::geocoords::CoordSys* csQuery) = 0; /** Query the database. * @@ -178,8 +172,7 @@ public: const spatialdata::geocoords::CoordSys* csQuery); // PROTECTED METHODS ////////////////////////////////////////////////// -protected: - + protected: /** Convert values to SI units. * * @param data Array of data. @@ -187,20 +180,17 @@ protected: * @param numLocs Number of locations. * @param numVals Number of values per location. */ - static - void _convertToSI(double* vals, - std::string* units, - const size_t numLocs, - const size_t numVals); + static void _convertToSI(double* vals, + std::string* units, + const size_t numLocs, + const size_t numVals); // PRIVATE METHODS //////////////////////////////////////////////////// -private: - + private: SpatialDB(const SpatialDB& data); ///< Not implemented const SpatialDB& operator=(const SpatialDB& data); ///< Not implemented -private: - + private: // PRIVATE MEMBERS //////////////////////////////////////////////////// std::string _description; ///< Description of spatial database. diff --git a/libsrc/spatialdata/spatialdb/SpatialDB.icc b/libsrc/spatialdata/spatialdb/SpatialDB.icc index 13055608..84d9e89e 100644 --- a/libsrc/spatialdata/spatialdb/SpatialDB.icc +++ b/libsrc/spatialdata/spatialdb/SpatialDB.icc @@ -10,16 +10,14 @@ #pragma once // Set description of spatial database. -inline -void +inline void spatialdata::spatialdb::SpatialDB::setDescription(const char* description) { _description = description; } // Get description of spatial database. -inline -const char* +inline const char* spatialdata::spatialdb::SpatialDB::getDescription(void) const { return _description.c_str(); } diff --git a/libsrc/spatialdata/spatialdb/TimeHistory.cc b/libsrc/spatialdata/spatialdb/TimeHistory.cc index 047a6d7b..b2020348 100644 --- a/libsrc/spatialdata/spatialdb/TimeHistory.cc +++ b/libsrc/spatialdata/spatialdb/TimeHistory.cc @@ -24,7 +24,8 @@ spatialdata::spatialdb::TimeHistory::TimeHistory(void) : _time(0), _amplitude(0), _npts(0), - _ilower(0) {} + _ilower(0) { +} // ---------------------------------------------------------------------- @@ -35,14 +36,17 @@ spatialdata::spatialdb::TimeHistory::TimeHistory(const char* label) : _time(0), _amplitude(0), _npts(0), - _ilower(0) {} + _ilower(0) { +} // ---------------------------------------------------------------------- /// Default destructor spatialdata::spatialdb::TimeHistory::~TimeHistory(void) { - delete[] _time;_time = 0; - delete[] _amplitude;_amplitude = 0; + delete[] _time; + _time = 0; + delete[] _amplitude; + _amplitude = 0; _npts = 0; } // destructor @@ -60,8 +64,10 @@ spatialdata::spatialdb::TimeHistory::open(void) { // Close the time history. void spatialdata::spatialdb::TimeHistory::close(void) { - delete[] _time;_time = 0; - delete[] _amplitude;_amplitude = 0; + delete[] _time; + _time = 0; + delete[] _amplitude; + _amplitude = 0; _npts = 0; } // close @@ -82,23 +88,23 @@ spatialdata::spatialdb::TimeHistory::query(double* value, } --_ilower; } // while - } else if (t > _time[_ilower+1]) { - const size_t imax = _npts-2; + } else if (t > _time[_ilower + 1]) { + const size_t imax = _npts - 2; while (_ilower < imax) { - if (t <= _time[_ilower+1]) { + if (t <= _time[_ilower + 1]) { break; } ++_ilower; } // while } // if/else - assert(_ilower < _npts-1); - if (( t >= _time[_ilower]) && ( t <= _time[_ilower+1]) ) { + assert(_ilower < _npts - 1); + if ((t >= _time[_ilower]) && (t <= _time[_ilower + 1])) { const double tL = _time[_ilower]; - const double tU = _time[_ilower+1]; + const double tU = _time[_ilower + 1]; const double wtL = (tU - t) / (tU - tL); const double wtU = (t - tL) / (tU - tL); - *value = wtL * _amplitude[_ilower] + wtU * _amplitude[_ilower+1]; + *value = wtL * _amplitude[_ilower] + wtU * _amplitude[_ilower + 1]; } else { return 1; } // else diff --git a/libsrc/spatialdata/spatialdb/TimeHistory.hh b/libsrc/spatialdata/spatialdb/TimeHistory.hh index 0ecf6b5e..d93ec7a0 100644 --- a/libsrc/spatialdata/spatialdb/TimeHistory.hh +++ b/libsrc/spatialdata/spatialdb/TimeHistory.hh @@ -17,8 +17,7 @@ class spatialdata::spatialdb::TimeHistory { // class TimeHistory friend class TestTimeHistory; -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /// Default constructor. @@ -87,8 +86,7 @@ public: int query(float* value, const float t); -private: - + private: // PRIVATE MEMBERS //////////////////////////////////////////////////// std::string _description; ///< Description of time history. @@ -98,8 +96,7 @@ private: size_t _npts; ///< Number of points in time history. size_t _ilower; ///< Current index for point preceding current time. -private: - + private: // NOT IMPLEMENTED //////////////////////////////////////////////////// TimeHistory(const TimeHistory&); ///< Not implemented diff --git a/libsrc/spatialdata/spatialdb/TimeHistory.icc b/libsrc/spatialdata/spatialdb/TimeHistory.icc index 08aa3407..e92a54de 100644 --- a/libsrc/spatialdata/spatialdb/TimeHistory.icc +++ b/libsrc/spatialdata/spatialdb/TimeHistory.icc @@ -10,32 +10,28 @@ #pragma once // Set description of time history. -inline -void +inline void spatialdata::spatialdb::TimeHistory::setDescription(const char* description) { _description = description; } // Get description of time history. -inline -const char* +inline const char* spatialdata::spatialdb::TimeHistory::getDescription(void) const { return _description.c_str(); } // Set filename for time history. -inline -void +inline void spatialdata::spatialdb::TimeHistory::setFilename(const char* name) { _filename = name; } // Set filename for time history. -inline -const char* +inline const char* spatialdata::spatialdb::TimeHistory::getFilename(void) { return _filename.c_str(); } diff --git a/libsrc/spatialdata/spatialdb/TimeHistoryIO.cc b/libsrc/spatialdata/spatialdb/TimeHistoryIO.cc index 75d3d586..af1d1d69 100644 --- a/libsrc/spatialdata/spatialdb/TimeHistoryIO.cc +++ b/libsrc/spatialdata/spatialdb/TimeHistoryIO.cc @@ -15,19 +15,18 @@ // Include ios here to avoid some Python/gcc issues #include -#include "spatialdata/utils/LineParser.hh" // USES LineParser #include "spatialdata/units/Parser.hh" // USES Parser +#include "spatialdata/utils/LineParser.hh" // USES LineParser #include // USES std::ifstream, std::ofstream -#include // USES setw(), setiosflags(), resetiosflags() #include // USES assert() -#include // USES std::runtime_error +#include // USES setw(), setiosflags(), resetiosflags() #include // USES std::ostringstream +#include // USES std::runtime_error // ---------------------------------------------------------------------- -const char* spatialdata::spatialdb::TimeHistoryIO::HEADER = - "#TIME HISTORY ascii"; +const char* spatialdata::spatialdb::TimeHistoryIO::HEADER = "#TIME HISTORY ascii"; // ---------------------------------------------------------------------- // Read time history file. @@ -59,13 +58,13 @@ spatialdata::spatialdb::TimeHistoryIO::read(double** ptime, const int headerLen = strlen(HEADER); std::string hbuffer; - hbuffer.resize(headerLen+1); - buffer.read((char*) hbuffer.c_str(), sizeof(char)*headerLen); + hbuffer.resize(headerLen + 1); + buffer.read((char*)hbuffer.c_str(), sizeof(char) * headerLen); hbuffer[headerLen] = '\0'; if (0 != strcasecmp(HEADER, hbuffer.c_str())) { std::ostringstream msg; - msg << "Magic header '" << buffer.str() << "' does not match expected header '" - << HEADER << "' in time history file '" << filename << "'.\n"; + msg << "Magic header '" << buffer.str() << "' does not match expected header '" << HEADER + << "' in time history file '" << filename << "'.\n"; throw std::runtime_error(msg.str()); } // if @@ -99,7 +98,7 @@ spatialdata::spatialdb::TimeHistoryIO::read(double** ptime, buffer.clear(); buffer >> token; } // while - if (( token != "}") || !filein.good()) { + if ((token != "}") || !filein.good()) { throw std::runtime_error("I/O error while parsing TimeHistory settings."); } @@ -135,7 +134,7 @@ spatialdata::spatialdb::TimeHistoryIO::read(double** ptime, } // for // Verify that the time stamps are ordered in time. for (size_t i = 1; i < size; ++i) { - if (time[i-1] >= time[i]) { + if (time[i - 1] >= time[i]) { throw std::runtime_error("Time history must be ordered in time."); } // if } // for @@ -151,18 +150,17 @@ spatialdata::spatialdb::TimeHistoryIO::read(double** ptime, throw std::runtime_error(msg.str()); } // if - delete[] *ptime;*ptime = time; - delete[] *pamplitude;*pamplitude = amplitude; + delete[] *ptime; + *ptime = time; + delete[] *pamplitude; + *pamplitude = amplitude; } catch (const std::exception& err) { std::ostringstream msg; - msg << "Error occurred while reading time history file '" - << filename << "'.\n" - << err.what(); + msg << "Error occurred while reading time history file '" << filename << "'.\n" << err.what(); throw std::runtime_error(msg.str()); } catch (...) { std::ostringstream msg; - msg << "Unknown error occurred while reading time history file '" - << filename << "'.\n"; + msg << "Unknown error occurred while reading time history file '" << filename << "'.\n"; throw std::runtime_error(msg.str()); } // try/catch } // read @@ -177,10 +175,8 @@ spatialdata::spatialdb::TimeHistoryIO::write(const double* time, const size_t nptsA, const char* timeUnits, const char* filename) { // write - assert( (0 == nptsT && !time) || - (0 < nptsT && time) ); - assert( (0 == nptsA && !amplitude) || - (0 < nptsA && amplitude) ); + assert((0 == nptsT && !time) || (0 < nptsT && time)); + assert((0 == nptsA && !amplitude) || (0 < nptsA && amplitude)); try { if (nptsT != nptsA) { @@ -208,27 +204,21 @@ spatialdata::spatialdb::TimeHistoryIO::write(const double* time, throw std::runtime_error("I/O error while writing TimeHistory settings."); } // if - fileout << std::resetiosflags(std::ios::fixed) - << std::setiosflags(std::ios::scientific) + fileout << std::resetiosflags(std::ios::fixed) << std::setiosflags(std::ios::scientific) << std::setprecision(6); for (size_t i = 0; i < npts; ++i) { - fileout << std::setw(14) << time[i] - << std::setw(14) << amplitude[i] - << "\n"; + fileout << std::setw(14) << time[i] << std::setw(14) << amplitude[i] << "\n"; } // for if (!fileout.good()) { throw std::runtime_error("I/O error while writing TimeHistory data."); } // if } catch (const std::exception& err) { std::ostringstream msg; - msg << "Error occurred while writing time history file '" - << filename << "'.\n" - << err.what(); + msg << "Error occurred while writing time history file '" << filename << "'.\n" << err.what(); throw std::runtime_error(msg.str()); } catch (...) { std::ostringstream msg; - msg << "Unknown error occurred while writing time history file '" - << filename << "'."; + msg << "Unknown error occurred while writing time history file '" << filename << "'."; throw std::runtime_error(msg.str()); } // try/catch } // write diff --git a/libsrc/spatialdata/spatialdb/TimeHistoryIO.hh b/libsrc/spatialdata/spatialdb/TimeHistoryIO.hh index 55ef1f9a..4282f6c8 100644 --- a/libsrc/spatialdata/spatialdb/TimeHistoryIO.hh +++ b/libsrc/spatialdata/spatialdb/TimeHistoryIO.hh @@ -15,8 +15,7 @@ /// C++ object for reading/writing time history files. class spatialdata::spatialdb::TimeHistoryIO { // class TimeHistoryIO -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /** Read time history file. @@ -26,11 +25,10 @@ public: * @param npts Number of points in time history. * @param filename Filename for time history. */ - static - void read(double** time, - double** amplitude, - size_t* npts, - const char* filename); + static void read(double** time, + double** amplitude, + size_t* npts, + const char* filename); /** Read time history file. Number of time history points given by * nptsT must equal nptsA. @@ -42,16 +40,14 @@ public: * @param timeUnits Units associated with time stamps. * @param filename Filename for time history. */ - static - void write(const double* time, - const size_t nptsT, - const double* amplitude, - const size_t nptsA, - const char* timeUnits, - const char* filename); - -private: - + static void write(const double* time, + const size_t nptsT, + const double* amplitude, + const size_t nptsA, + const char* timeUnits, + const char* filename); + + private: // PRIVATE MEMBERS //////////////////////////////////////////////////// static const char* HEADER; ///< Header for time history files. diff --git a/libsrc/spatialdata/spatialdb/UniformDB.cc b/libsrc/spatialdata/spatialdb/UniformDB.cc index 3b0f67a7..1d0492cd 100644 --- a/libsrc/spatialdata/spatialdb/UniformDB.cc +++ b/libsrc/spatialdata/spatialdb/UniformDB.cc @@ -17,12 +17,12 @@ #include "spatialdata/units/Parser.hh" // USES Parser -#include // USES std::vector #include // USES std::runtime_error +#include // USES std::vector +#include // USES assert() #include // USES std::ostringsgream #include // USES strcasecmp() -#include // USES assert() // ---------------------------------------------------------------------- /// Default constructor @@ -31,7 +31,8 @@ spatialdata::spatialdb::UniformDB::UniformDB(void) : _values(NULL), _queryValues(NULL), _numValues(0), - _querySize(0) {} + _querySize(0) { +} // ---------------------------------------------------------------------- @@ -42,15 +43,19 @@ spatialdata::spatialdb::UniformDB::UniformDB(const char* label) : _values(NULL), _queryValues(NULL), _numValues(0), - _querySize(0) {} + _querySize(0) { +} // ---------------------------------------------------------------------- /// Default destructor spatialdata::spatialdb::UniformDB::~UniformDB(void) { - delete[] _names;_names = NULL; - delete[] _values;_values = NULL; - delete[] _queryValues;_queryValues = NULL; + delete[] _names; + _names = NULL; + delete[] _values; + _values = NULL; + delete[] _queryValues; + _queryValues = NULL; _numValues = 0; _querySize = 0; } // destructor @@ -63,15 +68,17 @@ spatialdata::spatialdb::UniformDB::setData(const char* const* names, const char* const* units, const double* values, const size_t numValues) { - assert( (0 < numValues && names && units && values) || - (0 == numValues && !names && !units && !values) ); + assert((0 < numValues && names && units && values) || (0 == numValues && !names && !units && !values)); // clear out old data - delete[] _names;_names = NULL; - delete[] _values;_values = NULL; + delete[] _names; + _names = NULL; + delete[] _values; + _values = NULL; _numValues = numValues; - delete[] _queryValues;_queryValues = NULL; + delete[] _queryValues; + _queryValues = NULL; _querySize = 0; spatialdata::units::Parser parser; @@ -93,12 +100,13 @@ spatialdata::spatialdb::UniformDB::setData(const char* const* names, _values = new double[numValues]; for (size_t i = 0; i < numValues; ++i) { - _values[i] = values[i]*scales[i]; + _values[i] = values[i] * scales[i]; } // for // Default query values is all values. _querySize = _numValues; - delete[] _queryValues;_queryValues = (_querySize > 0) ? new size_t[_querySize] : NULL; + delete[] _queryValues; + _queryValues = (_querySize > 0) ? new size_t[_querySize] : NULL; for (size_t i = 0; i < _querySize; ++i) { _queryValues[i] = i; } // for @@ -130,14 +138,14 @@ spatialdata::spatialdb::UniformDB::setQueryValues(const char* const* names, const size_t numVals) { if (0 == numVals) { std::ostringstream msg; - msg << "Number of values for query in spatial database " << getDescription() - << "\n must be positive.\n"; + msg << "Number of values for query in spatial database " << getDescription() << "\n must be positive.\n"; throw std::invalid_argument(msg.str()); } // if assert(names && 0 < numVals); _querySize = numVals; - delete[] _queryValues;_queryValues = new size_t[numVals]; + delete[] _queryValues; + _queryValues = new size_t[numVals]; for (size_t iVal = 0; iVal < numVals; ++iVal) { size_t iName = 0; while (iName < _numValues) { @@ -148,8 +156,8 @@ spatialdata::spatialdb::UniformDB::setQueryValues(const char* const* names, } // while if (iName >= _numValues) { std::ostringstream msg; - msg << "Could not find value '" << names[iVal] << "' in spatial database '" - << getDescription() << "'. Available values are:"; + msg << "Could not find value '" << names[iVal] << "' in spatial database '" << getDescription() + << "'. Available values are:"; for (size_t iName = 0; iName < _numValues; ++iName) { msg << "\n " << _names[iName]; msg << "\n"; @@ -177,10 +185,8 @@ spatialdata::spatialdb::UniformDB::query(double* vals, } // if else if (numVals != _querySize) { std::ostringstream msg; - msg << "Number of values to be returned by spatial database " - << getDescription() << "\n" - << "(" << _querySize << ") does not match size of array provided (" - << numVals << ").\n"; + msg << "Number of values to be returned by spatial database " << getDescription() << "\n" + << "(" << _querySize << ") does not match size of array provided (" << numVals << ").\n"; throw std::invalid_argument(msg.str()); } // if diff --git a/libsrc/spatialdata/spatialdb/UniformDB.hh b/libsrc/spatialdata/spatialdb/UniformDB.hh index 23cce171..f636cd26 100644 --- a/libsrc/spatialdata/spatialdb/UniformDB.hh +++ b/libsrc/spatialdata/spatialdb/UniformDB.hh @@ -17,8 +17,7 @@ class spatialdata::spatialdb::UniformDB : public SpatialDB { // class UniformDB friend class TestUniformDB; // unit testing -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /// Default constructor. @@ -89,15 +88,13 @@ public: const size_t numDims, const spatialdata::geocoords::CoordSys* pCSQuery); -private: - + private: // PRIVATE METHODS //////////////////////////////////////////////////// UniformDB(const UniformDB& data); ///< Not implemented const UniformDB& operator=(const UniformDB& data); ///< Not implemented -private: - + private: // PRIVATE MEMBERS ///////////////////////////////////////////////////// std::string* _names; ///< Names of values in database diff --git a/libsrc/spatialdata/spatialdb/UniformDB.icc b/libsrc/spatialdata/spatialdb/UniformDB.icc index 2184ca37..4c8c7058 100644 --- a/libsrc/spatialdata/spatialdb/UniformDB.icc +++ b/libsrc/spatialdata/spatialdb/UniformDB.icc @@ -10,15 +10,13 @@ #pragma once // Open the database and prepare for querying. -inline -void +inline void spatialdata::spatialdb::UniformDB::open(void) { } // Close the database. -inline -void +inline void spatialdata::spatialdb::UniformDB::close(void) { } diff --git a/libsrc/spatialdata/spatialdb/UserFunctionDB.cc b/libsrc/spatialdata/spatialdb/UserFunctionDB.cc index f3a616c7..c51be589 100644 --- a/libsrc/spatialdata/spatialdb/UserFunctionDB.cc +++ b/libsrc/spatialdata/spatialdb/UserFunctionDB.cc @@ -15,73 +15,79 @@ // Include ios here to avoid some Python/gcc issues #include -#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys #include "spatialdata/geocoords/Converter.hh" // USES Converter +#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys #include "spatialdata/units/Parser.hh" // USES Parser -#include // USES std::string -#include // USES std::runtime_error -#include // USES std::ostringstream #include // USES assert() +#include // USES std::ostringstream +#include // USES std::runtime_error +#include // USES std::string #include // USES typeid() // ---------------------------------------------------------------------- namespace spatialdata { namespace spatialdb { class UserFunctionDB::QueryFn1D : public UserFunctionDB::QueryFn { -public: - - QueryFn1D(UserFunctionDB::userfn1D_type fn) : _fn(fn) {} + public: + QueryFn1D(UserFunctionDB::userfn1D_type fn) : _fn(fn) { + } - int query(double* value, - const double* coords, - const size_t dim) { - if (!value || !coords || ( 1 != dim) ) { return 1; } + int + query(double* value, + const double* coords, + const size_t dim) { + if (!value || !coords || (1 != dim)) { + return 1; + } *value = _fn(coords[0]); return 0; } -private: - + private: UserFunctionDB::userfn1D_type _fn; }; class UserFunctionDB::QueryFn2D : public UserFunctionDB::QueryFn { -public: - - QueryFn2D(UserFunctionDB::userfn2D_type fn) : _fn(fn) {} + public: + QueryFn2D(UserFunctionDB::userfn2D_type fn) : _fn(fn) { + } - int query(double* value, - const double* coords, - const size_t dim) { - if (!value || !coords || ( 2 != dim) ) { return 1; } + int + query(double* value, + const double* coords, + const size_t dim) { + if (!value || !coords || (2 != dim)) { + return 1; + } *value = _fn(coords[0], coords[1]); return 0; } -private: - + private: UserFunctionDB::userfn2D_type _fn; }; class UserFunctionDB::QueryFn3D : public UserFunctionDB::QueryFn { -public: - - QueryFn3D(UserFunctionDB::userfn3D_type fn) : _fn(fn) {} + public: + QueryFn3D(UserFunctionDB::userfn3D_type fn) : _fn(fn) { + } - int query(double* value, - const double* coords, - const size_t dim) { - if (!value || !coords || ( 3 != dim) ) { return 1; } + int + query(double* value, + const double* coords, + const size_t dim) { + if (!value || !coords || (3 != dim)) { + return 1; + } *value = _fn(coords[0], coords[1], coords[2]); return 0; } -private: - + private: UserFunctionDB::userfn3D_type _fn; }; @@ -94,21 +100,26 @@ spatialdata::spatialdb::UserFunctionDB::UserFunctionDB(void) : _queryFunctions(NULL), _cs(NULL), _converter(new spatialdata::geocoords::Converter), - _querySize(0) {} + _querySize(0) { +} // ---------------------------------------------------------------------- // Destructor spatialdata::spatialdb::UserFunctionDB::~UserFunctionDB(void) { - delete[] _queryFunctions;_queryFunctions = NULL; + delete[] _queryFunctions; + _queryFunctions = NULL; _querySize = 0; for (function_map::iterator iter = _functions.begin(); iter != _functions.end(); ++iter) { - delete iter->second.fn;iter->second.fn = NULL; + delete iter->second.fn; + iter->second.fn = NULL; } // for - delete _cs;_cs = NULL; - delete _converter;_converter = NULL; + delete _cs; + _cs = NULL; + delete _converter; + _converter = NULL; } // destructor @@ -169,7 +180,7 @@ spatialdata::spatialdb::UserFunctionDB::open(void) { const std::string& none = "none"; for (function_map::iterator iter = _functions.begin(); iter != _functions.end(); ++iter) { - if (strcasecmp(none.c_str(), iter->second.units.c_str()) != 0) { + if (strcasecmp(none.c_str(), iter->second.units.c_str()) != 0) { iter->second.scale = parser.parse(iter->second.units.c_str()); } else { iter->second.scale = 1.0; @@ -180,7 +191,8 @@ spatialdata::spatialdb::UserFunctionDB::open(void) { // Default query values is all values. _querySize = _functions.size(); - delete[] _queryFunctions;_queryFunctions = (_querySize > 0) ? new UserData*[_querySize] : NULL; + delete[] _queryFunctions; + _queryFunctions = (_querySize > 0) ? new UserData*[_querySize] : NULL; size_t index = 0; for (function_map::iterator iter = _functions.begin(); iter != _functions.end(); ++iter, ++index) { _queryFunctions[index] = &iter->second; @@ -192,7 +204,8 @@ spatialdata::spatialdb::UserFunctionDB::open(void) { // Close the database. void spatialdata::spatialdb::UserFunctionDB::close(void) { - delete[] _queryFunctions;_queryFunctions = NULL; + delete[] _queryFunctions; + _queryFunctions = NULL; } // close @@ -222,20 +235,20 @@ spatialdata::spatialdb::UserFunctionDB::setQueryValues(const char* const* names, const size_t numVals) { if (0 == numVals) { std::ostringstream msg; - msg << "Number of values for query in spatial database " << getDescription() - << "\n must be positive.\n"; + msg << "Number of values for query in spatial database " << getDescription() << "\n must be positive.\n"; throw std::invalid_argument(msg.str()); } // if assert(names && 0 < numVals); _querySize = numVals; - delete[] _queryFunctions;_queryFunctions = numVals > 0 ? new UserData*[numVals] : NULL; + delete[] _queryFunctions; + _queryFunctions = numVals > 0 ? new UserData*[numVals] : NULL; for (size_t iVal = 0; iVal < numVals; ++iVal) { const function_map::iterator iter = _functions.find(names[iVal]); if (_functions.end() == iter) { std::ostringstream msg; - msg << "Could not find value '" << names[iVal] << "' in spatial database '" - << getDescription() << "'. Available values are:"; + msg << "Could not find value '" << names[iVal] << "' in spatial database '" << getDescription() + << "'. Available values are:"; for (function_map::iterator viter = _functions.begin(); viter != _functions.end(); ++viter) { msg << "\n " << viter->first; } // for @@ -267,21 +280,20 @@ spatialdata::spatialdb::UserFunctionDB::query(double* vals, throw std::logic_error(msg.str()); } else if (numVals != querySize) { std::ostringstream msg; - msg << "Number of values to be returned by spatial database " - << getDescription() << " (" << querySize << ") does not match size of array provided (" - << numVals << ").\n"; + msg << "Number of values to be returned by spatial database " << getDescription() << " (" << querySize + << ") does not match size of array provided (" << numVals << ").\n"; throw std::invalid_argument(msg.str()); } else if (numDims != _cs->getSpaceDim()) { std::ostringstream msg; - msg << "Spatial dimension (" << numDims - << ") does not match spatial dimension of spatial database (" << _cs->getSpaceDim() << ")."; + msg << "Spatial dimension (" << numDims << ") does not match spatial dimension of spatial database (" + << _cs->getSpaceDim() << ")."; throw std::invalid_argument(msg.str()); } // if // Convert coordinates assert(numDims <= 3); double xyz[3]; - memcpy(xyz, coords, numDims*sizeof(double)); + memcpy(xyz, coords, numDims * sizeof(double)); assert(_converter); _converter->convert(xyz, 1, numDims, _cs, csQuery); @@ -289,7 +301,9 @@ spatialdata::spatialdb::UserFunctionDB::query(double* vals, for (size_t iVal = 0; iVal < querySize; ++iVal) { assert(_queryFunctions[iVal]->fn); queryFlag = _queryFunctions[iVal]->fn->query(&vals[iVal], xyz, numDims); - if (queryFlag) { break; } + if (queryFlag) { + break; + } vals[iVal] *= _queryFunctions[iVal]->scale; // Convert to SI units. } // for @@ -301,7 +315,9 @@ spatialdata::spatialdb::UserFunctionDB::query(double* vals, // Set filename containing data. void spatialdata::spatialdb::UserFunctionDB::setCoordSys(const geocoords::CoordSys& cs) { - delete _cs;_cs = cs.clone();assert(_cs); + delete _cs; + _cs = cs.clone(); + assert(_cs); } // setCoordSys @@ -351,7 +367,7 @@ spatialdata::spatialdb::UserFunctionDB::_checkCompatibility(void) const { throw std::logic_error(msg.str()); } // if - double coords[3] = { 0.0, 0.0, 0.0 }; + double coords[3] = {0.0, 0.0, 0.0}; const int spaceDim = _cs->getSpaceDim(); assert(0 < spaceDim && spaceDim <= 3); diff --git a/libsrc/spatialdata/spatialdb/UserFunctionDB.hh b/libsrc/spatialdata/spatialdb/UserFunctionDB.hh index 3d52fc77..3c34b87b 100644 --- a/libsrc/spatialdata/spatialdb/UserFunctionDB.hh +++ b/libsrc/spatialdata/spatialdb/UserFunctionDB.hh @@ -11,14 +11,13 @@ #include "SpatialDB.hh" // ISA SpatialDB -#include // HASA std::string #include // HASA std::map +#include // HASA std::string class spatialdata::spatialdb::UserFunctionDB : public SpatialDB { friend class TestUserFunctionDB; // unit testing -public: - + public: // PUBLIC TYPEDEF////////////////////////////////////////////////////// /** User function prototype in 1-D. @@ -49,8 +48,7 @@ public: const double z); // PUBLIC MEMBERS /////////////////////////////////////////////////////// -public: - + public: /// Constructor UserFunctionDB(void); @@ -138,8 +136,7 @@ public: */ void setCoordSys(const geocoords::CoordSys& cs); -private: - + private: // PRIVATE TYPEDEF////////////////////////////////////////////////////// /** User function prototype. @@ -154,8 +151,7 @@ private: const size_t dim); // PRIVATE METHODS ////////////////////////////////////////////////////// -private: - + private: /** Check suitability of arguments for adding user function. * * @parma[in] name Name of value. @@ -170,21 +166,20 @@ private: void _checkCompatibility(void) const; // PRIVATE STRUCTS ////////////////////////////////////////////////////// -private: - + private: class QueryFn { -public: - - QueryFn(void) {} + public: + QueryFn(void) { + } - virtual ~QueryFn(void) {} + virtual ~QueryFn(void) { + } virtual int query(double* value, const double* coords, const size_t dim) = 0; - }; class QueryFn1D; class QueryFn2D; @@ -200,8 +195,7 @@ public: typedef std::map function_map; // PRIVATE MEMBERS ////////////////////////////////////////////////////// -private: - + private: UserData** _queryFunctions; ///< Array of pointers to _functions of values to be returned in queries. std::map _functions; ///< User functions for values. spatialdata::geocoords::CoordSys* _cs; ///< Coordinate system @@ -209,8 +203,7 @@ private: size_t _querySize; ///< Number of values to be returned in queries. // NOT IMPLEMENTED ////////////////////////////////////////////////////// -private: - + private: UserFunctionDB(const UserFunctionDB&); ///< Not implemented const UserFunctionDB& operator=(const UserFunctionDB&); ///< Not implemented diff --git a/libsrc/spatialdata/spatialdb/cspatialdb.cc b/libsrc/spatialdata/spatialdb/cspatialdb.cc index 6279dd7f..144c0a7a 100644 --- a/libsrc/spatialdata/spatialdb/cspatialdb.cc +++ b/libsrc/spatialdata/spatialdb/cspatialdb.cc @@ -20,18 +20,15 @@ extern "C" { // ---------------------------------------------------------------------- // Call SpatialDB:Query(). -extern "C" -int +extern "C" int spatialdb_query(void* db, double* vals, const int numVals, const double* coords, const int numDims, const void* cs) { // spatialdb_query - spatialdata::spatialdb::SpatialDB* pDB = - (spatialdata::spatialdb::SpatialDB*) db; - const spatialdata::geocoords::CoordSys* pCS = - (const spatialdata::geocoords::CoordSys*) cs; + spatialdata::spatialdb::SpatialDB* pDB = (spatialdata::spatialdb::SpatialDB*)db; + const spatialdata::geocoords::CoordSys* pCS = (const spatialdata::geocoords::CoordSys*)cs; assert(0 != pDB); assert(0 != pCS); return pDB->query(vals, numVals, coords, numDims, pCS); diff --git a/libsrc/spatialdata/spatialdb/f77spatialdb.cc b/libsrc/spatialdata/spatialdb/f77spatialdb.cc index 69ca9cb0..e296711a 100644 --- a/libsrc/spatialdata/spatialdb/f77spatialdb.cc +++ b/libsrc/spatialdata/spatialdb/f77spatialdb.cc @@ -8,8 +8,8 @@ // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= -#include #include "f77spatialdb.h" +#include extern "C" { #include "cspatialdb.h" @@ -21,8 +21,7 @@ extern "C" { // ---------------------------------------------------------------------- // Call SpatialDB:Query(). -extern "C" -void +extern "C" void spatialdb_query_f(void* db, double* vals, const int* numVals, @@ -30,10 +29,8 @@ spatialdb_query_f(void* db, const int* numDims, const void* cs, int* ok) { // spatialdb_query_f - spatialdata::spatialdb::SpatialDB* pDB = - (spatialdata::spatialdb::SpatialDB*) db; - const spatialdata::geocoords::CoordSys* pCS = - (const spatialdata::geocoords::CoordSys*) cs; + spatialdata::spatialdb::SpatialDB* pDB = (spatialdata::spatialdb::SpatialDB*)db; + const spatialdata::geocoords::CoordSys* pCS = (const spatialdata::geocoords::CoordSys*)cs; assert(0 != pDB); assert(0 != pCS); assert(0 != numVals); diff --git a/libsrc/spatialdata/spatialdb/f77spatialdb.h b/libsrc/spatialdata/spatialdb/f77spatialdb.h index c8520ad3..aae65b27 100644 --- a/libsrc/spatialdata/spatialdb/f77spatialdb.h +++ b/libsrc/spatialdata/spatialdb/f77spatialdb.h @@ -13,8 +13,7 @@ // ---------------------------------------------------------------------- /** Fortran name mangling */ -#define spatialdb_query_f \ - FC_FUNC_(spatialdb_query_f, SPATIALDB_QUERY_F) +#define spatialdb_query_f FC_FUNC_(spatialdb_query_f, SPATIALDB_QUERY_F) /** Call SpatialDB:Query(). * * @param db Pointer to SpatialDB @@ -25,13 +24,12 @@ * @param cs Pointer to CS * @param ok Set to 0 on success, 1 on failure (i.e., values not set) */ -extern "C" -void spatialdb_query_f(void* db, - double* vals, - const int* numVals, - const double* coords, - const int* numDims, - const void* cs, - int* ok); +extern "C" void spatialdb_query_f(void* db, + double* vals, + const int* numVals, + const double* coords, + const int* numDims, + const void* cs, + int* ok); // End of file diff --git a/libsrc/spatialdata/spatialdb/spatialdbfwd.hh b/libsrc/spatialdata/spatialdb/spatialdbfwd.hh index 7c8a267f..2dc24d2d 100644 --- a/libsrc/spatialdata/spatialdb/spatialdbfwd.hh +++ b/libsrc/spatialdata/spatialdb/spatialdbfwd.hh @@ -33,7 +33,7 @@ namespace spatialdata { class TimeHistory; class TimeHistoryIO; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata // End of file diff --git a/libsrc/spatialdata/units/Parser.cc b/libsrc/spatialdata/units/Parser.cc index d3691331..baab327e 100644 --- a/libsrc/spatialdata/units/Parser.cc +++ b/libsrc/spatialdata/units/Parser.cc @@ -12,9 +12,9 @@ #include "Parser.hh" // implementation of class methods +#include // USES assert() #include // USES std::ostringstream #include // USES std::runtime_error -#include // USES assert() // ---------------------------------------------------------------------- // Default constructor diff --git a/libsrc/spatialdata/units/Parser.hh b/libsrc/spatialdata/units/Parser.hh index 0c0191c6..e68eadd3 100644 --- a/libsrc/spatialdata/units/Parser.hh +++ b/libsrc/spatialdata/units/Parser.hh @@ -17,8 +17,7 @@ class spatialdata::units::Parser { // class Parser friend class TestParser; // Unit testing -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /* MATT- I am not sure if we want just a single static method or we @@ -39,8 +38,7 @@ public: */ double parse(const char* units); -private: - + private: // PRIVATE MEMBERS //////////////////////////////////////////////////// PyObject* _parser; diff --git a/libsrc/spatialdata/units/unitsfwd.hh b/libsrc/spatialdata/units/unitsfwd.hh index 95a8d25e..3742d74a 100644 --- a/libsrc/spatialdata/units/unitsfwd.hh +++ b/libsrc/spatialdata/units/unitsfwd.hh @@ -12,7 +12,7 @@ namespace spatialdata { namespace units { class Parser; - } // units -} // spatialdata + } // namespace units +} // namespace spatialdata // End of file diff --git a/libsrc/spatialdata/utils/LineParser.cc b/libsrc/spatialdata/utils/LineParser.cc index e2d7ad06..1dca2082 100644 --- a/libsrc/spatialdata/utils/LineParser.cc +++ b/libsrc/spatialdata/utils/LineParser.cc @@ -29,7 +29,8 @@ spatialdata::utils::LineParser::LineParser(std::istream& sin, // ---------------------------------------------------------------------- spatialdata::utils::LineParser::~LineParser(void) { // destructor - delete[] _buffer;_buffer = 0; + delete[] _buffer; + _buffer = 0; } // destructor @@ -77,7 +78,7 @@ spatialdata::utils::LineParser::eatwhitespace(const bool flag) { // eatwhitespac void spatialdata::utils::LineParser::putback(const std::string& buffer) { // putback const size_t size = buffer.length(); - for (int i = size-1; i >= 0; --i) { + for (int i = size - 1; i >= 0; --i) { _in.putback(buffer[i]); } _in.clear(); diff --git a/libsrc/spatialdata/utils/LineParser.hh b/libsrc/spatialdata/utils/LineParser.hh index bdccf87a..fd8c67ce 100644 --- a/libsrc/spatialdata/utils/LineParser.hh +++ b/libsrc/spatialdata/utils/LineParser.hh @@ -11,13 +11,12 @@ #include "utilsfwd.hh" -#include // HASA std::string #include // USES std::istream +#include // HASA std::string class spatialdata::utils::LineParser { // LineParser // PUBLIC METHODS /////////////////////////////////////////////////////// -public: - + public: /** Constructor. * * @param sin Input stream. @@ -25,8 +24,8 @@ public: * @param bufsize Maximum size of line */ LineParser(std::istream& sin, - const char* delimiter="#", - const size_t bufsize=1024); + const char* delimiter = "#", + const size_t bufsize = 1024); // Destructor. ~LineParser(void); @@ -57,14 +56,12 @@ public: void putback(const std::string& buffer); // NOT IMPLEMENTED ////////////////////////////////////////////////////// -private: - + private: LineParser(const LineParser&); ///< Not implemented const LineParser& operator=(const LineParser&); ///< Not implemented // PRIVATE MEMBERS ////////////////////////////////////////////////////// -private: - + private: std::istream& _in; ///< Input stream. std::string _value; ///< Value for output. std::string _delimiter; ///< Comment delimiter. diff --git a/libsrc/spatialdata/utils/PointsStream.cc b/libsrc/spatialdata/utils/PointsStream.cc index 24d5e557..c51b1675 100644 --- a/libsrc/spatialdata/utils/PointsStream.cc +++ b/libsrc/spatialdata/utils/PointsStream.cc @@ -10,13 +10,13 @@ #include "PointsStream.hh" // Implementation of class methods -#include // USES std::cout, std::cin +#include // USES assert() #include // USES std::ifstream, std::ofstream #include // USES std::setprecision(), std::width() -#include // USES std::vector -#include // USES assert() +#include // USES std::cout, std::cin #include // USES std::ostringstream #include // USES std::runtime_error +#include // USES std::vector // ---------------------------------------------------------------------- // Default constructor @@ -24,12 +24,14 @@ spatialdata::utils::PointsStream::PointsStream(void) : _filename(""), _commentFlag("#"), _fieldWidth(14), - _precision(5) {} + _precision(5) { +} // ---------------------------------------------------------------------- // Default destructor -spatialdata::utils::PointsStream::~PointsStream(void) {} +spatialdata::utils::PointsStream::~PointsStream(void) { +} // ---------------------------------------------------------------------- @@ -50,13 +52,13 @@ spatialdata::utils::PointsStream::read(double** ppPoints, size_t numPts = 0; size_t numDims = 3; - const size_t initialCapacity = numDims*256; + const size_t initialCapacity = numDims * 256; std::vector buffer(initialCapacity); size_t capacity = initialCapacity; size_t index = 0; while (!sin->eof() && sin->good()) { - if (numPts*numDims >= capacity) { + if (numPts * numDims >= capacity) { capacity *= 2; buffer.resize(capacity); } // if @@ -110,10 +112,8 @@ spatialdata::utils::PointsStream::write(const double* pPoints, throw std::runtime_error(msg.str()); } // if - *pOut - << std::resetiosflags(std::ios::fixed) - << std::setiosflags(std::ios::scientific) - << std::setprecision(_precision); + *pOut << std::resetiosflags(std::ios::fixed) << std::setiosflags(std::ios::scientific) + << std::setprecision(_precision); for (size_t iPoint = 0, index = 0; iPoint < numPts; ++iPoint) { for (size_t iDim = 0; iDim < numDims; ++iDim) { diff --git a/libsrc/spatialdata/utils/PointsStream.hh b/libsrc/spatialdata/utils/PointsStream.hh index 4899236b..384ab1df 100644 --- a/libsrc/spatialdata/utils/PointsStream.hh +++ b/libsrc/spatialdata/utils/PointsStream.hh @@ -17,8 +17,7 @@ class spatialdata::utils::PointsStream { // class PointsStream friend class TestPointsStream; -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////////// /// Default constructor @@ -99,15 +98,13 @@ public: const size_t numPts, const size_t numDims) const; -private: - + private: // PRIVATE METHODS //////////////////////////////////////////////////// PointsStream(const PointsStream& p); ///< Not implemented const PointsStream& operator=(const PointsStream& p); ///< Not implemented -private: - + private: // PRIVATE MEMBERS //////////////////////////////////////////////////// std::string _filename; ///< Name of file for input/output diff --git a/libsrc/spatialdata/utils/PointsStream.icc b/libsrc/spatialdata/utils/PointsStream.icc index 331c7ecc..75e76d9f 100644 --- a/libsrc/spatialdata/utils/PointsStream.icc +++ b/libsrc/spatialdata/utils/PointsStream.icc @@ -10,64 +10,56 @@ #pragma once // Set name of file for input/output. -inline -void +inline void spatialdata::utils::PointsStream::setFilename(const char* filename) { _filename = filename; } // Get name of file for input/output. -inline -const char* +inline const char* spatialdata::utils::PointsStream::getFilename(void) const { return _filename.c_str(); } // Set comment flag. -inline -void +inline void spatialdata::utils::PointsStream::setCommentFlag(const char* flag) { _commentFlag = flag; } // Get comment flag. -inline -const char* +inline const char* spatialdata::utils::PointsStream::getCommentFlag(void) const { return _commentFlag.c_str(); } // Set field width. -inline -void +inline void spatialdata::utils::PointsStream::setFieldWidth(const size_t width) { _fieldWidth = width; } // Get field width. -inline -size_t +inline size_t spatialdata::utils::PointsStream::getFieldWidth(void) const { return _fieldWidth; } // Set precision. -inline -void +inline void spatialdata::utils::PointsStream::setPrecision(const size_t value) { _precision = value; } // Get precision. -inline -size_t +inline size_t spatialdata::utils::PointsStream::getPrecision(void) const { return _precision; } diff --git a/libsrc/spatialdata/utils/SpatialdataVersion.cc b/libsrc/spatialdata/utils/SpatialdataVersion.cc index 5fff5501..07b1f25a 100644 --- a/libsrc/spatialdata/utils/SpatialdataVersion.cc +++ b/libsrc/spatialdata/utils/SpatialdataVersion.cc @@ -18,7 +18,7 @@ #define STR_HELPER(x) #x #define STR(c) STR_HELPER(x) -#define VERSION_JOINER_HELPER(major, minor, patch, dot) STR_HELPER(major ## dot ## minor ## dot ## patch) +#define VERSION_JOINER_HELPER(major, minor, patch, dot) STR_HELPER(major##dot##minor##dot##patch) #define VERSION_JOINER(major, minor, patch) VERSION_JOINER_HELPER(major, minor, patch, .) const bool spatialdata::utils::SpatialdataVersion::_isRelease = int(SPATIALDATA_RELEASE_VERSION); @@ -32,12 +32,14 @@ const char* spatialdata::utils::SpatialdataVersion::_projVersion = // ---------------------------------------------------------------------- // Default constructor. -spatialdata::utils::SpatialdataVersion::SpatialdataVersion(void) {} +spatialdata::utils::SpatialdataVersion::SpatialdataVersion(void) { +} // ---------------------------------------------------------------------- // Default destrictor. -spatialdata::utils::SpatialdataVersion::~SpatialdataVersion(void) {} +spatialdata::utils::SpatialdataVersion::~SpatialdataVersion(void) { +} // ---------------------------------------------------------------------- diff --git a/libsrc/spatialdata/utils/SpatialdataVersion.hh b/libsrc/spatialdata/utils/SpatialdataVersion.hh index d105b5e5..228e86e7 100644 --- a/libsrc/spatialdata/utils/SpatialdataVersion.hh +++ b/libsrc/spatialdata/utils/SpatialdataVersion.hh @@ -16,8 +16,7 @@ class spatialdata::utils::SpatialdataVersion { // SpatialdataVersion friend class TestSpatialdataVersion; // unit testing // PUBLIC MEMBERS /////////////////////////////////////////////////////// -public: - + public: /// Default constructor. SpatialdataVersion(void); @@ -28,60 +27,51 @@ public: * * @returns True if source code comes from a release? */ - static - bool isRelease(void); + static bool isRelease(void); /** Get version number. * * @returns Version number. */ - static - const char* version(void); + static const char* version(void); /** Get GIT revision. * * @returns GIT revision. */ - static - const char* gitRevision(void); + static const char* gitRevision(void); /** Get GIT hash. * * @returns GIT hash. */ - static - const char* gitHash(void); + static const char* gitHash(void); /** Get date of GIT revision. * * @returns Date of GIT revision. */ - static - const char* gitDate(void); + static const char* gitDate(void); /** Get GIT branch. * * @returns GIT branch. */ - static - const char* gitBranch(void); + static const char* gitBranch(void); /** Get Proj.4 version number. * * @returns Version number. */ - static - const char* projVersion(void); + static const char* projVersion(void); // PRIVATE METHODS ////////////////////////////////////////////////////// -private: - + private: SpatialdataVersion(const SpatialdataVersion&); ///< Not implemented const SpatialdataVersion& operator=(const SpatialdataVersion&); ///< Not implemented // PRIVATE MEMBERS ////////////////////////////////////////////////////// -private: - + private: static const bool _isRelease; ///< Is source code from a release? static const char* _version; ///< Version number. static const char* _gitRevision; ///< GIT revision. diff --git a/libsrc/spatialdata/utils/utilsfwd.hh b/libsrc/spatialdata/utils/utilsfwd.hh index 00c9d19e..bbc5bfaf 100644 --- a/libsrc/spatialdata/utils/utilsfwd.hh +++ b/libsrc/spatialdata/utils/utilsfwd.hh @@ -15,7 +15,7 @@ namespace spatialdata { class PointsStream; class SpatialdataVersion; - } // utils -} // spatialdata + } // namespace utils +} // namespace spatialdata // End of file diff --git a/templates/spatialdb/UniformVelModel.cc b/templates/spatialdb/UniformVelModel.cc index 1761d695..c438c268 100644 --- a/templates/spatialdb/UniformVelModel.cc +++ b/templates/spatialdb/UniformVelModel.cc @@ -16,13 +16,13 @@ #include "UniformVelModel.hh" // Implementation of class methods #include "spatialdata/geocoords/CSGeoProj.hh" // USES CSGeoProj -#include "spatialdata/geocoords/Projector.hh" // USES Projector #include "spatialdata/geocoords/Converter.hh" // USES Converter +#include "spatialdata/geocoords/Projector.hh" // USES Projector -#include // USES strcasecmp() #include // USES assert() #include // USES std::ostringstream #include // USES std::runtime_error, std::logic_error +#include // USES strcasecmp() // ---------------------------------------------------------------------- // Constructor @@ -41,9 +41,11 @@ contrib::spatialdb::UniformVelModel::UniformVelModel(void) : // Destructor contrib::spatialdb::UniformVelModel::~UniformVelModel(void) { // destructor // Deallocate all data - delete _cs;_cs = 0; + delete _cs; + _cs = 0; - delete[] _queryVals;_queryVals = 0; + delete[] _queryVals; + _queryVals = 0; _querySize = 0; } // destructor @@ -57,20 +59,17 @@ contrib::spatialdb::UniformVelModel::open(void) { // open // Make sure the physical properties have been set. if (0 == _vs) { std::ostringstream msg; - msg << "S wave speed has not been set for spatial database " - << label() << "."; + msg << "S wave speed has not been set for spatial database " << label() << "."; throw std::runtime_error(msg.str()); } // if if (0 == _vp) { std::ostringstream msg; - msg << "P wave speed has not been set for spatial database " - << label() << "."; + msg << "P wave speed has not been set for spatial database " << label() << "."; throw std::runtime_error(msg.str()); } // if if (0 == _density) { std::ostringstream msg; - msg << "Density has not been set for spatial database " - << label() << "."; + msg << "Density has not been set for spatial database " << label() << "."; throw std::runtime_error(msg.str()); } // if @@ -84,7 +83,8 @@ contrib::spatialdb::UniformVelModel::open(void) { // open // Create a new coordinate system object (first deleting the old one // if it exists). - delete _cs;_cs = new spatialdata::geocoords::CSGeoProj; + delete _cs; + _cs = new spatialdata::geocoords::CSGeoProj; // Set parameters for the coordinate system. _cs->datumHoriz("NAD27"); @@ -104,7 +104,8 @@ contrib::spatialdb::UniformVelModel::close(void) { // close // Deallocate coordinate system object and set to null so that // subsequent calls to delete won't try to dellocate memory that has // already been deallocated. - delete _cs;_cs = 0; + delete _cs; + _cs = 0; } // close @@ -116,8 +117,7 @@ contrib::spatialdb::UniformVelModel::queryVals(const char* const* names, // Check function arguments. if (0 >= numVals) { std::ostringstream msg; - msg << "Number of values for query in spatial database " << label() - << "\n must be positive.\n"; + msg << "Number of values for query in spatial database " << label() << "\n must be positive.\n"; throw std::runtime_error(msg.str()); } // if assert(0 != names && 0 < numVals); @@ -127,7 +127,8 @@ contrib::spatialdb::UniformVelModel::queryVals(const char* const* names, // Allocate the array to store the flags for the queries (first // dellocating the array if necessary). - delete[] _queryVals;_queryVals = (numVals > 0) ? new int[numVals] : 0; + delete[] _queryVals; + _queryVals = (numVals > 0) ? new int[numVals] : 0; // Set the values in the array of values to include in queries. for (int iVal = 0; iVal < numVals; ++iVal) { @@ -177,14 +178,12 @@ contrib::spatialdb::UniformVelModel::query(double* vals, } // if if (numVals != _querySize) { std::ostringstream msg; - msg << "Number of values to be returned by spatial database " - << label() << "\n" - << "(" << _querySize << ") does not match size of array provided (" - << numVals << ").\n"; + msg << "Number of values to be returned by spatial database " << label() << "\n" + << "(" << _querySize << ") does not match size of array provided (" << numVals << ").\n"; throw std::runtime_error(msg.str()); } // if const int spaceDim = csQuery->spaceDim(); - if ((2 != spaceDim) && (3 != spaceDim) ) { + if ((2 != spaceDim) && (3 != spaceDim)) { std::ostringstream msg; msg << "Spatial dimension of coordinate system for query location must have " << "2 or 3 spatial dimensions while querying uniform velocity model " @@ -261,8 +260,7 @@ void contrib::spatialdb::UniformVelModel::density(const double value) { // density if (value <= 0.0) { std::ostringstream msg; - msg << "Densiy must be positive for uniform velocity model database " - << label() << ".\n"; + msg << "Densiy must be positive for uniform velocity model database " << label() << ".\n"; throw std::runtime_error(msg.str()); } // if diff --git a/templates/spatialdb/UniformVelModel.hh b/templates/spatialdb/UniformVelModel.hh index a1964229..de555457 100644 --- a/templates/spatialdb/UniformVelModel.hh +++ b/templates/spatialdb/UniformVelModel.hh @@ -16,19 +16,17 @@ namespace contrib { namespace spatialdb { class UniformVelModel; - } // spatialdb -} // contrib + } // namespace spatialdb +} // namespace contrib -class contrib::spatialdb::UniformVelModel : - public spatialdata::spatialdb::SpatialDB // inheritance from SpatialDB +class contrib::spatialdb::UniformVelModel : public spatialdata::spatialdb::SpatialDB // inheritance from SpatialDB { // UniformVelModel // Allow the unit testing TestUniformVelModel object access to // private class methods and members. friend class TestUniformVelModel; // PUBLIC METHODS /////////////////////////////////////////////////////// -public: - + public: /// Constructor UniformVelModel(void); @@ -36,8 +34,7 @@ public: ~UniformVelModel(void); // PUBLIC METHODS /////////////////////////////////////////////////////// -public: - + public: // Functions required to satisfy the SpatialDB interface. /// Open the database and prepare for querying. @@ -80,8 +77,7 @@ public: const spatialdata::geocoords::CoordSys* csQuery); // PUBLIC METHODS /////////////////////////////////////////////////////// -public: - + public: // Functions specific to this type of spatial database. /** Set the P wave speed. @@ -103,19 +99,17 @@ public: void density(const double value); // PRIVATE ENUMS //////////////////////////////////////////////////////// -private: - + private: // Indices of values in database (used in queryVals to indicate // which values to return in a query). enum QueryValsEnum { - QUERY_VP=0, // vp - QUERY_VS=1, // vs - QUERY_DENSITY=2, // density + QUERY_VP = 0, // vp + QUERY_VS = 1, // vs + QUERY_DENSITY = 2, // density }; // ValsEnum // PRIVATE MEMBERS ////////////////////////////////////////////////////// -private: - + private: // Physical property information (hardwired in this case). Replace // with data structures for holding the physical property // information. @@ -134,8 +128,7 @@ private: int _querySize; ///< Number of values requested to be returned in queries. // NOT IMPLEMENTED ////////////////////////////////////////////////////// -private: - + private: UniformVelModel(const UniformVelModel&); ///< Not implemented const UniformVelModel& operator=(const UniformVelModel&); ///< Not implemented diff --git a/tests/libtests/geocoords/TestCSCart.cc b/tests/libtests/geocoords/TestCSCart.cc index 1dbb638d..4bf676ed 100644 --- a/tests/libtests/geocoords/TestCSCart.cc +++ b/tests/libtests/geocoords/TestCSCart.cc @@ -21,35 +21,34 @@ namespace spatialdata { namespace geocoords { class TestCSCart; - } // geocoords -} // spatialdata + } // namespace geocoords +} // namespace spatialdata class spatialdata::geocoords::TestCSCart { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: // Test constructor - static - void testConstructor(void); + static void testConstructor(void); // Test accessors. - static - void testAccessors(void); + static void testAccessors(void); // Test pickle() & unpickle() - static - void testPickle(void); + static void testPickle(void); }; // class TestCSCart // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestCSCart::testConstructor", "[TestCSCart]") { +TEST_CASE("TestCSCart::testConstructor", + "[TestCSCart]") { spatialdata::geocoords::TestCSCart::testConstructor(); } -TEST_CASE("TestCSCart::testAccessors", "[TestCSCart]") { +TEST_CASE("TestCSCart::testAccessors", + "[TestCSCart]") { spatialdata::geocoords::TestCSCart::testAccessors(); } -TEST_CASE("TestCSCart::testPickle", "[TestCSCart]") { +TEST_CASE("TestCSCart::testPickle", + "[TestCSCart]") { spatialdata::geocoords::TestCSCart::testPickle(); } @@ -62,9 +61,11 @@ spatialdata::geocoords::TestCSCart::testConstructor(void) { CHECK(CoordSys::CARTESIAN == cs.getCSType()); cs.setSpaceDim(2); - CoordSys* csClone = cs.clone();assert(csClone); + CoordSys* csClone = cs.clone(); + assert(csClone); CHECK(cs.getSpaceDim() == csClone->getSpaceDim()); - delete csClone;csClone = NULL; + delete csClone; + csClone = NULL; } // testConstructor diff --git a/tests/libtests/geocoords/TestCSGeo.cc b/tests/libtests/geocoords/TestCSGeo.cc index 1cb4bced..7c1c9b76 100644 --- a/tests/libtests/geocoords/TestCSGeo.cc +++ b/tests/libtests/geocoords/TestCSGeo.cc @@ -17,49 +17,48 @@ #include // USES M_PI -#include // USES strcasecmp() #include // USES std::stringstream +#include // USES strcasecmp() // ------------------------------------------------------------------------------------------------ namespace spatialdata { namespace geocoords { class TestCSGeo; - } // geocoords -} // spatialdata + } // namespace geocoords +} // namespace spatialdata class spatialdata::geocoords::TestCSGeo { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Test constructor - static - void testConstructor(void); + static void testConstructor(void); /// Test accessors. - static - void testAccessors(void); + static void testAccessors(void); /// Test computeSurfaceNormal(). - static - void testComputeSurfaceNormal(void); + static void testComputeSurfaceNormal(void); /// Test pickle() & unpickle() - static - void testPickle(void); + static void testPickle(void); }; // class TestCSGeo // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestCSGeo::testConstructor", "[TestCSGeo]") { +TEST_CASE("TestCSGeo::testConstructor", + "[TestCSGeo]") { spatialdata::geocoords::TestCSGeo::testConstructor(); } -TEST_CASE("TestCSGeo::testAccessors", "[TestCSGeo]") { +TEST_CASE("TestCSGeo::testAccessors", + "[TestCSGeo]") { spatialdata::geocoords::TestCSGeo::testAccessors(); } -TEST_CASE("TestCSGeo::testComputeSurfaceNormal", "[TestCSGeo]") { +TEST_CASE("TestCSGeo::testComputeSurfaceNormal", + "[TestCSGeo]") { spatialdata::geocoords::TestCSGeo::testComputeSurfaceNormal(); } -TEST_CASE("TestCSGeo::testPickle", "[TestCSGeo]") { +TEST_CASE("TestCSGeo::testPickle", + "[TestCSGeo]") { spatialdata::geocoords::TestCSGeo::testPickle(); } @@ -79,10 +78,12 @@ spatialdata::geocoords::TestCSGeo::testConstructor(void) { const size_t cloneSpaceDim(2); cs.setSpaceDim(2); - CoordSys* csClone = cs.clone();assert(csClone); + CoordSys* csClone = cs.clone(); + assert(csClone); CHECK(CoordSys::GEOGRAPHIC == csClone->getCSType()); CHECK(cloneSpaceDim == csClone->getSpaceDim()); - delete csClone;csClone = NULL; + delete csClone; + csClone = NULL; } // testConstructor @@ -114,10 +115,18 @@ spatialdata::geocoords::TestCSGeo::testComputeSurfaceNormal(void) { const size_t numDims = 3; const size_t size = numLocs * numDims; const double coords[size] = { - 28.0, 23.0, 3.4, - 42.0, 34.0, 3.5, - -12.0, 65.7, 12.6, - 64.3, -163.0, -1.5, + 28.0, + 23.0, + 3.4, + 42.0, + 34.0, + 3.5, + -12.0, + 65.7, + 12.6, + 64.3, + -163.0, + -1.5, }; double* dirs = new double[size]; cs.setSpaceDim(numDims); @@ -127,7 +136,8 @@ spatialdata::geocoords::TestCSGeo::testComputeSurfaceNormal(void) { CHECK(0.0 == dirs[i++]); CHECK(1.0 == dirs[i++]); } // for - delete[] dirs;dirs = 0; + delete[] dirs; + dirs = 0; } // WGS84 { // UTM zone 10 @@ -136,10 +146,18 @@ spatialdata::geocoords::TestCSGeo::testComputeSurfaceNormal(void) { const size_t numDims = 3; const size_t size = numLocs * numDims; const double coords[size] = { - 570000.0, 4150000.0, -1.0, - 400000.0, 4000000.0, 20.0, - 300000.0, 4250000.0, 30.0, - 550000.0, 4100000.0, 40.0, + 570000.0, + 4150000.0, + -1.0, + 400000.0, + 4000000.0, + 20.0, + 300000.0, + 4250000.0, + 30.0, + 550000.0, + 4100000.0, + 40.0, }; double* dirs = new double[size]; cs.setSpaceDim(numDims); @@ -149,7 +167,8 @@ spatialdata::geocoords::TestCSGeo::testComputeSurfaceNormal(void) { CHECK(0.0 == dirs[i++]); CHECK(1.0 == dirs[i++]); } // for - delete[] dirs;dirs = 0; + delete[] dirs; + dirs = 0; } // UTM zone 10 { // Transverse mercator projection @@ -158,10 +177,18 @@ spatialdata::geocoords::TestCSGeo::testComputeSurfaceNormal(void) { const size_t numDims = 3; const size_t size = numLocs * numDims; const double coords[size] = { - 57.0, 41.0, -1.0, - 40.0, 40.0, 2.0, - 30.0, 42.0, 3.0, - 55.0, 41.0, 4.0, + 57.0, + 41.0, + -1.0, + 40.0, + 40.0, + 2.0, + 30.0, + 42.0, + 3.0, + 55.0, + 41.0, + 4.0, }; double* dirs = new double[size]; cs.setSpaceDim(numDims); @@ -171,7 +198,8 @@ spatialdata::geocoords::TestCSGeo::testComputeSurfaceNormal(void) { CHECK(0.0 == dirs[i++]); CHECK(1.0 == dirs[i++]); } // for - delete[] dirs;dirs = 0; + delete[] dirs; + dirs = 0; } // Transverse mercator projection { // Geocentric ECEF @@ -181,18 +209,38 @@ spatialdata::geocoords::TestCSGeo::testComputeSurfaceNormal(void) { const size_t numDims = 3; const size_t size = numLocs * numDims; const double coords[size] = { - 0.0, 0.0, 6356752.31424518, // (lon=0.0, lat=90.0) - 6378137.00, 0.0, 0.0, // (lon=0.0, lat=0.0) - 0.0, -6378137.00, 0.0, // (lon=-90.0, lat=0.0) - -2684785.48, -4296554.90, 3861564.10, // (lon=-122.0, lat=37.5) - -2680581.35, -4289826.89, 3855476.48, // (lon=-122.0, lat=37.5, elev=-10km) + 0.0, + 0.0, + 6356752.31424518, // (lon=0.0, lat=90.0) + 6378137.00, + 0.0, + 0.0, // (lon=0.0, lat=0.0) + 0.0, + -6378137.00, + 0.0, // (lon=-90.0, lat=0.0) + -2684785.48, + -4296554.90, + 3861564.10, // (lon=-122.0, lat=37.5) + -2680581.35, + -4289826.89, + 3855476.48, // (lon=-122.0, lat=37.5, elev=-10km) }; const double dirsE[size] = { - 0.0, 0.0, 1.0, - 1.0, 0.0, 0.0, - 0.0, -1.0, 0.0, - -0.4204132183640867, -0.6728017898133232, 0.6087614290087207, - -0.4204132183640867, -0.6728017898133232, 0.6087614290087207, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0, + 0.0, + -1.0, + 0.0, + -0.4204132183640867, + -0.6728017898133232, + 0.6087614290087207, + -0.4204132183640867, + -0.6728017898133232, + 0.6087614290087207, }; double* dirs = new double[size]; cs.computeSurfaceNormal(dirs, coords, numLocs, numDims); @@ -200,12 +248,13 @@ spatialdata::geocoords::TestCSGeo::testComputeSurfaceNormal(void) { const double tolerance = 1.0e-6; for (size_t i = 0; i < size; ++i) { if (fabs(dirsE[i]) > tolerance) { - CHECK_THAT(dirs[i]/dirsE[i], Catch::Matchers::WithinAbs(1.0, tolerance)); + CHECK_THAT(dirs[i] / dirsE[i], Catch::Matchers::WithinAbs(1.0, tolerance)); } else { CHECK_THAT(dirs[i], Catch::Matchers::WithinAbs(dirsE[i], tolerance)); } // if/else } - delete[] dirs;dirs = 0; + delete[] dirs; + dirs = 0; } // Geocentric ECEF } // testComputeSurfaceNormal diff --git a/tests/libtests/geocoords/TestCSGeoLocal.cc b/tests/libtests/geocoords/TestCSGeoLocal.cc index a4c1da78..7218c4d4 100644 --- a/tests/libtests/geocoords/TestCSGeoLocal.cc +++ b/tests/libtests/geocoords/TestCSGeoLocal.cc @@ -17,49 +17,48 @@ #include // USES M_PI -#include // USES strcasecmp() #include // USES std::stringstream +#include // USES strcasecmp() // ------------------------------------------------------------------------------------------------ namespace spatialdata { namespace geocoords { class TestCSGeoLocal; - } // geocoords -} // spatialdata + } // namespace geocoords +} // namespace spatialdata class spatialdata::geocoords::TestCSGeoLocal { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Test constructor - static - void testConstructor(void); + static void testConstructor(void); /// Test accessors. - static - void testAccessors(void); + static void testAccessors(void); /// Test computeSurfaceNormal(). - static - void testComputeSurfaceNormal(void); + static void testComputeSurfaceNormal(void); /// Test pickle() & unpickle() - static - void testPickle(void); + static void testPickle(void); }; // class TestCSGeoLocal // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestCSGeoLocal::testConstructor", "[TestCSGeoLocal]") { +TEST_CASE("TestCSGeoLocal::testConstructor", + "[TestCSGeoLocal]") { spatialdata::geocoords::TestCSGeoLocal::testConstructor(); } -TEST_CASE("TestCSGeoLocal::testAccessors", "[TestCSGeoLocal]") { +TEST_CASE("TestCSGeoLocal::testAccessors", + "[TestCSGeoLocal]") { spatialdata::geocoords::TestCSGeoLocal::testAccessors(); } -TEST_CASE("TestCSGeoLocal::testComputeSurfaceNormal", "[TestCSGeoLocal]") { +TEST_CASE("TestCSGeoLocal::testComputeSurfaceNormal", + "[TestCSGeoLocal]") { spatialdata::geocoords::TestCSGeoLocal::testComputeSurfaceNormal(); } -TEST_CASE("TestCSGeoLocal::testPickle", "[TestCSGeoLocal]") { +TEST_CASE("TestCSGeoLocal::testPickle", + "[TestCSGeoLocal]") { spatialdata::geocoords::TestCSGeoLocal::testPickle(); } @@ -91,7 +90,8 @@ spatialdata::geocoords::TestCSGeoLocal::testConstructor(void) { cs.setSpaceDim(2); cs.setLocal(cloneOriginX, cloneOriginY, cloneYAzimuth); - CoordSys* csClone = cs.clone();assert(csClone); + CoordSys* csClone = cs.clone(); + assert(csClone); CHECK(CoordSys::GEOGRAPHIC == csClone->getCSType()); CHECK(cloneSpaceDim == csClone->getSpaceDim()); double originX, originY, yAzimuth; @@ -101,7 +101,8 @@ spatialdata::geocoords::TestCSGeoLocal::testConstructor(void) { CHECK_THAT(originY, Catch::Matchers::WithinAbs(cloneOriginY, tolerance)); CHECK_THAT(yAzimuth, Catch::Matchers::WithinAbs(cloneYAzimuth, tolerance)); - delete csClone;csClone = NULL; + delete csClone; + csClone = NULL; } // testConstructor @@ -147,10 +148,18 @@ spatialdata::geocoords::TestCSGeoLocal::testComputeSurfaceNormal(void) { const size_t numDims = 3; const size_t size = numLocs * numDims; const double coords[size] = { - 28.0, 23.0, 3.4, - 42.0, 34.0, 3.5, - -12.0, 65.7, 12.6, - 64.3, -163.0, -1.5, + 28.0, + 23.0, + 3.4, + 42.0, + 34.0, + 3.5, + -12.0, + 65.7, + 12.6, + 64.3, + -163.0, + -1.5, }; double* dirs = new double[size]; cs.setSpaceDim(numDims); @@ -160,7 +169,8 @@ spatialdata::geocoords::TestCSGeoLocal::testComputeSurfaceNormal(void) { CHECK(0.0 == dirs[i++]); CHECK(1.0 == dirs[i++]); } // for - delete[] dirs;dirs = 0; + delete[] dirs; + dirs = 0; } // WGS84 { // UTM zone 10 @@ -170,10 +180,18 @@ spatialdata::geocoords::TestCSGeoLocal::testComputeSurfaceNormal(void) { const size_t numDims = 3; const size_t size = numLocs * numDims; const double coords[size] = { - 570000.0, 4150000.0, -1.0, - 400000.0, 4000000.0, 20.0, - 300000.0, 4250000.0, 30.0, - 550000.0, 4100000.0, 40.0, + 570000.0, + 4150000.0, + -1.0, + 400000.0, + 4000000.0, + 20.0, + 300000.0, + 4250000.0, + 30.0, + 550000.0, + 4100000.0, + 40.0, }; double* dirs = new double[size]; cs.setSpaceDim(numDims); @@ -183,7 +201,8 @@ spatialdata::geocoords::TestCSGeoLocal::testComputeSurfaceNormal(void) { CHECK(0.0 == dirs[i++]); CHECK(1.0 == dirs[i++]); } // for - delete[] dirs;dirs = 0; + delete[] dirs; + dirs = 0; } // UTM zone 10 { // Geocentric ECEF @@ -194,18 +213,38 @@ spatialdata::geocoords::TestCSGeoLocal::testComputeSurfaceNormal(void) { const size_t numDims = 3; const size_t size = numLocs * numDims; const double coords[size] = { - 0.0, 0.0, 6356752.31424518, // (lon=0.0, lat=90.0) - 6378137.00, 0.0, 0.0, // (lon=0.0, lat=0.0) - 0.0, -6378137.00, 0.0, // (lon=-90.0, lat=0.0) - -2684785.48, -4296554.90, 3861564.10, // (lon=-122.0, lat=37.5) - -2680581.35, -4289826.89, 3855476.48, // (lon=-122.0, lat=37.5, elev=-10km) + 0.0, + 0.0, + 6356752.31424518, // (lon=0.0, lat=90.0) + 6378137.00, + 0.0, + 0.0, // (lon=0.0, lat=0.0) + 0.0, + -6378137.00, + 0.0, // (lon=-90.0, lat=0.0) + -2684785.48, + -4296554.90, + 3861564.10, // (lon=-122.0, lat=37.5) + -2680581.35, + -4289826.89, + 3855476.48, // (lon=-122.0, lat=37.5, elev=-10km) }; const double dirsE[size] = { - 0.0, 0.0, 1.0, - 1.0, 0.0, 0.0, - 0.0, -1.0, 0.0, - -0.4204132183640867, -0.6728017898133232, 0.6087614290087207, - -0.4204132183640867, -0.6728017898133232, 0.6087614290087207, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0, + 0.0, + -1.0, + 0.0, + -0.4204132183640867, + -0.6728017898133232, + 0.6087614290087207, + -0.4204132183640867, + -0.6728017898133232, + 0.6087614290087207, }; double* dirs = new double[size]; cs.computeSurfaceNormal(dirs, coords, numLocs, numDims); @@ -213,12 +252,13 @@ spatialdata::geocoords::TestCSGeoLocal::testComputeSurfaceNormal(void) { const double tolerance = 1.0e-6; for (size_t i = 0; i < size; ++i) { if (fabs(dirsE[i]) > tolerance) { - CHECK_THAT(dirs[i]/dirsE[i], Catch::Matchers::WithinAbs(1.0, tolerance)); + CHECK_THAT(dirs[i] / dirsE[i], Catch::Matchers::WithinAbs(1.0, tolerance)); } else { CHECK_THAT(dirs[i], Catch::Matchers::WithinAbs(dirsE[i], tolerance)); } // if/else } - delete[] dirs;dirs = 0; + delete[] dirs; + dirs = 0; } // Geocentric ECEF } // testComputeSurfaceNormal diff --git a/tests/libtests/geocoords/TestCSPicklerAscii.cc b/tests/libtests/geocoords/TestCSPicklerAscii.cc index 0d11e945..cfa10fd4 100644 --- a/tests/libtests/geocoords/TestCSPicklerAscii.cc +++ b/tests/libtests/geocoords/TestCSPicklerAscii.cc @@ -26,35 +26,34 @@ namespace spatialdata { namespace geocoords { class TestCSPicklerAscii; - } // geocoords -} // spatialdata + } // namespace geocoords +} // namespace spatialdata class spatialdata::geocoords::TestCSPicklerAscii { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Test pickle() & unpickle() for CSCart - static - void testPickleCSCart(void); + static void testPickleCSCart(void); /// Test pickle() & unpickle() for CSGeo - static - void testPickleCSGeo(void); + static void testPickleCSGeo(void); /// Test pickle() & unpickle() for CSGeoLocal - static - void testPickleCSGeoLocal(void); + static void testPickleCSGeoLocal(void); }; // class TestCSPickleAscii // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestCSPicklerAscii::testPickleCSCart", "[TestCSPicklerAscii]") { +TEST_CASE("TestCSPicklerAscii::testPickleCSCart", + "[TestCSPicklerAscii]") { spatialdata::geocoords::TestCSPicklerAscii::testPickleCSCart(); } -TEST_CASE("TestCSPicklerAscii::testPickleCSGeo", "[TestCSPicklerAscii]") { +TEST_CASE("TestCSPicklerAscii::testPickleCSGeo", + "[TestCSPicklerAscii]") { spatialdata::geocoords::TestCSPicklerAscii::testPickleCSGeo(); } -TEST_CASE("TestCSPicklerAscii::testPickleCSGeoLocal", "[TestCSPicklerAscii]") { +TEST_CASE("TestCSPicklerAscii::testPickleCSGeoLocal", + "[TestCSPicklerAscii]") { spatialdata::geocoords::TestCSPicklerAscii::testPickleCSGeoLocal(); } @@ -73,7 +72,8 @@ spatialdata::geocoords::TestCSPicklerAscii::testPickleCSCart(void) { CHECK(dynamic_cast(csP)); - delete csP;csP = NULL; + delete csP; + csP = NULL; } // testPickleCSCart @@ -92,7 +92,8 @@ spatialdata::geocoords::TestCSPicklerAscii::testPickleCSGeo(void) { CHECK(dynamic_cast(csP)); - delete csP;csP = NULL; + delete csP; + csP = NULL; } // testPickleCSGeo @@ -111,7 +112,8 @@ spatialdata::geocoords::TestCSPicklerAscii::testPickleCSGeoLocal(void) { CHECK(dynamic_cast(csP)); - delete csP;csP = NULL; + delete csP; + csP = NULL; } // testPickleCSGeoLocal diff --git a/tests/libtests/geocoords/TestConverter.cc b/tests/libtests/geocoords/TestConverter.cc index f99b27b4..3a99a1a3 100644 --- a/tests/libtests/geocoords/TestConverter.cc +++ b/tests/libtests/geocoords/TestConverter.cc @@ -31,7 +31,8 @@ spatialdata::geocoords::TestConverter::TestConverter(TestConverter_Data* data) : // --------------------------------------------------------------------------------------------------------------------- // Destructor. spatialdata::geocoords::TestConverter::~TestConverter(void) { - delete _data;_data = NULL; + delete _data; + _data = NULL; } // destructor @@ -59,18 +60,19 @@ spatialdata::geocoords::TestConverter::testConvert(void) { assert(_data->coordsSrc); assert(_data->coordsDest); } // if - std::memcpy(coords, _data->coordsSrc, bufferSize*sizeof(double)); + std::memcpy(coords, _data->coordsSrc, bufferSize * sizeof(double)); Converter converter; converter.convert(coords, numPoints, spaceDim, _data->csDest, _data->csSrc); const double tolerance = 1.0e-6; for (size_t i = 0; i < bufferSize; ++i) { - const double toleranceV = std::max(fabs(tolerance*_data->coordsDest[i]), tolerance); + const double toleranceV = std::max(fabs(tolerance * _data->coordsDest[i]), tolerance); CHECK_THAT(coords[i], Catch::Matchers::WithinAbs(_data->coordsDest[i], toleranceV)); } // for - delete[] coords;coords = NULL; + delete[] coords; + coords = NULL; } // testConvert @@ -82,10 +84,12 @@ spatialdata::geocoords::TestConverter_Data::TestConverter_Data(void) : coordsSrc(NULL), coordsDest(NULL), csSrc(NULL), - csDest(NULL) {} + csDest(NULL) { +} // --------------------------------------------------------------------------------------------------------------------- // Destructor -spatialdata::geocoords::TestConverter_Data::~TestConverter_Data(void) {} // destructor +spatialdata::geocoords::TestConverter_Data::~TestConverter_Data(void) { +} // destructor diff --git a/tests/libtests/geocoords/TestConverter.hh b/tests/libtests/geocoords/TestConverter.hh index 26e588b2..33a8f918 100644 --- a/tests/libtests/geocoords/TestConverter.hh +++ b/tests/libtests/geocoords/TestConverter.hh @@ -17,14 +17,13 @@ namespace spatialdata { namespace geocoords { class TestConverter; class TestConverter_Data; - } // geocoords -} // spatialdata + } // namespace geocoords +} // namespace spatialdata // ------------------------------------------------------------------------------------------------ class spatialdata::geocoords::TestConverter { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Constructor. TestConverter(TestConverter_Data* data); @@ -32,15 +31,13 @@ public: ~TestConverter(void); /// Test constructor. - static - void testConstructor(void); + static void testConstructor(void); /// Test convert(). void testConvert(void); // PROTECTED MEMBERS ////////////////////////////////////////////////////////////////////////// -protected: - + protected: TestConverter_Data* _data; ///< Data for testing. }; // class TestConverter @@ -48,8 +45,7 @@ protected: // ------------------------------------------------------------------------------------------------ class spatialdata::geocoords::TestConverter_Data { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Constructor TestConverter_Data(void); @@ -57,8 +53,7 @@ public: ~TestConverter_Data(void); // PUBLIC MEMBERS ////////////////////////////////////////////////////////// -public: - + public: size_t numPoints; ///< Number of points. size_t spaceDim; ///< Dimension of coordinate system. const double* coordsSrc; ///< Coordinates of points in source coordinate system. diff --git a/tests/libtests/geocoords/TestConverter_Cases.cc b/tests/libtests/geocoords/TestConverter_Cases.cc index 3032fe14..e9dd049d 100644 --- a/tests/libtests/geocoords/TestConverter_Cases.cc +++ b/tests/libtests/geocoords/TestConverter_Cases.cc @@ -21,61 +21,61 @@ namespace spatialdata { namespace geocoords { class TestConverter_Cases; - } // geocoords -} // spatialdata + } // namespace geocoords +} // namespace spatialdata class spatialdata::geocoords::TestConverter_Cases { -public: - + public: // Factory methods - static - TestConverter_Data* NAD27ToWGS84(void); - - static - TestConverter_Data* WGS84ToNAD27(void); + static TestConverter_Data* NAD27ToWGS84(void); - static - TestConverter_Data* WGS84ToECEF(void); + static TestConverter_Data* WGS84ToNAD27(void); - static - TestConverter_Data* WGS84ToUTMLocal(void); + static TestConverter_Data* WGS84ToECEF(void); - static - TestConverter_Data* XYZToXYZ(void); + static TestConverter_Data* WGS84ToUTMLocal(void); - static - TestConverter_Data* Units(void); + static TestConverter_Data* XYZToXYZ(void); + static TestConverter_Data* Units(void); }; // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestConverter::testConstructor", "[TestConverter]") { +TEST_CASE("TestConverter::testConstructor", + "[TestConverter]") { spatialdata::geocoords::TestConverter::testConstructor(); } -TEST_CASE("TestConverter::NAD27ToWGS84", "[TestConverter]") { +TEST_CASE("TestConverter::NAD27ToWGS84", + "[TestConverter]") { spatialdata::geocoords::TestConverter(spatialdata::geocoords::TestConverter_Cases::NAD27ToWGS84()).testConvert(); } -TEST_CASE("TestConverter::WGS84ToNAD27", "[TestConverter]") { +TEST_CASE("TestConverter::WGS84ToNAD27", + "[TestConverter]") { spatialdata::geocoords::TestConverter(spatialdata::geocoords::TestConverter_Cases::WGS84ToNAD27()).testConvert(); } -TEST_CASE("TestConverter::WGS84ToUTMLocal", "[TestConverter]") { +TEST_CASE("TestConverter::WGS84ToUTMLocal", + "[TestConverter]") { spatialdata::geocoords::TestConverter(spatialdata::geocoords::TestConverter_Cases::WGS84ToUTMLocal()).testConvert(); } -TEST_CASE("TestConverter::WGS84ToECEF", "[TestConverter]") { +TEST_CASE("TestConverter::WGS84ToECEF", + "[TestConverter]") { spatialdata::geocoords::TestConverter(spatialdata::geocoords::TestConverter_Cases::WGS84ToECEF()).testConvert(); } -TEST_CASE("TestConverter::XYZToXYZ", "[TestConverter]") { +TEST_CASE("TestConverter::XYZToXYZ", + "[TestConverter]") { spatialdata::geocoords::TestConverter(spatialdata::geocoords::TestConverter_Cases::XYZToXYZ()).testConvert(); } -TEST_CASE("TestConverter::Units", "[TestConverter]") { +TEST_CASE("TestConverter::Units", + "[TestConverter]") { spatialdata::geocoords::TestConverter(spatialdata::geocoords::TestConverter_Cases::Units()).testConvert(); } // ------------------------------------------------------------------------------------------------ spatialdata::geocoords::TestConverter_Data* spatialdata::geocoords::TestConverter_Cases::NAD27ToWGS84(void) { - TestConverter_Data* data = new TestConverter_Data();assert(data); + TestConverter_Data* data = new TestConverter_Data(); + assert(data); data->numPoints = 6; data->spaceDim = 3; @@ -90,23 +90,47 @@ spatialdata::geocoords::TestConverter_Cases::NAD27ToWGS84(void) { csWGS84.setSpaceDim(data->spaceDim); data->csDest = &csWGS84; - static const double coordsLonLatNAD27[6*3] = { - -1.150000000000e+02, 3.900000000000e+01, 1.200000000000e+01, - -1.203425320000e+02, 4.323423000000e+01, 1.010000000000e+01, - -1.213425320000e+02, 4.523423000000e+01, 3.600000000000e+00, - -1.153425320000e+02, 3.623423000000e+01, 7.200000000000e+00, - -1.103425320000e+02, 3.923423000000e+01, 1.233000000000e+02, - -1.073425320000e+02, 3.323423000000e+01, 3.460000000000e+01, + static const double coordsLonLatNAD27[6 * 3] = { + -1.150000000000e+02, + 3.900000000000e+01, + 1.200000000000e+01, + -1.203425320000e+02, + 4.323423000000e+01, + 1.010000000000e+01, + -1.213425320000e+02, + 4.523423000000e+01, + 3.600000000000e+00, + -1.153425320000e+02, + 3.623423000000e+01, + 7.200000000000e+00, + -1.103425320000e+02, + 3.923423000000e+01, + 1.233000000000e+02, + -1.073425320000e+02, + 3.323423000000e+01, + 3.460000000000e+01, }; data->coordsSrc = coordsLonLatNAD27; - static const double coordsLonLatWGS84[6*3] = { - -1.150008507633e+02, 3.899994227695e+01, 1.200000018017e+01, - -1.203436181122e+02, 4.323409740913e+01, 1.010000021373e+01, - -1.213437106276e+02, 4.523406963911e+01, 3.600000226768e+00, - -1.153433730158e+02, 3.623419630177e+01, 7.200000158508e+00, - -1.103432442395e+02, 3.923419970866e+01, 1.233000001811e+02, - -1.073431211987e+02, 3.323430190358e+01, 3.460000013495e+01, + static const double coordsLonLatWGS84[6 * 3] = { + -1.150008507633e+02, + 3.899994227695e+01, + 1.200000018017e+01, + -1.203436181122e+02, + 4.323409740913e+01, + 1.010000021373e+01, + -1.213437106276e+02, + 4.523406963911e+01, + 3.600000226768e+00, + -1.153433730158e+02, + 3.623419630177e+01, + 7.200000158508e+00, + -1.103432442395e+02, + 3.923419970866e+01, + 1.233000001811e+02, + -1.073431211987e+02, + 3.323430190358e+01, + 3.460000013495e+01, }; data->coordsDest = coordsLonLatWGS84; @@ -117,7 +141,8 @@ spatialdata::geocoords::TestConverter_Cases::NAD27ToWGS84(void) { // ------------------------------------------------------------------------------------------------ spatialdata::geocoords::TestConverter_Data* spatialdata::geocoords::TestConverter_Cases::WGS84ToNAD27(void) { - TestConverter_Data* data = new TestConverter_Data();assert(data); + TestConverter_Data* data = new TestConverter_Data(); + assert(data); data->numPoints = 6; data->spaceDim = 3; @@ -132,23 +157,47 @@ spatialdata::geocoords::TestConverter_Cases::WGS84ToNAD27(void) { csNAD27.setSpaceDim(data->spaceDim); data->csDest = &csNAD27; - static const double coordsLonLatWGS84[6*3] = { - -1.150008507633e+02, 3.899994227695e+01, 1.200000018017e+01, - -1.203436181122e+02, 4.323409740913e+01, 1.010000021373e+01, - -1.213437106276e+02, 4.523406963911e+01, 3.600000226768e+00, - -1.153433730158e+02, 3.623419630177e+01, 7.200000158508e+00, - -1.103432442395e+02, 3.923419970866e+01, 1.233000001811e+02, - -1.073431211987e+02, 3.323430190358e+01, 3.460000013495e+01, + static const double coordsLonLatWGS84[6 * 3] = { + -1.150008507633e+02, + 3.899994227695e+01, + 1.200000018017e+01, + -1.203436181122e+02, + 4.323409740913e+01, + 1.010000021373e+01, + -1.213437106276e+02, + 4.523406963911e+01, + 3.600000226768e+00, + -1.153433730158e+02, + 3.623419630177e+01, + 7.200000158508e+00, + -1.103432442395e+02, + 3.923419970866e+01, + 1.233000001811e+02, + -1.073431211987e+02, + 3.323430190358e+01, + 3.460000013495e+01, }; data->coordsSrc = coordsLonLatWGS84; - static const double coordsLatLonNAD27[6*3] = { - 3.900000000000e+01, -1.150000000000e+02, 1.200000000000e+01, - 4.323423000000e+01, -1.203425320000e+02, 1.010000000000e+01, - 4.523423000000e+01, -1.213425320000e+02, 3.600000000000e+00, - 3.623423000000e+01, -1.153425320000e+02, 7.200000000000e+00, - 3.923423000000e+01, -1.103425320000e+02, 1.233000000000e+02, - 3.323423000000e+01, -1.073425320000e+02, 3.460000000000e+01, + static const double coordsLatLonNAD27[6 * 3] = { + 3.900000000000e+01, + -1.150000000000e+02, + 1.200000000000e+01, + 4.323423000000e+01, + -1.203425320000e+02, + 1.010000000000e+01, + 4.523423000000e+01, + -1.213425320000e+02, + 3.600000000000e+00, + 3.623423000000e+01, + -1.153425320000e+02, + 7.200000000000e+00, + 3.923423000000e+01, + -1.103425320000e+02, + 1.233000000000e+02, + 3.323423000000e+01, + -1.073425320000e+02, + 3.460000000000e+01, }; data->coordsDest = coordsLatLonNAD27; @@ -159,7 +208,8 @@ spatialdata::geocoords::TestConverter_Cases::WGS84ToNAD27(void) { // ------------------------------------------------------------------------------------------------ spatialdata::geocoords::TestConverter_Data* spatialdata::geocoords::TestConverter_Cases::WGS84ToUTMLocal(void) { - TestConverter_Data* data = new TestConverter_Data();assert(data); + TestConverter_Data* data = new TestConverter_Data(); + assert(data); data->numPoints = 6; data->spaceDim = 3; @@ -175,23 +225,47 @@ spatialdata::geocoords::TestConverter_Cases::WGS84ToUTMLocal(void) { csLocal.setLocal(500000.0, 3750000.0, 30.0); data->csDest = &csLocal; - static const double coordsLatLonWGS84[6*3] = { - 34.0, -115.0, 12.0, - 34.2, -119.6, 10.1, - 35.8, -117.2, 3.6, - 34.9, -115.8, 7.2, - 32.0, -118.3, 123.3, - 33.89036522863132, -117.0, 34.6, + static const double coordsLatLonWGS84[6 * 3] = { + 34.0, + -115.0, + 12.0, + 34.2, + -119.6, + 10.1, + 35.8, + -117.2, + 3.6, + 34.9, + -115.8, + 7.2, + 32.0, + -118.3, + 123.3, + 33.89036522863132, + -117.0, + 34.6, }; data->coordsSrc = coordsLatLonWGS84; - static const double coordsUTMLocal[6*3] = { - +152983.836, 104443.885, 12.0, - -226168.561, -87405.953, 10.1, - -121542.068, 174375.157, 3.6, - +38643.9012, 152342.458, 7.2, - -1931.97409, -242246.929, 123.3, - 0.0, 0.0, 34.6, + static const double coordsUTMLocal[6 * 3] = { + +152983.836, + 104443.885, + 12.0, + -226168.561, + -87405.953, + 10.1, + -121542.068, + 174375.157, + 3.6, + +38643.9012, + 152342.458, + 7.2, + -1931.97409, + -242246.929, + 123.3, + 0.0, + 0.0, + 34.6, }; data->coordsDest = coordsUTMLocal; @@ -202,7 +276,8 @@ spatialdata::geocoords::TestConverter_Cases::WGS84ToUTMLocal(void) { // ------------------------------------------------------------------------------------------------ spatialdata::geocoords::TestConverter_Data* spatialdata::geocoords::TestConverter_Cases::WGS84ToECEF(void) { - TestConverter_Data* data = new TestConverter_Data();assert(data); + TestConverter_Data* data = new TestConverter_Data(); + assert(data); data->numPoints = 6; data->spaceDim = 3; @@ -217,23 +292,47 @@ spatialdata::geocoords::TestConverter_Cases::WGS84ToECEF(void) { csECEF.setSpaceDim(data->spaceDim); data->csDest = &csECEF; - static const double coordsLatLonWGS84[6*3] = { - 3.899994227695e+01, -1.150008507633e+02, -8.950827822595e+00, - 4.323409740913e+01, -1.203436181122e+02, -9.225051786848e+00, - 4.523406963911e+01, -1.213437106276e+02, -1.651562577217e+01, - 3.623419630177e+01, -1.153433730158e+02, -2.018008883950e+01, - 3.923419970866e+01, -1.103432442395e+02, 1.046766831825e+02, - 3.323430190358e+01, -1.073431211987e+02, 1.087924313666e+01, + static const double coordsLatLonWGS84[6 * 3] = { + 3.899994227695e+01, + -1.150008507633e+02, + -8.950827822595e+00, + 4.323409740913e+01, + -1.203436181122e+02, + -9.225051786848e+00, + 4.523406963911e+01, + -1.213437106276e+02, + -1.651562577217e+01, + 3.623419630177e+01, + -1.153433730158e+02, + -2.018008883950e+01, + 3.923419970866e+01, + -1.103432442395e+02, + 1.046766831825e+02, + 3.323430190358e+01, + -1.073431211987e+02, + 1.087924313666e+01, }; data->coordsSrc = coordsLatLonWGS84; - static const double coordsECEF[6*3] = { - -2.097658330155e+06, -4.498268420315e+06, 3.992306409748e+06, - -2.351216279957e+06, -4.016601774689e+06, 4.346479509353e+06, - -2.340325349141e+06, -3.842552160654e+06, 4.505693105857e+06, - -2.204701624283e+06, -4.654958696636e+06, 3.749172150551e+06, - -1.719793652503e+06, -4.638444207813e+06, 4.012555773384e+06, - -1.591903914839e+06, -5.097499656067e+06, 3.475728975021e+06, + static const double coordsECEF[6 * 3] = { + -2.097658330155e+06, + -4.498268420315e+06, + 3.992306409748e+06, + -2.351216279957e+06, + -4.016601774689e+06, + 4.346479509353e+06, + -2.340325349141e+06, + -3.842552160654e+06, + 4.505693105857e+06, + -2.204701624283e+06, + -4.654958696636e+06, + 3.749172150551e+06, + -1.719793652503e+06, + -4.638444207813e+06, + 4.012555773384e+06, + -1.591903914839e+06, + -5.097499656067e+06, + 3.475728975021e+06, }; data->coordsDest = coordsECEF; @@ -244,7 +343,8 @@ spatialdata::geocoords::TestConverter_Cases::WGS84ToECEF(void) { // ------------------------------------------------------------------------------------------------ spatialdata::geocoords::TestConverter_Data* spatialdata::geocoords::TestConverter_Cases::XYZToXYZ(void) { - TestConverter_Data* data = new TestConverter_Data();assert(data); + TestConverter_Data* data = new TestConverter_Data(); + assert(data); data->numPoints = 3; data->spaceDim = 3; @@ -259,17 +359,29 @@ spatialdata::geocoords::TestConverter_Cases::XYZToXYZ(void) { csKilometer.setSpaceDim(data->spaceDim); data->csDest = &csKilometer; - static const double coordsMeter[3*3] = { - 1.0e+2, -5.0e+2, 1.0e+1, - 4.0e+3, -1.5e+3, 1.0e+2, - -5.0e+4, +2.0e+4, 2.5e+3, + static const double coordsMeter[3 * 3] = { + 1.0e+2, + -5.0e+2, + 1.0e+1, + 4.0e+3, + -1.5e+3, + 1.0e+2, + -5.0e+4, + +2.0e+4, + 2.5e+3, }; data->coordsSrc = coordsMeter; - static const double coordsKilometer[3*3] = { - 1.0e-1, -5.0e-1, 1.0e-2, - 4.0e+0, -1.5e+0, 1.0e-1, - -5.0e+1, +2.0e+1, 2.5e+0, + static const double coordsKilometer[3 * 3] = { + 1.0e-1, + -5.0e-1, + 1.0e-2, + 4.0e+0, + -1.5e+0, + 1.0e-1, + -5.0e+1, + +2.0e+1, + 2.5e+0, }; data->coordsDest = coordsKilometer; @@ -280,7 +392,8 @@ spatialdata::geocoords::TestConverter_Cases::XYZToXYZ(void) { // ------------------------------------------------------------------------------------------------ spatialdata::geocoords::TestConverter_Data* spatialdata::geocoords::TestConverter_Cases::Units(void) { - TestConverter_Data* data = new TestConverter_Data();assert(data); + TestConverter_Data* data = new TestConverter_Data(); + assert(data); data->numPoints = 6; data->spaceDim = 3; @@ -295,23 +408,47 @@ spatialdata::geocoords::TestConverter_Cases::Units(void) { csKilometer.setSpaceDim(data->spaceDim); data->csDest = &csKilometer; - static const double coordsMeter[6*3] = { - -1.284640402306e+06, 1.064304544651e+05, -1.314223695069e+05, - -1.617989794608e+06, 6.524818197004e+05, -2.429529262194e+05, - -1.637488936912e+06, 8.852730256936e+05, -2.774331769932e+05, - -1.362847273019e+06, -1.913287267184e+05, -1.500646038350e+05, - -8.881745594215e+05, 7.658679840913e+04, -6.239198222893e+04, - -6.825105930858e+05, -6.111332576090e+05, -6.615476230714e+04, + static const double coordsMeter[6 * 3] = { + -1.284640402306e+06, + 1.064304544651e+05, + -1.314223695069e+05, + -1.617989794608e+06, + 6.524818197004e+05, + -2.429529262194e+05, + -1.637488936912e+06, + 8.852730256936e+05, + -2.774331769932e+05, + -1.362847273019e+06, + -1.913287267184e+05, + -1.500646038350e+05, + -8.881745594215e+05, + 7.658679840913e+04, + -6.239198222893e+04, + -6.825105930858e+05, + -6.111332576090e+05, + -6.615476230714e+04, }; data->coordsSrc = coordsMeter; - static const double coordsKilometer[6*3] = { - -1.284640402306e+03, 1.064304544651e+02, -1.314223695069e+02, - -1.617989794608e+03, 6.524818197004e+02, -2.429529262194e+02, - -1.637488936912e+03, 8.852730256936e+02, -2.774331769932e+02, - -1.362847273019e+03, -1.913287267184e+02, -1.500646038350e+02, - -8.881745594215e+02, 7.658679840913e+01, -6.239198222893e+01, - -6.825105930858e+02, -6.111332576090e+02, -6.615476230714e+01, + static const double coordsKilometer[6 * 3] = { + -1.284640402306e+03, + 1.064304544651e+02, + -1.314223695069e+02, + -1.617989794608e+03, + 6.524818197004e+02, + -2.429529262194e+02, + -1.637488936912e+03, + 8.852730256936e+02, + -2.774331769932e+02, + -1.362847273019e+03, + -1.913287267184e+02, + -1.500646038350e+02, + -8.881745594215e+02, + 7.658679840913e+01, + -6.239198222893e+01, + -6.825105930858e+02, + -6.111332576090e+02, + -6.615476230714e+01, }; data->coordsDest = coordsKilometer; diff --git a/tests/libtests/spatialdb/TestAnalyticDB.cc b/tests/libtests/spatialdb/TestAnalyticDB.cc index ae01cae5..fa8c8143 100644 --- a/tests/libtests/spatialdb/TestAnalyticDB.cc +++ b/tests/libtests/spatialdb/TestAnalyticDB.cc @@ -24,63 +24,62 @@ namespace spatialdata { namespace spatialdb { class TestAnalyticDB; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata class spatialdata::spatialdb::TestAnalyticDB { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Test constructors - static - void testConstructors(void); + static void testConstructors(void); /// Test accessors. - static - void testAccessors(void); + static void testAccessors(void); /// Test setData() - static - void testSetData(void); + static void testSetData(void); /// Test getNamesDBValues(). - static - void testGetNamesDBValues(void); + static void testGetNamesDBValues(void); /// Test setQueryValues() - static - void testQueryVals(void); + static void testQueryVals(void); /// Test query() - static - void testQuery(void); + static void testQuery(void); /// Test query() WGS84 -> UTM. - static - void testQueryUTM(void); + static void testQueryUTM(void); }; // class TestAnalyticDB // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestAnalyticDB::testConstructors", "[TestAnalyticDB]") { +TEST_CASE("TestAnalyticDB::testConstructors", + "[TestAnalyticDB]") { spatialdata::spatialdb::TestAnalyticDB::testConstructors(); } -TEST_CASE("TestAnalyticDB::testAccessors", "[TestAnalyticDB]") { +TEST_CASE("TestAnalyticDB::testAccessors", + "[TestAnalyticDB]") { spatialdata::spatialdb::TestAnalyticDB::testAccessors(); } -TEST_CASE("TestAnalyticDB::testSetData", "[TestAnalyticDB]") { +TEST_CASE("TestAnalyticDB::testSetData", + "[TestAnalyticDB]") { spatialdata::spatialdb::TestAnalyticDB::testSetData(); } -TEST_CASE("TestAnalyticDB::testGetNamesDBValues", "[TestAnalyticDB]") { +TEST_CASE("TestAnalyticDB::testGetNamesDBValues", + "[TestAnalyticDB]") { spatialdata::spatialdb::TestAnalyticDB::testGetNamesDBValues(); } -TEST_CASE("TestAnalyticDB::testQueryVals", "[TestAnalyticDB]") { +TEST_CASE("TestAnalyticDB::testQueryVals", + "[TestAnalyticDB]") { spatialdata::spatialdb::TestAnalyticDB::testQueryVals(); } -TEST_CASE("TestAnalyticDB::testQuery", "[TestAnalyticDB]") { +TEST_CASE("TestAnalyticDB::testQuery", + "[TestAnalyticDB]") { spatialdata::spatialdb::TestAnalyticDB::testQuery(); } -TEST_CASE("TestAnalyticDB::testQueryUTM", "[TestAnalyticDB]") { +TEST_CASE("TestAnalyticDB::testQueryUTM", + "[TestAnalyticDB]") { spatialdata::spatialdb::TestAnalyticDB::testQueryUTM(); } @@ -115,9 +114,9 @@ spatialdata::spatialdb::TestAnalyticDB::testSetData(void) { AnalyticDB db; const size_t numValuesE = 3; - const char* names[numValuesE] = { "one", "two", "three" }; - const char* units[numValuesE] = { "m", "km", "cm" }; - const char* expressions[numValuesE] = { "x^2 + y^2", "x/z", "x + y + z" }; + const char* names[numValuesE] = {"one", "two", "three"}; + const char* units[numValuesE] = {"m", "km", "cm"}; + const char* expressions[numValuesE] = {"x^2 + y^2", "x/z", "x + y + z"}; db.setData(names, units, expressions, numValuesE); @@ -139,9 +138,9 @@ spatialdata::spatialdb::TestAnalyticDB::testSetData(void) { void spatialdata::spatialdb::TestAnalyticDB::testGetNamesDBValues(void) { const size_t numValuesE = 3; - const char* names[numValuesE] = { "one", "two", "three" }; - const char* units[numValuesE] = { "none", "none", "none" }; - const char* expressions[numValuesE] = { "x^2 + y^2", "x/z", "x + y + z" }; + const char* names[numValuesE] = {"one", "two", "three"}; + const char* units[numValuesE] = {"none", "none", "none"}; + const char* expressions[numValuesE] = {"x^2 + y^2", "x/z", "x + y + z"}; AnalyticDB db; db.setData(names, units, expressions, numValuesE); @@ -154,7 +153,8 @@ spatialdata::spatialdb::TestAnalyticDB::testGetNamesDBValues(void) { for (size_t i = 0; i < numValuesE; ++i) { CHECK(std::string(names[i]) == std::string(valueNames[i])); } // for - delete[] valueNames;valueNames = NULL; + delete[] valueNames; + valueNames = NULL; numValues = 0; } // testGetNamesDBValues @@ -166,13 +166,13 @@ spatialdata::spatialdb::TestAnalyticDB::testQueryVals(void) { AnalyticDB db; const size_t numValuesE = 3; - const char* names[numValuesE] = { "one", "two", "three" }; - const char* units[numValuesE] = { "none", "none", "none" }; - const char* expressions[numValuesE] = { "x^2 + y^2", "x/z", "x + y + z" }; + const char* names[numValuesE] = {"one", "two", "three"}; + const char* units[numValuesE] = {"none", "none", "none"}; + const char* expressions[numValuesE] = {"x^2 + y^2", "x/z", "x + y + z"}; const size_t querySize = 2; - const char* queryNames[querySize] = { "three", "two" }; - const size_t queryVals[querySize] = { 2, 1 }; + const char* queryNames[querySize] = {"three", "two"}; + const size_t queryVals[querySize] = {2, 1}; db.setData(names, units, expressions, numValuesE); db.setQueryValues(queryNames, querySize); @@ -193,22 +193,22 @@ spatialdata::spatialdb::TestAnalyticDB::testQuery(void) { const size_t spaceDim = 3; spatialdata::geocoords::CSCart cs; cs.setSpaceDim(spaceDim); - const double coords[spaceDim] = { 1.1, 2.3, 5.6 }; + const double coords[spaceDim] = {1.1, 2.3, 5.6}; const size_t numValues = 3; - const char* names[numValues] = { "one", "two", "three" }; - const char* units[numValues] = { "none", "km", "cm" }; - const char* expressions[numValues] = { "x^2 + y^2", "x/z", "x + y + z" }; - const double scales[numValues] = { 1.0, 1000.0, 0.01 }; + const char* names[numValues] = {"one", "two", "three"}; + const char* units[numValues] = {"none", "km", "cm"}; + const char* expressions[numValues] = {"x^2 + y^2", "x/z", "x + y + z"}; + const double scales[numValues] = {1.0, 1000.0, 0.01}; const double values[numValues] = { - coords[0]*coords[0], - coords[0]/coords[2], - coords[0]+coords[1]+coords[2], + coords[0] * coords[0], + coords[0] / coords[2], + coords[0] + coords[1] + coords[2], }; const size_t querySize = 2; - const char* queryNames[querySize] = { "three", "two" }; - const size_t queryVals[querySize] = { 2, 1 }; + const char* queryNames[querySize] = {"three", "two"}; + const size_t queryVals[querySize] = {2, 1}; db.setData(names, units, expressions, numValues); db.setQueryValues(queryNames, querySize); @@ -236,27 +236,27 @@ spatialdata::spatialdb::TestAnalyticDB::testQueryUTM(void) { spatialdata::geocoords::CSGeo csWGS84; csWGS84.setString("EPSG:4326"); csWGS84.setSpaceDim(spaceDim); - const double coordsLL[spaceDim] = { 37.50, -122.30, 5.6 }; + const double coordsLL[spaceDim] = {37.50, -122.30, 5.6}; spatialdata::geocoords::CSGeo csUTM; csUTM.setString("EPSG:32610"); csUTM.setSpaceDim(spaceDim); - const double coordsUTM[spaceDim] = { 561873.454241, 4150571.437855, 5.6 }; + const double coordsUTM[spaceDim] = {561873.454241, 4150571.437855, 5.6}; const size_t numValues = 3; - const char* names[numValues] = { "one", "two", "three" }; - const char* units[numValues] = { "none", "km", "cm" }; - const char* expressions[numValues] = { "x^2 + y^2", "x/z", "x + y + z" }; - const double scales[numValues] = { 1.0, 1000.0, 0.01 }; + const char* names[numValues] = {"one", "two", "three"}; + const char* units[numValues] = {"none", "km", "cm"}; + const char* expressions[numValues] = {"x^2 + y^2", "x/z", "x + y + z"}; + const double scales[numValues] = {1.0, 1000.0, 0.01}; const double values[numValues] = { - coordsUTM[0]*coordsUTM[0], - coordsUTM[0]/coordsUTM[2], - coordsUTM[0]+coordsUTM[1]+coordsUTM[2], + coordsUTM[0] * coordsUTM[0], + coordsUTM[0] / coordsUTM[2], + coordsUTM[0] + coordsUTM[1] + coordsUTM[2], }; const size_t querySize = 2; - const char* queryNames[querySize] = { "three", "two" }; - const size_t queryVals[querySize] = { 2, 1 }; + const char* queryNames[querySize] = {"three", "two"}; + const size_t queryVals[querySize] = {2, 1}; db.setCoordSys(csUTM); db.setData(names, units, expressions, numValues); diff --git a/tests/libtests/spatialdb/TestCompositeDB.cc b/tests/libtests/spatialdb/TestCompositeDB.cc index 8a16f446..60ce19fa 100644 --- a/tests/libtests/spatialdb/TestCompositeDB.cc +++ b/tests/libtests/spatialdb/TestCompositeDB.cc @@ -12,8 +12,8 @@ #include "spatialdata/spatialdb/CompositeDB.hh" // USES CompositeDB -#include "spatialdata/spatialdb/UniformDB.hh" // USES UniformDB #include "spatialdata/geocoords/CSCart.hh" // USES CSCart +#include "spatialdata/spatialdb/UniformDB.hh" // USES UniformDB #include "catch2/catch_test_macros.hpp" #include "catch2/matchers/catch_matchers_floating_point.hpp" @@ -24,19 +24,17 @@ namespace spatialdata { namespace spatialdb { class TestCompositeDB; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata class spatialdata::spatialdb::TestCompositeDB { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Constructor. TestCompositeDB(void); /// Test constructors - static - void testConstructors(void); + static void testConstructors(void); /// Test accessors. void testAccessors(void); @@ -62,39 +60,47 @@ class spatialdata::spatialdb::TestCompositeDB { /// Test query() with values in dbB. void testQueryB(void); -private: - + private: UniformDB _dbA; ///< Spatial database A. UniformDB _dbB; ///< Spatial databsae B. }; // class TestCompositeDB // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestCompositeDB::testConstructors", "[TestCompositeDB]") { +TEST_CASE("TestCompositeDB::testConstructors", + "[TestCompositeDB]") { spatialdata::spatialdb::TestCompositeDB::testConstructors(); } -TEST_CASE("TestCompositeDB::testAccessors", "[TestCompositeDB]") { +TEST_CASE("TestCompositeDB::testAccessors", + "[TestCompositeDB]") { spatialdata::spatialdb::TestCompositeDB().testAccessors(); } -TEST_CASE("TestCompositeDB::testGetNamesDBValues", "[TestCompositeDB]") { +TEST_CASE("TestCompositeDB::testGetNamesDBValues", + "[TestCompositeDB]") { spatialdata::spatialdb::TestCompositeDB().testGetNamesDBValues(); } -TEST_CASE("TestCompositeDB::testQueryValsAB", "[TestCompositeDB]") { +TEST_CASE("TestCompositeDB::testQueryValsAB", + "[TestCompositeDB]") { spatialdata::spatialdb::TestCompositeDB().testQueryValsAB(); } -TEST_CASE("TestCompositeDB::testQueryValsA", "[TestCompositeDB]") { +TEST_CASE("TestCompositeDB::testQueryValsA", + "[TestCompositeDB]") { spatialdata::spatialdb::TestCompositeDB().testQueryValsA(); } -TEST_CASE("TestCompositeDB::testQueryValsB", "[TestCompositeDB]") { +TEST_CASE("TestCompositeDB::testQueryValsB", + "[TestCompositeDB]") { spatialdata::spatialdb::TestCompositeDB().testQueryValsB(); } -TEST_CASE("TestCompositeDB::testQueryAB", "[TestCompositeDB]") { +TEST_CASE("TestCompositeDB::testQueryAB", + "[TestCompositeDB]") { spatialdata::spatialdb::TestCompositeDB().testQueryAB(); } -TEST_CASE("TestCompositeDB::testQueryA", "[TestCompositeDB]") { +TEST_CASE("TestCompositeDB::testQueryA", + "[TestCompositeDB]") { spatialdata::spatialdb::TestCompositeDB().testQueryA(); } -TEST_CASE("TestCompositeDB::testQueryB", "[TestCompositeDB]") { +TEST_CASE("TestCompositeDB::testQueryB", + "[TestCompositeDB]") { spatialdata::spatialdb::TestCompositeDB().testQueryB(); } @@ -102,17 +108,17 @@ TEST_CASE("TestCompositeDB::testQueryB", "[TestCompositeDB]") { spatialdata::spatialdb::TestCompositeDB::TestCompositeDB(void) { { // initialize db A const size_t numValues = 3; - const char* names[3] = { "one", "two", "three" }; - const char* units[3] = { "none", "none", "none" }; - const double values[3] = { 1.1, 2.2, 3.3 }; + const char* names[3] = {"one", "two", "three"}; + const char* units[3] = {"none", "none", "none"}; + const double values[3] = {1.1, 2.2, 3.3}; _dbA.setData(names, units, values, numValues); } // initialize db A { // initialize db B const size_t numValues = 2; - const char* names[2] = { "four", "five" }; - const char* units[2] = { "none", "none" }; - const double values[2] = { 4.4, 5.5 }; + const char* names[2] = {"four", "five"}; + const char* units[2] = {"none", "none"}; + const double values[2] = {4.4, 5.5}; _dbB.setData(names, units, values, numValues); } // initialize db B @@ -143,7 +149,7 @@ spatialdata::spatialdb::TestCompositeDB::testAccessors(void) { // Set database A const size_t numNamesA = 2; - const char* namesA[2] = { "three", "one" }; + const char* namesA[2] = {"three", "one"}; db.setDBA(&_dbA, namesA, numNamesA); CHECK(db._dbA); @@ -161,7 +167,7 @@ spatialdata::spatialdb::TestCompositeDB::testAccessors(void) { // Set database B const size_t numNamesB = 1; - const char* namesB[1] = { "five" }; + const char* namesB[1] = {"five"}; db.setDBB(&_dbB, namesB, numNamesB); CHECK(db._dbB); @@ -183,11 +189,11 @@ spatialdata::spatialdb::TestCompositeDB::testGetNamesDBValues(void) { CompositeDB db; const size_t numValuesA = 2; - const char* namesA[2] = { "three", "one" }; + const char* namesA[2] = {"three", "one"}; db.setDBA(&_dbA, namesA, numValuesA); const size_t numValuesB = 1; - const char* namesB[1] = { "five" }; + const char* namesB[1] = {"five"}; db.setDBB(&_dbB, namesB, numValuesB); const char** valueNames = NULL; @@ -202,7 +208,8 @@ spatialdata::spatialdb::TestCompositeDB::testGetNamesDBValues(void) { for (size_t iB = 0; iB < numValuesB; ++iB, ++iAB) { CHECK(std::string(namesB[iB]) == std::string(valueNames[iAB])); } // for - delete[] valueNames;valueNames = NULL; + delete[] valueNames; + valueNames = NULL; numValues = 0; } // testGetDBValues @@ -214,21 +221,21 @@ spatialdata::spatialdb::TestCompositeDB::testQueryValsAB(void) { CompositeDB db; const size_t numNamesA = 2; - const char* namesA[2] = { "three", "one" }; + const char* namesA[2] = {"three", "one"}; db.setDBA(&_dbA, namesA, numNamesA); const size_t numNamesB = 1; - const char* namesB[1] = { "five" }; + const char* namesB[1] = {"five"}; db.setDBB(&_dbB, namesB, numNamesB); const size_t querySize = 3; - const char* queryVals[3] = { "one", "five", "three" }; + const char* queryVals[3] = {"one", "five", "three"}; db.open(); { // Check defaults (all values in A and then all values in B). const size_t qsizeA = 2; - const size_t qindicesA[qsizeA] = { 0, 1 }; + const size_t qindicesA[qsizeA] = {0, 1}; CHECK(db._dbA); CHECK(db._infoA); CHECK(db._infoA->query_buffer); @@ -239,7 +246,7 @@ spatialdata::spatialdb::TestCompositeDB::testQueryValsAB(void) { } // for const size_t qsizeB = 1; - const size_t qindicesB[1] = { 2 }; + const size_t qindicesB[1] = {2}; CHECK(db._dbB); CHECK(db._infoB); CHECK(db._infoB->query_buffer); @@ -254,7 +261,7 @@ spatialdata::spatialdb::TestCompositeDB::testQueryValsAB(void) { db.close(); const size_t qsizeA = 2; - const size_t qindicesA[2] = { 0, 2 }; + const size_t qindicesA[2] = {0, 2}; CHECK(db._dbA); CHECK(db._infoA); CHECK(db._infoA->query_buffer); @@ -265,7 +272,7 @@ spatialdata::spatialdb::TestCompositeDB::testQueryValsAB(void) { } // for const size_t qsizeB = 1; - const size_t qindicesB[1] = { 1 }; + const size_t qindicesB[1] = {1}; CHECK(db._dbB); CHECK(db._infoB); CHECK(db._infoB->query_buffer); @@ -284,22 +291,22 @@ spatialdata::spatialdb::TestCompositeDB::testQueryValsA(void) { CompositeDB db; const size_t numNamesA = 2; - const char* namesA[2] = { "three", "one" }; + const char* namesA[2] = {"three", "one"}; db.setDBA(&_dbA, namesA, numNamesA); const size_t numNamesB = 1; - const char* namesB[1] = { "five" }; + const char* namesB[1] = {"five"}; db.setDBB(&_dbB, namesB, numNamesB); const size_t querySize = 2; - const char* queryVals[2] = { "one", "three" }; + const char* queryVals[2] = {"one", "three"}; db.open(); db.setQueryValues(queryVals, querySize); db.close(); const size_t qsizeA = 2; - const size_t qindicesA[2] = { 0, 1 }; + const size_t qindicesA[2] = {0, 1}; CHECK(db._dbA); CHECK(db._infoA); CHECK(db._infoA->query_buffer); @@ -325,15 +332,15 @@ spatialdata::spatialdb::TestCompositeDB::testQueryValsB(void) { CompositeDB db; const size_t numNamesA = 2; - const char* namesA[2] = { "three", "one" }; + const char* namesA[2] = {"three", "one"}; db.setDBA(&_dbA, namesA, numNamesA); const size_t numNamesB = 1; - const char* namesB[1] = { "five" }; + const char* namesB[1] = {"five"}; db.setDBB(&_dbB, namesB, numNamesB); const size_t querySize = 1; - const char* queryVals[1] = { "five" }; + const char* queryVals[1] = {"five"}; db.open(); db.setQueryValues(queryVals, querySize); @@ -347,7 +354,7 @@ spatialdata::spatialdb::TestCompositeDB::testQueryValsB(void) { REQUIRE(qsizeA == db._infoA->query_size); const size_t qsizeB = 1; - const size_t qindicesB[1] = { 0 }; + const size_t qindicesB[1] = {0}; CHECK(db._dbB); CHECK(db._infoB); CHECK(db._infoB->query_buffer); @@ -366,22 +373,22 @@ spatialdata::spatialdb::TestCompositeDB::testQueryAB(void) { CompositeDB db; const size_t numNamesA = 2; - const char* namesA[2] = { "three", "one" }; + const char* namesA[2] = {"three", "one"}; db.setDBA(&_dbA, namesA, numNamesA); const size_t numNamesB = 1; - const char* namesB[1] = { "five" }; + const char* namesB[1] = {"five"}; db.setDBB(&_dbB, namesB, numNamesB); const size_t querySize = 2; - const char* queryVals[2] = { "five", "one" }; + const char* queryVals[2] = {"five", "one"}; const size_t spaceDim = 2; spatialdata::geocoords::CSCart cs; cs.setSpaceDim(spaceDim); - const double coords[2] = { 2.3, 5.6 }; + const double coords[2] = {2.3, 5.6}; double data[querySize]; - const double valsE[2] = { 5.5, 1.1 }; + const double valsE[2] = {5.5, 1.1}; db.open(); db.setQueryValues(queryVals, querySize); @@ -390,7 +397,7 @@ spatialdata::spatialdb::TestCompositeDB::testQueryAB(void) { const double tolerance = 1.0e-6; for (size_t i = 0; i < querySize; ++i) { - const double toleranceV = fabs(valsE[i]) > 0.0 ? tolerance*valsE[i] : tolerance; + const double toleranceV = fabs(valsE[i]) > 0.0 ? tolerance * valsE[i] : tolerance; CHECK_THAT(data[i], Catch::Matchers::WithinAbs(valsE[i], toleranceV)); } // for } // testQueryAB @@ -403,22 +410,22 @@ spatialdata::spatialdb::TestCompositeDB::testQueryA(void) { // testQueryA CompositeDB db; const size_t numNamesA = 2; - const char* namesA[2] = { "three", "one" }; + const char* namesA[2] = {"three", "one"}; db.setDBA(&_dbA, namesA, numNamesA); const size_t numNamesB = 1; - const char* namesB[1] = { "five" }; + const char* namesB[1] = {"five"}; db.setDBB(&_dbB, namesB, numNamesB); const size_t querySize = 1; - const char* queryVals[1] = { "three" }; + const char* queryVals[1] = {"three"}; const size_t spaceDim = 2; spatialdata::geocoords::CSCart cs; cs.setSpaceDim(spaceDim); - const double coords[2] = { 2.3, 5.6 }; + const double coords[2] = {2.3, 5.6}; double data[querySize]; - const double valsE[1] = { 3.3 }; + const double valsE[1] = {3.3}; db.open(); db.setQueryValues(queryVals, querySize); @@ -427,7 +434,7 @@ spatialdata::spatialdb::TestCompositeDB::testQueryA(void) { // testQueryA const double tolerance = 1.0e-6; for (size_t i = 0; i < querySize; ++i) { - const double toleranceV = fabs(valsE[i]) > 0.0 ? tolerance*valsE[i] : tolerance; + const double toleranceV = fabs(valsE[i]) > 0.0 ? tolerance * valsE[i] : tolerance; CHECK_THAT(data[i], Catch::Matchers::WithinAbs(valsE[i], toleranceV)); } // for } // testQueryA @@ -440,22 +447,24 @@ spatialdata::spatialdb::TestCompositeDB::testQueryB(void) { CompositeDB db; const size_t numNamesA = 2; - const char* namesA[2] = { "three", "one" }; + const char* namesA[2] = {"three", "one"}; db.setDBA(&_dbA, namesA, numNamesA); const size_t numNamesB = 1; - const char* namesB[1] = { "five" }; + const char* namesB[1] = {"five"}; db.setDBB(&_dbB, namesB, numNamesB); const size_t querySize = 1; - const char* queryVals[1] = { "five", }; + const char* queryVals[1] = { + "five", + }; const size_t spaceDim = 2; spatialdata::geocoords::CSCart cs; cs.setSpaceDim(spaceDim); - const double coords[2] = { 2.3, 5.6 }; + const double coords[2] = {2.3, 5.6}; double data[querySize]; - const double valsE[1] = { 5.5 }; + const double valsE[1] = {5.5}; db.open(); db.setQueryValues(queryVals, querySize); @@ -464,7 +473,7 @@ spatialdata::spatialdb::TestCompositeDB::testQueryB(void) { const double tolerance = 1.0e-6; for (size_t i = 0; i < querySize; ++i) { - const double toleranceV = fabs(valsE[i]) > 0.0 ? tolerance*valsE[i] : tolerance; + const double toleranceV = fabs(valsE[i]) > 0.0 ? tolerance * valsE[i] : tolerance; CHECK_THAT(data[i], Catch::Matchers::WithinAbs(valsE[i], toleranceV)); } // for } // testQueryB diff --git a/tests/libtests/spatialdb/TestGravityField.cc b/tests/libtests/spatialdb/TestGravityField.cc index 280b1b7a..e1cabde2 100644 --- a/tests/libtests/spatialdb/TestGravityField.cc +++ b/tests/libtests/spatialdb/TestGravityField.cc @@ -23,8 +23,7 @@ // ---------------------------------------------------------------------- // Constructor. -spatialdata::spatialdb::TestGravityField::TestGravityField(TestGravityField_Data* data) : - _data(data) { +spatialdata::spatialdb::TestGravityField::TestGravityField(TestGravityField_Data* data) : _data(data) { assert(_data); } // constructor @@ -32,7 +31,8 @@ spatialdata::spatialdb::TestGravityField::TestGravityField(TestGravityField_Data // ---------------------------------------------------------------------- // Destructor. spatialdata::spatialdb::TestGravityField::~TestGravityField(void) { - delete _data;_data = NULL; + delete _data; + _data = NULL; } // tearDown @@ -62,12 +62,12 @@ spatialdata::spatialdb::TestGravityField::testAccessors(void) { db.setDescription(description.c_str()); CHECK(description == std::string(db.getDescription())); - const double gravityDirDefault[3] = { 0.0, 0.0, -1.0 }; + const double gravityDirDefault[3] = {0.0, 0.0, -1.0}; for (size_t i = 0; i < 3; ++i) { CHECK_THAT(db._gravityDir[i], Catch::Matchers::WithinAbs(gravityDirDefault[i], tolerance)); } // for - const double gravityDirUser[3] = { 1.1, 2.2, 3.3 }; + const double gravityDirUser[3] = {1.1, 2.2, 3.3}; const double gravityMag = 1.1 * sqrt(1.0 + 4.0 + 9.0); db.setGravityDir(gravityDirUser[0], gravityDirUser[1], gravityDirUser[2]); for (size_t i = 0; i < 3; ++i) { @@ -91,7 +91,7 @@ spatialdata::spatialdb::TestGravityField::testGetNamesDBValues(void) { GravityField db; const size_t numValuesE = 3; - const char* valueNamesE[numValuesE] = { "gravity_field_x", "gravity_field_y", "gravity_field_z" }; + const char* valueNamesE[numValuesE] = {"gravity_field_x", "gravity_field_y", "gravity_field_z"}; const char** valueNames = NULL; size_t numValues = 0; @@ -101,7 +101,8 @@ spatialdata::spatialdb::TestGravityField::testGetNamesDBValues(void) { for (size_t i = 0; i < numValues; ++i) { CHECK(std::string(valueNamesE[i]) == std::string(valueNames[i])); } // for - delete[] valueNames;valueNames = NULL; + delete[] valueNames; + valueNames = NULL; numValues = 0; } // testGetDBValues @@ -113,8 +114,8 @@ spatialdata::spatialdb::TestGravityField::testQueryVals(void) { GravityField db; const size_t querySize = 2; - const char* queryNames[2] = { "gravity_field_z", "gravity_field_y" }; - const size_t queryVals[2] = { 2, 1 }; + const char* queryNames[2] = {"gravity_field_z", "gravity_field_y"}; + const size_t queryVals[2] = {2, 1}; db.setQueryValues(queryNames, querySize); @@ -146,15 +147,16 @@ spatialdata::spatialdb::TestGravityField::testQuery(void) { double* gravity = (querySize > 0) ? new double[querySize] : NULL; for (size_t iPt = 0; iPt < _data->numPoints; ++iPt) { - const int err = db.query(gravity, querySize, &_data->coordinates[iPt*spaceDim], spaceDim, _data->cs); + const int err = db.query(gravity, querySize, &_data->coordinates[iPt * spaceDim], spaceDim, _data->cs); REQUIRE(!err); const double tolerance = 1.0e-06; for (size_t iDim = 0; iDim < querySize; ++iDim) { - const double valueE = _data->gravity[iPt*querySize+iDim]; + const double valueE = _data->gravity[iPt * querySize + iDim]; CHECK_THAT(gravity[iDim], Catch::Matchers::WithinAbs(valueE, tolerance)); } // for } // for - delete[] gravity;gravity = NULL; + delete[] gravity; + gravity = NULL; db.close(); } // testQuery @@ -178,7 +180,8 @@ spatialdata::spatialdb::TestGravityField_Data::TestGravityField_Data(void) : // ---------------------------------------------------------------------- // Destructor spatialdata::spatialdb::TestGravityField_Data::~TestGravityField_Data(void) { - delete cs;cs = NULL; + delete cs; + cs = NULL; gravityDir = NULL; coordinates = NULL; gravity = NULL; diff --git a/tests/libtests/spatialdb/TestGravityField.hh b/tests/libtests/spatialdb/TestGravityField.hh index dead8f38..55b8ce43 100644 --- a/tests/libtests/spatialdb/TestGravityField.hh +++ b/tests/libtests/spatialdb/TestGravityField.hh @@ -17,14 +17,13 @@ namespace spatialdata { namespace spatialdb { class TestGravityField; class TestGravityField_Data; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata // ------------------------------------------------------------------------------------------------ class spatialdata::spatialdb::TestGravityField { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Constructor. TestGravityField(TestGravityField_Data* data); @@ -32,27 +31,22 @@ public: ~TestGravityField(void); /// Test constructor - static - void testConstructor(void); + static void testConstructor(void); /// Test accessors. - static - void testAccessors(void); + static void testAccessors(void); /// Test getNamesDBValues(). - static - void testGetNamesDBValues(void); + static void testGetNamesDBValues(void); /// Test setQueryValues() - static - void testQueryVals(void); + static void testQueryVals(void); /// Test query(). void testQuery(void); // PROTECTED METHODS ////////////////////////////////////////////////////////////////////////// -protected: - + protected: TestGravityField_Data* _data; ///< Test data. }; // class TestGravityField @@ -60,8 +54,7 @@ protected: // ------------------------------------------------------------------------------------------------ class spatialdata::spatialdb::TestGravityField_Data { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Constructor TestGravityField_Data(void); @@ -69,8 +62,7 @@ public: ~TestGravityField_Data(void); // PUBLIC MEMBERS ///////////////////////////////////////////////////////////////////////////// -public: - + public: spatialdata::geocoords::CoordSys* cs; ///< Coordinate system. double gravityAcc; ///< Gravitational acceleration. const double* gravityDir; ///< Direction of gravitational acceleration. diff --git a/tests/libtests/spatialdb/TestGravityField_Cases.cc b/tests/libtests/spatialdb/TestGravityField_Cases.cc index 229ccffa..8ee61937 100644 --- a/tests/libtests/spatialdb/TestGravityField_Cases.cc +++ b/tests/libtests/spatialdb/TestGravityField_Cases.cc @@ -23,82 +23,87 @@ namespace spatialdata { namespace spatialdb { class TestGravityField_Cases; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata class spatialdata::spatialdb::TestGravityField_Cases { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: // Factories - static - TestGravityField_Data* Cart2D(void); + static TestGravityField_Data* Cart2D(void); - static - TestGravityField_Data* Cart3D(void); + static TestGravityField_Data* Cart3D(void); - static - TestGravityField_Data* Geo(void); + static TestGravityField_Data* Geo(void); - static - TestGravityField_Data* GeoProj(void); + static TestGravityField_Data* GeoProj(void); - static - TestGravityField_Data* Geocentric(void); + static TestGravityField_Data* Geocentric(void); }; // class TestGravity // ------------------------------------------------------------------------------------------------ // Static test cases -TEST_CASE("TestGravityField::testConstructor", "[TestGravityField]") { +TEST_CASE("TestGravityField::testConstructor", + "[TestGravityField]") { spatialdata::spatialdb::TestGravityField::testConstructor(); } -TEST_CASE("TestGravityField::testAccessors", "[TestGravityField]") { +TEST_CASE("TestGravityField::testAccessors", + "[TestGravityField]") { spatialdata::spatialdb::TestGravityField::testAccessors(); } -TEST_CASE("TestGravityField::testGetNamesDBValues", "[TestGravityField]") { +TEST_CASE("TestGravityField::testGetNamesDBValues", + "[TestGravityField]") { spatialdata::spatialdb::TestGravityField::testGetNamesDBValues(); } -TEST_CASE("TestGravityField::testQueryVals", "[TestGravityField]") { +TEST_CASE("TestGravityField::testQueryVals", + "[TestGravityField]") { spatialdata::spatialdb::TestGravityField::testQueryVals(); } // Data test cases -TEST_CASE("TestGravityField::Cart2D::testQuery", "[TestGravityField]") { +TEST_CASE("TestGravityField::Cart2D::testQuery", + "[TestGravityField]") { spatialdata::spatialdb::TestGravityField(spatialdata::spatialdb::TestGravityField_Cases::Cart2D()).testQuery(); } -TEST_CASE("TestGravityField::Cart3D::testQuery", "[TestGravityField]") { +TEST_CASE("TestGravityField::Cart3D::testQuery", + "[TestGravityField]") { spatialdata::spatialdb::TestGravityField(spatialdata::spatialdb::TestGravityField_Cases::Cart3D()).testQuery(); } -TEST_CASE("TestGravityField::Geo::testQuery", "[TestGravityField]") { +TEST_CASE("TestGravityField::Geo::testQuery", + "[TestGravityField]") { spatialdata::spatialdb::TestGravityField(spatialdata::spatialdb::TestGravityField_Cases::Geo()).testQuery(); } -TEST_CASE("TestGravityField::GeoProj::testQuery", "[TestGravityField]") { +TEST_CASE("TestGravityField::GeoProj::testQuery", + "[TestGravityField]") { spatialdata::spatialdb::TestGravityField(spatialdata::spatialdb::TestGravityField_Cases::GeoProj()).testQuery(); } -TEST_CASE("TestGravityField::Geocentric::testQuery", "[TestGravityField]") { +TEST_CASE("TestGravityField::Geocentric::testQuery", + "[TestGravityField]") { spatialdata::spatialdb::TestGravityField(spatialdata::spatialdb::TestGravityField_Cases::Geocentric()).testQuery(); } // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestGravityField_Data* spatialdata::spatialdb::TestGravityField_Cases::Cart2D(void) { - TestGravityField_Data* data = new TestGravityField_Data;assert(data); + TestGravityField_Data* data = new TestGravityField_Data; + assert(data); - data->cs = new spatialdata::geocoords::CSCart();assert(data->cs); + data->cs = new spatialdata::geocoords::CSCart(); + assert(data->cs); data->cs->setSpaceDim(2); data->gravityAcc = 2.0; - static const double gravityDir[2] = { +0.6, -0.8 }; + static const double gravityDir[2] = {+0.6, -0.8}; data->gravityDir = gravityDir; data->numPoints = 1; data->querySize = 2; - static const double coordinates[2] = { 2.5, 6.3 }; + static const double coordinates[2] = {2.5, 6.3}; data->coordinates = coordinates; - static const double gravity[2] = { +1.2, -1.6 }; + static const double gravity[2] = {+1.2, -1.6}; data->gravity = gravity; return data; @@ -108,20 +113,22 @@ spatialdata::spatialdb::TestGravityField_Cases::Cart2D(void) { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestGravityField_Data* spatialdata::spatialdb::TestGravityField_Cases::Cart3D(void) { - TestGravityField_Data* data = new TestGravityField_Data;assert(data); + TestGravityField_Data* data = new TestGravityField_Data; + assert(data); - data->cs = new spatialdata::geocoords::CSCart();assert(data->cs); + data->cs = new spatialdata::geocoords::CSCart(); + assert(data->cs); data->cs->setSpaceDim(3); data->gravityAcc = 2.0; - static const double gravityDir[3] = { +0.3, +0.4, -0.5 }; + static const double gravityDir[3] = {+0.3, +0.4, -0.5}; data->gravityDir = gravityDir; data->numPoints = 1; data->querySize = 3; - static const double coordinates[3] = { 2.5, 6.3, -2.4 }; + static const double coordinates[3] = {2.5, 6.3, -2.4}; data->coordinates = coordinates; static const double gravity[3] = { @@ -138,25 +145,27 @@ spatialdata::spatialdb::TestGravityField_Cases::Cart3D(void) { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestGravityField_Data* spatialdata::spatialdb::TestGravityField_Cases::Geo(void) { - TestGravityField_Data* data = new TestGravityField_Data;assert(data); + TestGravityField_Data* data = new TestGravityField_Data; + assert(data); - spatialdata::geocoords::CSGeo* cs = new spatialdata::geocoords::CSGeo();assert(cs); + spatialdata::geocoords::CSGeo* cs = new spatialdata::geocoords::CSGeo(); + assert(cs); cs->setString("EPSG:4326"); // WGS84 cs->setSpaceDim(3); data->cs = cs; data->gravityAcc = 2.0; - static const double gravityDir[3] = { 0.0, 0.0, -1.0 }; + static const double gravityDir[3] = {0.0, 0.0, -1.0}; data->gravityDir = gravityDir; data->numPoints = 1; data->querySize = 3; - static const double coordinates[3] = { 2.5, 6.3, -2.4 }; + static const double coordinates[3] = {2.5, 6.3, -2.4}; data->coordinates = coordinates; - static const double gravity[3] = { 0.0, 0.0, -2.0 }; + static const double gravity[3] = {0.0, 0.0, -2.0}; data->gravity = gravity; return data; @@ -166,25 +175,27 @@ spatialdata::spatialdb::TestGravityField_Cases::Geo(void) { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestGravityField_Data* spatialdata::spatialdb::TestGravityField_Cases::GeoProj(void) { - TestGravityField_Data* data = new TestGravityField_Data;assert(data); + TestGravityField_Data* data = new TestGravityField_Data; + assert(data); - spatialdata::geocoords::CSGeo* cs = new spatialdata::geocoords::CSGeo();assert(cs); + spatialdata::geocoords::CSGeo* cs = new spatialdata::geocoords::CSGeo(); + assert(cs); cs->setString("EPSG:3310"); // California AEA cs->setSpaceDim(3); data->cs = cs; data->gravityAcc = 2.0; - static const double gravityDir[3] = { 0.0, 0.0, -1.0 }; + static const double gravityDir[3] = {0.0, 0.0, -1.0}; data->gravityDir = gravityDir; data->numPoints = 1; data->querySize = 3; - static const double coordinates[3] = { 2.5, 6.3, -2.4 }; + static const double coordinates[3] = {2.5, 6.3, -2.4}; data->coordinates = coordinates; - static const double gravity[3] = { 0.0, 0.0, -2.0 }; + static const double gravity[3] = {0.0, 0.0, -2.0}; data->gravity = gravity; return data; @@ -194,9 +205,11 @@ spatialdata::spatialdb::TestGravityField_Cases::GeoProj(void) { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestGravityField_Data* spatialdata::spatialdb::TestGravityField_Cases::Geocentric(void) { - TestGravityField_Data* data = new TestGravityField_Data;assert(data); + TestGravityField_Data* data = new TestGravityField_Data; + assert(data); - spatialdata::geocoords::CSGeo* cs = new spatialdata::geocoords::CSGeo();assert(cs); + spatialdata::geocoords::CSGeo* cs = new spatialdata::geocoords::CSGeo(); + assert(cs); cs->setString("EPSG:4978"); // ECEF geocentric cs->setSpaceDim(3); data->cs = cs; @@ -207,21 +220,41 @@ spatialdata::spatialdb::TestGravityField_Cases::Geocentric(void) { data->numPoints = 5; data->querySize = 3; - static const double coordinates[5*3] = { - 0.0, 0.0, 6356752.31, // (lon=0.0, lat=90.0) - 6378137.00, 0.0, 0.0, // (lon=0.0, lat=0.0) - 0.0, -6378137.00, 0.0, // (lon=-90.0, lat=0.0) - -2684785.48, -4296554.90, 3861564.10, // (lon=-122.0, lat=37.5) - -2680581.35, -4289826.89, 3855476.48, // (lon=-122.0, lat=37.5, elev=-10km) + static const double coordinates[5 * 3] = { + 0.0, + 0.0, + 6356752.31, // (lon=0.0, lat=90.0) + 6378137.00, + 0.0, + 0.0, // (lon=0.0, lat=0.0) + 0.0, + -6378137.00, + 0.0, // (lon=-90.0, lat=0.0) + -2684785.48, + -4296554.90, + 3861564.10, // (lon=-122.0, lat=37.5) + -2680581.35, + -4289826.89, + 3855476.48, // (lon=-122.0, lat=37.5, elev=-10km) }; data->coordinates = coordinates; - static const double gravity[5*3] = { - 0.0, 0.0, -gacc, - -gacc, 0.0, 0.0, - 0.0, gacc, 0.0, - +0.4204132183640867*gacc, +0.6728017898133232*gacc, -0.6087614290087207*gacc, - +0.4204132183640867*gacc, +0.6728017898133232*gacc, -0.6087614290087207*gacc, + static const double gravity[5 * 3] = { + 0.0, + 0.0, + -gacc, + -gacc, + 0.0, + 0.0, + 0.0, + gacc, + 0.0, + +0.4204132183640867 * gacc, + +0.6728017898133232 * gacc, + -0.6087614290087207 * gacc, + +0.4204132183640867 * gacc, + +0.6728017898133232 * gacc, + -0.6087614290087207 * gacc, }; data->gravity = gravity; diff --git a/tests/libtests/spatialdb/TestSCECCVMH.cc b/tests/libtests/spatialdb/TestSCECCVMH.cc index 485a2d19..196c74e7 100644 --- a/tests/libtests/spatialdb/TestSCECCVMH.cc +++ b/tests/libtests/spatialdb/TestSCECCVMH.cc @@ -10,8 +10,8 @@ #include -#include "spatialdata/spatialdb/SCECCVMH.hh" // USES SCECCVMH #include "spatialdata/geocoords/CSGeo.hh" // USES CSGeo +#include "spatialdata/spatialdb/SCECCVMH.hh" // USES SCECCVMH #include "catch2/catch_test_macros.hpp" #include "catch2/matchers/catch_matchers_floating_point.hpp" @@ -21,70 +21,69 @@ namespace spatialdata { namespace spatialdb { class TestSCECCVMH; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata class spatialdata::spatialdb::TestSCECCVMH { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Test constructor. - static - void testConstructor(void); + static void testConstructor(void); /// Test accessors(). - static - void testAccessors(void); + static void testAccessors(void); /// Test getNamesDBValues(). - static - void testGetNamesDBValues(void); + static void testGetNamesDBValues(void); /// Test setQueryValues(). - static - void testQueryVals(void); + static void testQueryVals(void); /// Test calcDensity(). - static - void testCalcDensity(void); + static void testCalcDensity(void); /// Test calcVs(). - static - void testCalcVs(void); + static void testCalcVs(void); /// Test query(). - static - void testQuery(void); + static void testQuery(void); /// Test querySquashed(). - static - void testQuerySquashed(void); + static void testQuerySquashed(void); }; // class TestSCECCVMH // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestSCECCVMH::testConstructor", "[TestSCECCVMH]") { +TEST_CASE("TestSCECCVMH::testConstructor", + "[TestSCECCVMH]") { spatialdata::spatialdb::TestSCECCVMH::testConstructor(); } -TEST_CASE("TestSCECCVMH::testAccessors", "[TestSCECCVMH]") { +TEST_CASE("TestSCECCVMH::testAccessors", + "[TestSCECCVMH]") { spatialdata::spatialdb::TestSCECCVMH::testAccessors(); } -TEST_CASE("TestSCECCVMH::testGetNamesDBValues", "[TestSCECCVMH]") { +TEST_CASE("TestSCECCVMH::testGetNamesDBValues", + "[TestSCECCVMH]") { spatialdata::spatialdb::TestSCECCVMH::testGetNamesDBValues(); } -TEST_CASE("TestSCECCVMH::testQueryVals", "[TestSCECCVMH]") { +TEST_CASE("TestSCECCVMH::testQueryVals", + "[TestSCECCVMH]") { spatialdata::spatialdb::TestSCECCVMH::testQueryVals(); } -TEST_CASE("TestSCECCVMH::testQuery", "[TestSCECCVMH]") { +TEST_CASE("TestSCECCVMH::testQuery", + "[TestSCECCVMH]") { spatialdata::spatialdb::TestSCECCVMH::testQuery(); } -TEST_CASE("TestSCECCVMH::testQuerySquashed", "[TestSCECCVMH]") { +TEST_CASE("TestSCECCVMH::testQuerySquashed", + "[TestSCECCVMH]") { spatialdata::spatialdb::TestSCECCVMH::testQuerySquashed(); } -TEST_CASE("TestSCECCVMH::testCalcDensity", "[TestSCECCVMH]") { +TEST_CASE("TestSCECCVMH::testCalcDensity", + "[TestSCECCVMH]") { spatialdata::spatialdb::TestSCECCVMH::testCalcDensity(); } -TEST_CASE("TestSCECCVMH::testCalcVs", "[TestSCECCVMH]") { +TEST_CASE("TestSCECCVMH::testCalcVs", + "[TestSCECCVMH]") { spatialdata::spatialdb::TestSCECCVMH::testCalcVs(); } @@ -158,7 +157,8 @@ spatialdata::spatialdb::TestSCECCVMH::testGetNamesDBValues(void) { for (size_t i = 0; i < numValues; ++i) { CHECK(std::string(valueNamesE[i]) == std::string(valueNames[i])); } // for - delete[] valueNames;valueNames = NULL; + delete[] valueNames; + valueNames = NULL; numValues = 0; } // testGetDBValues @@ -171,24 +171,14 @@ spatialdata::spatialdb::TestSCECCVMH::testQueryVals(void) { { // all values const size_t querySize = 7; - const char* queryNames[7] = { - "moho-depth", - "topo-elev", - "vp-tag", - "Basement-Depth", - "vP", - "DenSity", - "VS" - }; - const size_t queryVals[7] = { - SCECCVMH::QUERY_MOHODEPTH, - SCECCVMH::QUERY_TOPOELEV, - SCECCVMH::QUERY_VPTAG, - SCECCVMH::QUERY_BASEDEPTH, - SCECCVMH::QUERY_VP, - SCECCVMH::QUERY_DENSITY, - SCECCVMH::QUERY_VS - }; + const char* queryNames[7] = {"moho-depth", "topo-elev", "vp-tag", "Basement-Depth", "vP", "DenSity", "VS"}; + const size_t queryVals[7] = {SCECCVMH::QUERY_MOHODEPTH, + SCECCVMH::QUERY_TOPOELEV, + SCECCVMH::QUERY_VPTAG, + SCECCVMH::QUERY_BASEDEPTH, + SCECCVMH::QUERY_VP, + SCECCVMH::QUERY_DENSITY, + SCECCVMH::QUERY_VS}; db.setQueryValues(queryNames, querySize); REQUIRE(querySize == db._querySize); @@ -199,16 +189,8 @@ spatialdata::spatialdb::TestSCECCVMH::testQueryVals(void) { { // subset of values const size_t querySize = 3; - const char* queryNames[3] = { - "Basement-Depth", - "vp-tag", - "VS" - }; - const size_t queryVals[3] = { - SCECCVMH::QUERY_BASEDEPTH, - SCECCVMH::QUERY_VPTAG, - SCECCVMH::QUERY_VS - }; + const char* queryNames[3] = {"Basement-Depth", "vp-tag", "VS"}; + const size_t queryVals[3] = {SCECCVMH::QUERY_BASEDEPTH, SCECCVMH::QUERY_VPTAG, SCECCVMH::QUERY_VS}; db.setQueryValues(queryNames, querySize); REQUIRE(querySize == db._querySize); @@ -277,7 +259,7 @@ spatialdata::spatialdb::TestSCECCVMH::testCalcVs(void) { 1860.0, }; const double vsE[10] = { - (1500.0-1360.0)/1.16, + (1500.0 - 1360.0) / 1.16, 3323.004705, 2584.759846, 2398.752778, @@ -329,84 +311,171 @@ spatialdata::spatialdb::TestSCECCVMH::testQuery(void) { const size_t numLocs = 18; const size_t spaceDim = 3; - const double lonlatelev[18*3] = { - -118.560000, 32.550000, -2450.00, - -118.513208, 33.884888, -1400.00, - -118.520000, 34.120000, -1400.00, - -116.400000, 32.340000, -1000.00, - -118.337765, 34.095691, -1770.00, - -118.337765, 34.095691, -17700.00, - -117.989344, 34.034148, -3000.00, - - -125.000000, 35.000000, -40000.0, // outside domain - -125.000000, 35.000000, -35000.0, - -125.000000, 35.000000, -28300.0, - -125.000000, 35.000000, -15000.0, - -125.000000, 35.000000, -4000.0, - -125.000000, 35.000000, 0.0, - - -115.000000, 30.000000, -800000.0, // outside domain - -115.000000, 30.000000, -4539.0, - - -117.989344, 34.034148, 5000.00, // above domain - -117.989344, 34.034148, -500000.0, // below domain - -117.682186, 34.357760, 1793.81, + const double lonlatelev[18 * 3] = { + -118.560000, 32.550000, -2450.00, -118.513208, 33.884888, -1400.00, -118.520000, 34.120000, + -1400.00, -116.400000, 32.340000, -1000.00, -118.337765, 34.095691, -1770.00, -118.337765, + 34.095691, -17700.00, -117.989344, 34.034148, -3000.00, + + -125.000000, 35.000000, -40000.0, // outside domain + -125.000000, 35.000000, -35000.0, -125.000000, 35.000000, -28300.0, -125.000000, 35.000000, + -15000.0, -125.000000, 35.000000, -4000.0, -125.000000, 35.000000, 0.0, + + -115.000000, 30.000000, -800000.0, // outside domain + -115.000000, 30.000000, -4539.0, + + -117.989344, 34.034148, 5000.00, // above domain + -117.989344, 34.034148, -500000.0, // below domain + -117.682186, 34.357760, 1793.81, }; const double tolerance = 1.0e-06; db.open(); { // all values const size_t querySize = 7; - const char* queryNames[7] = { - "moho-depth", - "topo-elev", - "vp-tag", - "Basement-Depth", - "vP", - "DenSity", - "VS" - }; - const double values[18*7] = { - -27991.001953, -1115.499268, 2.0, -1326.415405, 5560.209473, 3133.403158, 3333.334131, + const char* queryNames[7] = {"moho-depth", "topo-elev", "vp-tag", "Basement-Depth", "vP", "DenSity", "VS"}; + const double values[18 * 7] = { + -27991.001953, + -1115.499268, + 2.0, + -1326.415405, + 5560.209473, + 3133.403158, + 3333.334131, // -27991.00, -1115.50, 2.00, -1326.42, 5540.545410, 3126.848633, 3323.004705, - -27165.316406, -56.893856, 2.0, -1431.710449, 4384.126953, 2741.375651, 2584.759474, - -31178.105469, 489.975189, 2.0, 26.471289, 4142.553223, 2660.851074, 2398.752778, - -34526.414062, 801.209961, 2.0, 631.073059, 5226.578125, 3022.192708, 3148.777736, - -27857.322266, 106.671280, 3.0, -2361.386963, 4181.372070, 2673.790690, 2432.217302, - -27857.322266, 106.671280, 0.0, -2361.386963, 6351.574219, 3397.191406, 3707.466394, - -28512.111328, 93.515053, 2.0, -2860.919189, 4932.721191, 2924.240397, 2968.477965, - - -26312.804688, -50.465275, 1.0, -2875.716553, 7819.771973, 3886.590658, 4473.594442, - -26312.804688, -50.465275, 1.0, -2875.716553, 7800.935059, 3880.311686, 4459.966373, - -26312.804688, -50.465275, 0.0, -2875.716553, 6925.244140, 3588.414714, 3962.891997, - -26312.804688, -50.465275, 0.0, -2875.716553, 6585.769531, 3475.256510, 3810.172109, - -26312.804688, -50.465275, 0.0, -2875.716553, 6585.769531, 3475.256510, 3810.172109, - -26312.804688, -50.465275, 0.0, -2875.716553, 6585.769531, 3475.256510, 3810.172109, - - -26906.470703, 3.366069, 1.0, -973.515442, 7800.0, 3880.0, 4459.29424, - -26906.470703, 3.366069, 2.0, -973.515442, 6642.105469, 3494.035156, 3834.988779, - - -28512.111328, 93.515053, 0.0, -2860.919189, 6649.152832, 3496.384277, 3838.102107, - -28512.111328, 93.515053, 0.0, -2860.919189, 8159.479492, 3999.826497, 4751.5155415, - -34629.367188, 2266.779785, 2.0, 2001.1707764, 4491.211426, 2777.070475, 2664.4122143, - }; - const int flags[18] = { - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, - 0, 0, - 0 + -27165.316406, + -56.893856, + 2.0, + -1431.710449, + 4384.126953, + 2741.375651, + 2584.759474, + -31178.105469, + 489.975189, + 2.0, + 26.471289, + 4142.553223, + 2660.851074, + 2398.752778, + -34526.414062, + 801.209961, + 2.0, + 631.073059, + 5226.578125, + 3022.192708, + 3148.777736, + -27857.322266, + 106.671280, + 3.0, + -2361.386963, + 4181.372070, + 2673.790690, + 2432.217302, + -27857.322266, + 106.671280, + 0.0, + -2361.386963, + 6351.574219, + 3397.191406, + 3707.466394, + -28512.111328, + 93.515053, + 2.0, + -2860.919189, + 4932.721191, + 2924.240397, + 2968.477965, + + -26312.804688, + -50.465275, + 1.0, + -2875.716553, + 7819.771973, + 3886.590658, + 4473.594442, + -26312.804688, + -50.465275, + 1.0, + -2875.716553, + 7800.935059, + 3880.311686, + 4459.966373, + -26312.804688, + -50.465275, + 0.0, + -2875.716553, + 6925.244140, + 3588.414714, + 3962.891997, + -26312.804688, + -50.465275, + 0.0, + -2875.716553, + 6585.769531, + 3475.256510, + 3810.172109, + -26312.804688, + -50.465275, + 0.0, + -2875.716553, + 6585.769531, + 3475.256510, + 3810.172109, + -26312.804688, + -50.465275, + 0.0, + -2875.716553, + 6585.769531, + 3475.256510, + 3810.172109, + + -26906.470703, + 3.366069, + 1.0, + -973.515442, + 7800.0, + 3880.0, + 4459.29424, + -26906.470703, + 3.366069, + 2.0, + -973.515442, + 6642.105469, + 3494.035156, + 3834.988779, + + -28512.111328, + 93.515053, + 0.0, + -2860.919189, + 6649.152832, + 3496.384277, + 3838.102107, + -28512.111328, + 93.515053, + 0.0, + -2860.919189, + 8159.479492, + 3999.826497, + 4751.5155415, + -34629.367188, + 2266.779785, + 2.0, + 2001.1707764, + 4491.211426, + 2777.070475, + 2664.4122143, }; + const int flags[18] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; db.setQueryValues(queryNames, querySize); double data[querySize]; for (size_t iLoc = 0; iLoc < numLocs; ++iLoc) { - int err = db.query(data, querySize, &lonlatelev[iLoc*spaceDim], spaceDim, &cs); + int err = db.query(data, querySize, &lonlatelev[iLoc * spaceDim], spaceDim, &cs); REQUIRE(flags[iLoc] == err); for (size_t iVal = 0; iVal < querySize; ++iVal) { - const double dataE = values[iLoc*querySize+iVal]; + const double dataE = values[iLoc * querySize + iVal]; const double toleranceV = fabs(dataE) > 0.0 ? fabs(dataE) * tolerance : tolerance; CHECK_THAT(data[iVal], Catch::Matchers::WithinAbs(dataE, toleranceV)); } // for @@ -419,44 +488,23 @@ spatialdata::spatialdb::TestSCECCVMH::testQuery(void) { "DenSity", "vp-tag", }; - const double values[18*2] = { - 3133.403158, 2.0, - 2741.375651, 2.0, - 2660.851074, 2.0, - 3022.192708, 2.0, - 2673.790690, 3.0, - 3397.191406, 0.0, - 2924.240397, 2.0, - 3886.590657, 1.0, - 3880.311686, 1.0, - 3588.414714, 0.0, - 3475.256510, 0.0, - 3475.256510, 0.0, - 3475.256510, 0.0, - 3880.000000, 1.0, - 3494.035156, 2.0, - 3496.384277, 0.0, - 3999.826497, 0.0, - 2777.070475, 2.0, - }; - const int flags[18] = { - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, - 0, 0, - 0 + const double values[18 * 2] = { + 3133.403158, 2.0, 2741.375651, 2.0, 2660.851074, 2.0, 3022.192708, 2.0, 2673.790690, 3.0, 3397.191406, 0.0, + 2924.240397, 2.0, 3886.590657, 1.0, 3880.311686, 1.0, 3588.414714, 0.0, 3475.256510, 0.0, 3475.256510, 0.0, + 3475.256510, 0.0, 3880.000000, 1.0, 3494.035156, 2.0, 3496.384277, 0.0, 3999.826497, 0.0, 2777.070475, 2.0, }; + const int flags[18] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; db.setQueryValues(queryNames, querySize); double data[querySize]; for (size_t iLoc = 0; iLoc < numLocs; ++iLoc) { - int err = db.query(data, querySize, &lonlatelev[iLoc*spaceDim], spaceDim, &cs); + int err = db.query(data, querySize, &lonlatelev[iLoc * spaceDim], spaceDim, &cs); REQUIRE(flags[iLoc] == err); for (size_t iVal = 0; iVal < querySize; ++iVal) { - const double dataE = values[iLoc*querySize+iVal]; + const double dataE = values[iLoc * querySize + iVal]; const double toleranceV = fabs(dataE) > 0.0 ? fabs(dataE) * tolerance : tolerance; CHECK_THAT(data[iVal], Catch::Matchers::WithinAbs(dataE, toleranceV)); } // for @@ -468,7 +516,7 @@ spatialdata::spatialdb::TestSCECCVMH::testQuery(void) { const char* queryNames[1] = { "vs", }; - const double values[18*1] = { + const double values[18 * 1] = { 3333.334131, 2584.759474, 2398.752778, @@ -491,24 +539,18 @@ spatialdata::spatialdb::TestSCECCVMH::testQuery(void) { 4751.5155415, 2664.4122143, }; - const int flags[18] = { - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, - 0, 0, - 0 - }; + const int flags[18] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; db.setQueryValues(queryNames, querySize); double data[querySize]; for (size_t iLoc = 0; iLoc < numLocs; ++iLoc) { - int err = db.query(data, querySize, &lonlatelev[iLoc*spaceDim], spaceDim, &cs); + int err = db.query(data, querySize, &lonlatelev[iLoc * spaceDim], spaceDim, &cs); REQUIRE(flags[iLoc] == err); for (size_t iVal = 0; iVal < querySize; ++iVal) { - const double dataE = values[iLoc*querySize+iVal]; + const double dataE = values[iLoc * querySize + iVal]; const double toleranceV = fabs(dataE) > 0.0 ? fabs(dataE) * tolerance : tolerance; CHECK_THAT(data[iVal], Catch::Matchers::WithinAbs(dataE, toleranceV)); } // for @@ -531,74 +573,168 @@ spatialdata::spatialdb::TestSCECCVMH::testQuerySquashed(void) { const size_t numLocs = 18; const size_t spaceDim = 3; - const double lonlatelev[18*3] = { - -118.560000, 32.550000, -2450.00, - -118.513208, 33.884888, -1400.00+56.893856, - -118.520000, 34.120000, -1400.00-489.975189, - -116.400000, 32.340000, -1000.00-801.209961, - -118.337765, 34.095691, -1770.00-106.671280, - -118.337765, 34.095691, -17700.00, - -117.989344, 34.034148, -3000.00, - - -125.000000, 35.000000, -40000.0, // outside domain - -125.000000, 35.000000, -35000.0, - -125.000000, 35.000000, -28300.0, - -125.000000, 35.000000, -15000.0, - -125.000000, 35.000000, -4000.0, - -125.000000, 35.000000, 0.0-50.465275, - - -115.000000, 30.000000, -800000.0, // outside domain - -115.000000, 30.000000, -4539.0, - - -117.989344, 34.034148, 5000.00, // above domain - -117.989344, 34.034148, -500000.0, // below domain - -117.682186, 34.357760, 1793.81, + const double lonlatelev[18 * 3] = { + -118.560000, 32.550000, -2450.00, + -118.513208, 33.884888, -1400.00 + 56.893856, + -118.520000, 34.120000, -1400.00 - 489.975189, + -116.400000, 32.340000, -1000.00 - 801.209961, + -118.337765, 34.095691, -1770.00 - 106.671280, + -118.337765, 34.095691, -17700.00, + -117.989344, 34.034148, -3000.00, + + -125.000000, 35.000000, -40000.0, // outside domain + -125.000000, 35.000000, -35000.0, + -125.000000, 35.000000, -28300.0, + -125.000000, 35.000000, -15000.0, + -125.000000, 35.000000, -4000.0, + -125.000000, 35.000000, 0.0 - 50.465275, + + -115.000000, 30.000000, -800000.0, // outside domain + -115.000000, 30.000000, -4539.0, + + -117.989344, 34.034148, 5000.00, // above domain + -117.989344, 34.034148, -500000.0, // below domain + -117.682186, 34.357760, 1793.81, }; const double tolerance = 1.0e-06; db.open(); { // all values const int querySize = 7; - const char* queryNames[7] = { - "moho-depth", - "topo-elev", - "vp-tag", - "Basement-Depth", - "vP", - "DenSity", - "VS" - }; - const double values[18*7] = { - -27991.001953, -1115.499268, 2.0, -1326.415405, 5560.209473, 3133.403158, 3333.334131, + const char* queryNames[7] = {"moho-depth", "topo-elev", "vp-tag", "Basement-Depth", "vP", "DenSity", "VS"}; + const double values[18 * 7] = { + -27991.001953, + -1115.499268, + 2.0, + -1326.415405, + 5560.209473, + 3133.403158, + 3333.334131, // -27991.00, -1115.50, 2.00, -1326.42, 5540.545410, 3126.848633, 3323.004705, - -27165.316406, -56.893856, 2.0, -1431.710449, 4384.126953, 2741.375651, 2584.759474, - -31178.105469, 489.975189, 2.0, 26.471289, 4142.553223, 2660.851074, 2398.752778, - -34526.414062, 801.209961, 2.0, 631.073059, 5226.578125, 3022.192708, 3148.777736, - -27857.322266, 106.671280, 3.0, -2361.386963, 4181.372070, 2673.790690, 2432.217302, - -27857.322266, 106.671280, 0.0, -2361.386963, 6351.574219, 3397.191406, 3707.466394, - -28512.111328, 93.515053, 2.0, -2860.919189, 4932.721191, 2924.240397, 2968.477965, - - -26312.804688, -50.465275, 1.0, -2875.716553, 7819.771973, 3886.590658, 4473.594442, - -26312.804688, -50.465275, 1.0, -2875.716553, 7800.935059, 3880.311686, 4459.966373, - -26312.804688, -50.465275, 0.0, -2875.716553, 6925.244140, 3588.414714, 3962.891997, - -26312.804688, -50.465275, 0.0, -2875.716553, 6585.769531, 3475.256510, 3810.172109, - -26312.804688, -50.465275, 0.0, -2875.716553, 6585.769531, 3475.256510, 3810.172109, - -26312.804688, -50.465275, 0.0, -2875.716553, 6585.769531, 3475.256510, 3810.172109, - - -26906.470703, 3.36606908, 1.0, -973.515442, 7800.0, 3880.0, 4459.29424, - -26906.470703, 3.36606908, 2.0, -973.515442, 6642.105469, 3494.035156, 3834.988779, - - -28512.111328, 93.515053, 0.0, -2860.919189, 6649.152832, 3496.384277, 3838.102107, - -28512.111328, 93.515053, 0.0, -2860.919189, 8159.479492, 3999.826497, 4751.5155415, - -34629.367188, 2266.779785, 4.0, 2001.1707764, 3705.773438, 2515.257812, 2022.2184806, - }; - const int flags[18] = { - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, - 0, 0, - 0 + -27165.316406, + -56.893856, + 2.0, + -1431.710449, + 4384.126953, + 2741.375651, + 2584.759474, + -31178.105469, + 489.975189, + 2.0, + 26.471289, + 4142.553223, + 2660.851074, + 2398.752778, + -34526.414062, + 801.209961, + 2.0, + 631.073059, + 5226.578125, + 3022.192708, + 3148.777736, + -27857.322266, + 106.671280, + 3.0, + -2361.386963, + 4181.372070, + 2673.790690, + 2432.217302, + -27857.322266, + 106.671280, + 0.0, + -2361.386963, + 6351.574219, + 3397.191406, + 3707.466394, + -28512.111328, + 93.515053, + 2.0, + -2860.919189, + 4932.721191, + 2924.240397, + 2968.477965, + + -26312.804688, + -50.465275, + 1.0, + -2875.716553, + 7819.771973, + 3886.590658, + 4473.594442, + -26312.804688, + -50.465275, + 1.0, + -2875.716553, + 7800.935059, + 3880.311686, + 4459.966373, + -26312.804688, + -50.465275, + 0.0, + -2875.716553, + 6925.244140, + 3588.414714, + 3962.891997, + -26312.804688, + -50.465275, + 0.0, + -2875.716553, + 6585.769531, + 3475.256510, + 3810.172109, + -26312.804688, + -50.465275, + 0.0, + -2875.716553, + 6585.769531, + 3475.256510, + 3810.172109, + -26312.804688, + -50.465275, + 0.0, + -2875.716553, + 6585.769531, + 3475.256510, + 3810.172109, + + -26906.470703, + 3.36606908, + 1.0, + -973.515442, + 7800.0, + 3880.0, + 4459.29424, + -26906.470703, + 3.36606908, + 2.0, + -973.515442, + 6642.105469, + 3494.035156, + 3834.988779, + + -28512.111328, + 93.515053, + 0.0, + -2860.919189, + 6649.152832, + 3496.384277, + 3838.102107, + -28512.111328, + 93.515053, + 0.0, + -2860.919189, + 8159.479492, + 3999.826497, + 4751.5155415, + -34629.367188, + 2266.779785, + 4.0, + 2001.1707764, + 3705.773438, + 2515.257812, + 2022.2184806, }; + const int flags[18] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; db.setSquashFlag(true); db.setQueryValues(queryNames, querySize); @@ -606,11 +742,11 @@ spatialdata::spatialdb::TestSCECCVMH::testQuerySquashed(void) { double data[querySize]; for (size_t iLoc = 0; iLoc < numLocs; ++iLoc) { - int err = db.query(data, querySize, &lonlatelev[iLoc*spaceDim], spaceDim, &cs); + int err = db.query(data, querySize, &lonlatelev[iLoc * spaceDim], spaceDim, &cs); REQUIRE(flags[iLoc] == err); for (size_t iVal = 0; iVal < querySize; ++iVal) { - const double dataE = values[iLoc*querySize+iVal]; + const double dataE = values[iLoc * querySize + iVal]; const double toleranceV = fabs(dataE) > 0.0 ? fabs(dataE) * tolerance : tolerance; CHECK_THAT(data[iVal], Catch::Matchers::WithinAbs(dataE, toleranceV)); } // for diff --git a/tests/libtests/spatialdb/TestSimpleDB.cc b/tests/libtests/spatialdb/TestSimpleDB.cc index 8cb3490f..395ee352 100644 --- a/tests/libtests/spatialdb/TestSimpleDB.cc +++ b/tests/libtests/spatialdb/TestSimpleDB.cc @@ -37,8 +37,10 @@ spatialdata::spatialdb::TestSimpleDB::TestSimpleDB(TestSimpleDB_Data* data) : // ------------------------------------------------------------------------------------------------ // Deallocate test data; spatialdata::spatialdb::TestSimpleDB::~TestSimpleDB(void) { - delete _db;_db = NULL; - delete _data;_data = NULL; + delete _db; + _db = NULL; + delete _data; + _data = NULL; } // testDown @@ -90,7 +92,8 @@ spatialdata::spatialdb::TestSimpleDB::testGetNamesDBValues(void) { for (size_t i = 0; i < numValues; ++i) { CHECK(std::string(_data->names[i]) == std::string(valueNames[i])); } // for - delete[] valueNames;valueNames = NULL; + delete[] valueNames; + valueNames = NULL; numValues = 0; } // testGetDBValues @@ -157,10 +160,11 @@ spatialdata::spatialdb::TestSimpleDB::_checkQuery(const double* queryData, const char** queryNames = numValues > 0 ? new const char*[numValues] : NULL; for (size_t i = 0; i < numValues; ++i) { - queryNames[numValues-i-1] = _data->names[i]; + queryNames[numValues - i - 1] = _data->names[i]; } // for _db->setQueryValues(queryNames, numValues); - delete[] queryNames;queryNames = NULL; + delete[] queryNames; + queryNames = NULL; double* values = (numValues > 0) ? new double[numValues] : 0; const double tolerance = 1.0e-06; @@ -170,8 +174,8 @@ spatialdata::spatialdb::TestSimpleDB::_checkQuery(const double* queryData, const size_t locSize = spaceDim + numValues; spatialdata::geocoords::CSCart csCart; for (size_t iQuery = 0; iQuery < numQueries; ++iQuery) { - const double* coordinates = &queryData[iQuery*locSize]; - const double* valuesE = &queryData[iQuery*locSize+spaceDim]; + const double* coordinates = &queryData[iQuery * locSize]; + const double* valuesE = &queryData[iQuery * locSize + spaceDim]; const int err = _db->query(values, numValues, coordinates, spaceDim, &csCart); if (flagsE) { CHECK(flagsE[iQuery] == err); @@ -179,12 +183,13 @@ spatialdata::spatialdb::TestSimpleDB::_checkQuery(const double* queryData, CHECK(0 == err); } // if/else for (size_t iVal = 0; iVal < numValues; ++iVal) { - const double valueE = valuesE[numValues-iVal-1]; + const double valueE = valuesE[numValues - iVal - 1]; const double toleranceV = fabs(valueE) > 0.0 ? fabs(valueE) * tolerance : tolerance; CHECK_THAT(values[iVal], Catch::Matchers::WithinAbs(valueE, toleranceV)); } // for } // for - delete[] values;values = NULL; + delete[] values; + values = NULL; } // _checkQuery @@ -202,7 +207,8 @@ spatialdata::spatialdb::TestSimpleDB_Data::TestSimpleDB_Data(void) : units(NULL), queryNearest(NULL), queryLinear(NULL), - errFlags(NULL) {} + errFlags(NULL) { +} // ------------------------------------------------------------------------------------------------ diff --git a/tests/libtests/spatialdb/TestSimpleDB.hh b/tests/libtests/spatialdb/TestSimpleDB.hh index 51fc802a..e83083e5 100644 --- a/tests/libtests/spatialdb/TestSimpleDB.hh +++ b/tests/libtests/spatialdb/TestSimpleDB.hh @@ -17,14 +17,13 @@ namespace spatialdata { namespace spatialdb { class TestSimpleDB; class TestSimpleDB_Data; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata // ------------------------------------------------------------------------------------------------ class spatialdata::spatialdb::TestSimpleDB { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Constructor. TestSimpleDB(TestSimpleDB_Data* data); @@ -32,12 +31,10 @@ public: ~TestSimpleDB(void); /// Test constructors. - static - void testConstructors(void); + static void testConstructors(void); /// Test accessors. - static - void testAccessors(void); + static void testAccessors(void); /// Test getNamesDBValues(). void testGetNamesDBValues(void); @@ -48,23 +45,20 @@ public: /// Test queryLinear() void testQueryLinear(void); -protected: - + protected: // PROTECTED METHODS ////////////////////////////////////////////////////////////////////////// /// Populate database with data. void _initializeDB(void); -protected: - + protected: // PROTECTED MEMBERS ////////////////////////////////////////////////////////////////////////// SimpleDB* _db; ///< Test subject TestSimpleDB_Data* _data; ///< Data for tests. // PRIVATE METHODS //////////////////////////////////////////////////////////////////////////// -private: - + private: /** Test query method by doing query and checking values returned. * * @param queryData Query locations and expected values @@ -78,8 +72,7 @@ private: // ------------------------------------------------------------------------------------------------ class spatialdata::spatialdb::TestSimpleDB_Data { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Constructor TestSimpleDB_Data(void); @@ -87,8 +80,7 @@ public: ~TestSimpleDB_Data(void); // PUBLIC MEMBERS //////////////////////////////////////////////////////////////////////////// -public: - + public: size_t numLocs; size_t spaceDim; size_t numValues; @@ -103,7 +95,6 @@ public: const double* queryNearest; const double* queryLinear; const int* errFlags; - }; // End of file diff --git a/tests/libtests/spatialdb/TestSimpleDBData.cc b/tests/libtests/spatialdb/TestSimpleDBData.cc index 9022f1b8..8ec1e316 100644 --- a/tests/libtests/spatialdb/TestSimpleDBData.cc +++ b/tests/libtests/spatialdb/TestSimpleDBData.cc @@ -23,56 +23,55 @@ namespace spatialdata { namespace spatialdb { class TestSimpleDBData; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata class spatialdata::spatialdb::TestSimpleDBData { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Test constructor. - static - void testConstructor(void); + static void testConstructor(void); /// Test allocate(), getNumLocs(), numValues(), spaceDim(). - static - void testAllocate(void); + static void testAllocate(void); /// Test data() and dataDim(). - static - void testData(void); + static void testData(void); /// Test coordinates() - static - void testCoordinates(void); + static void testCoordinates(void); /// Test names() - static - void testNames(void); + static void testNames(void); /// Test units() - static - void testUnits(void); + static void testUnits(void); }; // class TestSimpleDBData // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestSimpleDBData::testConstructor", "[TestSimpleDBData]") { +TEST_CASE("TestSimpleDBData::testConstructor", + "[TestSimpleDBData]") { spatialdata::spatialdb::TestSimpleDBData::testConstructor(); } -TEST_CASE("TestSimpleDBData::testAllocate", "[TestSimpleDBData]") { +TEST_CASE("TestSimpleDBData::testAllocate", + "[TestSimpleDBData]") { spatialdata::spatialdb::TestSimpleDBData::testAllocate(); } -TEST_CASE("TestSimpleDBData::testData", "[TestSimpleDBData]") { +TEST_CASE("TestSimpleDBData::testData", + "[TestSimpleDBData]") { spatialdata::spatialdb::TestSimpleDBData::testData(); } -TEST_CASE("TestSimpleDBData::testCoordinates", "[TestSimpleDBData]") { +TEST_CASE("TestSimpleDBData::testCoordinates", + "[TestSimpleDBData]") { spatialdata::spatialdb::TestSimpleDBData::testCoordinates(); } -TEST_CASE("TestSimpleDBData::testNames", "[TestSimpleDBData]") { +TEST_CASE("TestSimpleDBData::testNames", + "[TestSimpleDBData]") { spatialdata::spatialdb::TestSimpleDBData::testNames(); } -TEST_CASE("TestSimpleDBData::testUnits", "[TestSimpleDBData]") { +TEST_CASE("TestSimpleDBData::testUnits", + "[TestSimpleDBData]") { spatialdata::spatialdb::TestSimpleDBData::testUnits(); } @@ -117,11 +116,15 @@ spatialdata::spatialdb::TestSimpleDBData::testData(void) { const size_t spaceDim = 3; const size_t dataDim = 1; - const double valuesE[numLocs*numValues] = { - 0.11, 0.21, - 0.12, 0.22, - 0.13, 0.23, - 0.14, 0.24, + const double valuesE[numLocs * numValues] = { + 0.11, + 0.21, + 0.12, + 0.22, + 0.13, + 0.23, + 0.14, + 0.24, }; SimpleDBData data; @@ -147,11 +150,19 @@ spatialdata::spatialdb::TestSimpleDBData::testCoordinates(void) { const size_t spaceDim = 3; const size_t dataDim = 1; - const double coordsE[numLocs*spaceDim] = { - 1.1, 2.1, 3.1, - 1.2, 2.2, 3.2, - 1.3, 2.3, 3.3, - 1.4, 2.4, 3.4, + const double coordsE[numLocs * spaceDim] = { + 1.1, + 2.1, + 3.1, + 1.2, + 2.2, + 3.2, + 1.3, + 2.3, + 3.3, + 1.4, + 2.4, + 3.4, }; SimpleDBData data; @@ -178,7 +189,8 @@ spatialdata::spatialdb::TestSimpleDBData::testNames(void) { const size_t dataDim = 1; const char* namesE[numValues] = { - "one", "two", + "one", + "two", }; SimpleDBData data; @@ -201,7 +213,8 @@ spatialdata::spatialdb::TestSimpleDBData::testUnits(void) { const size_t dataDim = 1; const char* unitsE[numValues] = { - "m", "m/s", + "m", + "m/s", }; SimpleDBData data; diff --git a/tests/libtests/spatialdb/TestSimpleDBQuery.cc b/tests/libtests/spatialdb/TestSimpleDBQuery.cc index 9a0f8a13..99a5491f 100644 --- a/tests/libtests/spatialdb/TestSimpleDBQuery.cc +++ b/tests/libtests/spatialdb/TestSimpleDBQuery.cc @@ -13,8 +13,8 @@ #include "TestSimpleDBQuery.hh" // Implementation of class methods #include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB -#include "spatialdata/spatialdb/SimpleDBQuery.hh" // USES SimpleDBQuery #include "spatialdata/spatialdb/SimpleDBData.hh" // USES SimpleDBData +#include "spatialdata/spatialdb/SimpleDBQuery.hh" // USES SimpleDBQuery #include "spatialdata/geocoords/CSCart.hh" // USE CSCart @@ -25,19 +25,23 @@ // ---------------------------------------------------------------------- // Constructor. -spatialdata::spatialdb::TestSimpleDBQuery::TestSimpleDBQuery(TestSimpleDBQuery_Data* data) : - _data(data) { - _db = new SimpleDB;assert(_db); - _query = new SimpleDBQuery(*_db);assert(_query); +spatialdata::spatialdb::TestSimpleDBQuery::TestSimpleDBQuery(TestSimpleDBQuery_Data* data) : _data(data) { + _db = new SimpleDB; + assert(_db); + _query = new SimpleDBQuery(*_db); + assert(_query); } // constructor // ---------------------------------------------------------------------- // Destructor. spatialdata::spatialdb::TestSimpleDBQuery::~TestSimpleDBQuery(void) { - delete _data;_data = NULL; - delete _db;_db = NULL; - delete _query;_query = NULL; + delete _data; + _data = NULL; + delete _db; + _db = NULL; + delete _query; + _query = NULL; } // destructor @@ -72,8 +76,8 @@ spatialdata::spatialdb::TestSimpleDBQuery::testQueryVals(void) { _initializeDB(); const size_t numNames = 3; - const char* names[3] = { "two", "one", "three" }; - const size_t queryIndices[3] = { 1, 0, 2 }; + const char* names[3] = {"two", "one", "three"}; + const size_t queryIndices[3] = {1, 0, 2}; assert(_query); _query->setQueryValues(names, numNames); @@ -93,7 +97,8 @@ spatialdata::spatialdb::TestSimpleDBQuery::testDistSquared(void) { assert(_data->numPoints >= 2); const size_t spaceDim = _data->spaceDim; - const double dist2 = SimpleDBQuery::_distSquared(&_data->coordinates[0*spaceDim], &_data->coordinates[1*spaceDim]); + const double dist2 = + SimpleDBQuery::_distSquared(&_data->coordinates[0 * spaceDim], &_data->coordinates[1 * spaceDim]); const double tolerance = 1.0e-06; const double toleranceV = fabs(_data->dist2) > 0.0 ? fabs(_data->dist2) * tolerance : tolerance; CHECK_THAT(dist2, Catch::Matchers::WithinAbs(_data->dist2, toleranceV)); @@ -108,15 +113,18 @@ spatialdata::spatialdb::TestSimpleDBQuery::testArea(void) { assert(_data); const size_t spaceDim = _data->spaceDim; - if (spaceDim < 2) { return; } + if (spaceDim < 2) { + return; + } assert(_data->numPoints >= 3); double area = 0; double areaDir[3]; - SimpleDBQuery::_area(&area, areaDir, - &_data->coordinates[0*spaceDim], - &_data->coordinates[1*spaceDim], - &_data->coordinates[2*spaceDim]); + SimpleDBQuery::_area(&area, + areaDir, + &_data->coordinates[0 * spaceDim], + &_data->coordinates[1 * spaceDim], + &_data->coordinates[2 * spaceDim]); const double tolerance = 1.0e-06; double toleranceV = fabs(_data->area) > 0.0 ? fabs(_data->area) * tolerance : tolerance; CHECK_THAT(area, Catch::Matchers::WithinAbs(_data->area, toleranceV)); @@ -135,14 +143,15 @@ spatialdata::spatialdb::TestSimpleDBQuery::testVolume(void) { assert(_data); const size_t spaceDim = _data->spaceDim; - if (spaceDim < 3) { return; } + if (spaceDim < 3) { + return; + } assert(_data->numPoints >= 4); - const double volume = - SimpleDBQuery::_volume(&_data->coordinates[0*spaceDim], - &_data->coordinates[1*spaceDim], - &_data->coordinates[2*spaceDim], - &_data->coordinates[3*spaceDim]); + const double volume = SimpleDBQuery::_volume(&_data->coordinates[0 * spaceDim], + &_data->coordinates[1 * spaceDim], + &_data->coordinates[2 * spaceDim], + &_data->coordinates[3 * spaceDim]); const double tolerance = 1.0e-06; const double toleranceV = fabs(_data->volume) > 0.0 ? fabs(_data->volume) * tolerance : tolerance; CHECK_THAT(volume, Catch::Matchers::WithinAbs(_data->volume, toleranceV)); @@ -155,15 +164,19 @@ void spatialdata::spatialdb::TestSimpleDBQuery::_initializeDB(void) { assert(_data); - SimpleDBData* dbData = new SimpleDBData;assert(dbData); + SimpleDBData* dbData = new SimpleDBData; + assert(dbData); dbData->allocate(_data->numLocs, _data->numValues, _data->spaceDim, _data->dataDim); dbData->setData(_data->dbValues, _data->numLocs, _data->numValues); dbData->setCoordinates(_data->dbCoordinates, _data->numLocs, _data->spaceDim); dbData->setNames(_data->names, _data->numValues); dbData->setUnits(_data->units, _data->numValues); - delete _db->_data;_db->_data = dbData; - delete _db->_cs;_db->_cs = new spatialdata::geocoords::CSCart;assert(_db->_cs); + delete _db->_data; + _db->_data = dbData; + delete _db->_cs; + _db->_cs = new spatialdata::geocoords::CSCart; + assert(_db->_cs); } // _initializeDB @@ -182,7 +195,8 @@ spatialdata::spatialdb::TestSimpleDBQuery_Data::TestSimpleDBQuery_Data(void) : coordinates(NULL), dist2(0.0), areaDir(NULL), - volume(0.0) {} + volume(0.0) { +} // ---------------------------------------------------------------------- diff --git a/tests/libtests/spatialdb/TestSimpleDBQuery.hh b/tests/libtests/spatialdb/TestSimpleDBQuery.hh index 4ae0b764..40d28aca 100644 --- a/tests/libtests/spatialdb/TestSimpleDBQuery.hh +++ b/tests/libtests/spatialdb/TestSimpleDBQuery.hh @@ -18,14 +18,13 @@ namespace spatialdata { namespace spatialdb { class TestSimpleDBQuery; class TestSimpleDBQuery_Data; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata // ------------------------------------------------------------------------------------------------ class spatialdata::spatialdb::TestSimpleDBQuery { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Constructor. TestSimpleDBQuery(TestSimpleDBQuery_Data* data); @@ -51,14 +50,12 @@ public: void testVolume(void); // PROTECTED MEMBERS ////////////////////////////////////////////////////////////////////////// -protected: - + protected: /// Populdate database with values. void _initializeDB(void); // PROTECTED MEMBERS ////////////////////////////////////////////////////////////////////////// -protected: - + protected: SimpleDB* _db; ///< Database for test subject. SimpleDBQuery* _query; ///< Test subject. TestSimpleDBQuery_Data* _data; ///< Test data. @@ -68,8 +65,7 @@ protected: // ------------------------------------------------------------------------------------------------ class spatialdata::spatialdb::TestSimpleDBQuery_Data { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Constructor TestSimpleDBQuery_Data(void); @@ -77,8 +73,7 @@ public: ~TestSimpleDBQuery_Data(void); // PUBLIC MEMBERS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// @name Database information //@{ size_t numLocs; ///< Number of locations in database. diff --git a/tests/libtests/spatialdb/TestSimpleDBQuery_Cases.cc b/tests/libtests/spatialdb/TestSimpleDBQuery_Cases.cc index 2bdbc934..032ef0a8 100644 --- a/tests/libtests/spatialdb/TestSimpleDBQuery_Cases.cc +++ b/tests/libtests/spatialdb/TestSimpleDBQuery_Cases.cc @@ -20,43 +20,52 @@ namespace spatialdata { namespace spatialdb { class TestSimpleDBQuery_3D; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata // ------------------------------------------------------------------------------------------------ class spatialdata::spatialdb::TestSimpleDBQuery_3D { -public: - + public: // Factory methods - static - TestSimpleDBQuery_Data* createData(void); + static TestSimpleDBQuery_Data* createData(void); }; // TestSimpleDBQuery_3D // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestSimpleDBQuery::testConstructor", "[TestSimpleDBQuery][3D]") { - spatialdata::spatialdb::TestSimpleDBQuery(spatialdata::spatialdb::TestSimpleDBQuery_3D::createData()).testConstructor(); +TEST_CASE("TestSimpleDBQuery::testConstructor", + "[TestSimpleDBQuery][3D]") { + spatialdata::spatialdb::TestSimpleDBQuery(spatialdata::spatialdb::TestSimpleDBQuery_3D::createData()) + .testConstructor(); } -TEST_CASE("TestSimpleDBQuery::testAccessors", "[TestSimpleDBQuery][3D]") { - spatialdata::spatialdb::TestSimpleDBQuery(spatialdata::spatialdb::TestSimpleDBQuery_3D::createData()).testAccessors(); +TEST_CASE("TestSimpleDBQuery::testAccessors", + "[TestSimpleDBQuery][3D]") { + spatialdata::spatialdb::TestSimpleDBQuery(spatialdata::spatialdb::TestSimpleDBQuery_3D::createData()) + .testAccessors(); } -TEST_CASE("TestSimpleDBQuery::testQueryVals", "[TestSimpleDBQuery][3D]") { - spatialdata::spatialdb::TestSimpleDBQuery(spatialdata::spatialdb::TestSimpleDBQuery_3D::createData()).testQueryVals(); +TEST_CASE("TestSimpleDBQuery::testQueryVals", + "[TestSimpleDBQuery][3D]") { + spatialdata::spatialdb::TestSimpleDBQuery(spatialdata::spatialdb::TestSimpleDBQuery_3D::createData()) + .testQueryVals(); } -TEST_CASE("TestSimpleDBQuery::testDistSquared", "[TestSimpleDBQuery][3D]") { - spatialdata::spatialdb::TestSimpleDBQuery(spatialdata::spatialdb::TestSimpleDBQuery_3D::createData()).testDistSquared(); +TEST_CASE("TestSimpleDBQuery::testDistSquared", + "[TestSimpleDBQuery][3D]") { + spatialdata::spatialdb::TestSimpleDBQuery(spatialdata::spatialdb::TestSimpleDBQuery_3D::createData()) + .testDistSquared(); } -TEST_CASE("TestSimpleDBQuery::testArea", "[TestSimpleDBQuery][3D]") { +TEST_CASE("TestSimpleDBQuery::testArea", + "[TestSimpleDBQuery][3D]") { spatialdata::spatialdb::TestSimpleDBQuery(spatialdata::spatialdb::TestSimpleDBQuery_3D::createData()).testArea(); } -TEST_CASE("TestSimpleDBQuery::testVolume", "[TestSimpleDBQuery][3D]") { +TEST_CASE("TestSimpleDBQuery::testVolume", + "[TestSimpleDBQuery][3D]") { spatialdata::spatialdb::TestSimpleDBQuery(spatialdata::spatialdb::TestSimpleDBQuery_3D::createData()).testVolume(); } // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestSimpleDBQuery_Data* spatialdata::spatialdb::TestSimpleDBQuery_3D::createData(void) { - spatialdata::spatialdb::TestSimpleDBQuery_Data* data = new TestSimpleDBQuery_Data;assert(data); + spatialdata::spatialdb::TestSimpleDBQuery_Data* data = new TestSimpleDBQuery_Data; + assert(data); data->numLocs = 5; data->spaceDim = 3; @@ -68,21 +77,41 @@ spatialdata::spatialdb::TestSimpleDBQuery_3D::createData(void) { data->area = 7.28666752e+00; data->volume = 2.95458000e+00; - static const double dbCoordinates[5*3] = { - 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, - 1.00000000e+00, 1.00000000e-01, 3.00000000e-01, - 2.00000000e+00, 2.00000000e-01, 2.00000000e-01, - 3.00000000e+00, 3.00000000e-01, 1.00000000e-01, - 4.00000000e+00, 4.00000000e-01, 9.00000000e-01, + static const double dbCoordinates[5 * 3] = { + 0.00000000e+00, + 0.00000000e+00, + 0.00000000e+00, + 1.00000000e+00, + 1.00000000e-01, + 3.00000000e-01, + 2.00000000e+00, + 2.00000000e-01, + 2.00000000e-01, + 3.00000000e+00, + 3.00000000e-01, + 1.00000000e-01, + 4.00000000e+00, + 4.00000000e-01, + 9.00000000e-01, }; data->dbCoordinates = dbCoordinates; - static const double dbValues[5*3] = { - 1.1, 5.5, 3.4, - 2.2, 6.6, 4.5, - 3.3, 7.7, 5.6, - 4.4, 8.8, 6.7, - 4.5, 9.9, 7.8, + static const double dbValues[5 * 3] = { + 1.1, + 5.5, + 3.4, + 2.2, + 6.6, + 4.5, + 3.3, + 7.7, + 5.6, + 4.4, + 8.8, + 6.7, + 4.5, + 9.9, + 7.8, }; data->dbValues = dbValues; @@ -100,16 +129,26 @@ spatialdata::spatialdb::TestSimpleDBQuery_3D::createData(void) { }; data->units = units; - static const double coordinates[4*3] = { - 2.95000000e+00, 4.48000000e+00, 3.44000000e+00, - 5.80000000e+00, 5.32000000e+00, 4.46000000e+00, - 7.97000000e+00, 1.06200000e+01, 7.00000000e+00, - 8.38000000e+00, 1.30100000e+01, 9.34000000e+00, + static const double coordinates[4 * 3] = { + 2.95000000e+00, + 4.48000000e+00, + 3.44000000e+00, + 5.80000000e+00, + 5.32000000e+00, + 4.46000000e+00, + 7.97000000e+00, + 1.06200000e+01, + 7.00000000e+00, + 8.38000000e+00, + 1.30100000e+01, + 9.34000000e+00, }; data->coordinates = coordinates; static const double areaDir[3] = { - -2.24547092e-01, -3.44848999e-01, 9.11404285e-01, + -2.24547092e-01, + -3.44848999e-01, + 9.11404285e-01, }; data->areaDir = areaDir; diff --git a/tests/libtests/spatialdb/TestSimpleDB_Cases.cc b/tests/libtests/spatialdb/TestSimpleDB_Cases.cc index 965079c3..520e39bc 100644 --- a/tests/libtests/spatialdb/TestSimpleDB_Cases.cc +++ b/tests/libtests/spatialdb/TestSimpleDB_Cases.cc @@ -20,82 +20,92 @@ namespace spatialdata { namespace spatialdb { class TestSimpleDB_Cases; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata class spatialdata::spatialdb::TestSimpleDB_Cases { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: // Factories - static - TestSimpleDB_Data* Point3D(void); + static TestSimpleDB_Data* Point3D(void); - static - TestSimpleDB_Data* Line3D(void); + static TestSimpleDB_Data* Line3D(void); - static - TestSimpleDB_Data* Area3D(void); + static TestSimpleDB_Data* Area3D(void); - static - TestSimpleDB_Data* Volume3D(void); + static TestSimpleDB_Data* Volume3D(void); }; // class TestSimpleDB // ------------------------------------------------------------------------------------------------ // Static test cases -TEST_CASE("TestSimpleDB::testConstructors", "[TestSimpleDB]") { +TEST_CASE("TestSimpleDB::testConstructors", + "[TestSimpleDB]") { spatialdata::spatialdb::TestSimpleDB::testConstructors(); } -TEST_CASE("TestSimpleDB::testAccessors", "[TestSimpleDB]") { +TEST_CASE("TestSimpleDB::testAccessors", + "[TestSimpleDB]") { spatialdata::spatialdb::TestSimpleDB::testAccessors(); } // Data test cases -TEST_CASE("TestSimpleDB::testGetNamesDBValues", "[TestSimpleDB][Point3D]") { +TEST_CASE("TestSimpleDB::testGetNamesDBValues", + "[TestSimpleDB][Point3D]") { spatialdata::spatialdb::TestSimpleDB(spatialdata::spatialdb::TestSimpleDB_Cases::Point3D()).testGetNamesDBValues(); } -TEST_CASE("TestSimpleDB::testQueryNearest", "[TestSimpleDB][Point3D]") { +TEST_CASE("TestSimpleDB::testQueryNearest", + "[TestSimpleDB][Point3D]") { spatialdata::spatialdb::TestSimpleDB(spatialdata::spatialdb::TestSimpleDB_Cases::Point3D()).testQueryNearest(); } -TEST_CASE("TestSimpleDB::testQueryLinear", "[TestSimpleDB][Point3D]") { +TEST_CASE("TestSimpleDB::testQueryLinear", + "[TestSimpleDB][Point3D]") { spatialdata::spatialdb::TestSimpleDB(spatialdata::spatialdb::TestSimpleDB_Cases::Point3D()).testQueryLinear(); } -TEST_CASE("TestSimpleDB::testGetNamesDBValues", "[TestSimpleDB][Line3D]") { +TEST_CASE("TestSimpleDB::testGetNamesDBValues", + "[TestSimpleDB][Line3D]") { spatialdata::spatialdb::TestSimpleDB(spatialdata::spatialdb::TestSimpleDB_Cases::Line3D()).testGetNamesDBValues(); } -TEST_CASE("TestSimpleDB::testQueryNearest", "[TestSimpleDB][Line3D]") { +TEST_CASE("TestSimpleDB::testQueryNearest", + "[TestSimpleDB][Line3D]") { spatialdata::spatialdb::TestSimpleDB(spatialdata::spatialdb::TestSimpleDB_Cases::Line3D()).testQueryNearest(); } -TEST_CASE("TestSimpleDB::testQueryLinear", "[TestSimpleDB][Line3D]") { +TEST_CASE("TestSimpleDB::testQueryLinear", + "[TestSimpleDB][Line3D]") { spatialdata::spatialdb::TestSimpleDB(spatialdata::spatialdb::TestSimpleDB_Cases::Line3D()).testQueryLinear(); } -TEST_CASE("TestSimpleDB::testGetNamesDBValues", "[TestSimpleDB][Area3D]") { +TEST_CASE("TestSimpleDB::testGetNamesDBValues", + "[TestSimpleDB][Area3D]") { spatialdata::spatialdb::TestSimpleDB(spatialdata::spatialdb::TestSimpleDB_Cases::Area3D()).testGetNamesDBValues(); } -TEST_CASE("TestSimpleDB::testQueryNearest", "[TestSimpleDB][Area3D]") { +TEST_CASE("TestSimpleDB::testQueryNearest", + "[TestSimpleDB][Area3D]") { spatialdata::spatialdb::TestSimpleDB(spatialdata::spatialdb::TestSimpleDB_Cases::Area3D()).testQueryNearest(); } -TEST_CASE("TestSimpleDB::testQueryLinear", "[TestSimpleDB][Area3D]") { +TEST_CASE("TestSimpleDB::testQueryLinear", + "[TestSimpleDB][Area3D]") { spatialdata::spatialdb::TestSimpleDB(spatialdata::spatialdb::TestSimpleDB_Cases::Area3D()).testQueryLinear(); } -TEST_CASE("TestSimpleDB::testGetNamesDBValues", "[TestSimpleDB][Volume3D]") { +TEST_CASE("TestSimpleDB::testGetNamesDBValues", + "[TestSimpleDB][Volume3D]") { spatialdata::spatialdb::TestSimpleDB(spatialdata::spatialdb::TestSimpleDB_Cases::Volume3D()).testGetNamesDBValues(); } -TEST_CASE("TestSimpleDB::testQueryNearest", "[TestSimpleDB][Volume3D]") { +TEST_CASE("TestSimpleDB::testQueryNearest", + "[TestSimpleDB][Volume3D]") { spatialdata::spatialdb::TestSimpleDB(spatialdata::spatialdb::TestSimpleDB_Cases::Volume3D()).testQueryNearest(); } -TEST_CASE("TestSimpleDB::testQueryLinear", "[TestSimpleDB][Volume3D]") { +TEST_CASE("TestSimpleDB::testQueryLinear", + "[TestSimpleDB][Volume3D]") { spatialdata::spatialdb::TestSimpleDB(spatialdata::spatialdb::TestSimpleDB_Cases::Volume3D()).testQueryLinear(); } // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestSimpleDB_Data* spatialdata::spatialdb::TestSimpleDB_Cases::Point3D(void) { - spatialdata::spatialdb::TestSimpleDB_Data* data = new TestSimpleDB_Data;assert(data); + spatialdata::spatialdb::TestSimpleDB_Data* data = new TestSimpleDB_Data; + assert(data); data->numLocs = 1; data->spaceDim = 3; @@ -104,12 +114,15 @@ spatialdata::spatialdb::TestSimpleDB_Cases::Point3D(void) { data->numQueries = 3; static const double dbCoordinates[3] = { - 1.00000000e-01, 2.00000000e-01, 3.00000000e-01, + 1.00000000e-01, + 2.00000000e-01, + 3.00000000e-01, }; data->dbCoordinates = dbCoordinates; static const double dbValues[2] = { - 6.30000000e+00, 7.40000000e+00, + 6.30000000e+00, + 7.40000000e+00, }; data->dbValues = dbValues; @@ -125,22 +138,49 @@ spatialdata::spatialdb::TestSimpleDB_Cases::Point3D(void) { }; data->units = units; - static const double queryNearest[3*(3+2)] = { - 4.50000000e+00, 2.30000000e+00, 4.00000000e+00, 6.30000000e+00, 7.40000000e+00, - 3.20000000e+00, 7.40000000e+00, 5.80000000e+00, 6.30000000e+00, 7.40000000e+00, - 4.00000000e+00, 9.80000000e+00, 5.70000000e+00, 6.30000000e+00, 7.40000000e+00, + static const double queryNearest[3 * (3 + 2)] = { + 4.50000000e+00, + 2.30000000e+00, + 4.00000000e+00, + 6.30000000e+00, + 7.40000000e+00, + 3.20000000e+00, + 7.40000000e+00, + 5.80000000e+00, + 6.30000000e+00, + 7.40000000e+00, + 4.00000000e+00, + 9.80000000e+00, + 5.70000000e+00, + 6.30000000e+00, + 7.40000000e+00, }; data->queryNearest = queryNearest; - static const double queryLinear[3*(3+2)] = { - 2.90000000e+00, 3.40000000e+00, 8.70000000e+00, 6.30000000e+00, 7.40000000e+00, - 2.20000000e+00, 9.00000000e+00, 8.50000000e+00, 6.30000000e+00, 7.40000000e+00, - 2.00000000e-01, 5.80000000e+00, 6.60000000e+00, 6.30000000e+00, 7.40000000e+00, + static const double queryLinear[3 * (3 + 2)] = { + 2.90000000e+00, + 3.40000000e+00, + 8.70000000e+00, + 6.30000000e+00, + 7.40000000e+00, + 2.20000000e+00, + 9.00000000e+00, + 8.50000000e+00, + 6.30000000e+00, + 7.40000000e+00, + 2.00000000e-01, + 5.80000000e+00, + 6.60000000e+00, + 6.30000000e+00, + 7.40000000e+00, }; data->queryLinear = queryLinear; static const int errFlags[3] = { - 0, 0, 0,}; + 0, + 0, + 0, + }; data->errFlags = errFlags; return data; @@ -150,7 +190,8 @@ spatialdata::spatialdb::TestSimpleDB_Cases::Point3D(void) { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestSimpleDB_Data* spatialdata::spatialdb::TestSimpleDB_Cases::Line3D(void) { - spatialdata::spatialdb::TestSimpleDB_Data* data = new TestSimpleDB_Data;assert(data); + spatialdata::spatialdb::TestSimpleDB_Data* data = new TestSimpleDB_Data; + assert(data); data->numLocs = 5; data->spaceDim = 3; @@ -158,21 +199,36 @@ spatialdata::spatialdb::TestSimpleDB_Cases::Line3D(void) { data->dataDim = 1; data->numQueries = 4; - static const double dbCoordinates[5*3] = { - 3.40000000e+00, 9.50000000e+00, 8.70000000e+00, - 5.70000000e+00, 9.90000000e+00, 1.85000000e+01, - 6.85000000e+00, 1.01000000e+01, 2.34000000e+01, - 8.00000000e+00, 1.03000000e+01, 2.83000000e+01, - 1.49000000e+01, 1.15000000e+01, 5.77000000e+01, + static const double dbCoordinates[5 * 3] = { + 3.40000000e+00, + 9.50000000e+00, + 8.70000000e+00, + 5.70000000e+00, + 9.90000000e+00, + 1.85000000e+01, + 6.85000000e+00, + 1.01000000e+01, + 2.34000000e+01, + 8.00000000e+00, + 1.03000000e+01, + 2.83000000e+01, + 1.49000000e+01, + 1.15000000e+01, + 5.77000000e+01, }; data->dbCoordinates = dbCoordinates; - static const double dbValues[5*2] = { - 1.00000000e-01, 1.10000000e+00, - 3.00000000e-01, 3.30000000e+00, - 2.00000000e-01, 2.20000000e+00, - 1.00000000e-01, 1.10000000e+00, - -4.00000000e-01, -4.40000000e+00, + static const double dbValues[5 * 2] = { + 1.00000000e-01, + 1.10000000e+00, + 3.00000000e-01, + 3.30000000e+00, + 2.00000000e-01, + 2.20000000e+00, + 1.00000000e-01, + 1.10000000e+00, + -4.00000000e-01, + -4.40000000e+00, }; data->dbValues = dbValues; @@ -188,24 +244,28 @@ spatialdata::spatialdb::TestSimpleDB_Cases::Line3D(void) { }; data->units = units; - static const double queryNearest[4*(3+2)] = { - 5.70000000e+00, 9.90000000e+00, 1.85000000e+01, 3.00000000e-01, 3.30000000e+00, - 1.26000000e+01, 1.11000000e+01, 4.79000000e+01, -4.00000000e-01, -4.40000000e+00, - 1.72000000e+01, 1.19000000e+01, 6.75000000e+01, -4.00000000e-01, -4.40000000e+00, - 6.16000000e+00, 9.98000000e+00, 2.04600000e+01, 3.00000000e-01, 3.30000000e+00, + static const double queryNearest[4 * (3 + 2)] = { + 5.70000000e+00, 9.90000000e+00, 1.85000000e+01, 3.00000000e-01, 3.30000000e+00, + 1.26000000e+01, 1.11000000e+01, 4.79000000e+01, -4.00000000e-01, -4.40000000e+00, + 1.72000000e+01, 1.19000000e+01, 6.75000000e+01, -4.00000000e-01, -4.40000000e+00, + 6.16000000e+00, 9.98000000e+00, 2.04600000e+01, 3.00000000e-01, 3.30000000e+00, }; data->queryNearest = queryNearest; - static const double queryLinear[4*(3+2)] = { - 5.70000000e+00, 9.90000000e+00, 1.85000000e+01, 3.00000000e-01, 3.30000000e+00, - 1.26000000e+01, 1.11000000e+01, 4.79000000e+01, -2.33333333e-01, -2.56666667e+00, - 1.72000000e+01, 1.19000000e+01, 6.75000000e+01, 0.00000000e+00, 0.00000000e+00, - 6.16000000e+00, 9.98000000e+00, 2.04600000e+01, 2.60000000e-01, 2.86000000e+00, + static const double queryLinear[4 * (3 + 2)] = { + 5.70000000e+00, 9.90000000e+00, 1.85000000e+01, 3.00000000e-01, 3.30000000e+00, + 1.26000000e+01, 1.11000000e+01, 4.79000000e+01, -2.33333333e-01, -2.56666667e+00, + 1.72000000e+01, 1.19000000e+01, 6.75000000e+01, 0.00000000e+00, 0.00000000e+00, + 6.16000000e+00, 9.98000000e+00, 2.04600000e+01, 2.60000000e-01, 2.86000000e+00, }; data->queryLinear = queryLinear; static const int errFlags[4] = { - 0, 0, 1, 0,}; + 0, + 0, + 1, + 0, + }; data->errFlags = errFlags; return data; @@ -215,7 +275,8 @@ spatialdata::spatialdb::TestSimpleDB_Cases::Line3D(void) { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestSimpleDB_Data* spatialdata::spatialdb::TestSimpleDB_Cases::Area3D(void) { - spatialdata::spatialdb::TestSimpleDB_Data* data = new TestSimpleDB_Data;assert(data); + spatialdata::spatialdb::TestSimpleDB_Data* data = new TestSimpleDB_Data; + assert(data); data->numLocs = 6; data->spaceDim = 3; @@ -223,23 +284,41 @@ spatialdata::spatialdb::TestSimpleDB_Cases::Area3D(void) { data->dataDim = 2; data->numQueries = 4; - static const double dbCoordinates[6*3] = { - 3.40000000e+00, 9.50000000e+00, 8.70000000e+00, - 4.29442719e+00, 9.50000000e+00, 9.14721360e+00, - 6.97770876e+00, 9.50000000e+00, 1.04888544e+01, - 7.63236243e+00, 1.21186147e+01, 9.17954704e+00, - 3.83643578e+00, 1.12457431e+01, 7.82712844e+00, - 4.05465367e+00, 1.21186147e+01, 7.39069266e+00, + static const double dbCoordinates[6 * 3] = { + 3.40000000e+00, + 9.50000000e+00, + 8.70000000e+00, + 4.29442719e+00, + 9.50000000e+00, + 9.14721360e+00, + 6.97770876e+00, + 9.50000000e+00, + 1.04888544e+01, + 7.63236243e+00, + 1.21186147e+01, + 9.17954704e+00, + 3.83643578e+00, + 1.12457431e+01, + 7.82712844e+00, + 4.05465367e+00, + 1.21186147e+01, + 7.39069266e+00, }; data->dbCoordinates = dbCoordinates; - static const double dbValues[6*2] = { - 1.00000000e-01, 1.10000000e+00, - 3.00000000e-01, 3.30000000e+00, - 2.00000000e-01, 2.20000000e+00, - 1.00000000e-01, 1.10000000e+00, - -4.00000000e-01, -4.40000000e+00, - -3.00000000e-01, -3.20000000e+00, + static const double dbValues[6 * 2] = { + 1.00000000e-01, + 1.10000000e+00, + 3.00000000e-01, + 3.30000000e+00, + 2.00000000e-01, + 2.20000000e+00, + 1.00000000e-01, + 1.10000000e+00, + -4.00000000e-01, + -4.40000000e+00, + -3.00000000e-01, + -3.20000000e+00, }; data->dbValues = dbValues; @@ -255,24 +334,28 @@ spatialdata::spatialdb::TestSimpleDB_Cases::Area3D(void) { }; data->units = units; - static const double queryNearest[4*(3+2)] = { - 6.30149946e+00, 1.03728716e+01, 9.60520501e+00, 2.00000000e-01, 2.20000000e+00, - 3.78727022e+00, 1.01546537e+01, 8.48447656e+00, 1.00000000e-01, 1.10000000e+00, - 6.95615313e+00, 1.29914862e+01, 8.29589766e+00, 1.00000000e-01, 1.10000000e+00, - 4.89452639e+00, 1.19003968e+01, 7.94701520e+00, -3.00000000e-01, -3.20000000e+00, + static const double queryNearest[4 * (3 + 2)] = { + 6.30149946e+00, 1.03728716e+01, 9.60520501e+00, 2.00000000e-01, 2.20000000e+00, + 3.78727022e+00, 1.01546537e+01, 8.48447656e+00, 1.00000000e-01, 1.10000000e+00, + 6.95615313e+00, 1.29914862e+01, 8.29589766e+00, 1.00000000e-01, 1.10000000e+00, + 4.89452639e+00, 1.19003968e+01, 7.94701520e+00, -3.00000000e-01, -3.20000000e+00, }; data->queryNearest = queryNearest; - static const double queryLinear[4*(3+2)] = { - 6.30149946e+00, 1.03728716e+01, 9.60520501e+00, 2.00000000e-01, 2.20000000e+00, - 3.78727022e+00, 1.01546537e+01, 8.48447656e+00, -3.75000000e-02, -4.12500000e-01, - 6.95615313e+00, 1.29914862e+01, 8.29589766e+00, 0.00000000e+00, 0.00000000e+00, - 4.89452639e+00, 1.19003968e+01, 7.94701520e+00, -2.25000000e-01, -2.42500000e+00, + static const double queryLinear[4 * (3 + 2)] = { + 6.30149946e+00, 1.03728716e+01, 9.60520501e+00, 2.00000000e-01, 2.20000000e+00, + 3.78727022e+00, 1.01546537e+01, 8.48447656e+00, -3.75000000e-02, -4.12500000e-01, + 6.95615313e+00, 1.29914862e+01, 8.29589766e+00, 0.00000000e+00, 0.00000000e+00, + 4.89452639e+00, 1.19003968e+01, 7.94701520e+00, -2.25000000e-01, -2.42500000e+00, }; data->queryLinear = queryLinear; static const int errFlags[4] = { - 0, 0, 1, 0,}; + 0, + 0, + 1, + 0, + }; data->errFlags = errFlags; return data; @@ -283,7 +366,8 @@ spatialdata::spatialdb::TestSimpleDB_Cases::Area3D(void) { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestSimpleDB_Data* spatialdata::spatialdb::TestSimpleDB_Cases::Volume3D(void) { - spatialdata::spatialdb::TestSimpleDB_Data* data = new TestSimpleDB_Data;assert(data); + spatialdata::spatialdb::TestSimpleDB_Data* data = new TestSimpleDB_Data; + assert(data); data->numLocs = 8; data->spaceDim = 3; @@ -291,27 +375,31 @@ spatialdata::spatialdb::TestSimpleDB_Cases::Volume3D(void) { data->dataDim = 3; data->numQueries = 5; - static const double dbCoordinates[8*3] = { - 4.46656933e+00, 8.13917840e+00, 8.80292932e+00, - 2.67771495e+00, 8.13917840e+00, 7.90850213e+00, - 4.90300511e+00, 9.88492152e+00, 7.93005776e+00, - 3.11415073e+00, 9.88492152e+00, 7.03563057e+00, - 3.68584927e+00, 9.11507848e+00, 1.03643694e+01, - 1.89699489e+00, 9.11507848e+00, 9.46994224e+00, - 4.12228505e+00, 1.08608216e+01, 9.49149787e+00, - 2.33343067e+00, 1.08608216e+01, 8.59707068e+00, + static const double dbCoordinates[8 * 3] = { + 4.46656933e+00, 8.13917840e+00, 8.80292932e+00, 2.67771495e+00, 8.13917840e+00, 7.90850213e+00, + 4.90300511e+00, 9.88492152e+00, 7.93005776e+00, 3.11415073e+00, 9.88492152e+00, 7.03563057e+00, + 3.68584927e+00, 9.11507848e+00, 1.03643694e+01, 1.89699489e+00, 9.11507848e+00, 9.46994224e+00, + 4.12228505e+00, 1.08608216e+01, 9.49149787e+00, 2.33343067e+00, 1.08608216e+01, 8.59707068e+00, }; data->dbCoordinates = dbCoordinates; - static const double dbValues[8*2] = { - 1.00000000e-01, 1.10000000e+00, - 3.00000000e-01, 3.30000000e+00, - 2.00000000e-01, 2.20000000e+00, - 1.00000000e-01, 1.10000000e+00, - 4.00000000e-01, 4.60000000e+00, - 3.00000000e-01, 3.20000000e+00, - 7.00000000e-01, 5.20000000e+00, - 5.00000000e-01, 4.60000000e+00, + static const double dbValues[8 * 2] = { + 1.00000000e-01, + 1.10000000e+00, + 3.00000000e-01, + 3.30000000e+00, + 2.00000000e-01, + 2.20000000e+00, + 1.00000000e-01, + 1.10000000e+00, + 4.00000000e-01, + 4.60000000e+00, + 3.00000000e-01, + 3.20000000e+00, + 7.00000000e-01, + 5.20000000e+00, + 5.00000000e-01, + 4.60000000e+00, }; data->dbValues = dbValues; @@ -327,26 +415,29 @@ spatialdata::spatialdb::TestSimpleDB_Cases::Volume3D(void) { }; data->units = units; - static const double queryNearest[5*(3+2)] = { - 4.38173419e+00, 8.36254772e+00, 8.74899281e+00, 1.00000000e-01, 1.10000000e+00, - 2.35495601e+00, 1.00264422e+01, 9.00123360e+00, 5.00000000e-01, 4.60000000e+00, - 3.91112675e+00, 1.07838373e+01, 9.69020768e+00, 7.00000000e-01, 5.20000000e+00, - 3.87701461e+00, 1.04910673e+01, 9.08761157e+00, 7.00000000e-01, 5.20000000e+00, - 3.01795532e+00, 8.84019490e+00, 8.79326896e+00, 3.00000000e-01, 3.30000000e+00, + static const double queryNearest[5 * (3 + 2)] = { + 4.38173419e+00, 8.36254772e+00, 8.74899281e+00, 1.00000000e-01, 1.10000000e+00, 2.35495601e+00, 1.00264422e+01, + 9.00123360e+00, 5.00000000e-01, 4.60000000e+00, 3.91112675e+00, 1.07838373e+01, 9.69020768e+00, 7.00000000e-01, + 5.20000000e+00, 3.87701461e+00, 1.04910673e+01, 9.08761157e+00, 7.00000000e-01, 5.20000000e+00, 3.01795532e+00, + 8.84019490e+00, 8.79326896e+00, 3.00000000e-01, 3.30000000e+00, }; data->queryNearest = queryNearest; - static const double queryLinear[5*(3+2)] = { - 4.38173419e+00, 8.36254772e+00, 8.74899281e+00, 1.35000000e-01, 1.49500000e+00, - 2.35495601e+00, 1.00264422e+01, 9.00123360e+00, 4.10000000e-01, 3.85500000e+00, - 3.91112675e+00, 1.07838373e+01, 9.69020768e+00, 0.00000000e+00, 0.00000000e+00, - 3.87701461e+00, 1.04910673e+01, 9.08761157e+00, 5.30000000e-01, 4.42000000e+00, - 3.01795532e+00, 8.84019490e+00, 8.79326896e+00, 2.00000000e-01, 2.15500000e+00, + static const double queryLinear[5 * (3 + 2)] = { + 4.38173419e+00, 8.36254772e+00, 8.74899281e+00, 1.35000000e-01, 1.49500000e+00, 2.35495601e+00, 1.00264422e+01, + 9.00123360e+00, 4.10000000e-01, 3.85500000e+00, 3.91112675e+00, 1.07838373e+01, 9.69020768e+00, 0.00000000e+00, + 0.00000000e+00, 3.87701461e+00, 1.04910673e+01, 9.08761157e+00, 5.30000000e-01, 4.42000000e+00, 3.01795532e+00, + 8.84019490e+00, 8.79326896e+00, 2.00000000e-01, 2.15500000e+00, }; data->queryLinear = queryLinear; static const int errFlags[5] = { - 0, 0, 1, 0, 0, }; + 0, + 0, + 1, + 0, + 0, + }; data->errFlags = errFlags; return data; diff --git a/tests/libtests/spatialdb/TestSimpleGridAscii.cc b/tests/libtests/spatialdb/TestSimpleGridAscii.cc index ab57a5d0..95acc7ca 100644 --- a/tests/libtests/spatialdb/TestSimpleGridAscii.cc +++ b/tests/libtests/spatialdb/TestSimpleGridAscii.cc @@ -26,35 +26,34 @@ namespace spatialdata { namespace spatialdb { class TestSimpleGridAscii; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata class spatialdata::spatialdb::TestSimpleGridAscii { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Test read() and write() with CSCart. - static - void testIOCSCart(void); + static void testIOCSCart(void); /// Test read() and write() with CSGeo. - static - void testIOCSGeo(void); + static void testIOCSGeo(void); /// Test read() with comments. - static - void testReadComments(void); + static void testReadComments(void); }; // class TestSimpleGridAscii // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestSimpleGridAscii::testIOCSCart", "[TestSimpleGridAscii]") { +TEST_CASE("TestSimpleGridAscii::testIOCSCart", + "[TestSimpleGridAscii]") { spatialdata::spatialdb::TestSimpleGridAscii::testIOCSCart(); } -TEST_CASE("TestSimpleGridAscii::testIOCSGeo", "[TestSimpleGridAscii]") { +TEST_CASE("TestSimpleGridAscii::testIOCSGeo", + "[TestSimpleGridAscii]") { spatialdata::spatialdb::TestSimpleGridAscii::testIOCSGeo(); } -TEST_CASE("TestSimpleGridAscii::testReadComments", "[TestSimpleGridAscii]") { +TEST_CASE("TestSimpleGridAscii::testReadComments", + "[TestSimpleGridAscii]") { spatialdata::spatialdb::TestSimpleGridAscii::testReadComments(); } @@ -69,28 +68,46 @@ spatialdata::spatialdb::TestSimpleGridAscii::testIOCSCart(void) { const size_t numValues = 2; const size_t dataDim = 2; - const double x[numX] = { -2.0 }; - const double y[numY] = { 0.0, 1.0 }; - const double z[numZ] = { -2.0, -1.0, 2.0 }; - - const double coords[numX*numY*numZ*spaceDim] = { - -2.0, 0.0, -2.0, - -2.0, 1.0, -2.0, - -2.0, 0.0, -1.0, - -2.0, 1.0, -1.0, - -2.0, 0.0, 2.0, - -2.0, 1.0, 2.0, + const double x[numX] = {-2.0}; + const double y[numY] = {0.0, 1.0}; + const double z[numZ] = {-2.0, -1.0, 2.0}; + + const double coords[numX * numY * numZ * spaceDim] = { + -2.0, + 0.0, + -2.0, + -2.0, + 1.0, + -2.0, + -2.0, + 0.0, + -1.0, + -2.0, + 1.0, + -1.0, + -2.0, + 0.0, + 2.0, + -2.0, + 1.0, + 2.0, }; - const double data[numX*numY*numZ*numValues] = { - 6.6, 3.4, - 5.5, 6.7, - 2.3, 4.1, - 5.7, 2.0, - 6.3, 6.9, - 3.4, 6.4, + const double data[numX * numY * numZ * numValues] = { + 6.6, + 3.4, + 5.5, + 6.7, + 2.3, + 4.1, + 5.7, + 2.0, + 6.3, + 6.9, + 3.4, + 6.4, }; - const char* names[numValues] = { "One", "Two" }; - const char* units[numValues] = { "m", "m" }; + const char* names[numValues] = {"One", "Two"}; + const char* units[numValues] = {"m", "m"}; geocoords::CSCart csOut; SimpleGridDB dbOut; @@ -99,7 +116,7 @@ spatialdata::spatialdb::TestSimpleGridAscii::testIOCSCart(void) { dbOut.setX(x, numX); dbOut.setY(y, numY); dbOut.setZ(z, numZ); - dbOut.setData(coords, numX*numY*numZ, spaceDim, data, numX*numY*numZ, numValues); + dbOut.setData(coords, numX * numY * numZ, spaceDim, data, numX * numY * numZ, numValues); dbOut.setNames(names, numValues); dbOut.setUnits(units, numValues); @@ -133,8 +150,8 @@ spatialdata::spatialdb::TestSimpleGridAscii::testIOCSCart(void) { for (size_t iY = 0; iY < numY; ++iY) { const size_t iD = dbIn._getDataIndex(iX, numX, iY, numY, iZ, numZ); for (size_t iVal = 0; iVal < numValues; ++iVal, ++i) { - const double toleranceV = (fabs(data[i]) > 0.0) ? tolerance*data[i] : tolerance; - CHECK_THAT(dbIn._data[iD+iVal], Catch::Matchers::WithinAbs(data[i], toleranceV)); + const double toleranceV = (fabs(data[i]) > 0.0) ? tolerance * data[i] : tolerance; + CHECK_THAT(dbIn._data[iD + iVal], Catch::Matchers::WithinAbs(data[i], toleranceV)); } // for } // for } // for @@ -143,25 +160,34 @@ spatialdata::spatialdb::TestSimpleGridAscii::testIOCSCart(void) { // Perform simple nearest query to ensure consistency of read/query dbIn.setQueryValues(names, numValues); const size_t numLocs = 3; - const double points[numLocs*spaceDim] = { - -2.0, 1.0, -2.0, - -5.0, 0.0, 2.0, - +6.0, 1.0, -1.0, + const double points[numLocs * spaceDim] = { + -2.0, + 1.0, + -2.0, + -5.0, + 0.0, + 2.0, + +6.0, + 1.0, + -1.0, }; - const double dataE[numLocs*numValues] = { - 5.5, 6.7, - 6.3, 6.9, - 5.7, 2.0, + const double dataE[numLocs * numValues] = { + 5.5, + 6.7, + 6.3, + 6.9, + 5.7, + 2.0, }; - const int errE[numLocs] = { 0, 0 }; + const int errE[numLocs] = {0, 0}; for (size_t iLoc = 0; iLoc < numLocs; ++iLoc) { double data[numValues]; - int err = dbIn.query(data, numValues, &points[iLoc*spaceDim], spaceDim, &csOut); + int err = dbIn.query(data, numValues, &points[iLoc * spaceDim], spaceDim, &csOut); REQUIRE(errE[iLoc] == err); for (size_t iVal = 0; iVal < numValues; ++iVal) { - const double valueE = dataE[iLoc*numValues+iVal]; - const double toleranceV = fabs(valueE) > 0.0 ? tolerance*valueE : tolerance; + const double valueE = dataE[iLoc * numValues + iVal]; + const double toleranceV = fabs(valueE) > 0.0 ? tolerance * valueE : tolerance; CHECK_THAT(data[iVal], Catch::Matchers::WithinAbs(valueE, toleranceV)); } // for } // for @@ -179,28 +205,37 @@ spatialdata::spatialdb::TestSimpleGridAscii::testIOCSGeo(void) { const size_t numValues = 10; const size_t dataDim = 2; - const double x[numX] = { -2.0 }; - const double y[numY] = { 0.0, 1.0 }; - const double z[numZ] = { -2.0, -1.0, 2.0 }; - - const double coords[numX*numY*numZ*spaceDim] = { - -2.0, 0.0, -2.0, - -2.0, 1.0, -2.0, - -2.0, 0.0, -1.0, - -2.0, 1.0, -1.0, - -2.0, 0.0, 2.0, - -2.0, 1.0, 2.0, + const double x[numX] = {-2.0}; + const double y[numY] = {0.0, 1.0}; + const double z[numZ] = {-2.0, -1.0, 2.0}; + + const double coords[numX * numY * numZ * spaceDim] = { + -2.0, + 0.0, + -2.0, + -2.0, + 1.0, + -2.0, + -2.0, + 0.0, + -1.0, + -2.0, + 1.0, + -1.0, + -2.0, + 0.0, + 2.0, + -2.0, + 1.0, + 2.0, }; - const double data[numX*numY*numZ*numValues] = { - 6.6, 3.4, 2.3, 8.3, 3.6, 9.4, 8.4, 3.7, 7.3, 1.5, - 5.5, 6.7, 3.4, 9.4, 4.7, 1.5, 9.5, 4.8, 8.4, 2.6, - 2.3, 4.1, 4.5, 0.5, 5.8, 2.6, 0.6, 5.9, 9.5, 3.7, - 5.7, 2.0, 5.6, 1.6, 6.9, 3.7, 1.7, 6.0, 0.6, 4.8, - 6.3, 6.9, 6.7, 2.7, 7.0, 4.8, 2.8, 7.0, 0.7, 5.9, - 3.4, 6.4, 7.8, 3.8, 8.1, 5.9, 3.9, 8.0, 0.8, 6.0, + const double data[numX * numY * numZ * numValues] = { + 6.6, 3.4, 2.3, 8.3, 3.6, 9.4, 8.4, 3.7, 7.3, 1.5, 5.5, 6.7, 3.4, 9.4, 4.7, 1.5, 9.5, 4.8, 8.4, 2.6, + 2.3, 4.1, 4.5, 0.5, 5.8, 2.6, 0.6, 5.9, 9.5, 3.7, 5.7, 2.0, 5.6, 1.6, 6.9, 3.7, 1.7, 6.0, 0.6, 4.8, + 6.3, 6.9, 6.7, 2.7, 7.0, 4.8, 2.8, 7.0, 0.7, 5.9, 3.4, 6.4, 7.8, 3.8, 8.1, 5.9, 3.9, 8.0, 0.8, 6.0, }; - const char* names[numValues] = { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten" }; - const char* units[numValues] = { "m", "none", "m", "Pa", "Pa", "m", "kg", "m", "none", "none" }; + const char* names[numValues] = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"}; + const char* units[numValues] = {"m", "none", "m", "Pa", "Pa", "m", "kg", "m", "none", "none"}; spatialdata::geocoords::CSGeo csOut; csOut.setString("+proj=tmerc +datum=WGS84 +lon_0=-122.6765 +lat_0=45.5231 +k=0.9996 +units=m +vunits=m"); @@ -210,7 +245,7 @@ spatialdata::spatialdb::TestSimpleGridAscii::testIOCSGeo(void) { dbOut.setX(x, numX); dbOut.setY(y, numY); dbOut.setZ(z, numZ); - dbOut.setData(coords, numX*numY*numZ, spaceDim, data, numX*numY*numZ, numValues); + dbOut.setData(coords, numX * numY * numZ, spaceDim, data, numX * numY * numZ, numValues); dbOut.setNames(names, numValues); dbOut.setUnits(units, numValues); @@ -245,8 +280,8 @@ spatialdata::spatialdb::TestSimpleGridAscii::testIOCSGeo(void) { for (size_t iY = 0; iY < numY; ++iY) { const size_t iD = dbIn._getDataIndex(iX, numX, iY, numY, iZ, numZ); for (size_t iVal = 0; iVal < numValues; ++iVal, ++i) { - const double toleranceV = (fabs(data[i]) > 0.0) ? tolerance*data[i] : tolerance; - CHECK_THAT(dbIn._data[iD+iVal], Catch::Matchers::WithinAbs(data[i], toleranceV)); + const double toleranceV = (fabs(data[i]) > 0.0) ? tolerance * data[i] : tolerance; + CHECK_THAT(dbIn._data[iD + iVal], Catch::Matchers::WithinAbs(data[i], toleranceV)); } // for } // for } // for @@ -255,25 +290,30 @@ spatialdata::spatialdb::TestSimpleGridAscii::testIOCSGeo(void) { // Perform simple nearest query to ensure consistency of read/query dbIn.setQueryValues(names, numValues); const size_t numLocs = 3; - const double points[numLocs*spaceDim] = { - -2.0, 1.0, -2.0, - -5.0, 0.0, 2.0, - +6.0, 1.0, -1.0, + const double points[numLocs * spaceDim] = { + -2.0, + 1.0, + -2.0, + -5.0, + 0.0, + 2.0, + +6.0, + 1.0, + -1.0, }; - const double dataE[numLocs*numValues] = { - 5.5, 6.7, 3.4, 9.4, 4.7, 1.5, 9.5, 4.8, 8.4, 2.6, - 6.3, 6.9, 6.7, 2.7, 7.0, 4.8, 2.8, 7.0, 0.7, 5.9, - 5.7, 2.0, 5.6, 1.6, 6.9, 3.7, 1.7, 6.0, 0.6, 4.8, + const double dataE[numLocs * numValues] = { + 5.5, 6.7, 3.4, 9.4, 4.7, 1.5, 9.5, 4.8, 8.4, 2.6, 6.3, 6.9, 6.7, 2.7, 7.0, + 4.8, 2.8, 7.0, 0.7, 5.9, 5.7, 2.0, 5.6, 1.6, 6.9, 3.7, 1.7, 6.0, 0.6, 4.8, }; - const int errE[numLocs] = { 0, 0, 0 }; + const int errE[numLocs] = {0, 0, 0}; for (size_t iLoc = 0; iLoc < numLocs; ++iLoc) { double data[numValues]; - int err = dbIn.query(data, numValues, &points[iLoc*spaceDim], spaceDim, &csOut); + int err = dbIn.query(data, numValues, &points[iLoc * spaceDim], spaceDim, &csOut); REQUIRE(errE[iLoc] == err); for (size_t iVal = 0; iVal < numValues; ++iVal) { - const double valueE = dataE[iLoc*numValues+iVal]; - const double toleranceV = fabs(valueE) > 0.0 ? tolerance*valueE : tolerance; + const double valueE = dataE[iLoc * numValues + iVal]; + const double toleranceV = fabs(valueE) > 0.0 ? tolerance * valueE : tolerance; CHECK_THAT(data[iVal], Catch::Matchers::WithinAbs(valueE, toleranceV)); } // for } // for @@ -291,16 +331,15 @@ spatialdata::spatialdb::TestSimpleGridAscii::testReadComments(void) { const size_t numValues = 13; const size_t dataDim = 1; - const double x[numX] = { 0.0 }; - const double y[numY] = { 0.0 }; - const double z[numZ] = { -400.01, -100.0, -30.0, -20.0, 0.0 }; + const double x[numX] = {0.0}; + const double y[numY] = {0.0}; + const double z[numZ] = {-400.01, -100.0, -30.0, -20.0, 0.0}; - const double data[numX*numY*numZ*numValues] = { - 1.0e+20, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, - 2.0e+20, 0.4, 1.4, 2.4, 3.4, 4.4, 5.4, 6.4, 7.4, 8.4, 9.4, 10.4, 11.4, - 4.0e+20, 0.3, 1.3, 2.3, 3.3, 4.3, 5.3, 6.3, 7.3, 8.3, 9.3, 10.3, 11.3, - 1.0e+21, 0.2, 1.2, 2.2, 3.2, 4.2, 5.2, 6.2, 7.2, 8.2, 9.2, 10.2, 11.2, - 1.0e+22, 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 8.1, 9.1, 10.1, 11.1, + const double data[numX * numY * numZ * numValues] = { + 1.0e+20, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 2.0e+20, 0.4, 1.4, 2.4, + 3.4, 4.4, 5.4, 6.4, 7.4, 8.4, 9.4, 10.4, 11.4, 4.0e+20, 0.3, 1.3, 2.3, 3.3, 4.3, 5.3, 6.3, + 7.3, 8.3, 9.3, 10.3, 11.3, 1.0e+21, 0.2, 1.2, 2.2, 3.2, 4.2, 5.2, 6.2, 7.2, 8.2, 9.2, 10.2, + 11.2, 1.0e+22, 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 8.1, 9.1, 10.1, 11.1, }; const char* names[numValues] = { "viscosity", @@ -373,8 +412,8 @@ spatialdata::spatialdb::TestSimpleGridAscii::testReadComments(void) { for (size_t iY = 0; iY < numY; ++iY) { const size_t iD = dbIn._getDataIndex(iX, numX, iY, numY, iZ, numZ); for (size_t iVal = 0; iVal < numValues; ++iVal, ++i) { - const double toleranceV = (fabs(data[i]) > 0.0) ? tolerance*data[i] : tolerance; - CHECK_THAT(dbIn._data[iD+iVal], Catch::Matchers::WithinAbs(data[i], toleranceV)); + const double toleranceV = (fabs(data[i]) > 0.0) ? tolerance * data[i] : tolerance; + CHECK_THAT(dbIn._data[iD + iVal], Catch::Matchers::WithinAbs(data[i], toleranceV)); } // for } // for } // for diff --git a/tests/libtests/spatialdb/TestSimpleGridDB.cc b/tests/libtests/spatialdb/TestSimpleGridDB.cc index 581bdbba..ca50e9ba 100644 --- a/tests/libtests/spatialdb/TestSimpleGridDB.cc +++ b/tests/libtests/spatialdb/TestSimpleGridDB.cc @@ -12,8 +12,8 @@ #include "TestSimpleGridDB.hh" // Implementation of class methods -#include "spatialdata/spatialdb/SimpleGridDB.hh" // USES SimpleGridDB #include "spatialdata/spatialdb/SimpleGridAscii.hh" // USES SimpleGridAscii +#include "spatialdata/spatialdb/SimpleGridDB.hh" // USES SimpleGridDB #include "spatialdata/geocoords/CSCart.hh" // USE CSCart @@ -24,8 +24,7 @@ // ---------------------------------------------------------------------- // Constructor. -spatialdata::spatialdb::TestSimpleGridDB::TestSimpleGridDB(TestSimpleGridDB_Data* data) : - _data(data) { +spatialdata::spatialdb::TestSimpleGridDB::TestSimpleGridDB(TestSimpleGridDB_Data* data) : _data(data) { assert(_data); } // setUp @@ -33,7 +32,8 @@ spatialdata::spatialdb::TestSimpleGridDB::TestSimpleGridDB(TestSimpleGridDB_Data // ---------------------------------------------------------------------- // Tear down testing data. spatialdata::spatialdb::TestSimpleGridDB::~TestSimpleGridDB(void) { - delete _data;_data = NULL; + delete _data; + _data = NULL; } // tearDown @@ -76,7 +76,11 @@ void spatialdata::spatialdb::TestSimpleGridDB::testSearch(void) { const size_t numX = 5; const double x[numX] = { - -3.0, -1.0, 0.0, 5.0, 8.0, + -3.0, + -1.0, + 0.0, + 5.0, + 8.0, }; const double tolerance = 1.0e-6; @@ -141,13 +145,13 @@ spatialdata::spatialdb::TestSimpleGridDB::testDataIndex(void) { db._numValues = 10; CHECK(size_t(0) == db._getDataIndex(0, db._numX, 0, db._numY, 0, db._numZ)); - CHECK(size_t(1*3*4*10) == db._getDataIndex(0, db._numX, 0, db._numY, 1, db._numZ)); + CHECK(size_t(1 * 3 * 4 * 10) == db._getDataIndex(0, db._numX, 0, db._numY, 1, db._numZ)); - CHECK(size_t(1*4*10) == db._getDataIndex(0, db._numX, 1, db._numY, 0, db._numZ)); - CHECK(size_t(4*3*4*10 + 1*4*10) == db._getDataIndex(0, db._numX, 1, db._numY, 4, db._numZ)); + CHECK(size_t(1 * 4 * 10) == db._getDataIndex(0, db._numX, 1, db._numY, 0, db._numZ)); + CHECK(size_t(4 * 3 * 4 * 10 + 1 * 4 * 10) == db._getDataIndex(0, db._numX, 1, db._numY, 4, db._numZ)); - CHECK(size_t(1*10) == db._getDataIndex(1, db._numX, 0, db._numY, 0, db._numZ)); - CHECK(size_t(3*4*3*10 + 1*4*10 + 2*10) == db._getDataIndex(2, db._numX, 1, db._numY, 3, db._numZ)); + CHECK(size_t(1 * 10) == db._getDataIndex(1, db._numX, 0, db._numY, 0, db._numZ)); + CHECK(size_t(3 * 4 * 3 * 10 + 1 * 4 * 10 + 2 * 10) == db._getDataIndex(2, db._numX, 1, db._numY, 3, db._numZ)); } // testDataIndex @@ -168,7 +172,8 @@ spatialdata::spatialdb::TestSimpleGridDB::testGetNamesDBValues(void) { for (size_t i = 0; i < numValues; ++i) { CHECK(std::string(_data->names[i]) == std::string(valueNames[i])); } // for - delete[] valueNames;valueNames = NULL; + delete[] valueNames; + valueNames = NULL; numValues = 0; } // testGetDBValues @@ -195,7 +200,13 @@ spatialdata::spatialdb::TestSimpleGridDB::testQueryLinear(void) { SimpleGridDB db; _setupDB(&db); db.setQueryType(SimpleGridDB::LINEAR); - _checkQuery(db, _data->names, _data->queryLinear, _data->errFlags, _data->numQueries, _data->spaceDim, _data->numValues); + _checkQuery(db, + _data->names, + _data->queryLinear, + _data->errFlags, + _data->numQueries, + _data->spaceDim, + _data->numValues); } // _testQueryLinear @@ -265,12 +276,18 @@ spatialdata::spatialdb::TestSimpleGridDB::_setupDB(SimpleGridDB* const db) { assert(_data); assert(_data->numValues > 0); - delete[] db->_x;db->_x = NULL; - delete[] db->_y;db->_y = NULL; - delete[] db->_z;db->_z = NULL; - delete[] db->_data;db->_data = NULL; - delete[] db->_names;db->_names = NULL; - delete[] db->_units;db->_units = NULL; + delete[] db->_x; + db->_x = NULL; + delete[] db->_y; + db->_y = NULL; + delete[] db->_z; + db->_z = NULL; + delete[] db->_data; + db->_data = NULL; + delete[] db->_names; + db->_names = NULL; + delete[] db->_units; + db->_units = NULL; db->setDescription("Test database"); db->_numValues = _data->numValues; @@ -303,8 +320,8 @@ spatialdata::spatialdb::TestSimpleGridDB::_setupDB(SimpleGridDB* const db) { } // for } // if - db->_data = (numLocs > 0) ? new double[numLocs*_data->numValues] : NULL; - for (size_t i = 0; i < numLocs*_data->numValues; ++i) { + db->_data = (numLocs > 0) ? new double[numLocs * _data->numValues] : NULL; + for (size_t i = 0; i < numLocs * _data->numValues; ++i) { db->_data[i] = _data->dbData[i]; } // for @@ -341,9 +358,9 @@ spatialdata::spatialdb::TestSimpleGridDB::_checkQuery(SimpleGridDB& db, assert(numValues); // reverse order of vals in queries - std::vectorvalueNames(numValues); + std::vector valueNames(numValues); for (size_t i = 0; i < numValues; ++i) { - valueNames[numValues-i-1] = names[i]; + valueNames[numValues - i - 1] = names[i]; } db.setQueryValues(valueNames.data(), numValues); @@ -354,21 +371,22 @@ spatialdata::spatialdb::TestSimpleGridDB::_checkQuery(SimpleGridDB& db, spatialdata::geocoords::CSCart csCart; csCart.setSpaceDim(spaceDim); for (size_t iQuery = 0; iQuery < numQueries; ++iQuery) { - const double* coords = &queryData[iQuery*locSize]; - const double* valsE = &queryData[iQuery*locSize+spaceDim]; + const double* coords = &queryData[iQuery * locSize]; + const double* valsE = &queryData[iQuery * locSize + spaceDim]; const int err = db.query(vals, numValues, coords, spaceDim, &csCart); if (0 != flagsE) { REQUIRE(flagsE[iQuery] == err); } else { REQUIRE(!err); for (size_t iVal = 0; iVal < numValues; ++iVal) { - const double valueE = valsE[numValues-iVal-1]; + const double valueE = valsE[numValues - iVal - 1]; const double toleranceV = fabs(valueE) > 0.0 ? fabs(valueE) * tolerance : tolerance; CHECK_THAT(vals[iVal], Catch::Matchers::WithinAbs(valueE, toleranceV)); } // for } // if/else } // for - delete[] vals;vals = NULL; + delete[] vals; + vals = NULL; } // _checkQuery @@ -390,7 +408,8 @@ spatialdata::spatialdb::TestSimpleGridDB_Data::TestSimpleGridDB_Data(void) : queryNearest(NULL), queryLinear(NULL), errFlags(NULL), - filename(NULL) {} + filename(NULL) { +} // ---------------------------------------------------------------------- diff --git a/tests/libtests/spatialdb/TestSimpleGridDB.hh b/tests/libtests/spatialdb/TestSimpleGridDB.hh index 795aaf4f..a874c086 100644 --- a/tests/libtests/spatialdb/TestSimpleGridDB.hh +++ b/tests/libtests/spatialdb/TestSimpleGridDB.hh @@ -11,21 +11,20 @@ #include "spatialdata/spatialdb/spatialdbfwd.hh" -#include // USES size_t #include +#include // USES size_t namespace spatialdata { namespace spatialdb { class TestSimpleGridDB; class TestSimpleGridDB_Data; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata // ------------------------------------------------------------------------------------------------ class spatialdata::spatialdb::TestSimpleGridDB { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Constructor. TestSimpleGridDB(TestSimpleGridDB_Data* data); @@ -33,20 +32,16 @@ public: ~TestSimpleGridDB(void); /// Test constructor. - static - void testConstructor(void); + static void testConstructor(void); /// Test accessors. - static - void testAccessors(void); + static void testAccessors(void); /// Test _search() - static - void testSearch(void); + static void testSearch(void); /// Test _dataIndex() - static - void testDataIndex(void); + static void testDataIndex(void); /// Test getNamesDBValues(). void testGetNamesDBValues(void); @@ -61,8 +56,7 @@ public: void testRead(void); // PRIVATE METHODS //////////////////////////////////////////////////////////////////////////// -private: - + private: /** Populate database with data. * * @param db Database @@ -88,8 +82,7 @@ private: const size_t spaceDim, const size_t numVals); -private: - + private: // PRIVATE MEMBERS //////////////////////////////////////////////////////////////////////////// TestSimpleGridDB_Data* _data; ///< Test data. @@ -99,8 +92,7 @@ private: // ------------------------------------------------------------------------------------------------ class spatialdata::spatialdb::TestSimpleGridDB_Data { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Constructor TestSimpleGridDB_Data(void); @@ -108,8 +100,7 @@ public: ~TestSimpleGridDB_Data(void); // PUBLIC MEMBERS /////////////////////////////////////////////////////// -public: - + public: /// @name Database information //@{ size_t numX; ///< Number of locations in x dimension. @@ -138,7 +129,6 @@ public: //@{ const char* filename; ///< Filename of matching spatial database. //@} - }; // End of file diff --git a/tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc b/tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc index 8de9a246..a35efb14 100644 --- a/tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc +++ b/tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc @@ -12,8 +12,8 @@ #include "TestSimpleGridDB.hh" // ISA TestSimpleGridDB -#include "spatialdata/spatialdb/SimpleGridDB.hh" // USES SimpleGridDB #include "spatialdata/geocoords/CSCart.hh" // USES CSCart +#include "spatialdata/spatialdb/SimpleGridDB.hh" // USES SimpleGridDB #include "catch2/catch_test_macros.hpp" @@ -22,174 +22,247 @@ namespace spatialdata { namespace spatialdb { class TestSimpleGridDB_Cases; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata class spatialdata::spatialdb::TestSimpleGridDB_Cases { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: // Factories - static - TestSimpleGridDB_Data* Line1D(void); + static TestSimpleGridDB_Data* Line1D(void); - static - TestSimpleGridDB_Data* Line2D(void); + static TestSimpleGridDB_Data* Line2D(void); - static - TestSimpleGridDB_Data* Line3D(void); + static TestSimpleGridDB_Data* Line3D(void); - static - TestSimpleGridDB_Data* Area2D(void); + static TestSimpleGridDB_Data* Area2D(void); - static - TestSimpleGridDB_Data* Area3D(void); + static TestSimpleGridDB_Data* Area3D(void); - static - TestSimpleGridDB_Data* Volume3D(void); + static TestSimpleGridDB_Data* Volume3D(void); }; // class TestSimpleGridDB // ------------------------------------------------------------------------------------------------ // Static test cases -TEST_CASE("TestSimpleGridDB::testConstructor", "[TestSimpleGridDB]") { +TEST_CASE("TestSimpleGridDB::testConstructor", + "[TestSimpleGridDB]") { spatialdata::spatialdb::TestSimpleGridDB::testConstructor(); } -TEST_CASE("TestSimpleGridDB::testAccessors", "[TestSimpleGridDB]") { +TEST_CASE("TestSimpleGridDB::testAccessors", + "[TestSimpleGridDB]") { spatialdata::spatialdb::TestSimpleGridDB::testAccessors(); } -TEST_CASE("TestSimpleGridDB::testSearch", "[TestSimpleGridDB]") { +TEST_CASE("TestSimpleGridDB::testSearch", + "[TestSimpleGridDB]") { spatialdata::spatialdb::TestSimpleGridDB::testSearch(); } -TEST_CASE("TestSimpleGridDB::testDataIndex", "[TestSimpleGridDB]") { +TEST_CASE("TestSimpleGridDB::testDataIndex", + "[TestSimpleGridDB]") { spatialdata::spatialdb::TestSimpleGridDB::testDataIndex(); } // Data test cases -TEST_CASE("TestSimpleGridDB::testGetNamesDBValues", "[TestSimpleGridDB][Line1D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line1D()).testGetNamesDBValues(); +TEST_CASE("TestSimpleGridDB::testGetNamesDBValues", + "[TestSimpleGridDB][Line1D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line1D()) + .testGetNamesDBValues(); } -TEST_CASE("TestSimpleGridDB::testQueryNearest", "[TestSimpleGridDB][Line1D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line1D()).testQueryNearest(); +TEST_CASE("TestSimpleGridDB::testQueryNearest", + "[TestSimpleGridDB][Line1D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line1D()) + .testQueryNearest(); } -TEST_CASE("TestSimpleGridDB::testQueryLinear", "[TestSimpleGridDB][Line1D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line1D()).testQueryLinear(); +TEST_CASE("TestSimpleGridDB::testQueryLinear", + "[TestSimpleGridDB][Line1D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line1D()) + .testQueryLinear(); } -TEST_CASE("TestSimpleGridDB::testRead", "[TestSimpleGridDB][Line1D]") { +TEST_CASE("TestSimpleGridDB::testRead", + "[TestSimpleGridDB][Line1D]") { spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line1D()).testRead(); } -TEST_CASE("TestSimpleGridDB::testGetNamesDBValues", "[TestSimpleGridDB][Line2D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line2D()).testGetNamesDBValues(); +TEST_CASE("TestSimpleGridDB::testGetNamesDBValues", + "[TestSimpleGridDB][Line2D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line2D()) + .testGetNamesDBValues(); } -TEST_CASE("TestSimpleGridDB::testQueryNearest", "[TestSimpleGridDB][Line2D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line2D()).testQueryNearest(); +TEST_CASE("TestSimpleGridDB::testQueryNearest", + "[TestSimpleGridDB][Line2D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line2D()) + .testQueryNearest(); } -TEST_CASE("TestSimpleGridDB::testQueryLinear", "[TestSimpleGridDB][Line2D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line2D()).testQueryLinear(); +TEST_CASE("TestSimpleGridDB::testQueryLinear", + "[TestSimpleGridDB][Line2D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line2D()) + .testQueryLinear(); } -TEST_CASE("TestSimpleGridDB::testRead", "[TestSimpleGridDB][Line2D]") { +TEST_CASE("TestSimpleGridDB::testRead", + "[TestSimpleGridDB][Line2D]") { spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line2D()).testRead(); } -TEST_CASE("TestSimpleGridDB::testGetNamesDBValues", "[TestSimpleGridDB][Line3D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line3D()).testGetNamesDBValues(); +TEST_CASE("TestSimpleGridDB::testGetNamesDBValues", + "[TestSimpleGridDB][Line3D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line3D()) + .testGetNamesDBValues(); } -TEST_CASE("TestSimpleGridDB::testQueryNearest", "[TestSimpleGridDB][Line3D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line3D()).testQueryNearest(); +TEST_CASE("TestSimpleGridDB::testQueryNearest", + "[TestSimpleGridDB][Line3D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line3D()) + .testQueryNearest(); } -TEST_CASE("TestSimpleGridDB::testQueryLinear", "[TestSimpleGridDB][Line3D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line3D()).testQueryLinear(); +TEST_CASE("TestSimpleGridDB::testQueryLinear", + "[TestSimpleGridDB][Line3D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line3D()) + .testQueryLinear(); } -TEST_CASE("TestSimpleGridDB::testRead", "[TestSimpleGridDB][Line3D]") { +TEST_CASE("TestSimpleGridDB::testRead", + "[TestSimpleGridDB][Line3D]") { spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Line3D()).testRead(); } -TEST_CASE("TestSimpleGridDB::testGetNamesDBValues", "[TestSimpleGridDB][Area2D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Area2D()).testGetNamesDBValues(); +TEST_CASE("TestSimpleGridDB::testGetNamesDBValues", + "[TestSimpleGridDB][Area2D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Area2D()) + .testGetNamesDBValues(); } -TEST_CASE("TestSimpleGridDB::testQueryNearest", "[TestSimpleGridDB][Area2D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Area2D()).testQueryNearest(); +TEST_CASE("TestSimpleGridDB::testQueryNearest", + "[TestSimpleGridDB][Area2D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Area2D()) + .testQueryNearest(); } -TEST_CASE("TestSimpleGridDB::testQueryLinear", "[TestSimpleGridDB][Area2D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Area2D()).testQueryLinear(); +TEST_CASE("TestSimpleGridDB::testQueryLinear", + "[TestSimpleGridDB][Area2D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Area2D()) + .testQueryLinear(); } -TEST_CASE("TestSimpleGridDB::testRead", "[TestSimpleGridDB][Area2D]") { +TEST_CASE("TestSimpleGridDB::testRead", + "[TestSimpleGridDB][Area2D]") { spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Area2D()).testRead(); } -TEST_CASE("TestSimpleGridDB::testGetNamesDBValues", "[TestSimpleGridDB][Area3D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Area3D()).testGetNamesDBValues(); +TEST_CASE("TestSimpleGridDB::testGetNamesDBValues", + "[TestSimpleGridDB][Area3D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Area3D()) + .testGetNamesDBValues(); } -TEST_CASE("TestSimpleGridDB::testQueryNearest", "[TestSimpleGridDB][Area3D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Area3D()).testQueryNearest(); +TEST_CASE("TestSimpleGridDB::testQueryNearest", + "[TestSimpleGridDB][Area3D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Area3D()) + .testQueryNearest(); } -TEST_CASE("TestSimpleGridDB::testQueryLinear", "[TestSimpleGridDB][Area3D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Area3D()).testQueryLinear(); +TEST_CASE("TestSimpleGridDB::testQueryLinear", + "[TestSimpleGridDB][Area3D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Area3D()) + .testQueryLinear(); } -TEST_CASE("TestSimpleGridDB::testRead", "[TestSimpleGridDB][Area3D]") { +TEST_CASE("TestSimpleGridDB::testRead", + "[TestSimpleGridDB][Area3D]") { spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Area3D()).testRead(); } -TEST_CASE("TestSimpleGridDB::testGetNamesDBValues", "[TestSimpleGridDB][Volume3D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Volume3D()).testGetNamesDBValues(); +TEST_CASE("TestSimpleGridDB::testGetNamesDBValues", + "[TestSimpleGridDB][Volume3D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Volume3D()) + .testGetNamesDBValues(); } -TEST_CASE("TestSimpleGridDB::testQueryNearest", "[TestSimpleGridDB][Volume3D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Volume3D()).testQueryNearest(); +TEST_CASE("TestSimpleGridDB::testQueryNearest", + "[TestSimpleGridDB][Volume3D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Volume3D()) + .testQueryNearest(); } -TEST_CASE("TestSimpleGridDB::testQueryLinear", "[TestSimpleGridDB][Volume3D]") { - spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Volume3D()).testQueryLinear(); +TEST_CASE("TestSimpleGridDB::testQueryLinear", + "[TestSimpleGridDB][Volume3D]") { + spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Volume3D()) + .testQueryLinear(); } -TEST_CASE("TestSimpleGridDB::testRead", "[TestSimpleGridDB][Volume3D]") { +TEST_CASE("TestSimpleGridDB::testRead", + "[TestSimpleGridDB][Volume3D]") { spatialdata::spatialdb::TestSimpleGridDB(spatialdata::spatialdb::TestSimpleGridDB_Cases::Volume3D()).testRead(); } // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestSimpleGridDB_Data* spatialdata::spatialdb::TestSimpleGridDB_Cases::Line1D(void) { - spatialdata::spatialdb::TestSimpleGridDB_Data* data = new TestSimpleGridDB_Data;assert(data); + spatialdata::spatialdb::TestSimpleGridDB_Data* data = new TestSimpleGridDB_Data; + assert(data); data->numX = 3; data->spaceDim = 1; data->numValues = 2; data->dataDim = 1; - static const double dbX[3] = { -3.0, 1.0, 2.0, }; + static const double dbX[3] = { + -3.0, + 1.0, + 2.0, + }; data->dbX = dbX; - static const double dbData[3*2] = { - 1.00000000e-01, 1.10000000e+00, // 0,0,0 - 0.00000000e-01, 1.20000000e+00, // 1,0,0 - 5.00000000e-01, 1.60000000e+00, // 2,0,0 + static const double dbData[3 * 2] = { + 1.00000000e-01, + 1.10000000e+00, // 0,0,0 + 0.00000000e-01, + 1.20000000e+00, // 1,0,0 + 5.00000000e-01, + 1.60000000e+00, // 2,0,0 }; data->dbData = dbData; - static const char* names[2] = { "One", "Two" }; + static const char* names[2] = {"One", "Two"}; data->names = names; - static const char* units[2] = { "m", "m" }; + static const char* units[2] = {"m", "m"}; data->units = units; data->numQueries = 5; - static const double queryNearest[5*(1+2)] = { - -3.2, 1.00000000e-01, 1.10000000e+00, // (0) - 1.1, 0.00000000e-01, 1.20000000e+00, // (1) - 0.0, 0.00000000e-01, 1.20000000e+00, // (1) - 1.6, 5.00000000e-01, 1.60000000e+00, // (2) - -2.0, 1.00000000e-01, 1.10000000e+00, // (0) + static const double queryNearest[5 * (1 + 2)] = { + -3.2, + 1.00000000e-01, + 1.10000000e+00, // (0) + 1.1, + 0.00000000e-01, + 1.20000000e+00, // (1) + 0.0, + 0.00000000e-01, + 1.20000000e+00, // (1) + 1.6, + 5.00000000e-01, + 1.60000000e+00, // (2) + -2.0, + 1.00000000e-01, + 1.10000000e+00, // (0) }; data->queryNearest = queryNearest; - static const double queryLinear[5*(1+2)] = { - -3.0, 1.00000000e-01, 1.10000000e+00, // (0) - -1.0, 0.50000000e-01, 1.05000000e+00, // (0.5) - 1.25, 0.12500000e-01, 1.30000000e+00, // (1.25) - -4.0, 0.0, 0.0, // not found - 3.0, 0.0, 0.0, // not fount + static const double queryLinear[5 * (1 + 2)] = { + -3.0, + 1.00000000e-01, + 1.10000000e+00, // (0) + -1.0, + 0.50000000e-01, + 1.05000000e+00, // (0.5) + 1.25, + 0.12500000e-01, + 1.30000000e+00, // (1.25) + -4.0, + 0.0, + 0.0, // not found + 3.0, + 0.0, + 0.0, // not fount }; data->queryLinear = queryLinear; - static const int errFlags[5] = { 0, 0, 0, 1, 1, }; + static const int errFlags[5] = { + 0, + 0, + 0, + 1, + 1, + }; data->errFlags = errFlags; data->filename = "data/grid_line1d.spatialdb"; @@ -201,7 +274,8 @@ spatialdata::spatialdb::TestSimpleGridDB_Cases::Line1D(void) { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestSimpleGridDB_Data* spatialdata::spatialdb::TestSimpleGridDB_Cases::Line2D(void) { - spatialdata::spatialdb::TestSimpleGridDB_Data* data = new TestSimpleGridDB_Data;assert(data); + spatialdata::spatialdb::TestSimpleGridDB_Data* data = new TestSimpleGridDB_Data; + assert(data); data->numX = 1; data->numY = 3; @@ -209,45 +283,75 @@ spatialdata::spatialdb::TestSimpleGridDB_Cases::Line2D(void) { data->numValues = 2; data->dataDim = 1; - static const double dbX[1] = { 2.0, }; + static const double dbX[1] = { + 2.0, + }; data->dbX = dbX; - static const double dbY[3] = { -3.0, 1.0, 2.0, }; + static const double dbY[3] = { + -3.0, + 1.0, + 2.0, + }; data->dbY = dbY; - static const double dbData[3*2] = { - 1.00000000e-01, 1.10000000e+00, // 0,0,0 - 0.00000000e-01, 1.20000000e+00, // 1,0,0 - 5.00000000e-01, 1.60000000e+00, // 2,0,0 + static const double dbData[3 * 2] = { + 1.00000000e-01, + 1.10000000e+00, // 0,0,0 + 0.00000000e-01, + 1.20000000e+00, // 1,0,0 + 5.00000000e-01, + 1.60000000e+00, // 2,0,0 }; data->dbData = dbData; - static const char* names[2] = { "One", "Two" }; + static const char* names[2] = {"One", "Two"}; data->names = names; - static const char* units[2] = { "m", "m" }; + static const char* units[2] = {"m", "m"}; data->units = units; data->numQueries = 5; - static const double queryNearest[5*(2+2)] = { - 3.8, -3.2, 1.00000000e-01, 1.10000000e+00, // (0) - 1.3, 1.1, 0.00000000e-01, 1.20000000e+00, // (1) - 6.0, 0.0, 0.00000000e-01, 1.20000000e+00, // (1) - 3.4, 1.6, 5.00000000e-01, 1.60000000e+00, // (2) - 3.5, -2.0, 1.00000000e-01, 1.10000000e+00, // (0) + static const double queryNearest[5 * (2 + 2)] = { + 3.8, -3.2, 1.00000000e-01, 1.10000000e+00, // (0) + 1.3, 1.1, 0.00000000e-01, 1.20000000e+00, // (1) + 6.0, 0.0, 0.00000000e-01, 1.20000000e+00, // (1) + 3.4, 1.6, 5.00000000e-01, 1.60000000e+00, // (2) + 3.5, -2.0, 1.00000000e-01, 1.10000000e+00, // (0) }; data->queryNearest = queryNearest; - static const double queryLinear[5*(2+2)] = { - 3.8, -3.0, 1.00000000e-01, 1.10000000e+00, // (0) - 1.3, -1.0, 0.50000000e-01, 1.05000000e+00, // (0.5) - 6.0, 1.25, 0.12500000e-01, 1.30000000e+00, // (1.25) - 3.4, -4.0, 0.0, 0.0, // not found - 3.5, 3.0, 0.0, 0.0, // not fount + static const double queryLinear[5 * (2 + 2)] = { + 3.8, + -3.0, + 1.00000000e-01, + 1.10000000e+00, // (0) + 1.3, + -1.0, + 0.50000000e-01, + 1.05000000e+00, // (0.5) + 6.0, + 1.25, + 0.12500000e-01, + 1.30000000e+00, // (1.25) + 3.4, + -4.0, + 0.0, + 0.0, // not found + 3.5, + 3.0, + 0.0, + 0.0, // not fount }; data->queryLinear = queryLinear; - static const int errFlags[5] = { 0, 0, 0, 1, 1, }; + static const int errFlags[5] = { + 0, + 0, + 0, + 1, + 1, + }; data->errFlags = errFlags; data->filename = "data/grid_line2d.spatialdb"; @@ -259,7 +363,8 @@ spatialdata::spatialdb::TestSimpleGridDB_Cases::Line2D(void) { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestSimpleGridDB_Data* spatialdata::spatialdb::TestSimpleGridDB_Cases::Line3D(void) { - spatialdata::spatialdb::TestSimpleGridDB_Data* data = new TestSimpleGridDB_Data;assert(data); + spatialdata::spatialdb::TestSimpleGridDB_Data* data = new TestSimpleGridDB_Data; + assert(data); data->numX = 1; data->numY = 1; @@ -268,48 +373,85 @@ spatialdata::spatialdb::TestSimpleGridDB_Cases::Line3D(void) { data->numValues = 2; data->dataDim = 1; - static const double dbX[1] = { 2.0, }; + static const double dbX[1] = { + 2.0, + }; data->dbX = dbX; - static const double dbY[1] = { 0.6, }; + static const double dbY[1] = { + 0.6, + }; data->dbY = dbY; - static const double dbZ[3] = { -3.0, 1.0, 2.0, }; + static const double dbZ[3] = { + -3.0, + 1.0, + 2.0, + }; data->dbZ = dbZ; - static const double dbData[3*2] = { - 1.00000000e-01, 1.10000000e+00, // 0,0,0 - 0.00000000e-01, 1.20000000e+00, // 1,0,0 - 5.00000000e-01, 1.60000000e+00, // 2,0,0 + static const double dbData[3 * 2] = { + 1.00000000e-01, + 1.10000000e+00, // 0,0,0 + 0.00000000e-01, + 1.20000000e+00, // 1,0,0 + 5.00000000e-01, + 1.60000000e+00, // 2,0,0 }; data->dbData = dbData; - static const char* names[2] = { "One", "Two" }; + static const char* names[2] = {"One", "Two"}; data->names = names; - static const char* units[2] = { "m", "m" }; + static const char* units[2] = {"m", "m"}; data->units = units; data->numQueries = 5; - static const double queryNearest[5*(3+2)] = { - 3.8, 3.8, -3.2, 1.00000000e-01, 1.10000000e+00, // (0) - 1.3, 6.3, 1.1, 0.00000000e-01, 1.20000000e+00, // (1) - 6.0, 5.0, 0.0, 0.00000000e-01, 1.20000000e+00, // (1) - 3.4, 4.4, 1.6, 5.00000000e-01, 1.60000000e+00, // (2) - 3.5, 7.5, -2.0, 1.00000000e-01, 1.10000000e+00, // (0) + static const double queryNearest[5 * (3 + 2)] = { + 3.8, 3.8, -3.2, 1.00000000e-01, 1.10000000e+00, // (0) + 1.3, 6.3, 1.1, 0.00000000e-01, 1.20000000e+00, // (1) + 6.0, 5.0, 0.0, 0.00000000e-01, 1.20000000e+00, // (1) + 3.4, 4.4, 1.6, 5.00000000e-01, 1.60000000e+00, // (2) + 3.5, 7.5, -2.0, 1.00000000e-01, 1.10000000e+00, // (0) }; data->queryNearest = queryNearest; - static const double queryLinear[5*(3+2)] = { - 3.8, 3.8, -3.0, 1.00000000e-01, 1.10000000e+00, // (0) - 1.3, 6.3, -1.0, 0.50000000e-01, 1.05000000e+00, // (0.5) - 6.0, 5.0, 1.25, 0.12500000e-01, 1.30000000e+00, // (1.25) - 3.4, 4.4, -4.0, 0.0, 0.0, // not found - 3.5, 7.5, 3.0, 0.0, 0.0, // not fount + static const double queryLinear[5 * (3 + 2)] = { + 3.8, + 3.8, + -3.0, + 1.00000000e-01, + 1.10000000e+00, // (0) + 1.3, + 6.3, + -1.0, + 0.50000000e-01, + 1.05000000e+00, // (0.5) + 6.0, + 5.0, + 1.25, + 0.12500000e-01, + 1.30000000e+00, // (1.25) + 3.4, + 4.4, + -4.0, + 0.0, + 0.0, // not found + 3.5, + 7.5, + 3.0, + 0.0, + 0.0, // not fount }; data->queryLinear = queryLinear; - static const int errFlags[5] = { 0, 0, 0, 1, 1, }; + static const int errFlags[5] = { + 0, + 0, + 0, + 1, + 1, + }; data->errFlags = errFlags; data->filename = "data/grid_line3d.spatialdb"; @@ -321,7 +463,8 @@ spatialdata::spatialdb::TestSimpleGridDB_Cases::Line3D(void) { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestSimpleGridDB_Data* spatialdata::spatialdb::TestSimpleGridDB_Cases::Area2D(void) { - spatialdata::spatialdb::TestSimpleGridDB_Data* data = new TestSimpleGridDB_Data;assert(data); + spatialdata::spatialdb::TestSimpleGridDB_Data* data = new TestSimpleGridDB_Data; + assert(data); data->numX = 3; data->numY = 2; @@ -329,48 +472,82 @@ spatialdata::spatialdb::TestSimpleGridDB_Cases::Area2D(void) { data->numValues = 2; data->dataDim = 2; - static const double dbX[3] = { -3.0, 1.0, 2.0, }; + static const double dbX[3] = { + -3.0, + 1.0, + 2.0, + }; data->dbX = dbX; - static const double dbY[2] = { 2.0, 4.0, }; + static const double dbY[2] = { + 2.0, + 4.0, + }; data->dbY = dbY; - static const double dbData[3*2*2] = { - 1.00000000e-01, 1.10000000e+00, // 0,0 - 0.00000000e-01, 1.20000000e+00, // 1,0 - 5.00000000e-01, 1.60000000e+00, // 2,0 - 4.00000000e-01, 4.60000000e+00, // 0,1 - 9.00000000e-01, 4.70000000e+00, // 1,1 - 7.00000000e-01, 4.80000000e+00, // 2,1 + static const double dbData[3 * 2 * 2] = { + 1.00000000e-01, + 1.10000000e+00, // 0,0 + 0.00000000e-01, + 1.20000000e+00, // 1,0 + 5.00000000e-01, + 1.60000000e+00, // 2,0 + 4.00000000e-01, + 4.60000000e+00, // 0,1 + 9.00000000e-01, + 4.70000000e+00, // 1,1 + 7.00000000e-01, + 4.80000000e+00, // 2,1 }; data->dbData = dbData; - static const char* names[2] = { "One", "Two" }; + static const char* names[2] = {"One", "Two"}; data->names = names; - static const char* units[2] = { "m", "m" }; + static const char* units[2] = {"m", "m"}; data->units = units; data->numQueries = 5; - static const double queryNearest[5*(2+2)] = { - -3.2, 3.8, 4.00000000e-01, 4.60000000e+00, // (0,1) - 1.1, 1.3, 0.00000000e-01, 1.20000000e+00, // (1,0) - 0.0, -6.0, 0.00000000e-01, 1.20000000e+00, // (1,0) - 1.6, 3.4, 7.00000000e-01, 4.80000000e+00, // (2,1) - -2.0, 3.5, 4.00000000e-01, 4.60000000e+00, // (0,1) + static const double queryNearest[5 * (2 + 2)] = { + -3.2, 3.8, 4.00000000e-01, 4.60000000e+00, // (0,1) + 1.1, 1.3, 0.00000000e-01, 1.20000000e+00, // (1,0) + 0.0, -6.0, 0.00000000e-01, 1.20000000e+00, // (1,0) + 1.6, 3.4, 7.00000000e-01, 4.80000000e+00, // (2,1) + -2.0, 3.5, 4.00000000e-01, 4.60000000e+00, // (0,1) }; data->queryNearest = queryNearest; - static const double queryLinear[5*(2+2)] = { - -3.0, 4.0, 4.00000000e-01, 4.60000000e+00, // (0,1) - -1.0, 2.5, 2.00000000e-01, 2.02500000e+00, // (0.5, 0.25) - 1.25, 3.0, 4.87500000e-01, 3.01250000e+00, // (1.25, 0.5) - 0.0, 4.1, 0.0, 0.0, // not found - 3.0, 2.0, 0.0, 0.0, // not fount + static const double queryLinear[5 * (2 + 2)] = { + -3.0, + 4.0, + 4.00000000e-01, + 4.60000000e+00, // (0,1) + -1.0, + 2.5, + 2.00000000e-01, + 2.02500000e+00, // (0.5, 0.25) + 1.25, + 3.0, + 4.87500000e-01, + 3.01250000e+00, // (1.25, 0.5) + 0.0, + 4.1, + 0.0, + 0.0, // not found + 3.0, + 2.0, + 0.0, + 0.0, // not fount }; data->queryLinear = queryLinear; - static const int errFlags[5] = { 0, 0, 0, 1, 1, }; + static const int errFlags[5] = { + 0, + 0, + 0, + 1, + 1, + }; data->errFlags = errFlags; data->filename = "data/grid_area2d.spatialdb"; @@ -382,7 +559,8 @@ spatialdata::spatialdb::TestSimpleGridDB_Cases::Area2D(void) { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestSimpleGridDB_Data* spatialdata::spatialdb::TestSimpleGridDB_Cases::Area3D(void) { - spatialdata::spatialdb::TestSimpleGridDB_Data* data = new TestSimpleGridDB_Data;assert(data); + spatialdata::spatialdb::TestSimpleGridDB_Data* data = new TestSimpleGridDB_Data; + assert(data); data->numX = 3; data->numY = 1; @@ -391,51 +569,92 @@ spatialdata::spatialdb::TestSimpleGridDB_Cases::Area3D(void) { data->numValues = 2; data->dataDim = 2; - static const double dbX[3] = { -3.0, 1.0, 2.0, }; + static const double dbX[3] = { + -3.0, + 1.0, + 2.0, + }; data->dbX = dbX; - static const double dbY[1] = { 8.0, }; + static const double dbY[1] = { + 8.0, + }; data->dbY = dbY; - static const double dbZ[2] = { 2.0, 4.0, }; + static const double dbZ[2] = { + 2.0, + 4.0, + }; data->dbZ = dbZ; - static const double dbData[3*1*2*2] = { - 1.00000000e-01, 1.10000000e+00, // 0,0 - 0.00000000e-01, 1.20000000e+00, // 1,0 - 5.00000000e-01, 1.60000000e+00, // 2,0 - 4.00000000e-01, 4.60000000e+00, // 0,1 - 9.00000000e-01, 4.70000000e+00, // 1,1 - 7.00000000e-01, 4.80000000e+00, // 2,1 + static const double dbData[3 * 1 * 2 * 2] = { + 1.00000000e-01, + 1.10000000e+00, // 0,0 + 0.00000000e-01, + 1.20000000e+00, // 1,0 + 5.00000000e-01, + 1.60000000e+00, // 2,0 + 4.00000000e-01, + 4.60000000e+00, // 0,1 + 9.00000000e-01, + 4.70000000e+00, // 1,1 + 7.00000000e-01, + 4.80000000e+00, // 2,1 }; data->dbData = dbData; - static const char* names[2] = { "One", "Two" }; + static const char* names[2] = {"One", "Two"}; data->names = names; - static const char* units[2] = { "m", "m" }; + static const char* units[2] = {"m", "m"}; data->units = units; data->numQueries = 5; - static const double queryNearest[5*(3+2)] = { - -3.2, 7.8, 3.8, 4.00000000e-01, 4.60000000e+00, // (0,1) - 1.1, 3.3, 1.3, 0.00000000e-01, 1.20000000e+00, // (1,0) - 0.0, -5.0, -6.0, 0.00000000e-01, 1.20000000e+00, // (1,0) - 1.6, 9.4, 3.4, 7.00000000e-01, 4.80000000e+00, // (2,1) - -2.0, 2.5, 3.5, 4.00000000e-01, 4.60000000e+00, // (0,1) + static const double queryNearest[5 * (3 + 2)] = { + -3.2, 7.8, 3.8, 4.00000000e-01, 4.60000000e+00, // (0,1) + 1.1, 3.3, 1.3, 0.00000000e-01, 1.20000000e+00, // (1,0) + 0.0, -5.0, -6.0, 0.00000000e-01, 1.20000000e+00, // (1,0) + 1.6, 9.4, 3.4, 7.00000000e-01, 4.80000000e+00, // (2,1) + -2.0, 2.5, 3.5, 4.00000000e-01, 4.60000000e+00, // (0,1) }; data->queryNearest = queryNearest; - static const double queryLinear[5*(3+2)] = { - -3.0, 7.8, 4.0, 4.00000000e-01, 4.60000000e+00, // (0,1) - -1.0, 3.3, 2.5, 2.00000000e-01, 2.02500000e+00, // (0.5, 0.25) - 1.25, 5.0, 3.0, 4.87500000e-01, 3.01250000e+00, // (1.25, 0.5) - 0.0, 9.4, 4.1, 0.0, 0.0, // not found - 3.0, 2.5, 2.0, 0.0, 0.0, // not found + static const double queryLinear[5 * (3 + 2)] = { + -3.0, + 7.8, + 4.0, + 4.00000000e-01, + 4.60000000e+00, // (0,1) + -1.0, + 3.3, + 2.5, + 2.00000000e-01, + 2.02500000e+00, // (0.5, 0.25) + 1.25, + 5.0, + 3.0, + 4.87500000e-01, + 3.01250000e+00, // (1.25, 0.5) + 0.0, + 9.4, + 4.1, + 0.0, + 0.0, // not found + 3.0, + 2.5, + 2.0, + 0.0, + 0.0, // not found }; data->queryLinear = queryLinear; - static const int errFlags[5] = { 0, 0, 0, 1, 1, }; + static const int errFlags[5] = { + 0, + 0, + 0, + 1, + 1, + }; data->errFlags = errFlags; data->filename = "data/grid_area3d.spatialdb"; @@ -447,7 +666,8 @@ spatialdata::spatialdb::TestSimpleGridDB_Cases::Area3D(void) { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestSimpleGridDB_Data* spatialdata::spatialdb::TestSimpleGridDB_Cases::Volume3D(void) { - spatialdata::spatialdb::TestSimpleGridDB_Data* data = new TestSimpleGridDB_Data;assert(data); + spatialdata::spatialdb::TestSimpleGridDB_Data* data = new TestSimpleGridDB_Data; + assert(data); data->numX = 3; data->numY = 2; @@ -456,69 +676,107 @@ spatialdata::spatialdb::TestSimpleGridDB_Cases::Volume3D(void) { data->numValues = 2; data->dataDim = 3; - static const double dbX[3] = { -3.0, 1.0, 2.0, }; + static const double dbX[3] = { + -3.0, + 1.0, + 2.0, + }; data->dbX = dbX; - static const double dbY[2] = { 2.0, 4.0, }; + static const double dbY[2] = { + 2.0, + 4.0, + }; data->dbY = dbY; - static const double dbZ[4] = { -0.5, 0.0, 1.0, 4.0, }; + static const double dbZ[4] = { + -0.5, + 0.0, + 1.0, + 4.0, + }; data->dbZ = dbZ; - static const double dbData[3*2*4*2] = { - 1.00000000e-01, 1.10000000e+00, // 0,0,0 - 0.00000000e-01, 1.20000000e+00, // 1,0,0 - 5.00000000e-01, 1.60000000e+00, // 2,0,0 - 4.00000000e-01, 4.60000000e+00, // 0,1,0 - 9.00000000e-01, 4.70000000e+00, // 1,1,0 - 7.00000000e-01, 4.80000000e+00, // 2,1,0 - 3.00000000e-01, 3.30000000e+00, // 0,0,1 - 1.00000000e-01, 3.40000000e+00, // 1,0,1 - 3.00000000e-01, 3.30000000e+00, // 2,0,1 - 3.00000000e-01, 3.20000000e+00, // 0,1,1 - 4.00000000e-01, 3.30000000e+00, // 1,1,1 - 4.00000000e-01, 3.40000000e+00, // 2,1,1 - 2.00000000e-01, 2.20000000e+00, // 0,0,2 - 2.00000000e-01, 2.10000000e+00, // 1,0,2 - 8.00000000e-01, 2.80000000e+00, // 2,0,2 - 7.00000000e-01, 5.20000000e+00, // 0,1,2 - 7.00000000e-01, 5.50000000e+00, // 1,1,2 - 3.00000000e-01, 5.70000000e+00, // 2,1,2 - 1.00000000e-01, 1.10000000e+00, // 0,0,3 - 6.00000000e-01, 1.40000000e+00, // 1,0,3 - 3.00000000e-01, 1.50000000e+00, // 2,0,3 - 5.00000000e-01, 4.60000000e+00, // 0,1,3 - 6.00000000e-01, 4.70000000e+00, // 1,1,3 - 4.00000000e-01, 4.50000000e+00, // 2,1,3 + static const double dbData[3 * 2 * 4 * 2] = { + 1.00000000e-01, 1.10000000e+00, // 0,0,0 + 0.00000000e-01, 1.20000000e+00, // 1,0,0 + 5.00000000e-01, 1.60000000e+00, // 2,0,0 + 4.00000000e-01, 4.60000000e+00, // 0,1,0 + 9.00000000e-01, 4.70000000e+00, // 1,1,0 + 7.00000000e-01, 4.80000000e+00, // 2,1,0 + 3.00000000e-01, 3.30000000e+00, // 0,0,1 + 1.00000000e-01, 3.40000000e+00, // 1,0,1 + 3.00000000e-01, 3.30000000e+00, // 2,0,1 + 3.00000000e-01, 3.20000000e+00, // 0,1,1 + 4.00000000e-01, 3.30000000e+00, // 1,1,1 + 4.00000000e-01, 3.40000000e+00, // 2,1,1 + 2.00000000e-01, 2.20000000e+00, // 0,0,2 + 2.00000000e-01, 2.10000000e+00, // 1,0,2 + 8.00000000e-01, 2.80000000e+00, // 2,0,2 + 7.00000000e-01, 5.20000000e+00, // 0,1,2 + 7.00000000e-01, 5.50000000e+00, // 1,1,2 + 3.00000000e-01, 5.70000000e+00, // 2,1,2 + 1.00000000e-01, 1.10000000e+00, // 0,0,3 + 6.00000000e-01, 1.40000000e+00, // 1,0,3 + 3.00000000e-01, 1.50000000e+00, // 2,0,3 + 5.00000000e-01, 4.60000000e+00, // 0,1,3 + 6.00000000e-01, 4.70000000e+00, // 1,1,3 + 4.00000000e-01, 4.50000000e+00, // 2,1,3 }; data->dbData = dbData; - static const char* names[2] = { "One", "Two" }; + static const char* names[2] = {"One", "Two"}; data->names = names; - static const char* units[2] = { "m", "m" }; + static const char* units[2] = {"m", "m"}; data->units = units; data->numQueries = 5; - static const double queryNearest[5*(3+2)] = { - -3.2, 3.8, 2.0, 7.00000000e-01, 5.20000000e+00, // (0,1,2) - 1.1, 1.3, -0.1, 1.00000000e-01, 3.40000000e+00, // (1,0,1) - 0.0, -6.0, 5.0, 6.00000000e-01, 1.40000000e+00, // (1,0,3) - 1.6, 3.4, -0.6, 7.00000000e-01, 4.80000000e+00, // (2,1,0) - -2.0, 3.5, 0.9, 7.00000000e-01, 5.20000000e+00, // (0,1,2) + static const double queryNearest[5 * (3 + 2)] = { + -3.2, 3.8, 2.0, 7.00000000e-01, 5.20000000e+00, // (0,1,2) + 1.1, 1.3, -0.1, 1.00000000e-01, 3.40000000e+00, // (1,0,1) + 0.0, -6.0, 5.0, 6.00000000e-01, 1.40000000e+00, // (1,0,3) + 1.6, 3.4, -0.6, 7.00000000e-01, 4.80000000e+00, // (2,1,0) + -2.0, 3.5, 0.9, 7.00000000e-01, 5.20000000e+00, // (0,1,2) }; data->queryNearest = queryNearest; - static const double queryLinear[5*(3+2)] = { - -3.0, 4.0, 1.0, 7.00000000e-01, 5.20000000e+00, // (0,1,2) - -1.0, 2.5, 2.5, 3.62500000e-01, 2.52500000e+00, // (0,5, 0.25, 2.5) - 1.25, 3.0, 0.25, 3.25000000e-01, 3.49062500e+00, // (1.25, 0.5, 1.25) - 0.0, 4.1, 0.0, 0.0, 0.0, // not found - 1.0, 2.0, -0.6, 0.0, 0.0, // not found + static const double queryLinear[5 * (3 + 2)] = { + -3.0, + 4.0, + 1.0, + 7.00000000e-01, + 5.20000000e+00, // (0,1,2) + -1.0, + 2.5, + 2.5, + 3.62500000e-01, + 2.52500000e+00, // (0,5, 0.25, 2.5) + 1.25, + 3.0, + 0.25, + 3.25000000e-01, + 3.49062500e+00, // (1.25, 0.5, 1.25) + 0.0, + 4.1, + 0.0, + 0.0, + 0.0, // not found + 1.0, + 2.0, + -0.6, + 0.0, + 0.0, // not found }; data->queryLinear = queryLinear; - static const int errFlags[5] = { 0, 0, 0, 1, 1, }; + static const int errFlags[5] = { + 0, + 0, + 0, + 1, + 1, + }; data->errFlags = errFlags; data->filename = "data/grid_volume3d.spatialdb"; diff --git a/tests/libtests/spatialdb/TestSimpleIOAscii.cc b/tests/libtests/spatialdb/TestSimpleIOAscii.cc index 97ad5978..afdbc51b 100644 --- a/tests/libtests/spatialdb/TestSimpleIOAscii.cc +++ b/tests/libtests/spatialdb/TestSimpleIOAscii.cc @@ -12,8 +12,8 @@ #include "spatialdata/spatialdb/SimpleIOAscii.hh" // Test subject -#include "spatialdata/spatialdb/SimpleDBData.hh" // USES SimpleDBData #include "spatialdata/geocoords/CSCart.hh" // USES CSCart +#include "spatialdata/spatialdb/SimpleDBData.hh" // USES SimpleDBData #include "catch2/catch_test_macros.hpp" #include "catch2/matchers/catch_matchers_floating_point.hpp" @@ -24,29 +24,28 @@ namespace spatialdata { namespace spatialdb { class TestSimpleIOAscii; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata class spatialdata::spatialdb::TestSimpleIOAscii { // PUBLIC METHODS ///////////////////////////////////////////////////// -public: - + public: /// Test filename(), read(), write(). - static - void testWriteRead(void); + static void testWriteRead(void); /// Test filename(), read() with spatial database file that contains /// comments. - static - void testReadComments(void); + static void testReadComments(void); }; // class TestSimpleIOAscii // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestSimpleIOAscii::testWriteRead", "[TestSimpleIOAscii]") { +TEST_CASE("TestSimpleIOAscii::testWriteRead", + "[TestSimpleIOAscii]") { spatialdata::spatialdb::TestSimpleIOAscii::testWriteRead(); } -TEST_CASE("TestSimpleIOAscii::testReadComments", "[TestSimpleIOAscii]") { +TEST_CASE("TestSimpleIOAscii::testReadComments", + "[TestSimpleIOAscii]") { spatialdata::spatialdb::TestSimpleIOAscii::testReadComments(); } @@ -58,21 +57,36 @@ spatialdata::spatialdb::TestSimpleIOAscii::testWriteRead(void) { const size_t numLocsE = 5; const size_t numValsE = 2; const size_t dataDimE = 3; - const char* names[numValsE] = { "One", "Two" }; - const char* units[numValsE] = { "m", "m" }; - const double coordsE[numLocsE*spaceDimE] = { - 0.6, 0.1, 0.2, - 1.0, 1.1, 1.2, - 4.7, 9.5, 8.7, - 3.4, 0.7, 9.8, - 3.4, 9.8, 5.7, + const char* names[numValsE] = {"One", "Two"}; + const char* units[numValsE] = {"m", "m"}; + const double coordsE[numLocsE * spaceDimE] = { + 0.6, + 0.1, + 0.2, + 1.0, + 1.1, + 1.2, + 4.7, + 9.5, + 8.7, + 3.4, + 0.7, + 9.8, + 3.4, + 9.8, + 5.7, }; - const double dataE[numLocsE*numValsE] = { - 6.6, 3.4, - 5.5, 6.7, - 2.3, 4.1, - 5.7, 2.0, - 6.3, 6.7, + const double dataE[numLocsE * numValsE] = { + 6.6, + 3.4, + 5.5, + 6.7, + 2.3, + 4.1, + 5.7, + 2.0, + 6.3, + 6.7, }; SimpleDBData dataOut; @@ -118,7 +132,8 @@ spatialdata::spatialdb::TestSimpleIOAscii::testWriteRead(void) { } // for } // for - delete csIn;csIn = NULL; + delete csIn; + csIn = NULL; } // testWriteRead @@ -131,21 +146,36 @@ spatialdata::spatialdb::TestSimpleIOAscii::testReadComments(void) { const size_t numLocsE = 5; const size_t numValsE = 2; const size_t dataDimE = 3; - const char* names[numValsE] = { "One", "Two" }; - const char* units[numValsE] = { "m", "m" }; - const double coordsE[numLocsE*spaceDimE] = { - 0.6, 0.1, 0.2, - 1.0, 1.1, 1.2, - 4.7, 9.5, 8.7, - 3.4, 0.7, 9.8, - 3.4, 9.8, 5.7, + const char* names[numValsE] = {"One", "Two"}; + const char* units[numValsE] = {"m", "m"}; + const double coordsE[numLocsE * spaceDimE] = { + 0.6, + 0.1, + 0.2, + 1.0, + 1.1, + 1.2, + 4.7, + 9.5, + 8.7, + 3.4, + 0.7, + 9.8, + 3.4, + 9.8, + 5.7, }; - const double dataE[numLocsE*numValsE] = { - 6.6, 3.4, - 5.5, 6.7, - 2.3, 4.1, - 5.7, 2.0, - 6.3, 6.7, + const double dataE[numLocsE * numValsE] = { + 6.6, + 3.4, + 5.5, + 6.7, + 2.3, + 4.1, + 5.7, + 2.0, + 6.3, + 6.7, }; const char* filename = "data/spatial_comments.dat"; @@ -182,7 +212,8 @@ spatialdata::spatialdb::TestSimpleIOAscii::testReadComments(void) { } // for } // for - delete csIn;csIn = NULL; + delete csIn; + csIn = NULL; } // testReadComments diff --git a/tests/libtests/spatialdb/TestSpatialDB.cc b/tests/libtests/spatialdb/TestSpatialDB.cc index 88de7f91..a2be6882 100644 --- a/tests/libtests/spatialdb/TestSpatialDB.cc +++ b/tests/libtests/spatialdb/TestSpatialDB.cc @@ -19,26 +19,25 @@ extern "C" { #include "spatialdata/spatialdb/cspatialdb.h" } -#include "spatialdata/geocoords/CoordSys.hh" // USES CSCart #include "spatialdata/geocoords/CSCart.hh" // USES CSCart +#include "spatialdata/geocoords/CoordSys.hh" // USES CSCart #include "catch2/catch_test_macros.hpp" #include "catch2/matchers/catch_matchers_floating_point.hpp" -#include // USES fabs() #include +#include // USES fabs() // ------------------------------------------------------------------------------------------------ namespace spatialdata { namespace spatialdb { class TestSpatialDB; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata class spatialdata::spatialdb::TestSpatialDB { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Constructor. TestSpatialDB(void); @@ -55,27 +54,30 @@ class spatialdata::spatialdb::TestSpatialDB { void testDB_CAPI(void); // PRIVATE MEMBERS //////////////////////////////////////////////////////////////////////////// -private: - + private: SpatialDB* _db; ///< Test subject }; // class TestSpatialDB // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestSpatialDB::testDB", "[TestSpatialDB]") { +TEST_CASE("TestSpatialDB::testDB", + "[TestSpatialDB]") { spatialdata::spatialdb::TestSpatialDB().testDB(); } -TEST_CASE("TestSpatialDB::testDBmulti", "[TestSpatialDB]") { +TEST_CASE("TestSpatialDB::testDBmulti", + "[TestSpatialDB]") { spatialdata::spatialdb::TestSpatialDB().testDBmulti(); } -TEST_CASE("TestSpatialDB::testDB_CAPI", "[TestSpatialDB]") { +TEST_CASE("TestSpatialDB::testDB_CAPI", + "[TestSpatialDB]") { spatialdata::spatialdb::TestSpatialDB().testDB_CAPI(); } // ---------------------------------------------------------------------- // Constructor. spatialdata::spatialdb::TestSpatialDB::TestSpatialDB(void) { - spatialdata::spatialdb::SimpleDB* db = new spatialdata::spatialdb::SimpleDB;assert(db); + spatialdata::spatialdb::SimpleDB* db = new spatialdata::spatialdb::SimpleDB; + assert(db); const char* filename = "data/spatialdb.dat"; SimpleIOAscii iohandler; @@ -91,7 +93,8 @@ spatialdata::spatialdb::TestSpatialDB::TestSpatialDB(void) { // ---------------------------------------------------------------------- // Destructor. spatialdata::spatialdb::TestSpatialDB::~TestSpatialDB(void) { - delete _db;_db = 0; + delete _db; + _db = 0; } // tearDown @@ -103,9 +106,9 @@ spatialdata::spatialdb::TestSpatialDB::testDB(void) { // testDB const char* names[4] = {"two", "one", "four", "three"}; const size_t numVals = 4; - const double queryLoc[3] = { 0.6, 0.1, 0.2 }; - const double vals[4] = { 6.3e+3, 4.7, 0.8, 1.2e+6 }; - const int errFlags[1] = { 0 }; + const double queryLoc[3] = {0.6, 0.1, 0.2}; + const double vals[4] = {6.3e+3, 4.7, 0.8, 1.2e+6}; + const int errFlags[1] = {0}; const int spaceDim = 3; _db->setQueryValues(names, numVals); @@ -121,7 +124,8 @@ spatialdata::spatialdb::TestSpatialDB::testDB(void) { // testDB CHECK_THAT(valsQ[iVal], Catch::Matchers::WithinAbs(vals[iVal], toleranceV)); } // for - delete[] valsQ;valsQ = NULL; + delete[] valsQ; + valsQ = NULL; _db->close(); } // testDB @@ -136,15 +140,25 @@ spatialdata::spatialdb::TestSpatialDB::testDBmulti(void) { // testDBmulti const size_t numLocs = 2; const size_t spaceDim = 3; const char* names[numVals] = {"two", "one", "four", "three"}; - const double queryLocs[numLocs*spaceDim] = { - 0.6, 0.1, 0.2, - 0.1, 0.6, 0.3, + const double queryLocs[numLocs * spaceDim] = { + 0.6, + 0.1, + 0.2, + 0.1, + 0.6, + 0.3, }; - const double vals[numLocs*numVals] = { - 6.3e+3, 4.7, 0.8, 1.2e+6, - 3.6e+3, 7.4, 8.0, 2.1e+6, + const double vals[numLocs * numVals] = { + 6.3e+3, + 4.7, + 0.8, + 1.2e+6, + 3.6e+3, + 7.4, + 8.0, + 2.1e+6, }; - const int errFlags[numLocs] = { 0, 0 }; + const int errFlags[numLocs] = {0, 0}; _db->setQueryValues(names, numVals); @@ -155,8 +169,7 @@ spatialdata::spatialdb::TestSpatialDB::testDBmulti(void) { // testDBmulti spatialdata::geocoords::CSCart csCart; - _db->multiquery(valsQ, numLocs, numVals, - errQ, numLocs, queryLocs, numLocs, spaceDim, &csCart); + _db->multiquery(valsQ, numLocs, numVals, errQ, numLocs, queryLocs, numLocs, spaceDim, &csCart); const double tolerance = 1.0e-06; for (size_t iLoc = 0; iLoc < numLocs; ++iLoc) { @@ -167,8 +180,10 @@ spatialdata::spatialdb::TestSpatialDB::testDBmulti(void) { // testDBmulti } } // for - delete[] valsQ;valsQ = NULL; - delete[] errQ;errQ = NULL; + delete[] valsQ; + valsQ = NULL; + delete[] errQ; + errQ = NULL; _db->close(); } // testDBmulti @@ -182,17 +197,17 @@ spatialdata::spatialdb::TestSpatialDB::testDB_CAPI(void) { const char* names[2] = {"two", "one"}; const size_t numVals = 2; - const double queryLoc[3] = { 0.6, 0.1, 0.2 }; + const double queryLoc[3] = {0.6, 0.1, 0.2}; const size_t spaceDim = 3; - const double vals[2] = { 6.3e+3, 4.7 }; - const int errFlags[1] = { 0 }; + const double vals[2] = {6.3e+3, 4.7}; + const int errFlags[1] = {0}; _db->setQueryValues(names, numVals); double* valsQ = (0 < numVals) ? new double[numVals] : 0; spatialdata::geocoords::CSCart csCart; - const int err = spatialdb_query((void*) _db, valsQ, numVals, queryLoc, spaceDim, (void*) &csCart); + const int err = spatialdb_query((void*)_db, valsQ, numVals, queryLoc, spaceDim, (void*)&csCart); REQUIRE(err == errFlags[0]); const double tolerance = 1.0e-06; @@ -201,7 +216,8 @@ spatialdata::spatialdb::TestSpatialDB::testDB_CAPI(void) { CHECK_THAT(valsQ[iVal], Catch::Matchers::WithinAbs(vals[iVal], toleranceV)); } // for - delete[] valsQ;valsQ = NULL; + delete[] valsQ; + valsQ = NULL; _db->close(); } // testDB_c diff --git a/tests/libtests/spatialdb/TestTimeHistory.cc b/tests/libtests/spatialdb/TestTimeHistory.cc index ce6625fd..b4f10483 100644 --- a/tests/libtests/spatialdb/TestTimeHistory.cc +++ b/tests/libtests/spatialdb/TestTimeHistory.cc @@ -23,35 +23,34 @@ namespace spatialdata { namespace spatialdb { class TestTimeHistory; class TimeHistory; // USES TimeHistory - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata class spatialdata::spatialdb::TestTimeHistory { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Test accessors. - static - void testAccessors(void); + static void testAccessors(void); /// Test open() and close() - static - void testOpenClose(void); + static void testOpenClose(void); /// Test query(). - static - void testQuery(void); + static void testQuery(void); }; // class TestTimeHistory // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestTimeHistory::testAccessors", "[TestTimeHistory]") { +TEST_CASE("TestTimeHistory::testAccessors", + "[TestTimeHistory]") { spatialdata::spatialdb::TestTimeHistory::testAccessors(); } -TEST_CASE("TestTimeHistory::testOpenClose", "[TestTimeHistory]") { +TEST_CASE("TestTimeHistory::testOpenClose", + "[TestTimeHistory]") { spatialdata::spatialdb::TestTimeHistory::testOpenClose(); } -TEST_CASE("TestTimeHistory::testQuery", "[TestTimeHistory]") { +TEST_CASE("TestTimeHistory::testQuery", + "[TestTimeHistory]") { spatialdata::spatialdb::TestTimeHistory::testQuery(); } @@ -76,8 +75,8 @@ spatialdata::spatialdb::TestTimeHistory::testAccessors(void) { void spatialdata::spatialdb::TestTimeHistory::testOpenClose(void) { const size_t npts = 6; - const double time[npts] = { 0.0, 0.2, 0.8, 1.0, 2.0, 10.0 }; - const double amplitude[npts] = { 0.0, 0.4, 1.6, 2.0, 4.0, 0.0 }; + const double time[npts] = {0.0, 0.2, 0.8, 1.0, 2.0, 10.0}; + const double amplitude[npts] = {0.0, 0.4, 1.6, 2.0, 4.0, 0.0}; const char* timeUnits = "minute"; const char* filename = "data/timehistory.data"; @@ -100,7 +99,7 @@ spatialdata::spatialdb::TestTimeHistory::testOpenClose(void) { REQUIRE(th._amplitude); const double tolerance = 1.0e-06; for (size_t i = 0; i < npts; ++i) { - CHECK_THAT(th._time[i]/scale, Catch::Matchers::WithinAbs(time[i], tolerance)); + CHECK_THAT(th._time[i] / scale, Catch::Matchers::WithinAbs(time[i], tolerance)); CHECK_THAT(th._amplitude[i], Catch::Matchers::WithinAbs(amplitude[i], tolerance)); } // for @@ -119,15 +118,9 @@ void spatialdata::spatialdb::TestTimeHistory::testQuery(void) { const char* filename = "data/timehistory.timedb"; const size_t nqueries = 7; - const double timeQ[nqueries] = { - 0.5, 0.0, 0.6, 2.0, 5.0, 20.0, 8.0 - }; - const double amplitudeE[nqueries] = { - 1.0, 0.0, 1.2, 4.0, 2.5, 0.0, 1.0 - }; - const int errE[nqueries] = { - 0, 0, 0, 0, 0, 1, 0 - }; + const double timeQ[nqueries] = {0.5, 0.0, 0.6, 2.0, 5.0, 20.0, 8.0}; + const double amplitudeE[nqueries] = {1.0, 0.0, 1.2, 4.0, 2.5, 0.0, 1.0}; + const int errE[nqueries] = {0, 0, 0, 0, 0, 1, 0}; TimeHistory th; th.setFilename(filename); diff --git a/tests/libtests/spatialdb/TestTimeHistoryIO.cc b/tests/libtests/spatialdb/TestTimeHistoryIO.cc index 91d2da19..19ae3109 100644 --- a/tests/libtests/spatialdb/TestTimeHistoryIO.cc +++ b/tests/libtests/spatialdb/TestTimeHistoryIO.cc @@ -20,28 +20,27 @@ namespace spatialdata { namespace spatialdb { class TestTimeHistoryIO; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata class spatialdata::spatialdb::TestTimeHistoryIO { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Test read(), write(). - static - void testWriteRead(void); + static void testWriteRead(void); /// Test read() with time history file that contains comments. - static - void testReadComments(void); + static void testReadComments(void); }; // class TestTimeHistoryIO // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestTimeHistoryIO::testWriteRead", "[TestTimeHistoryIO]") { +TEST_CASE("TestTimeHistoryIO::testWriteRead", + "[TestTimeHistoryIO]") { spatialdata::spatialdb::TestTimeHistoryIO::testWriteRead(); } -TEST_CASE("TestTimeHistoryIO::testReadComments", "[TestTimeHistoryIO]") { +TEST_CASE("TestTimeHistoryIO::testReadComments", + "[TestTimeHistoryIO]") { spatialdata::spatialdb::TestTimeHistoryIO::testReadComments(); } @@ -50,8 +49,8 @@ TEST_CASE("TestTimeHistoryIO::testReadComments", "[TestTimeHistoryIO]") { void spatialdata::spatialdb::TestTimeHistoryIO::testWriteRead(void) { const size_t npts = 6; - const double time[npts] = { 0.0, 0.2, 0.8, 1.0, 2.0, 10.0 }; - const double amplitude[npts] = { 0.0, 0.4, 1.6, 2.0, 4.0, 0.0 }; + const double time[npts] = {0.0, 0.2, 0.8, 1.0, 2.0, 10.0}; + const double amplitude[npts] = {0.0, 0.4, 1.6, 2.0, 4.0, 0.0}; const char* timeUnits = "minute"; const char* filename = "timehistory.dat"; @@ -69,12 +68,14 @@ spatialdata::spatialdb::TestTimeHistoryIO::testWriteRead(void) { REQUIRE(npts == nptsIn); const double tolerance = 1.0e-06; for (size_t i = 0; i < npts; ++i) { - CHECK_THAT(timeIn[i]/scale, Catch::Matchers::WithinAbs(time[i], tolerance)); + CHECK_THAT(timeIn[i] / scale, Catch::Matchers::WithinAbs(time[i], tolerance)); CHECK_THAT(amplitude[i], Catch::Matchers::WithinAbs(amplitudeIn[i], tolerance)); } // for - delete[] timeIn;timeIn = 0; - delete[] amplitudeIn;amplitudeIn = 0; + delete[] timeIn; + timeIn = 0; + delete[] amplitudeIn; + amplitudeIn = 0; } // testWriteRead @@ -83,8 +84,8 @@ spatialdata::spatialdb::TestTimeHistoryIO::testWriteRead(void) { void spatialdata::spatialdb::TestTimeHistoryIO::testReadComments(void) { const size_t npts = 6; - const double time[npts] = { 0.0, 0.2, 0.8, 1.0, 2.0, 10.0 }; - const double amplitude[npts] = { 0.0, 0.4, 1.6, 2.0, 4.0, 0.0 }; + const double time[npts] = {0.0, 0.2, 0.8, 1.0, 2.0, 10.0}; + const double amplitude[npts] = {0.0, 0.4, 1.6, 2.0, 4.0, 0.0}; const char* filename = "data/timehistory_comments.dat"; size_t nptsIn = 0; @@ -99,8 +100,10 @@ spatialdata::spatialdb::TestTimeHistoryIO::testReadComments(void) { CHECK_THAT(amplitude[i], Catch::Matchers::WithinAbs(amplitudeIn[i], tolerance)); } // for - delete[] timeIn;timeIn = 0; - delete[] amplitudeIn;amplitudeIn = 0; + delete[] timeIn; + timeIn = 0; + delete[] amplitudeIn; + amplitudeIn = 0; } // testReadComments diff --git a/tests/libtests/spatialdb/TestUniformDB.cc b/tests/libtests/spatialdb/TestUniformDB.cc index 572d3d38..5ddf1983 100644 --- a/tests/libtests/spatialdb/TestUniformDB.cc +++ b/tests/libtests/spatialdb/TestUniformDB.cc @@ -24,56 +24,55 @@ namespace spatialdata { namespace spatialdb { class TestUniformDB; class UniformDB; // USES UniformDB - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata class spatialdata::spatialdb::TestUniformDB { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Test constructors - static - void testConstructors(void); + static void testConstructors(void); /// Test accessors. - static - void testAccessors(void); + static void testAccessors(void); /// Test setData() - static - void testSetData(void); + static void testSetData(void); /// Test getNamesDBValues(). - static - void testGetNamesDBValues(void); + static void testGetNamesDBValues(void); /// Test setQueryValues() - static - void testQueryVals(void); + static void testQueryVals(void); /// Test query() - static - void testQuery(void); + static void testQuery(void); }; // class TestUniformDB // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestUniformDB::testConstructors", "[TestUniformDB]") { +TEST_CASE("TestUniformDB::testConstructors", + "[TestUniformDB]") { spatialdata::spatialdb::TestUniformDB::testConstructors(); } -TEST_CASE("TestUniformDB::testAccessors", "[TestUniformDB]") { +TEST_CASE("TestUniformDB::testAccessors", + "[TestUniformDB]") { spatialdata::spatialdb::TestUniformDB::testAccessors(); } -TEST_CASE("TestUniformDB::testSetData", "[TestUniformDB]") { +TEST_CASE("TestUniformDB::testSetData", + "[TestUniformDB]") { spatialdata::spatialdb::TestUniformDB::testSetData(); } -TEST_CASE("TestUniformDB::testGetNamesDBValues", "[TestUniformDB]") { +TEST_CASE("TestUniformDB::testGetNamesDBValues", + "[TestUniformDB]") { spatialdata::spatialdb::TestUniformDB::testGetNamesDBValues(); } -TEST_CASE("TestUniformDB::testQueryVals", "[TestUniformDB]") { +TEST_CASE("TestUniformDB::testQueryVals", + "[TestUniformDB]") { spatialdata::spatialdb::TestUniformDB::testQueryVals(); } -TEST_CASE("TestUniformDB::testQuery", "[TestUniformDB]") { +TEST_CASE("TestUniformDB::testQuery", + "[TestUniformDB]") { spatialdata::spatialdb::TestUniformDB::testQuery(); } @@ -108,10 +107,10 @@ spatialdata::spatialdb::TestUniformDB::testSetData(void) { UniformDB db; const size_t numValues = 3; - const char* names[numValues] = { "one", "two", "three" }; - const char* units[numValues] = { "m", "km", "cm" }; - const double values[numValues] = { 1.1, 2.2, 3.3 }; - const double valuesE[numValues] = { 1.1, 2.2e+3, 3.3e-2 }; + const char* names[numValues] = {"one", "two", "three"}; + const char* units[numValues] = {"m", "km", "cm"}; + const double values[numValues] = {1.1, 2.2, 3.3}; + const double valuesE[numValues] = {1.1, 2.2e+3, 3.3e-2}; db.setData(names, units, values, numValues); @@ -136,9 +135,9 @@ spatialdata::spatialdb::TestUniformDB::testSetData(void) { void spatialdata::spatialdb::TestUniformDB::testGetNamesDBValues(void) { const size_t numValuesE = 3; - const char* names[numValuesE] = { "one", "two", "three" }; - const char* units[numValuesE] = { "none", "none", "none" }; - const double values[numValuesE] = { 1.1, 2.2, 3.3 }; + const char* names[numValuesE] = {"one", "two", "three"}; + const char* units[numValuesE] = {"none", "none", "none"}; + const double values[numValuesE] = {1.1, 2.2, 3.3}; UniformDB db; db.setData(names, units, values, numValuesE); @@ -151,7 +150,8 @@ spatialdata::spatialdb::TestUniformDB::testGetNamesDBValues(void) { for (size_t i = 0; i < numValuesE; ++i) { CHECK(std::string(names[i]) == std::string(valueNames[i])); } // for - delete[] valueNames;valueNames = NULL; + delete[] valueNames; + valueNames = NULL; numValues = 0; } // testGetDBValues @@ -163,13 +163,13 @@ spatialdata::spatialdb::TestUniformDB::testQueryVals(void) { UniformDB db; const size_t numValues = 3; - const char* names[numValues] = { "one", "two", "three" }; - const char* units[numValues] = { "none", "none", "none" }; - const double values[numValues] = { 1.1, 2.2, 3.3 }; + const char* names[numValues] = {"one", "two", "three"}; + const char* units[numValues] = {"none", "none", "none"}; + const double values[numValues] = {1.1, 2.2, 3.3}; const size_t querySize = 2; - const char* queryNames[querySize] = { "three", "two" }; - const size_t queryVals[querySize] = { 2, 1 }; + const char* queryNames[querySize] = {"three", "two"}; + const size_t queryVals[querySize] = {2, 1}; db.setData(names, units, values, numValues); db.setQueryValues(queryNames, querySize); @@ -188,13 +188,13 @@ spatialdata::spatialdb::TestUniformDB::testQuery(void) { UniformDB db; const size_t numValues = 3; - const char* names[numValues] = { "one", "two", "three" }; - const char* units[numValues] = { "none", "none", "none" }; - const double values[numValues] = { 1.1, 2.2, 3.3 }; + const char* names[numValues] = {"one", "two", "three"}; + const char* units[numValues] = {"none", "none", "none"}; + const double values[numValues] = {1.1, 2.2, 3.3}; const size_t querySize = 2; - const char* queryNames[querySize] = { "three", "two" }; - const size_t queryVals[querySize] = { 2, 1 }; + const char* queryNames[querySize] = {"three", "two"}; + const size_t queryVals[querySize] = {2, 1}; db.setData(names, units, values, numValues); db.setQueryValues(queryNames, querySize); @@ -202,7 +202,7 @@ spatialdata::spatialdb::TestUniformDB::testQuery(void) { const size_t spaceDim = 2; spatialdata::geocoords::CSCart cs; cs.setSpaceDim(spaceDim); - const double coords[spaceDim] = { 2.3, 5.6 }; + const double coords[spaceDim] = {2.3, 5.6}; double data[querySize]; db.query(data, querySize, coords, spaceDim, &cs); diff --git a/tests/libtests/spatialdb/TestUserFunctionDB.cc b/tests/libtests/spatialdb/TestUserFunctionDB.cc index 8903366c..24524300 100644 --- a/tests/libtests/spatialdb/TestUserFunctionDB.cc +++ b/tests/libtests/spatialdb/TestUserFunctionDB.cc @@ -12,8 +12,8 @@ #include "TestUserFunctionDB.hh" // Implementation of class methods -#include "spatialdata/spatialdb/UserFunctionDB.hh" // USES UserFunctionDB #include "spatialdata/geocoords/CSCart.hh" // USE CSCart +#include "spatialdata/spatialdb/UserFunctionDB.hh" // USES UserFunctionDB #include "catch2/catch_test_macros.hpp" #include "catch2/matchers/catch_matchers_floating_point.hpp" @@ -37,8 +37,10 @@ spatialdata::spatialdb::TestUserFunctionDB::TestUserFunctionDB(TestUserFunctionD // ---------------------------------------------------------------------- // Tear down testing data. spatialdata::spatialdb::TestUserFunctionDB::~TestUserFunctionDB(void) { - delete _db;_db = NULL; - delete _data;_data = NULL; + delete _db; + _db = NULL; + delete _data; + _data = NULL; } // tearDown @@ -148,7 +150,8 @@ spatialdata::spatialdb::TestUserFunctionDB::testGetNamesDBValues(void) { FAIL("Could not find value '" << valueNames[i] << "' in UserFunctionDB test data."); } // if } // for - delete[] valueNames;valueNames = NULL; + delete[] valueNames; + valueNames = NULL; numValues = 0; } // testGetDBValues @@ -166,10 +169,11 @@ spatialdata::spatialdb::TestUserFunctionDB::testQueryVals(void) { const int numValues = _data->numValues - 1; const char** names = (numValues > 0) ? new const char*[numValues] : NULL; for (int i = 0; i < numValues; ++i) { - names[i] = _data->values[numValues-1-i].name.c_str(); + names[i] = _data->values[numValues - 1 - i].name.c_str(); } // for _db->setQueryValues(names, numValues); - delete[] names;names = NULL; + delete[] names; + names = NULL; // Check result. for (int i = 0; i < numValues; ++i) { @@ -210,20 +214,22 @@ spatialdata::spatialdb::TestUserFunctionDB::testQuery(void) { names[i] = _data->values[i].name.c_str(); } // for _db->setQueryValues(names, numValues); - delete[] names;names = NULL; + delete[] names; + names = NULL; // Call query() and check result. const double tolerance = 1.0e-6; for (size_t iQuery = 0; iQuery < numQueries; ++iQuery) { - const int flag = _db->query(values, numValues, &_data->queryXYZ[iQuery*spaceDim], spaceDim, _data->cs); + const int flag = _db->query(values, numValues, &_data->queryXYZ[iQuery * spaceDim], spaceDim, _data->cs); CHECK(0 == flag); for (size_t iVal = 0; iVal < numValues; ++iVal) { - const double valueE = _data->queryValues[iQuery*numValues+iVal]*_data->values[iVal].scale; + const double valueE = _data->queryValues[iQuery * numValues + iVal] * _data->values[iVal].scale; CHECK_THAT(values[iVal], Catch::Matchers::WithinAbs(valueE, tolerance)); } // for } // for - delete[] values;values = NULL; + delete[] values; + values = NULL; _db->close(); @@ -238,13 +244,15 @@ spatialdata::spatialdb::TestUserFunctionDB_Data::TestUserFunctionDB_Data(void) : cs(NULL), queryXYZ(NULL), queryValues(NULL), - numQueryPoints(0) {} + numQueryPoints(0) { +} // ---------------------------------------------------------------------- // Destructor spatialdata::spatialdb::TestUserFunctionDB_Data::~TestUserFunctionDB_Data(void) { - delete cs;cs = NULL; + delete cs; + cs = NULL; } diff --git a/tests/libtests/spatialdb/TestUserFunctionDB.hh b/tests/libtests/spatialdb/TestUserFunctionDB.hh index 502fc438..f81d2a10 100644 --- a/tests/libtests/spatialdb/TestUserFunctionDB.hh +++ b/tests/libtests/spatialdb/TestUserFunctionDB.hh @@ -16,14 +16,13 @@ namespace spatialdata { namespace spatialdb { class TestUserFunctionDB; class TestUserFunctionDB_Data; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata // ------------------------------------------------------------------------------------------------ class spatialdata::spatialdb::TestUserFunctionDB { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Constructor. TestUserFunctionDB(TestUserFunctionDB_Data* data, UserFunctionDB* db); @@ -32,16 +31,13 @@ public: ~TestUserFunctionDB(void); /// Test constructor - static - void testConstructor(void); + static void testConstructor(void); /// Test setDescription() - static - void testDescription(void); + static void testDescription(void); /// Test coordsys() - static - void testCoordsys(void); + static void testCoordsys(void); /// Test addValue() void testAddValue(void); @@ -58,8 +54,7 @@ public: /// Test query(). void testQuery(void); -protected: - + protected: // PROTECTED MEMBERS ////////////////////////////////////////////////// UserFunctionDB* _db; ///< Test subject. @@ -70,8 +65,7 @@ protected: // ------------------------------------------------------------------------------------------------ class spatialdata::spatialdb::TestUserFunctionDB_Data { // PUBLIC STRUCTS /////////////////////////////////////////////////////// -public: - + public: /// Structure for holding user data struct UserData { std::string name; ///< Name of value. @@ -80,8 +74,7 @@ public: }; // UserData // PUBLIC METHODS /////////////////////////////////////////////////////// -public: - + public: /// Constructor TestUserFunctionDB_Data(void); @@ -89,8 +82,7 @@ public: ~TestUserFunctionDB_Data(void); // PUBLIC MEMBERS /////////////////////////////////////////////////////// -public: - + public: size_t numValues; ///< Number of values in spatial database. const UserData* values; ///< Names of values in spatial database. spatialdata::geocoords::CoordSys* cs; ///< Coordinate system. diff --git a/tests/libtests/spatialdb/TestUserFunctionDB_Cases.cc b/tests/libtests/spatialdb/TestUserFunctionDB_Cases.cc index c0e64b43..c282f045 100644 --- a/tests/libtests/spatialdb/TestUserFunctionDB_Cases.cc +++ b/tests/libtests/spatialdb/TestUserFunctionDB_Cases.cc @@ -23,43 +23,45 @@ namespace spatialdata { class TestUserFunctionDB_1D; class TestUserFunctionDB_2D; class TestUserFunctionDB_3D; - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata // ------------------------------------------------------------------------------------------------ class spatialdata::spatialdb::TestUserFunctionDB_1D { -public: - + public: // Factories - static - TestUserFunctionDB_Data* createData(void); - - static - UserFunctionDB* createDB(void); + static TestUserFunctionDB_Data* createData(void); -private: + static UserFunctionDB* createDB(void); - static double density(const double x) { - return 100.0*x; + private: + static double + density(const double x) { + return 100.0 * x; } - static const char* density_units(void) { + static const char* + density_units(void) { return "kg/m**3"; } - static double vs(const double x) { - return 2.0*x; + static double + vs(const double x) { + return 2.0 * x; } - static const char* vs_units(void) { + static const char* + vs_units(void) { return "km/s"; } - static double vp(const double x) { - return 3.5*x; + static double + vp(const double x) { + return 3.5 * x; } - static const char* vp_units(void) { + static const char* + vp_units(void) { return "km/s"; } @@ -68,32 +70,42 @@ class spatialdata::spatialdb::TestUserFunctionDB_1D { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestUserFunctionDB_Data* spatialdata::spatialdb::TestUserFunctionDB_1D::createData(void) { - spatialdata::spatialdb::TestUserFunctionDB_Data* data = new TestUserFunctionDB_Data();assert(data); + spatialdata::spatialdb::TestUserFunctionDB_Data* data = new TestUserFunctionDB_Data(); + assert(data); data->numValues = 3; static const TestUserFunctionDB_Data::UserData values[3] = { - {"density", density_units(), 1.0 }, - {"vs", vs_units(), 1000.0 }, - {"vp", vp_units(), 1000.0 }, + {"density", density_units(), 1.0}, + {"vs", vs_units(), 1000.0}, + {"vp", vp_units(), 1000.0}, }; data->values = values; - data->cs = new spatialdata::geocoords::CSCart();assert(data->cs); + data->cs = new spatialdata::geocoords::CSCart(); + assert(data->cs); data->cs->setSpaceDim(1); data->numQueryPoints = 4; - static const double queryXYZ[4*1] = { + static const double queryXYZ[4 * 1] = { 0.0, -10.0, 4.0, 0.5, }; data->queryXYZ = queryXYZ; - static const double queryValues[4*3] = { - density(0.0), vs(0.0), vp(0.0), - density(-10.0), vs(-10.0), vp(-10.0), - density(4.0), vs(4.0), vp(4.0), - density(0.5), vs(0.5), vp(0.5), + static const double queryValues[4 * 3] = { + density(0.0), + vs(0.0), + vp(0.0), + density(-10.0), + vs(-10.0), + vp(-10.0), + density(4.0), + vs(4.0), + vp(4.0), + density(0.5), + vs(0.5), + vp(0.5), }; data->queryValues = queryValues; @@ -104,7 +116,8 @@ spatialdata::spatialdb::TestUserFunctionDB_1D::createData(void) { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::UserFunctionDB* spatialdata::spatialdb::TestUserFunctionDB_1D::createDB(void) { - UserFunctionDB* db = new UserFunctionDB();assert(db); + UserFunctionDB* db = new UserFunctionDB(); + assert(db); db->addValue("density", density, density_units()); db->addValue("vs", vs, vs_units()); @@ -116,41 +129,43 @@ spatialdata::spatialdb::TestUserFunctionDB_1D::createDB(void) { // ------------------------------------------------------------------------------------------------ class spatialdata::spatialdb::TestUserFunctionDB_2D { -public: - + public: // Factories - static - TestUserFunctionDB_Data* createData(void); - - static - UserFunctionDB* createDB(void); + static TestUserFunctionDB_Data* createData(void); -private: + static UserFunctionDB* createDB(void); - static double density(const double x, - const double y) { - return 100.0*x*y; + private: + static double + density(const double x, + const double y) { + return 100.0 * x * y; } - static const char* density_units(void) { + static const char* + density_units(void) { return "kg/m**3"; } - static double vs(const double x, - const double y) { - return 2.0*x + 0.3*y; + static double + vs(const double x, + const double y) { + return 2.0 * x + 0.3 * y; } - static const char* vs_units(void) { + static const char* + vs_units(void) { return "km/s"; } - static double vp(const double x, - const double y) { - return 0.2*x + 3.5*y; + static double + vp(const double x, + const double y) { + return 0.2 * x + 3.5 * y; } - static const char* vp_units(void) { + static const char* + vp_units(void) { return "km/s"; } @@ -159,32 +174,58 @@ class spatialdata::spatialdb::TestUserFunctionDB_2D { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestUserFunctionDB_Data* spatialdata::spatialdb::TestUserFunctionDB_2D::createData(void) { - spatialdata::spatialdb::TestUserFunctionDB_Data* data = new TestUserFunctionDB_Data();assert(data); + spatialdata::spatialdb::TestUserFunctionDB_Data* data = new TestUserFunctionDB_Data(); + assert(data); data->numValues = 3; static const TestUserFunctionDB_Data::UserData values[3] = { - { "vs", vs_units(), 1000.0, }, - { "vp", vp_units(), 1000.0, }, - { "density", density_units(), 1.0, }, + { + "vs", + vs_units(), + 1000.0, + }, + { + "vp", + vp_units(), + 1000.0, + }, + { + "density", + density_units(), + 1.0, + }, }; data->values = values; - data->cs = new spatialdata::geocoords::CSCart();assert(data->cs); + data->cs = new spatialdata::geocoords::CSCart(); + assert(data->cs); data->cs->setSpaceDim(2); data->numQueryPoints = 4; - static const double queryXYZ[4*2] = { - 0.0, 0.0, - -10.0, 4.0, - 4.0, 2.0, - 0.5, 0.1, + static const double queryXYZ[4 * 2] = { + 0.0, + 0.0, + -10.0, + 4.0, + 4.0, + 2.0, + 0.5, + 0.1, }; data->queryXYZ = queryXYZ; - static const double queryValues[4*3] = { - vs(0.0, 0.0), vp(0.0, 0.0), density(0.0, 0.0), - vs(-10.0, 4.0), vp(-10.0, 4.0), density(-10.0, 4.0), - vs(4.0, 2.0), vp(4.0, 2.0), density(4.0, 2.0), - vs(0.5, 0.1), vp(0.5, 0.1), density(0.5, 0.1), + static const double queryValues[4 * 3] = { + vs(0.0, 0.0), + vp(0.0, 0.0), + density(0.0, 0.0), + vs(-10.0, 4.0), + vp(-10.0, 4.0), + density(-10.0, 4.0), + vs(4.0, 2.0), + vp(4.0, 2.0), + density(4.0, 2.0), + vs(0.5, 0.1), + vp(0.5, 0.1), + density(0.5, 0.1), }; data->queryValues = queryValues; @@ -195,7 +236,8 @@ spatialdata::spatialdb::TestUserFunctionDB_2D::createData(void) { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::UserFunctionDB* spatialdata::spatialdb::TestUserFunctionDB_2D::createDB(void) { - UserFunctionDB* db = new UserFunctionDB();assert(db); + UserFunctionDB* db = new UserFunctionDB(); + assert(db); db->addValue("vs", vs, vs_units()); db->addValue("vp", vp, vp_units()); @@ -207,34 +249,34 @@ spatialdata::spatialdb::TestUserFunctionDB_2D::createDB(void) { // ------------------------------------------------------------------------------------------------ class spatialdata::spatialdb::TestUserFunctionDB_3D { -public: - + public: // Factories - static - TestUserFunctionDB_Data* createData(void); - - static - UserFunctionDB* createDB(void); + static TestUserFunctionDB_Data* createData(void); -private: + static UserFunctionDB* createDB(void); - static double density(const double x, - const double y, - const double z) { - return 2.3 + 1.0*x*y + 0.3*z*x; + private: + static double + density(const double x, + const double y, + const double z) { + return 2.3 + 1.0 * x * y + 0.3 * z * x; } - static const char* density_units(void) { + static const char* + density_units(void) { return "kg/m**3"; } - static double vs(const double x, - const double y, - const double z) { - return 0.34 + 2.0*x + 0.2*y + 4.0*z; + static double + vs(const double x, + const double y, + const double z) { + return 0.34 + 2.0 * x + 0.2 * y + 4.0 * z; } - static const char* vs_units(void) { + static const char* + vs_units(void) { return "km/s"; } @@ -243,27 +285,43 @@ class spatialdata::spatialdb::TestUserFunctionDB_3D { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::TestUserFunctionDB_Data* spatialdata::spatialdb::TestUserFunctionDB_3D::createData(void) { - spatialdata::spatialdb::TestUserFunctionDB_Data* data = new TestUserFunctionDB_Data();assert(data); + spatialdata::spatialdb::TestUserFunctionDB_Data* data = new TestUserFunctionDB_Data(); + assert(data); data->numValues = 2; static const TestUserFunctionDB_Data::UserData values[2] = { - { "density", density_units(), 1.0, }, - { "vs", vs_units(), 1000.0, }, + { + "density", + density_units(), + 1.0, + }, + { + "vs", + vs_units(), + 1000.0, + }, }; data->values = values; - data->cs = new spatialdata::geocoords::CSCart();assert(data->cs); + data->cs = new spatialdata::geocoords::CSCart(); + assert(data->cs); data->cs->setSpaceDim(3); data->numQueryPoints = 2; - static const double queryXYZ[2*3] = { - 0.0, 0.0, 0.0, - 1.0, 4.3, -3.6, + static const double queryXYZ[2 * 3] = { + 0.0, + 0.0, + 0.0, + 1.0, + 4.3, + -3.6, }; data->queryXYZ = queryXYZ; - static const double queryValues[2*2] = { - density(0.0, 0.0, 0.0), vs(0.0, 0.0, 0.0), - density(1.0, 4.3, -3.6), vs(1.0, 4.3, -3.6), + static const double queryValues[2 * 2] = { + density(0.0, 0.0, 0.0), + vs(0.0, 0.0, 0.0), + density(1.0, 4.3, -3.6), + vs(1.0, 4.3, -3.6), }; data->queryValues = queryValues; @@ -274,7 +332,8 @@ spatialdata::spatialdb::TestUserFunctionDB_3D::createData(void) { // ------------------------------------------------------------------------------------------------ spatialdata::spatialdb::UserFunctionDB* spatialdata::spatialdb::TestUserFunctionDB_3D::createDB(void) { - UserFunctionDB* db = new UserFunctionDB();assert(db); + UserFunctionDB* db = new UserFunctionDB(); + assert(db); db->addValue("density", density, density_units()); db->addValue("vs", vs, vs_units()); @@ -285,78 +344,111 @@ spatialdata::spatialdb::TestUserFunctionDB_3D::createDB(void) { // ------------------------------------------------------------------------------------------------ // Static test cases -TEST_CASE("TestUserFunctionDB::testConstructor", "[TestUserFunctionDB]") { +TEST_CASE("TestUserFunctionDB::testConstructor", + "[TestUserFunctionDB]") { spatialdata::spatialdb::TestUserFunctionDB::testConstructor(); } -TEST_CASE("TestUserFunctionDB::testDescription", "[TestUserFunctionDB]") { +TEST_CASE("TestUserFunctionDB::testDescription", + "[TestUserFunctionDB]") { spatialdata::spatialdb::TestUserFunctionDB::testDescription(); } -TEST_CASE("TestUserFunctionDB::testCoordsys", "[TestUserFunctionDB]") { +TEST_CASE("TestUserFunctionDB::testCoordsys", + "[TestUserFunctionDB]") { spatialdata::spatialdb::TestUserFunctionDB::testCoordsys(); } // Data test cases -TEST_CASE("TestUserFunctionDB::testAddValue", "[TestUserFunctionDB][1D]") { +TEST_CASE("TestUserFunctionDB::testAddValue", + "[TestUserFunctionDB][1D]") { spatialdata::spatialdb::TestUserFunctionDB(spatialdata::spatialdb::TestUserFunctionDB_1D::createData(), - spatialdata::spatialdb::TestUserFunctionDB_1D::createDB()).testAddValue(); + spatialdata::spatialdb::TestUserFunctionDB_1D::createDB()) + .testAddValue(); } -TEST_CASE("TestUserFunctionDB::testOpenClose", "[TestUserFunctionDB][1D]") { +TEST_CASE("TestUserFunctionDB::testOpenClose", + "[TestUserFunctionDB][1D]") { spatialdata::spatialdb::TestUserFunctionDB(spatialdata::spatialdb::TestUserFunctionDB_1D::createData(), - spatialdata::spatialdb::TestUserFunctionDB_1D::createDB()).testOpenClose(); + spatialdata::spatialdb::TestUserFunctionDB_1D::createDB()) + .testOpenClose(); } -TEST_CASE("TestUserFunctionDB::testGetNamesDBValues", "[TestUserFunctionDB][1D]") { +TEST_CASE("TestUserFunctionDB::testGetNamesDBValues", + "[TestUserFunctionDB][1D]") { spatialdata::spatialdb::TestUserFunctionDB(spatialdata::spatialdb::TestUserFunctionDB_1D::createData(), - spatialdata::spatialdb::TestUserFunctionDB_1D::createDB()).testGetNamesDBValues(); + spatialdata::spatialdb::TestUserFunctionDB_1D::createDB()) + .testGetNamesDBValues(); } -TEST_CASE("TestUserFunctionDB::testQueryVals", "[TestUserFunctionDB][1D]") { +TEST_CASE("TestUserFunctionDB::testQueryVals", + "[TestUserFunctionDB][1D]") { spatialdata::spatialdb::TestUserFunctionDB(spatialdata::spatialdb::TestUserFunctionDB_1D::createData(), - spatialdata::spatialdb::TestUserFunctionDB_1D::createDB()).testQueryVals(); + spatialdata::spatialdb::TestUserFunctionDB_1D::createDB()) + .testQueryVals(); } -TEST_CASE("TestUserFunctionDB::testQuery", "[TestUserFunctionDB][1D]") { +TEST_CASE("TestUserFunctionDB::testQuery", + "[TestUserFunctionDB][1D]") { spatialdata::spatialdb::TestUserFunctionDB(spatialdata::spatialdb::TestUserFunctionDB_1D::createData(), - spatialdata::spatialdb::TestUserFunctionDB_1D::createDB()).testQuery(); + spatialdata::spatialdb::TestUserFunctionDB_1D::createDB()) + .testQuery(); } -TEST_CASE("TestUserFunctionDB::testAddValue", "[TestUserFunctionDB][2D]") { +TEST_CASE("TestUserFunctionDB::testAddValue", + "[TestUserFunctionDB][2D]") { spatialdata::spatialdb::TestUserFunctionDB(spatialdata::spatialdb::TestUserFunctionDB_2D::createData(), - spatialdata::spatialdb::TestUserFunctionDB_2D::createDB()).testAddValue(); + spatialdata::spatialdb::TestUserFunctionDB_2D::createDB()) + .testAddValue(); } -TEST_CASE("TestUserFunctionDB::testOpenClose", "[TestUserFunctionDB][2D]") { +TEST_CASE("TestUserFunctionDB::testOpenClose", + "[TestUserFunctionDB][2D]") { spatialdata::spatialdb::TestUserFunctionDB(spatialdata::spatialdb::TestUserFunctionDB_2D::createData(), - spatialdata::spatialdb::TestUserFunctionDB_2D::createDB()).testOpenClose(); + spatialdata::spatialdb::TestUserFunctionDB_2D::createDB()) + .testOpenClose(); } -TEST_CASE("TestUserFunctionDB::testGetNamesDBValues", "[TestUserFunctionDB][2D]") { +TEST_CASE("TestUserFunctionDB::testGetNamesDBValues", + "[TestUserFunctionDB][2D]") { spatialdata::spatialdb::TestUserFunctionDB(spatialdata::spatialdb::TestUserFunctionDB_2D::createData(), - spatialdata::spatialdb::TestUserFunctionDB_2D::createDB()).testGetNamesDBValues(); + spatialdata::spatialdb::TestUserFunctionDB_2D::createDB()) + .testGetNamesDBValues(); } -TEST_CASE("TestUserFunctionDB::testQueryVals", "[TestUserFunctionDB][2D]") { +TEST_CASE("TestUserFunctionDB::testQueryVals", + "[TestUserFunctionDB][2D]") { spatialdata::spatialdb::TestUserFunctionDB(spatialdata::spatialdb::TestUserFunctionDB_2D::createData(), - spatialdata::spatialdb::TestUserFunctionDB_2D::createDB()).testQueryVals(); + spatialdata::spatialdb::TestUserFunctionDB_2D::createDB()) + .testQueryVals(); } -TEST_CASE("TestUserFunctionDB::testQuery", "[TestUserFunctionDB][2D]") { +TEST_CASE("TestUserFunctionDB::testQuery", + "[TestUserFunctionDB][2D]") { spatialdata::spatialdb::TestUserFunctionDB(spatialdata::spatialdb::TestUserFunctionDB_2D::createData(), - spatialdata::spatialdb::TestUserFunctionDB_2D::createDB()).testQuery(); + spatialdata::spatialdb::TestUserFunctionDB_2D::createDB()) + .testQuery(); } -TEST_CASE("TestUserFunctionDB::testAddValue", "[TestUserFunctionDB][3D]") { +TEST_CASE("TestUserFunctionDB::testAddValue", + "[TestUserFunctionDB][3D]") { spatialdata::spatialdb::TestUserFunctionDB(spatialdata::spatialdb::TestUserFunctionDB_3D::createData(), - spatialdata::spatialdb::TestUserFunctionDB_3D::createDB()).testAddValue(); + spatialdata::spatialdb::TestUserFunctionDB_3D::createDB()) + .testAddValue(); } -TEST_CASE("TestUserFunctionDB::testOpenClose", "[TestUserFunctionDB][3D]") { +TEST_CASE("TestUserFunctionDB::testOpenClose", + "[TestUserFunctionDB][3D]") { spatialdata::spatialdb::TestUserFunctionDB(spatialdata::spatialdb::TestUserFunctionDB_3D::createData(), - spatialdata::spatialdb::TestUserFunctionDB_3D::createDB()).testOpenClose(); + spatialdata::spatialdb::TestUserFunctionDB_3D::createDB()) + .testOpenClose(); } -TEST_CASE("TestUserFunctionDB::testGetNamesDBValues", "[TestUserFunctionDB][3D]") { +TEST_CASE("TestUserFunctionDB::testGetNamesDBValues", + "[TestUserFunctionDB][3D]") { spatialdata::spatialdb::TestUserFunctionDB(spatialdata::spatialdb::TestUserFunctionDB_3D::createData(), - spatialdata::spatialdb::TestUserFunctionDB_3D::createDB()).testGetNamesDBValues(); + spatialdata::spatialdb::TestUserFunctionDB_3D::createDB()) + .testGetNamesDBValues(); } -TEST_CASE("TestUserFunctionDB::testQueryVals", "[TestUserFunctionDB][3D]") { +TEST_CASE("TestUserFunctionDB::testQueryVals", + "[TestUserFunctionDB][3D]") { spatialdata::spatialdb::TestUserFunctionDB(spatialdata::spatialdb::TestUserFunctionDB_3D::createData(), - spatialdata::spatialdb::TestUserFunctionDB_3D::createDB()).testQueryVals(); + spatialdata::spatialdb::TestUserFunctionDB_3D::createDB()) + .testQueryVals(); } -TEST_CASE("TestUserFunctionDB::testQuery", "[TestUserFunctionDB][3D]") { +TEST_CASE("TestUserFunctionDB::testQuery", + "[TestUserFunctionDB][3D]") { spatialdata::spatialdb::TestUserFunctionDB(spatialdata::spatialdb::TestUserFunctionDB_3D::createData(), - spatialdata::spatialdb::TestUserFunctionDB_3D::createDB()).testQuery(); + spatialdata::spatialdb::TestUserFunctionDB_3D::createDB()) + .testQuery(); } // End of file diff --git a/tests/libtests/spatialdb/testf77query.h b/tests/libtests/spatialdb/testf77query.h index 92cf9dbb..5f652f7b 100644 --- a/tests/libtests/spatialdb/testf77query.h +++ b/tests/libtests/spatialdb/testf77query.h @@ -12,8 +12,7 @@ #pragma once /** Fortran name mangling */ -#define testf77query \ - FC_FUNC_(testf77query, TESTF77QUERY) +#define testf77query FC_FUNC_(testf77query, TESTF77QUERY) /** Call spatialdb_query_f(). * * @param db Pointer to SpatialDB diff --git a/tests/libtests/units/TestParser.cc b/tests/libtests/units/TestParser.cc index 15b23d37..b54f0264 100644 --- a/tests/libtests/units/TestParser.cc +++ b/tests/libtests/units/TestParser.cc @@ -21,68 +21,66 @@ namespace spatialdata { namespace units { class TestParser; - } // units -} // spatialdata + } // namespace units +} // namespace spatialdata class spatialdata::units::TestParser { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Test constructor. - static - void testConstructor(void); + static void testConstructor(void); /// Test parse() with length scale. - static - void testLength(void); + static void testLength(void); /// Test parse() with time scale. - static - void testTime(void); + static void testTime(void); /// Test parse() with velocity scale. - static - void testVelocity(void); + static void testVelocity(void); /// Test parse() with density scale. - static - void testDensity(void); + static void testDensity(void); /// Test parse() with pressure scale. - static - void testPressure(void); + static void testPressure(void); /// Test trapping errors with parse(). - static - void testError(void); + static void testError(void); // PRIVATE MEMBERS //////////////////////////////////////////////////////////////////////////// -private: - + private: static const double _tolerance; }; // class TestParser const double spatialdata::units::TestParser::_tolerance = 1.0e-6; // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestParser::testConstructor", "[TestParser]") { +TEST_CASE("TestParser::testConstructor", + "[TestParser]") { spatialdata::units::TestParser::testConstructor(); } -TEST_CASE("TestParser::testLength", "[TestParser]") { +TEST_CASE("TestParser::testLength", + "[TestParser]") { spatialdata::units::TestParser::testLength(); } -TEST_CASE("TestParser::testTime", "[TestParser]") { +TEST_CASE("TestParser::testTime", + "[TestParser]") { spatialdata::units::TestParser::testTime(); } -TEST_CASE("TestParser::testVelocity", "[TestParser]") { +TEST_CASE("TestParser::testVelocity", + "[TestParser]") { spatialdata::units::TestParser::testVelocity(); } -TEST_CASE("TestParser::testDensity", "[TestParser]") { +TEST_CASE("TestParser::testDensity", + "[TestParser]") { spatialdata::units::TestParser::testDensity(); } -TEST_CASE("TestParser::testPressure", "[TestParser]") { +TEST_CASE("TestParser::testPressure", + "[TestParser]") { spatialdata::units::TestParser::testPressure(); } -TEST_CASE("TestParser::testError", "[TestParser]") { +TEST_CASE("TestParser::testError", + "[TestParser]") { spatialdata::units::TestParser::testError(); } @@ -127,7 +125,7 @@ spatialdata::units::TestParser::testVelocity(void) { Parser parser; CHECK_THAT(parser.parse("cm/s"), Catch::Matchers::WithinAbs(0.01, _tolerance)); - CHECK_THAT(parser.parse("km/hour"), Catch::Matchers::WithinAbs(1.0/3.6, _tolerance)); + CHECK_THAT(parser.parse("km/hour"), Catch::Matchers::WithinAbs(1.0 / 3.6, _tolerance)); } // testVelocity diff --git a/tests/libtests/utils/TestPointsStream.cc b/tests/libtests/utils/TestPointsStream.cc index 6dd395b9..db7fd851 100644 --- a/tests/libtests/utils/TestPointsStream.cc +++ b/tests/libtests/utils/TestPointsStream.cc @@ -21,24 +21,20 @@ namespace spatialdata { namespace utils { class TestPointsStream; - } // utils -} // spatialdata + } // namespace utils +} // namespace spatialdata class spatialdata::utils::TestPointsStream { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Test accessors. - static - void testAccessors(void); + static void testAccessors(void); /// Test write()/read() - static - void testWriteRead(void); + static void testWriteRead(void); // PRIVATE METHODS //////////////////////////////////////////////////////////////////////////// -private: - + private: static const double _POINTS[]; ///< Array of points static const size_t _NUMPTS; ///< Number of points static const size_t _NUMDIMS; ///< Number of dimensions @@ -46,18 +42,16 @@ class spatialdata::utils::TestPointsStream { }; // class TestPointsStream const size_t spatialdata::utils::TestPointsStream::_NUMPTS = 4; const size_t spatialdata::utils::TestPointsStream::_NUMDIMS = 3; -const double spatialdata::utils::TestPointsStream::_POINTS[4*3] = { - 1.0, 2.0, 3.0, - 1.1, 2.1, 3.1, - 1.2, 2.2, 3.2, - 1.3, 2.3, 3.3 -}; +const double spatialdata::utils::TestPointsStream::_POINTS[4 * 3] = + {1.0, 2.0, 3.0, 1.1, 2.1, 3.1, 1.2, 2.2, 3.2, 1.3, 2.3, 3.3}; // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestPointsStream::testAccessors", "[TestPointsStream]") { +TEST_CASE("TestPointsStream::testAccessors", + "[TestPointsStream]") { spatialdata::utils::TestPointsStream::testAccessors(); } -TEST_CASE("TestPointsStream::testWriteRead", "[TestPointsStream]") { +TEST_CASE("TestPointsStream::testWriteRead", + "[TestPointsStream]") { spatialdata::utils::TestPointsStream::testWriteRead(); } @@ -107,7 +101,8 @@ spatialdata::utils::TestPointsStream::testWriteRead(void) { CHECK_THAT(points[i], Catch::Matchers::WithinAbs(_POINTS[i], tolerance)); } // for - delete[] points;points = NULL; + delete[] points; + points = NULL; } // testWriteRead diff --git a/tests/libtests/utils/TestSpatialdataVersion.cc b/tests/libtests/utils/TestSpatialdataVersion.cc index 5e415f91..d5b53822 100644 --- a/tests/libtests/utils/TestSpatialdataVersion.cc +++ b/tests/libtests/utils/TestSpatialdataVersion.cc @@ -18,44 +18,43 @@ extern "C" { #include "catch2/catch_test_macros.hpp" -#include // USES std::string() #include // USES strlen() -#include // USES snprintf() #include // USES std::ostringstream +#include // USES snprintf() +#include // USES std::string() // ------------------------------------------------------------------------------------------------ namespace spatialdata { namespace utils { class TestSpatialdataVersion; - } // utils -} // spatialdata + } // namespace utils +} // namespace spatialdata class spatialdata::utils::TestSpatialdataVersion { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Test version() - static - void testVersion(void); + static void testVersion(void); /// Test git testGitMetadata. - static - void testGitMetadata(void); + static void testGitMetadata(void); /// Test projVersion() - static - void testProjVersion(void); + static void testProjVersion(void); }; // class TestSpatialdataVersion // ------------------------------------------------------------------------------------------------ -TEST_CASE("TestSpatialdataVersion::testVersion", "[TestSpatialdataVersion]") { +TEST_CASE("TestSpatialdataVersion::testVersion", + "[TestSpatialdataVersion]") { spatialdata::utils::TestSpatialdataVersion::testVersion(); } -TEST_CASE("TestSpatialdataVersion::testGitMetadata", "[TestSpatialdataVersion]") { +TEST_CASE("TestSpatialdataVersion::testGitMetadata", + "[TestSpatialdataVersion]") { spatialdata::utils::TestSpatialdataVersion::testGitMetadata(); } -TEST_CASE("TestSpatialdataVersion::testProjVersion", "[TestSpatialdataVersion]") { +TEST_CASE("TestSpatialdataVersion::testProjVersion", + "[TestSpatialdataVersion]") { spatialdata::utils::TestSpatialdataVersion::testProjVersion(); } diff --git a/tests/src/driver_catch2.cc b/tests/src/driver_catch2.cc index e2dc0b59..03aacbcc 100644 --- a/tests/src/driver_catch2.cc +++ b/tests/src/driver_catch2.cc @@ -17,13 +17,12 @@ namespace pylith { namespace testing { class TestDriver; } -} +} // namespace pylith // ------------------------------------------------------------------------------------------------ class pylith::testing::TestDriver { // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////// -public: - + public: /// Constructor. TestDriver(void); @@ -37,16 +36,15 @@ class pylith::testing::TestDriver { char* argv[]); // NOT IMPLEMENTED //////////////////////////////////////////////////////////////////////////// -private: - + private: TestDriver(const TestDriver&); ///< Not implemented const TestDriver& operator=(const TestDriver&); ///< Not implemented - }; // ------------------------------------------------------------------------------------------------ // Constructor -pylith::testing::TestDriver::TestDriver(void) { } +pylith::testing::TestDriver::TestDriver(void) { +} // --------------------------------------------------------------------------------------------------------------------- From ce72b4f289bc6fde262709c546bc708db843396b Mon Sep 17 00:00:00 2001 From: Brad Aagaard Date: Sun, 15 Nov 2026 15:06:43 -0700 Subject: [PATCH 02/10] python: Format using black. --- applications/gensimpledb.py | 4 +- setup.py | 1 + spatialdata/__init__.py | 11 +- spatialdata/geocoords/CSCart.py | 9 +- spatialdata/geocoords/CSGeo.py | 8 +- spatialdata/geocoords/CSGeoLocal.py | 15 +- spatialdata/geocoords/Converter.py | 10 +- spatialdata/geocoords/CoordSys.py | 2 +- spatialdata/geocoords/__init__.py | 10 +- spatialdata/spatialdb/AnalyticDB.py | 33 +++- spatialdata/spatialdb/CompositeDB.py | 27 +-- spatialdata/spatialdb/GravityField.py | 19 +- spatialdata/spatialdb/SCECCVMH.py | 18 +- spatialdata/spatialdb/SimpleDB.py | 9 +- spatialdata/spatialdb/SimpleGridAscii.py | 56 +++--- spatialdata/spatialdb/SimpleGridDB.py | 8 +- spatialdata/spatialdb/SimpleIO.py | 17 +- spatialdata/spatialdb/SimpleIOAscii.py | 23 ++- spatialdata/spatialdb/SpatialDBObj.py | 4 +- spatialdata/spatialdb/TimeHistory.py | 8 +- spatialdata/spatialdb/TimeHistoryIO.py | 3 +- spatialdata/spatialdb/UniformDB.py | 23 ++- spatialdata/spatialdb/UserFunctionDB.py | 13 +- spatialdata/spatialdb/__init__.py | 2 +- .../spatialdb/generator/GenSimpleDBApp.py | 44 +++-- spatialdata/spatialdb/generator/Geometry.py | 16 +- spatialdata/spatialdb/generator/Shaper.py | 19 +- spatialdata/spatialdb/generator/Value.py | 21 ++- spatialdata/spatialdb/generator/__init__.py | 2 +- spatialdata/testing/TestCases.py | 3 +- spatialdata/testing/UnitTestApp.py | 11 +- spatialdata/utils/PointsStream.py | 10 +- spatialdata/utils/__init__.py | 2 +- templates/spatialdb/UniformVelModel.py | 11 +- templates/spatialdb/__init__.py | 7 +- .../spatialdb/tests/TestUniformVelModel.py | 171 +++++++++--------- templates/spatialdb/tests/testcontrib.py | 5 +- tests/pytests/geocoords/TestCSCart.py | 4 +- tests/pytests/geocoords/TestCSGeo.py | 2 +- tests/pytests/geocoords/TestCSGeoLocal.py | 6 +- tests/pytests/geocoords/TestConverter.py | 59 +++--- tests/pytests/geocoords/test_geocoords.py | 5 +- tests/pytests/spatialdb/TestAnalyticDB.py | 6 +- tests/pytests/spatialdb/TestCompositeDB.py | 12 +- tests/pytests/spatialdb/TestGenSimpleDBApp.py | 5 +- tests/pytests/spatialdb/TestGravityField.py | 4 +- tests/pytests/spatialdb/TestSimpleDB.py | 7 +- tests/pytests/spatialdb/TestSimpleGridDB.py | 168 +++++++++++------ tests/pytests/spatialdb/TestSimpleIOAscii.py | 40 ++-- tests/pytests/spatialdb/TestTimeHistory.py | 5 +- tests/pytests/spatialdb/TestTimeHistoryIO.py | 5 +- tests/pytests/spatialdb/TestUniformDB.py | 4 +- tests/pytests/spatialdb/TestUserFunctionDB.py | 2 +- tests/pytests/spatialdb/test_sceccvmh.py | 7 +- tests/pytests/spatialdb/test_spatialdb.py | 5 +- tests/pytests/utils/TestSpatialdataVersion.py | 7 +- tests/pytests/utils/test_utils.py | 5 +- 57 files changed, 580 insertions(+), 433 deletions(-) diff --git a/applications/gensimpledb.py b/applications/gensimpledb.py index 4d48786d..606e3b26 100644 --- a/applications/gensimpledb.py +++ b/applications/gensimpledb.py @@ -7,14 +7,14 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= # @file spatialdata/applications/gensimpledb.py # # @brief Generic use of GenSimpleDBApp. # ---------------------------------------------------------------------- -if __name__ == '__main__': +if __name__ == "__main__": from spatialdata.spatialdb.generator.GenSimpleDBApp import GenSimpleDBApp app = GenSimpleDBApp() diff --git a/setup.py b/setup.py index f3ed6334..6a3aa6db 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ # Setup configuration is in setup.cfg. import setuptools + setuptools.setup() diff --git a/spatialdata/__init__.py b/spatialdata/__init__.py index 256a254e..288b6ada 100644 --- a/spatialdata/__init__.py +++ b/spatialdata/__init__.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= # @file spatialdata/__init__.py # @@ -13,6 +13,7 @@ try: import importlib.metadata + version = importlib.metadata.version("spatialdata") except: version = "Could not get version information via importlib.metadata." @@ -21,10 +22,10 @@ __all__ = [ - 'geocoords', - 'spatialdb', - 'units', - 'utils', + "geocoords", + "spatialdb", + "units", + "utils", ] diff --git a/spatialdata/geocoords/CSCart.py b/spatialdata/geocoords/CSCart.py index bf2edc42..ba01406d 100644 --- a/spatialdata/geocoords/CSCart.py +++ b/spatialdata/geocoords/CSCart.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from .CoordSys import CoordSys @@ -18,6 +18,7 @@ class CSCart(CoordSys, ModuleCSCart): Implements `CoordSys`. """ + DOC_CONFIG = { "cfg": """ [coordsys] @@ -29,10 +30,10 @@ class CSCart(CoordSys, ModuleCSCart): import pythia.pyre.inventory units = pythia.pyre.inventory.str("units", default="m") - units.meta['tip'] = "Units of coordinates." + units.meta["tip"] = "Units of coordinates." spaceDim = pythia.pyre.inventory.int("space_dim", default=3) - spaceDim.meta['tip'] = "Number of dimensions for coordinate system." + spaceDim.meta["tip"] = "Number of dimensions for coordinate system." # PUBLIC METHODS ///////////////////////////////////////////////////// @@ -52,6 +53,7 @@ def _configure(self): CoordSys._configure(self) import pythia.pyre.units + uparser = pythia.pyre.units.parser() coordUnits = uparser.parse(self.inventory.units) ModuleCSCart.setToMeters(self, coordUnits.value) @@ -68,6 +70,7 @@ def _createModuleObj(self): # FACTORIES //////////////////////////////////////////////////////////// + def coordsys(): """ Factory associated with CoordSys. diff --git a/spatialdata/geocoords/CSGeo.py b/spatialdata/geocoords/CSGeo.py index d5c5bc13..05014e09 100644 --- a/spatialdata/geocoords/CSGeo.py +++ b/spatialdata/geocoords/CSGeo.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from .CoordSys import CoordSys @@ -18,6 +18,7 @@ class CSGeo(CoordSys, ModuleCSGeo): Implements `CoordSys`. """ + DOC_CONFIG = { "cfg": """ [coordsys] @@ -30,10 +31,10 @@ class CSGeo(CoordSys, ModuleCSGeo): import pythia.pyre.inventory crsString = pythia.pyre.inventory.str("crs_string", default="EPSG:4326") - crsString.meta['tip'] = "String specifying coordinate system (PROJ parameters, EPSG, or WKT). Default is WGS84." + crsString.meta["tip"] = "String specifying coordinate system (PROJ parameters, EPSG, or WKT). Default is WGS84." spaceDim = pythia.pyre.inventory.int("space_dim", default=3) - spaceDim.meta['tip'] = "Number of dimensions for coordinate system." + spaceDim.meta["tip"] = "Number of dimensions for coordinate system." # PUBLIC METHODS ///////////////////////////////////////////////////// @@ -65,6 +66,7 @@ def _createModuleObj(self): # FACTORIES //////////////////////////////////////////////////////////// + def coordsys(): """ Factory associated with CoordSys. diff --git a/spatialdata/geocoords/CSGeoLocal.py b/spatialdata/geocoords/CSGeoLocal.py index f32f25c5..c6be4d15 100644 --- a/spatialdata/geocoords/CSGeoLocal.py +++ b/spatialdata/geocoords/CSGeoLocal.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from .CSGeo import CSGeo @@ -18,6 +18,7 @@ class CSGeoLocal(CSGeo, ModuleCSGeoLocal): Implements `CSGeo`. """ + DOC_CONFIG = { "cfg": """ [coordsys] @@ -33,20 +34,19 @@ class CSGeoLocal(CSGeo, ModuleCSGeoLocal): import pythia.pyre.inventory crsString = pythia.pyre.inventory.str("crs_string", default="EPSG:4326") - crsString.meta['tip'] = "String specifying coordinate system (PROJ parameters, EPSG, or WKT). Default is WGS84." + crsString.meta["tip"] = "String specifying coordinate system (PROJ parameters, EPSG, or WKT). Default is WGS84." spaceDim = pythia.pyre.inventory.int("space_dim", default=3) - spaceDim.meta['tip'] = "Number of dimensions for coordinate system." + spaceDim.meta["tip"] = "Number of dimensions for coordinate system." originX = pythia.pyre.inventory.float("origin_x", default=0.0) - originX.meta['tip'] = "X coordinate of local origin." + originX.meta["tip"] = "X coordinate of local origin." originY = pythia.pyre.inventory.float("origin_y", default=0.0) - originY.meta['tip'] = "Y coordinate of local origin." + originY.meta["tip"] = "Y coordinate of local origin." yAzimuth = pythia.pyre.inventory.float("y_azimuth", default=0.0) - yAzimuth.meta['tip'] = "Azimuth (degrees) of local y axis." - + yAzimuth.meta["tip"] = "Azimuth (degrees) of local y axis." # PUBLIC METHODS ///////////////////////////////////////////////////// @@ -77,6 +77,7 @@ def _createModuleObj(self): # FACTORIES //////////////////////////////////////////////////////////// + def coordsys(): """ Factory associated with CSGeo. diff --git a/spatialdata/geocoords/Converter.py b/spatialdata/geocoords/Converter.py index 167c4051..2cdaa456 100644 --- a/spatialdata/geocoords/Converter.py +++ b/spatialdata/geocoords/Converter.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= @@ -20,12 +20,14 @@ def convert(points, csDest, csSrc): """ if not csDest.getSpaceDim() == csSrc.getSpaceDim(): - msg = "Spatial dimensions of source (%d) and destination (%d) " \ - "coordinate systems must match." % ( - csSrc.getSpaceDim(), csDest.getSpaceDim()) + msg = "Spatial dimensions of source (%d) and destination (%d) " "coordinate systems must match." % ( + csSrc.getSpaceDim(), + csDest.getSpaceDim(), + ) raise ValueError(msg) from . import geocoords + converter = geocoords.Converter() converter.convert(points, csDest, csSrc) return diff --git a/spatialdata/geocoords/CoordSys.py b/spatialdata/geocoords/CoordSys.py index 908e3f6c..272444b5 100644 --- a/spatialdata/geocoords/CoordSys.py +++ b/spatialdata/geocoords/CoordSys.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from pythia.pyre.components.Component import Component diff --git a/spatialdata/geocoords/__init__.py b/spatialdata/geocoords/__init__.py index 7154441d..872b5824 100644 --- a/spatialdata/geocoords/__init__.py +++ b/spatialdata/geocoords/__init__.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= # @@ -14,10 +14,10 @@ # @brief Python spatialdata geocoords module initialization. __all__ = [ - 'CoordSys', - 'CSCart', - 'CSGeo', - 'Converter', + "CoordSys", + "CSCart", + "CSGeo", + "Converter", ] diff --git a/spatialdata/spatialdb/AnalyticDB.py b/spatialdata/spatialdb/AnalyticDB.py index c04f53de..bdfa6861 100644 --- a/spatialdata/spatialdb/AnalyticDB.py +++ b/spatialdata/spatialdb/AnalyticDB.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= @@ -19,6 +19,7 @@ class AnalyticDB(SpatialDBObj, ModuleAnalyticDB): Implements `SpatialDB`. """ + DOC_CONFIG = { "cfg": """ [db] @@ -34,17 +35,18 @@ class AnalyticDB(SpatialDBObj, ModuleAnalyticDB): import pythia.pyre.inventory values = pythia.pyre.inventory.list("values", default=[]) - values.meta['tip'] = "Names of values in spatial database." + values.meta["tip"] = "Names of values in spatial database." units = pythia.pyre.inventory.list("units", default=[]) - units.meta['tip'] = "Units for values in spatial database." + units.meta["tip"] = "Units for values in spatial database." expressions = pythia.pyre.inventory.list("expressions", default=[]) - expressions.meta['tip'] = "Analytical expressions for values in spatial database." + expressions.meta["tip"] = "Analytical expressions for values in spatial database." from spatialdata.geocoords.CSCart import CSCart + cs = pythia.pyre.inventory.facility("coordsys", factory=CSCart) - cs.meta['tip'] = "Coordinate system." + cs.meta["tip"] = "Coordinate system." def __init__(self, name="AnalyticDB"): """ @@ -52,6 +54,7 @@ def __init__(self, name="AnalyticDB"): """ SpatialDBObj.__init__(self, name) from pythia.pyre.units import parser + self.parser = parser() def _configure(self): @@ -84,17 +87,27 @@ def _validateParameters(self, params): if len(params.expressions) == 0: raise ValueError("Analytical expressions for AnalyticDB '%s' not specified." % self.description) if len(params.values) != len(params.units or len(params.values) != len(params.expressions)): - raise ValueError("Incompatible settings for uniform spatial database '%s'.\n" - "'values', 'units', and 'expressions' must be lists of the same size.\n" - "Size of 'values'=%d, 'units'=%d, and 'expressions'=%d." - % (self.description, len(params.values), len(params.units), len(params.expressions))) + raise ValueError( + "Incompatible settings for uniform spatial database '{}'.\n" + "'values', 'units', and 'expressions' must be lists of the same size.\n" + "Size of 'values'={}}, 'units'={}}, and 'expressions'={}}." + % ( + self.description, + len(params.values), + len(params.units), + len(params.expressions), + ) + ) try: for x in params.units: if len(str(x).split("*")) > 1: xdim = self.parser.parse(str(x)) except: raise ValueError( - "'units' for AnalyticDB '%s' must contain dimensioned or nondimensional values." % self.description) + "'units' for AnalyticDB '{}' must contain dimensioned or nondimensional values.".format( + self.description + ) + ) def spatial_database(): diff --git a/spatialdata/spatialdb/CompositeDB.py b/spatialdata/spatialdb/CompositeDB.py index 6cf69332..c08cda22 100644 --- a/spatialdata/spatialdb/CompositeDB.py +++ b/spatialdata/spatialdb/CompositeDB.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from .SpatialDBObj import SpatialDBObj @@ -19,6 +19,7 @@ class CompositeDB(SpatialDBObj, ModuleCompositeDB): Implements `SpatialDB`. """ + DOC_CONFIG = { "cfg": """ [db] @@ -39,17 +40,18 @@ class CompositeDB(SpatialDBObj, ModuleCompositeDB): import pythia.pyre.inventory namesA = pythia.pyre.inventory.list("values_A", default=[]) - namesA.meta['tip'] = "Names of values to query with database A." + namesA.meta["tip"] = "Names of values to query with database A." namesB = pythia.pyre.inventory.list("values_B", default=[]) - namesB.meta['tip'] = "Names of values to query with database B." + namesB.meta["tip"] = "Names of values to query with database B." from .UniformDB import UniformDB + dbA = pythia.pyre.inventory.facility("db_A", factory=UniformDB, family="spatial_database") - dbA.meta['tip'] = "Spatial database A." + dbA.meta["tip"] = "Spatial database A." dbB = pythia.pyre.inventory.facility("db_B", factory=UniformDB, family="spatial_database") - dbB.meta['tip'] = "Spatial database B." + dbB.meta["tip"] = "Spatial database B." # PUBLIC METHODS ///////////////////////////////////////////////////// @@ -81,17 +83,20 @@ def _validateParameters(self, data): """ Validate parameters. """ - if (0 == len(data.namesA)): - raise ValueError("Error in spatial database '%s'\n" - "Names of values to query in database A not set." % self.description) - if (0 == len(data.namesB)): - raise ValueError("Error in spatial database '%s'\n" - "Names of values to query in database B not set." % self.description) + if 0 == len(data.namesA): + raise ValueError( + "Error in spatial database '%s'\n" "Names of values to query in database A not set." % self.description + ) + if 0 == len(data.namesB): + raise ValueError( + "Error in spatial database '%s'\n" "Names of values to query in database B not set." % self.description + ) return # FACTORIES //////////////////////////////////////////////////////////// + def spatial_database(): """ Factory associated with CompositeDB. diff --git a/spatialdata/spatialdb/GravityField.py b/spatialdata/spatialdb/GravityField.py index 97553d7e..c912dee3 100644 --- a/spatialdata/spatialdb/GravityField.py +++ b/spatialdata/spatialdb/GravityField.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from .SpatialDBObj import SpatialDBObj @@ -16,8 +16,9 @@ class GravityField(SpatialDBObj, ModuleGravityField): """ Spatial database with gravity field information. - Implements `SpatialDB`. + Implements `SpatialDB`. """ + DOC_CONFIG = { "cfg": """ # Specify a gravity field in 2D with gravity in the -y direction. @@ -30,14 +31,13 @@ class GravityField(SpatialDBObj, ModuleGravityField): import pythia.pyre.inventory gravityDir = pythia.pyre.inventory.list("gravity_dir", default=[0.0, 0.0, -1.0]) - gravityDir.meta['tip'] = "Direction of gravitational body force. " \ - "(used only with a Cartesian coordinate system." + gravityDir.meta["tip"] = "Direction of gravitational body force. " "(used only with a Cartesian coordinate system." from pythia.pyre.units.length import meter from pythia.pyre.units.time import second - acceleration = pythia.pyre.inventory.dimensional("acceleration", - default=9.80665 * meter / second**2) - acceleration.meta['tip'] = "Gravitational acceleration." + + acceleration = pythia.pyre.inventory.dimensional("acceleration", default=9.80665 * meter / second**2) + acceleration.meta["tip"] = "Gravitational acceleration." def __init__(self, name="gravityfield"): """ @@ -48,7 +48,7 @@ def __init__(self, name="gravityfield"): def _defaults(self): self.description = "Gravity field" - + def _configure(self): """ Set members based on inventory. @@ -69,7 +69,7 @@ def _validateParameters(self, params): """ Validate parameters. """ - if (len(params.gravityDir) != 3): + if len(params.gravityDir) != 3: raise ValueError("Gravity direction must be a 3 component list or tuple.") try: dirFloat = list(map(float, params.gravityDir)) @@ -79,6 +79,7 @@ def _validateParameters(self, params): # FACTORIES //////////////////////////////////////////////////////////// + def spatial_database(): """ Factory associated with GravityField. diff --git a/spatialdata/spatialdb/SCECCVMH.py b/spatialdata/spatialdb/SCECCVMH.py index 45140577..b89402b9 100644 --- a/spatialdata/spatialdb/SCECCVMH.py +++ b/spatialdata/spatialdb/SCECCVMH.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from .SpatialDBObj import SpatialDBObj @@ -17,11 +17,12 @@ class SCECCVMH(SpatialDBObj, ModuleSCECCVMH): Spatial database for the SCEC CVM-H seismic velocity model versions 5.2 and 5.3. Implements `SpatialDB`. - + :::{danger} These models are obsolete and no longer available from SCEC. ::: """ + DOC_CONFIG = { "cfg": """ data_dir = data/scec-cvmh @@ -34,19 +35,21 @@ class SCECCVMH(SpatialDBObj, ModuleSCECCVMH): import pythia.pyre.inventory dataDir = pythia.pyre.inventory.str("data_dir", default=".") - dataDir.meta['tip'] = "Directory containing SCEC CVM-H data files." + dataDir.meta["tip"] = "Directory containing SCEC CVM-H data files." from pythia.pyre.units.length import meter from pythia.pyre.units.time import second + minVs = pythia.pyre.inventory.dimensional("min_vs", default=500.0 * meter / second) - minVs.meta['tip'] = "Minimum shear wave speed." + minVs.meta["tip"] = "Minimum shear wave speed." squash = pythia.pyre.inventory.bool("squash", default=False) - squash.meta['tip'] = "Squash topography/bathymetry to sea level." + squash.meta["tip"] = "Squash topography/bathymetry to sea level." from pythia.pyre.units.length import km + squashLimit = pythia.pyre.inventory.dimensional("squash_limit", default=-2.0 * km) - squashLimit.meta['tip'] = "Elevation above which topography is squashed." + squashLimit.meta["tip"] = "Elevation above which topography is squashed." def __init__(self, name="sceccvmh"): """ @@ -56,7 +59,7 @@ def __init__(self, name="sceccvmh"): def _defaults(self): self.description = "SCEC CVM-H v5.3" - + def _configure(self): """ Set members based on inventory. @@ -76,6 +79,7 @@ def _createModuleObj(self): # FACTORIES //////////////////////////////////////////////////////////// + def spatial_database(): """ Factory associated with SCECCVMH. diff --git a/spatialdata/spatialdb/SimpleDB.py b/spatialdata/spatialdb/SimpleDB.py index b259115f..afe00d32 100644 --- a/spatialdata/spatialdb/SimpleDB.py +++ b/spatialdata/spatialdb/SimpleDB.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from .SpatialDBObj import SpatialDBObj @@ -19,6 +19,7 @@ class SimpleDB(SpatialDBObj, ModuleSimpleDB): Implements `SpatialDB`. """ + DOC_CONFIG = { "cfg": """ [db] @@ -32,11 +33,12 @@ class SimpleDB(SpatialDBObj, ModuleSimpleDB): queryType = pythia.pyre.inventory.str("query_type", default="nearest") queryType.validator = pythia.pyre.inventory.choice(["nearest", "linear"]) - queryType.meta['tip'] = "Type of query to perform." + queryType.meta["tip"] = "Type of query to perform." from .SimpleIOAscii import SimpleIOAscii + iohandler = pythia.pyre.inventory.facility("iohandler", family="simpledb_io", factory=SimpleIOAscii) - iohandler.meta['tip'] = "I/O handler for database." + iohandler.meta["tip"] = "I/O handler for database." # PUBLIC METHODS ///////////////////////////////////////////////////// @@ -74,6 +76,7 @@ def _parseQueryString(self, label): # FACTORIES //////////////////////////////////////////////////////////// + def spatial_database(): """ Factory associated with SimpleDB. diff --git a/spatialdata/spatialdb/SimpleGridAscii.py b/spatialdata/spatialdb/SimpleGridAscii.py index a95c5d6c..58d0b271 100644 --- a/spatialdata/spatialdb/SimpleGridAscii.py +++ b/spatialdata/spatialdb/SimpleGridAscii.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= @@ -26,6 +26,7 @@ class SimpleGridAscii(Component, ModuleSimpleGridAscii): """ ASCII writer for a simple grid spatial database. """ + DOC_CONFIG = { "cfg": """ [dbio] @@ -36,7 +37,7 @@ class SimpleGridAscii(Component, ModuleSimpleGridAscii): import pythia.pyre.inventory filename = pythia.pyre.inventory.str("filename", default="", validator=validateFilename) - filename.meta['tip'] = "Name of database file." + filename.meta["tip"] = "Name of database file." # PUBLIC METHODS ///////////////////////////////////////////////////// @@ -63,43 +64,47 @@ def write(self, data): """ import numpy - (numLocs, spaceDim) = data['points'].shape - numValues = len(data['values']) + numLocs, spaceDim = data["points"].shape + numValues = len(data["values"]) names = [] units = [] values = numpy.zeros((numLocs, numValues), dtype=numpy.float64) i = 0 - for value in data['values']: - names.append(value['name']) - units.append(value['units']) - values[:, i] = value['data'][:] + for value in data["values"]: + names.append(value["name"]) + units.append(value["units"]) + values[:, i] = value["data"][:] i += 1 - numX = data['x'].shape[0] - numY = data['y'].shape[0] - if data['coordsys'].getSpaceDim() == 2: + numX = data["x"].shape[0] + numY = data["y"].shape[0] + if data["coordsys"].getSpaceDim() == 2: numZ = 0 - if (numLocs != numX * numY): - raise ValueError("Number of locations (%d) does not match coordinate dimensions (%d, %d)." % - (numLocs, numX, numY)) + if numLocs != numX * numY: + raise ValueError( + "Number of locations (%d) does not match coordinate dimensions (%d, %d)." % (numLocs, numX, numY) + ) else: - numZ = data['z'].shape[0] - if (numLocs != numX * numY * numZ): - raise ValueError("Number of locations (%d) does not match coordinate dimensions (%d, %d, %d)." % - (numLocs, numX, numY, numZ)) + numZ = data["z"].shape[0] + if numLocs != numX * numY * numZ: + raise ValueError( + "Number of locations (%d) does not match coordinate dimensions (%d, %d, %d)." + % (numLocs, numX, numY, numZ) + ) from .SimpleGridDB import SimpleGridDB + db = SimpleGridDB() db._configure() db.setDescription("Temporary SimpleGridDB for writing") db.setFilename(self.filename) - db.setCoordSys(data['coordsys']) - db.allocate(numX, numY, numZ, numValues, spaceDim, data['data_dim']) - db.setX(data['x']) - db.setY(data['y']) - if data['coordsys'].getSpaceDim() == 3: - db.setZ(data['z']) - db.setData(data['points'], values) + db.setCoordSys(data["coordsys"]) + db.allocate(numX, numY, numZ, numValues, spaceDim, data["data_dim"]) + db.setX(data["x"]) + db.setY(data["y"]) + if data["coordsys"].getSpaceDim() == 3: + db.setZ(data["z"]) + db.setData(data["points"], values) db.setNames(names) db.setUnits(units) @@ -122,6 +127,7 @@ def _createModuleObj(self): # FACTORIES //////////////////////////////////////////////////////////// + def createWriter(filename): writer = SimpleGridAscii() writer.inventory.filename = filename diff --git a/spatialdata/spatialdb/SimpleGridDB.py b/spatialdata/spatialdb/SimpleGridDB.py index e652d211..590ac6f6 100644 --- a/spatialdata/spatialdb/SimpleGridDB.py +++ b/spatialdata/spatialdb/SimpleGridDB.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import pathlib @@ -32,6 +32,7 @@ class SimpleGridDB(SpatialDBObj, ModuleSimpleGridDB): Implements `SpatialDB`. """ + DOC_CONFIG = { "cfg": """ [db] @@ -44,11 +45,11 @@ class SimpleGridDB(SpatialDBObj, ModuleSimpleGridDB): import pythia.pyre.inventory filename = pythia.pyre.inventory.str("filename", default="", validator=validateFilename) - filename.meta['tip'] = "Name for data file." + filename.meta["tip"] = "Name for data file." queryType = pythia.pyre.inventory.str("query_type", default="nearest") queryType.validator = pythia.pyre.inventory.choice(["nearest", "linear"]) - queryType.meta['tip'] = "Type of query to perform." + queryType.meta["tip"] = "Type of query to perform." # PUBLIC METHODS ///////////////////////////////////////////////////// @@ -87,6 +88,7 @@ def _parseQueryString(self, label): # FACTORIES //////////////////////////////////////////////////////////// + def spatial_database(): """ Factory associated with SimpleGridDB. diff --git a/spatialdata/spatialdb/SimpleIO.py b/spatialdata/spatialdb/SimpleIO.py index 64884f93..cda7e73f 100644 --- a/spatialdata/spatialdb/SimpleIO.py +++ b/spatialdata/spatialdb/SimpleIO.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import pathlib @@ -28,6 +28,7 @@ class SimpleIO(Component): """ Abstract base class for writing a simple spatial database (SimpleDB). """ + DOC_CONFIG = { "cfg": """ [dbio] @@ -38,7 +39,7 @@ class SimpleIO(Component): import pythia.pyre.inventory filename = pythia.pyre.inventory.str("filename", default="", validator=validateFilename) - filename.meta['tip'] = "Name of database file." + filename.meta["tip"] = "Name of database file." # PUBLIC METHODS ///////////////////////////////////////////////////// @@ -62,16 +63,18 @@ def _validateData(self, data): """ Check consistency of database data. """ - (numLocs, spaceDim) = data['points'].shape - cs = data['coordsys'] + numLocs, spaceDim = data["points"].shape + cs = data["coordsys"] if spaceDim != cs.getSpaceDim(): - raise ValueError("Simple database '%s' space-dim (%d) does not agree with spatial " - "dimension of coordinate system (%d)." % - (self.filename, spaceDim, cs.getSpaceDim())) + raise ValueError( + "Simple database '%s' space-dim (%d) does not agree with spatial " + "dimension of coordinate system (%d)." % (self.filename, spaceDim, cs.getSpaceDim()) + ) # FACTORIES //////////////////////////////////////////////////////////// + def simpledb_io(): """ Factory associated with SimpleIO. diff --git a/spatialdata/spatialdb/SimpleIOAscii.py b/spatialdata/spatialdb/SimpleIOAscii.py index f673d0b1..f2f7d117 100644 --- a/spatialdata/spatialdb/SimpleIOAscii.py +++ b/spatialdata/spatialdb/SimpleIOAscii.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from .SimpleIO import SimpleIO @@ -18,6 +18,7 @@ class SimpleIOAscii(SimpleIO, ModuleSimpleIOAscii): Implements `SimpleIO`. """ + DOC_CONFIG = { "cfg": """ [dbio] @@ -50,28 +51,29 @@ def write(self, data): self._validateData(data) - (numLocs, spaceDim) = data['points'].shape - dataDim = data['data_dim'] - numValues = len(data['values']) + numLocs, spaceDim = data["points"].shape + dataDim = data["data_dim"] + numValues = len(data["values"]) names = [] units = [] values = numpy.zeros((numLocs, numValues), dtype=numpy.float64) i = 0 - for value in data['values']: - names.append(value['name']) - units.append(value['units']) - values[:, i] = value['data'][:] + for value in data["values"]: + names.append(value["name"]) + units.append(value["units"]) + values[:, i] = value["data"][:] i += 1 from .spatialdb import SimpleDBData + dbData = SimpleDBData() dbData.allocate(numLocs, numValues, spaceDim, dataDim) - dbData.setCoordinates(data['points']) + dbData.setCoordinates(data["points"]) dbData.setData(values) dbData.setNames(names) dbData.setUnits(units) - ModuleSimpleIOAscii.write(self, dbData, data['coordsys']) + ModuleSimpleIOAscii.write(self, dbData, data["coordsys"]) # PRIVATE METHODS //////////////////////////////////////////////////// @@ -87,6 +89,7 @@ def _createModuleObj(self): # FACTORIES //////////////////////////////////////////////////////////// + def createWriter(filename): writer = SimpleIOAscii() writer.setFilename(filename) diff --git a/spatialdata/spatialdb/SpatialDBObj.py b/spatialdata/spatialdb/SpatialDBObj.py index 11387cc3..2c644c40 100644 --- a/spatialdata/spatialdb/SpatialDBObj.py +++ b/spatialdata/spatialdb/SpatialDBObj.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= @@ -30,7 +30,7 @@ class SpatialDBObj(Component, ModuleSpatialDB): import pythia.pyre.inventory description = pythia.pyre.inventory.str("description", default="", validator=validateDescription) - description.meta['tip'] = "Description for database." + description.meta["tip"] = "Description for database." # PUBLIC METHODS ///////////////////////////////////////////////////// diff --git a/spatialdata/spatialdb/TimeHistory.py b/spatialdata/spatialdb/TimeHistory.py index b87d201c..8e8a7ca4 100644 --- a/spatialdata/spatialdb/TimeHistory.py +++ b/spatialdata/spatialdb/TimeHistory.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import pathlib @@ -29,6 +29,7 @@ class TimeHistory(Component, ModuleTimeHistory): """ Time history object for specifying temporal variation in a field. """ + DOC_CONFIG = { "cfg": """ [timehistory] @@ -40,10 +41,10 @@ class TimeHistory(Component, ModuleTimeHistory): import pythia.pyre.inventory description = pythia.pyre.inventory.str("description", default="temporal database") - description.meta['tip'] = "Description for time history." + description.meta["tip"] = "Description for time history." filename = pythia.pyre.inventory.str("filename", default="timehistory.timedb", validator=validateFilename) - filename.meta['tip'] = "Name of file for time history." + filename.meta["tip"] = "Name of file for time history." # PUBLIC METHODS ///////////////////////////////////////////////////// @@ -73,6 +74,7 @@ def _createModuleObj(self): # FACTORIES //////////////////////////////////////////////////////////// + def createWriter(filename, description="Time history writer"): writer = TimeHistory() writer.setDescription(description) diff --git a/spatialdata/spatialdb/TimeHistoryIO.py b/spatialdata/spatialdb/TimeHistoryIO.py index 979df2c7..2e30b8bb 100644 --- a/spatialdata/spatialdb/TimeHistoryIO.py +++ b/spatialdata/spatialdb/TimeHistoryIO.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= @@ -14,6 +14,7 @@ def write(time, amplitude, units, filename): Write time history file. """ from .spatialdb import TimeHistoryIO as ModuleTimeHistoryIO + ModuleTimeHistoryIO.write(time, amplitude, units, filename) return diff --git a/spatialdata/spatialdb/UniformDB.py b/spatialdata/spatialdb/UniformDB.py index 37c587b7..45f8a2b1 100644 --- a/spatialdata/spatialdb/UniformDB.py +++ b/spatialdata/spatialdb/UniformDB.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= @@ -19,6 +19,7 @@ class UniformDB(SpatialDBObj, ModuleUniformDB): Implements `SpatialDB`. """ + DOC_CONFIG = { "cfg": """ [db] @@ -31,10 +32,10 @@ class UniformDB(SpatialDBObj, ModuleUniformDB): import pythia.pyre.inventory values = pythia.pyre.inventory.list("values", default=[]) - values.meta['tip'] = "Names of values in spatial database." + values.meta["tip"] = "Names of values in spatial database." data = pythia.pyre.inventory.list("data", default=[]) - data.meta['tip'] = "Values in spatial database." + data.meta["tip"] = "Values in spatial database." # PUBLIC METHODS ///////////////////////////////////////////////////// @@ -44,6 +45,7 @@ def __init__(self, name="uniformdb"): """ SpatialDBObj.__init__(self, name) from pythia.pyre.units import parser + self.parser = parser() # PRIVATE METHODS //////////////////////////////////////////////////// @@ -89,10 +91,12 @@ def _validateParameters(self, params): if len(params.data) == 0: raise ValueError("Data for UniformDB '%s' not specified." % self.description) if len(params.values) != len(params.data): - raise ValueError("Incompatible settings for uniform spatial database '%s'.\n" - "'values' and 'data' must be lists of the same size.\n" - "'values' has size of %d but 'data' has size of %d." - % (self.description, len(params.values), len(params.data))) + raise ValueError( + "Incompatible settings for uniform spatial database '%s'.\n" + "'values' and 'data' must be lists of the same size.\n" + "'values' has size of %d but 'data' has size of %d." + % (self.description, len(params.values), len(params.data)) + ) try: for x in params.data: if len(str(x).split("*")) > 1: @@ -102,11 +106,14 @@ def _validateParameters(self, params): dataFloat = float(x) except: raise ValueError( - "'data' list for UniformDB '%s' must contain dimensioned or nondimensional values." % self.inventory.label) + "'data' list for UniformDB '%s' must contain dimensioned or nondimensional values." + % self.inventory.label + ) # FACTORIES //////////////////////////////////////////////////////////// + def spatial_database(): """ Factory associated with UniformDB. diff --git a/spatialdata/spatialdb/UserFunctionDB.py b/spatialdata/spatialdb/UserFunctionDB.py index 9445a65e..d8f9594a 100644 --- a/spatialdata/spatialdb/UserFunctionDB.py +++ b/spatialdata/spatialdb/UserFunctionDB.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from .SpatialDBObj import SpatialDBObj @@ -20,6 +20,7 @@ class UserFunctionDB(SpatialDBObj, ModuleUserFunctionDB): Implements `SpatialDB`. """ + DOC_CONFIG = { "cfg": """ [db] @@ -32,8 +33,9 @@ class UserFunctionDB(SpatialDBObj, ModuleUserFunctionDB): import pythia.pyre.inventory from spatialdata.geocoords.CSCart import CSCart + cs = pythia.pyre.inventory.facility("coordsys", factory=CSCart) - cs.meta['tip'] = "Coordinate system." + cs.meta["tip"] = "Coordinate system." # PUBLIC METHODS ///////////////////////////////////////////////////// @@ -57,7 +59,11 @@ def _configure(self): """ SpatialDBObj._configure(self) ModuleUserFunctionDB.setCoordSys(self, self.cs) - for (name, fn, units,) in self.functions: + for ( + name, + fn, + units, + ) in self.functions: ModuleUserFunctionDB.addValue(self, name, fn, units) return @@ -71,6 +77,7 @@ def _createModuleObj(self): # FACTORIES //////////////////////////////////////////////////////////// + def spatial_database(): """ Factory associated with UserFunctionDB. diff --git a/spatialdata/spatialdb/__init__.py b/spatialdata/spatialdb/__init__.py index 3cff4374..d6daf6c3 100644 --- a/spatialdata/spatialdb/__init__.py +++ b/spatialdata/spatialdb/__init__.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= # # @file spatialdata/spatialdb/__init__.py diff --git a/spatialdata/spatialdb/generator/GenSimpleDBApp.py b/spatialdata/spatialdb/generator/GenSimpleDBApp.py index 5eea958d..e08b927f 100644 --- a/spatialdata/spatialdb/generator/GenSimpleDBApp.py +++ b/spatialdata/spatialdb/generator/GenSimpleDBApp.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from pythia.pyre.applications.Script import Script @@ -19,6 +19,7 @@ def valueFactory(name): Factory for values. """ from pythia.pyre.inventory import facility + return facility(name, family="database_value", factory=Value) @@ -37,8 +38,9 @@ class SingleValue(Component): """ import pythia.pyre.inventory + dbValue = pythia.pyre.inventory.facility("value", family="database_value", factory=Value) - dbValue.meta['tip'] = "Value in spatial database." + dbValue.meta["tip"] = "Value in spatial database." def __init__(self, name="siglevalue"): """ @@ -51,8 +53,8 @@ class GenSimpleDBApp(Script): """ Application to generate simple spatial database. """ - DOC_CONFIG = { - "cfg": """ + + DOC_CONFIG = {"cfg": """ # Create a spatial dabaset with values `Vp` and `Vs`. # # Vp is generated from a background value given in `vp_background.spatialdb` @@ -109,23 +111,22 @@ class GenSimpleDBApp(Script): db.description = Multiply db.query_type = linear db.iohandler.filename = vs_scaling.spatialdb - """ - } + """} import pythia.pyre.inventory from .Geometry import Geometry + geometry = pythia.pyre.inventory.facility("geometry", family="geometry", factory=Geometry) - geometry.meta['tip'] = "Object defining geometry of region covered by database." + geometry.meta["tip"] = "Object defining geometry of region covered by database." values = pythia.pyre.inventory.facilityArray("values", itemFactory=valueFactory, factory=SingleValue) - values.meta['tip'] = "Values in database." + values.meta["tip"] = "Values in database." filename = pythia.pyre.inventory.str("filename", default="", validator=validateFilename) - filename.meta['tip'] = "Filename for generated ASCII SimpleDB." - + filename.meta["tip"] = "Filename for generated ASCII SimpleDB." - def __init__(self, name='gensimpledb'): + def __init__(self, name="gensimpledb"): """ Constructor. """ @@ -142,20 +143,23 @@ def main(self, *args, **kwds): points = self.geometry.vertices coordsys = self.geometry.coordsys data = { - 'points': points, - 'coordsys': coordsys, - 'data_dim': self.geometry.dataDim, - 'values': [], + "points": points, + "coordsys": coordsys, + "data_dim": self.geometry.dataDim, + "values": [], } for value in self.values.components(): self._info.log("Creating value '%s'" % value.name) - data['values'].append({ - 'name': value.vname, - 'units': value.units, - 'data': value.calculate(points, coordsys), - }) + data["values"].append( + { + "name": value.vname, + "units": value.units, + "data": value.calculate(points, coordsys), + } + ) self._info.log("Writing database.") writer = createWriter(self.filename) writer.write(data) + # End of file diff --git a/spatialdata/spatialdb/generator/Geometry.py b/spatialdata/spatialdb/generator/Geometry.py index 043b63b1..f05f1ab8 100644 --- a/spatialdata/spatialdb/generator/Geometry.py +++ b/spatialdata/spatialdb/generator/Geometry.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from pythia.pyre.components.Component import Component @@ -21,27 +21,27 @@ class Geometry(Component): """ Geometry used in generating database. """ - DOC_CONFIG = { - "cfg": """ + + DOC_CONFIG = {"cfg": """ [gensimplebd.geometry] data_dim = 2 reader = read_geometry coordsys = spatialdata.geocoords.CSCart - """ - } + """} import pythia.pyre.inventory dataDim = pythia.pyre.inventory.int("data_dim", default=2) dataDim.validator = pythia.pyre.inventory.choice([0, 1, 2, 3]) - dataDim.meta['tip'] = "Spatial dimension of database locations." + dataDim.meta["tip"] = "Spatial dimension of database locations." reader = pythia.pyre.inventory.facility("reader", family="reader", factory=Dummy) - reader.meta['tip'] = "Object to read geometry." + reader.meta["tip"] = "Object to read geometry." from spatialdata.geocoords.CSCart import CSCart + coordsys = pythia.pyre.inventory.facility("coordsys", family="coordsys", factory=CSCart) - coordsys.meta['tip'] = "Coordinate system for database." + coordsys.meta["tip"] = "Coordinate system for database." def __init__(self, name="geometry"): """ diff --git a/spatialdata/spatialdb/generator/Shaper.py b/spatialdata/spatialdb/generator/Shaper.py index 54d78a8e..7ad4a09e 100644 --- a/spatialdata/spatialdb/generator/Shaper.py +++ b/spatialdata/spatialdb/generator/Shaper.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from pythia.pyre.components.Component import Component @@ -17,8 +17,8 @@ class Shaper(Component): """ Object for shaping spatial distribution of data while generating database. """ - DOC_CONFIG = { - "cfg": """ + + DOC_CONFIG = {"cfg": """ [gensimpledb.values.density] shapers = [bg, add] @@ -36,24 +36,24 @@ class Shaper(Component): operand = add db = spatialdata.spatialdb.SimpleGridDB db.filename = density_perturbation.spatialdb - """ - } + """} import pythia.pyre.inventory defaultValue = pythia.pyre.inventory.float("default", default=0.0) - defaultValue.meta['tip'] = "Default value for shaper." + defaultValue.meta["tip"] = "Default value for shaper." dbValue = pythia.pyre.inventory.str("db_value", default="") - dbValue.meta['tip'] = "Name of value supplied in spatial database." + dbValue.meta["tip"] = "Name of value supplied in spatial database." operand = pythia.pyre.inventory.str("operand", default="multiply") operand.validator = pythia.pyre.inventory.choice(["add", "subtract", "multiply", "divide"]) - operand.meta['tip'] = "Operand to use in applying shaper." + operand.meta["tip"] = "Operand to use in applying shaper." from spatialdata.spatialdb.SimpleDB import SimpleDB + db = pythia.pyre.inventory.facility("db", family="spatial_database", factory=SimpleDB) - db.meta['tip'] = "Database containing value defining shaper." + db.meta["tip"] = "Database containing value defining shaper." def __init__(self, name="shaper"): """ @@ -108,6 +108,7 @@ def apply(self, value): # FACTORIES //////////////////////////////////////////////////////////// + def shaper(): """ Factory associated with Shaper. diff --git a/spatialdata/spatialdb/generator/Value.py b/spatialdata/spatialdb/generator/Value.py index 570bb48e..14665c3a 100644 --- a/spatialdata/spatialdb/generator/Value.py +++ b/spatialdata/spatialdb/generator/Value.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import numpy @@ -20,6 +20,7 @@ def shaperFactory(name): Factory for shapers. """ from pythia.pyre.inventory import facility + return facility(name, family="shaper", factory=Shaper) @@ -29,8 +30,9 @@ class SingleShaper(Component): """ import pythia.pyre.inventory + valueShaper = pythia.pyre.inventory.facility("shaper", family="shaper", factory=Shaper) - valueShaper.meta['tip'] = "Shaper for database value." + valueShaper.meta["tip"] = "Shaper for database value." def __init__(self, name="sigleshaper"): """ @@ -43,8 +45,8 @@ class Value(Component): """ Value generated in spatial database. """ - DOC_CONFIG = { - "cfg": """ + + DOC_CONFIG = {"cfg": """ [gensimpledb] values = [vp, vs] @@ -52,19 +54,18 @@ class Value(Component): name = Vp units = m/s shapers = [bg, perturbation] - """ - } + """} import pythia.pyre.inventory vname = pythia.pyre.inventory.str("name", default="") - vname.meta['tip'] = "Name of value." + vname.meta["tip"] = "Name of value." units = pythia.pyre.inventory.str("units", default="none") - units.meta['tip'] = "Units associated with value." + units.meta["tip"] = "Units associated with value." shapers = pythia.pyre.inventory.facilityArray("shapers", itemFactory=shaperFactory, factory=SingleShaper) - shapers.meta['tip'] = "Shapers/filters used to construct spatial distribution." + shapers.meta["tip"] = "Shapers/filters used to construct spatial distribution." def __init__(self, name="value"): """ @@ -76,7 +77,7 @@ def calculate(self, locs, cs): """ Calculate spatial distribution for value using shapers. """ - (numLocs, spaceDim) = locs.shape + numLocs, spaceDim = locs.shape value = numpy.zeros((numLocs,), dtype=numpy.float64) for shaper in self.shapers.components(): shaper.initialize(locs, cs) diff --git a/spatialdata/spatialdb/generator/__init__.py b/spatialdata/spatialdb/generator/__init__.py index 9200bd6f..1d4c44d3 100644 --- a/spatialdata/spatialdb/generator/__init__.py +++ b/spatialdata/spatialdb/generator/__init__.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= # @file spatialdata/spatialdb/generator/__init__.py # diff --git a/spatialdata/testing/TestCases.py b/spatialdata/testing/TestCases.py index 7f1dc741..1b4d8f34 100644 --- a/spatialdata/testing/TestCases.py +++ b/spatialdata/testing/TestCases.py @@ -5,12 +5,13 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= """PyLith module for unit test helper functions.""" import unittest + def make_suite(test_classes, loader=unittest.defaultTestLoader): suite = unittest.TestSuite() for cls in test_classes: diff --git a/spatialdata/testing/UnitTestApp.py b/spatialdata/testing/UnitTestApp.py index ff16e59f..8744a448 100644 --- a/spatialdata/testing/UnitTestApp.py +++ b/spatialdata/testing/UnitTestApp.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= """Application for running Python unit tests with code coverage. @@ -13,14 +13,14 @@ subdirectories. """ - import unittest -class UnitTestApp(): +class UnitTestApp: """ Test application. """ + test_modules = [] def __init__(self, test_modules, src_dirs=["spatialdata"]): @@ -28,6 +28,7 @@ def __init__(self, test_modules, src_dirs=["spatialdata"]): self.test_modules = test_modules try: import coverage + self.cov = coverage.Coverage(source=src_dirs) except ImportError: pass @@ -45,11 +46,11 @@ def run(self): self.cov.stop() self.cov.save() self.cov.report() - + if not success: import sys - sys.exit(1) + sys.exit(1) def _suite(self): loader = unittest.defaultTestLoader diff --git a/spatialdata/utils/PointsStream.py b/spatialdata/utils/PointsStream.py index e51d1f85..17eb05e8 100644 --- a/spatialdata/utils/PointsStream.py +++ b/spatialdata/utils/PointsStream.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from pythia.pyre.components.Component import Component @@ -17,6 +17,7 @@ class PointsStream(Component): """ Object for reading/writing points from stdin/stdout. """ + DOC_CONFIG = { "cfg": """ [points_writer] @@ -29,13 +30,13 @@ class PointsStream(Component): import pythia.pyre.inventory filename = pythia.pyre.inventory.str("filename", default="") - filename.meta['tip'] = "Name of file for input/output." + filename.meta["tip"] = "Name of file for input/output." commentFlag = pythia.pyre.inventory.str("comment_flag", default="#") - commentFlag.meta['tip'] = "String identifying comment." + commentFlag.meta["tip"] = "String identifying comment." numFormat = pythia.pyre.inventory.str("number_format", default="%14.5e") - numFormat.meta['tip'] = "C style string specifying number format." + numFormat.meta["tip"] = "C style string specifying number format." # PUBLIC METHODS ///////////////////////////////////////////////////// @@ -63,6 +64,7 @@ def __init__(self, name="pointsstream"): # FACTORIES //////////////////////////////////////////////////////////// + def writer(): """ Factory associated with PointsStream. diff --git a/spatialdata/utils/__init__.py b/spatialdata/utils/__init__.py index c203566a..cf2bd942 100644 --- a/spatialdata/utils/__init__.py +++ b/spatialdata/utils/__init__.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= # @file spatialdata/utils/__init__.py diff --git a/templates/spatialdb/UniformVelModel.py b/templates/spatialdb/UniformVelModel.py index 0e66648a..df51c981 100644 --- a/templates/spatialdb/UniformVelModel.py +++ b/templates/spatialdb/UniformVelModel.py @@ -7,7 +7,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= # @brief Python object associated with the C++ UniformVelModel @@ -78,15 +78,15 @@ class Inventory(SpatialDBObj.Inventory): # # Create a pythia.pyre property named vs with a default value of 2.6 km/s. vs = pythia.pyre.inventory.dimensional("vs", default=2.6 * km / s) - vs.meta['tip'] = "S wave speed." + vs.meta["tip"] = "S wave speed." # Create a pythia.pyre property named vp with a default value of 4.5 km/s. vp = pythia.pyre.inventory.dimensional("vp", default=4.5 * km / s) - vp.meta['tip'] = "P wave speed." + vp.meta["tip"] = "P wave speed." # Create a pythia.pyre property named density with a default value of 2500 kg/m**3. - density = pythia.pyre.inventory.dimensional("density", default=2.5e+3 * kg / m**3) - density.meta['tip'] = "Density." + density = pythia.pyre.inventory.dimensional("density", default=2.5e3 * kg / m**3) + density.meta["tip"] = "Density." # PUBLIC METHODS ///////////////////////////////////////////////////// @@ -126,6 +126,7 @@ def _createModuleObj(self): # FACTORIES //////////////////////////////////////////////////////////// + # Factory used when setting UniformVelModel to a pythia.pyre 'spatial_database' facility. def spatial_database(): """ diff --git a/templates/spatialdb/__init__.py b/templates/spatialdb/__init__.py index 7702af86..c933f8e6 100644 --- a/templates/spatialdb/__init__.py +++ b/templates/spatialdb/__init__.py @@ -7,15 +7,16 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= ## @file __init__.py ## ## @brief Python module initialization -__all__ = ['UniformVelModel', - ] +__all__ = [ + "UniformVelModel", +] # End of file diff --git a/templates/spatialdb/tests/TestUniformVelModel.py b/templates/spatialdb/tests/TestUniformVelModel.py index 00ebb11b..47e02f6a 100644 --- a/templates/spatialdb/tests/TestUniformVelModel.py +++ b/templates/spatialdb/tests/TestUniformVelModel.py @@ -7,97 +7,96 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest import numpy + class TestUniformVelModel(unittest.TestCase): - def setUp(self): - from spatialdata.spatialdb.contrib.UniformVelModel import UniformVelModel - db = UniformVelModel() - db.inventory.label = "Uniform properties" - db._configure() - self._db = db - - from spatialdata.geocoords.CSGeo import CSGeo - csQ = CSGeo() - csQ.inventory.datumHoriz = "NAD27" - csQ.inventory.datumVert = "mean sea level" - csQ.inventory.ellipsoid = "clrk66" - csQ._configure() - csQ.initialize() - self._csQ = csQ - return - - - def test_queryVp(self): - locs = numpy.array( [[-118.520000, 34.120000, -1400.00], - [-116.400000, 32.340000, -1000.00]], - numpy.float64) - queryVals = ["vp"] - dataE = numpy.array([[4.5e+3], - [4.5e+3]], - numpy.float64) - errE = [0, 0] - - db = self._db - db.open() - db.queryVals(queryVals) - data = numpy.zeros(dataE.shape, dtype=numpy.float64) - err = [] - nlocs = locs.shape[0] - for i in range(nlocs): - e = db.query(data[i,:], locs[i,:], self._csQ) - err.append(e) - db.close() - - self.assertEqual(len(errE), len(err)) - for vE, v in zip(errE, err): - self.assertEqual(vE, v) - - self.assertEqual(len(dataE.shape), len(data.shape)) - for dE, d in zip(dataE.shape, data.shape): - self.assertEqual(dE, d) - for vE, v in zip(numpy.reshape(dataE, -1), numpy.reshape(data, -1)): - self.assertAlmostEqual(vE, v, 6) - return - - - def test_query(self): - locs = numpy.array( [[-118.520000, 34.120000, -1400.00], - [-116.400000, 32.340000, -1000.00]], - numpy.float64) - queryVals = ["density", "vs"] - dataE = numpy.array([[2.5e+3, 2.6e+3], - [2.5e+3, 2.6e+3]], - numpy.float64) - errE = [0, 0] - - db = self._db - db.open() - db.queryVals(queryVals) - data = numpy.zeros(dataE.shape, dtype=numpy.float64) - err = [] - nlocs = locs.shape[0] - for i in range(nlocs): - e = db.query(data[i,:], locs[i,:], self._csQ) - err.append(e) - db.close() - - self.assertEqual(len(errE), len(err)) - for vE, v in zip(errE, err): - self.assertEqual(vE, v) - - self.assertEqual(len(dataE.shape), len(data.shape)) - for dE, d in zip(dataE.shape, data.shape): - self.assertEqual(dE, d) - for vE, v in zip(numpy.reshape(dataE, -1), numpy.reshape(data, -1)): - self.assertAlmostEqual(vE, v, 6) - return - - -# End of file + def setUp(self): + from spatialdata.spatialdb.contrib.UniformVelModel import UniformVelModel + + db = UniformVelModel() + db.inventory.label = "Uniform properties" + db._configure() + self._db = db + + from spatialdata.geocoords.CSGeo import CSGeo + + csQ = CSGeo() + csQ.inventory.datumHoriz = "NAD27" + csQ.inventory.datumVert = "mean sea level" + csQ.inventory.ellipsoid = "clrk66" + csQ._configure() + csQ.initialize() + self._csQ = csQ + return + + def test_queryVp(self): + locs = numpy.array( + [[-118.520000, 34.120000, -1400.00], [-116.400000, 32.340000, -1000.00]], + numpy.float64, + ) + queryVals = ["vp"] + dataE = numpy.array([[4.5e3], [4.5e3]], numpy.float64) + errE = [0, 0] + + db = self._db + db.open() + db.queryVals(queryVals) + data = numpy.zeros(dataE.shape, dtype=numpy.float64) + err = [] + nlocs = locs.shape[0] + for i in range(nlocs): + e = db.query(data[i, :], locs[i, :], self._csQ) + err.append(e) + db.close() + + self.assertEqual(len(errE), len(err)) + for vE, v in zip(errE, err): + self.assertEqual(vE, v) + + self.assertEqual(len(dataE.shape), len(data.shape)) + for dE, d in zip(dataE.shape, data.shape): + self.assertEqual(dE, d) + for vE, v in zip(numpy.reshape(dataE, -1), numpy.reshape(data, -1)): + self.assertAlmostEqual(vE, v, 6) + return + + def test_query(self): + locs = numpy.array( + [[-118.520000, 34.120000, -1400.00], [-116.400000, 32.340000, -1000.00]], + numpy.float64, + ) + queryVals = ["density", "vs"] + dataE = numpy.array([[2.5e3, 2.6e3], [2.5e3, 2.6e3]], numpy.float64) + errE = [0, 0] + + db = self._db + db.open() + db.queryVals(queryVals) + data = numpy.zeros(dataE.shape, dtype=numpy.float64) + err = [] + nlocs = locs.shape[0] + for i in range(nlocs): + e = db.query(data[i, :], locs[i, :], self._csQ) + err.append(e) + db.close() + + self.assertEqual(len(errE), len(err)) + for vE, v in zip(errE, err): + self.assertEqual(vE, v) + + self.assertEqual(len(dataE.shape), len(data.shape)) + for dE, d in zip(dataE.shape, data.shape): + self.assertEqual(dE, d) + for vE, v in zip(numpy.reshape(dataE, -1), numpy.reshape(data, -1)): + self.assertAlmostEqual(vE, v, 6) + return + + +# End of file diff --git a/templates/spatialdb/tests/testcontrib.py b/templates/spatialdb/tests/testcontrib.py index 4a82da8d..eae9eee3 100644 --- a/templates/spatialdb/tests/testcontrib.py +++ b/templates/spatialdb/tests/testcontrib.py @@ -7,7 +7,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest @@ -18,6 +18,7 @@ def suite(): suite = unittest.TestSuite() from TestUniformVelModel import TestUniformVelModel + suite.addTest(unittest.makeSuite(TestUniformVelModel)) return suite @@ -28,7 +29,7 @@ def main(): return -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/tests/pytests/geocoords/TestCSCart.py b/tests/pytests/geocoords/TestCSCart.py index 5ebefe46..fd17c63f 100644 --- a/tests/pytests/geocoords/TestCSCart.py +++ b/tests/pytests/geocoords/TestCSCart.py @@ -7,7 +7,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest @@ -29,7 +29,7 @@ def test_accessors(self): cs.inventory.spaceDim = 2 cs._configure() - self.assertEqual(1.0e+3, cs.getToMeters()) + self.assertEqual(1.0e3, cs.getToMeters()) self.assertEqual(2, cs.getSpaceDim()) diff --git a/tests/pytests/geocoords/TestCSGeo.py b/tests/pytests/geocoords/TestCSGeo.py index 0af9e072..d82f7925 100644 --- a/tests/pytests/geocoords/TestCSGeo.py +++ b/tests/pytests/geocoords/TestCSGeo.py @@ -7,7 +7,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest diff --git a/tests/pytests/geocoords/TestCSGeoLocal.py b/tests/pytests/geocoords/TestCSGeoLocal.py index c1c072d7..f864ce05 100644 --- a/tests/pytests/geocoords/TestCSGeoLocal.py +++ b/tests/pytests/geocoords/TestCSGeoLocal.py @@ -7,7 +7,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest @@ -24,7 +24,7 @@ def test_constructor(self): self.assertEqual(3, cs.getSpaceDim()) def test_accessors(self): - projString = "EPSG:29610" # UTM Zone 10 + projString = "EPSG:29610" # UTM Zone 10 cs = CSGeoLocal() cs.inventory.crsString = projString @@ -39,7 +39,7 @@ def test_accessors(self): originX, originY, yAzimuth = cs.getLocal() self.assertEqual(20.0, originX) self.assertEqual(21.0, originY) - self.assertEqual(30.0, yAzimuth) + self.assertEqual(30.0, yAzimuth) def load_tests(loader, tests, pattern): diff --git a/tests/pytests/geocoords/TestConverter.py b/tests/pytests/geocoords/TestConverter.py index 37bc665b..11769cce 100644 --- a/tests/pytests/geocoords/TestConverter.py +++ b/tests/pytests/geocoords/TestConverter.py @@ -7,7 +7,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest @@ -16,33 +16,37 @@ import numpy -lonlatNAD27 = numpy.array([ - [3.900000000000e+01, -1.150000000000e+02], - [4.323423000000e+01, -1.203425320000e+02], - [4.523423000000e+01, -1.213425320000e+02], - [3.623423000000e+01, -1.153425320000e+02], - [3.923423000000e+01, -1.103425320000e+02], - [3.323423000000e+01, -1.073425320000e+02]], - numpy.float64) -lonlatWGS84 = numpy.array([ - [38.99994227694298, -115.00085076334376], - [43.234128917800746, -120.34362083668957], - [45.23410304341094, -121.34368736399294], - [36.234196301769245, -115.3433730158481], - [39.23419970865653, -110.34324423951884], - [33.23430190357505, -107.34312119874491]], - numpy.float64) - -xyKm = numpy.array([ - [1.01, 2.02], - [2.02, 3.02]], - numpy.float64) +lonlatNAD27 = numpy.array( + [ + [3.900000000000e01, -1.150000000000e02], + [4.323423000000e01, -1.203425320000e02], + [4.523423000000e01, -1.213425320000e02], + [3.623423000000e01, -1.153425320000e02], + [3.923423000000e01, -1.103425320000e02], + [3.323423000000e01, -1.073425320000e02], + ], + numpy.float64, +) +lonlatWGS84 = numpy.array( + [ + [38.99994227694298, -115.00085076334376], + [43.234128917800746, -120.34362083668957], + [45.23410304341094, -121.34368736399294], + [36.234196301769245, -115.3433730158481], + [39.23419970865653, -110.34324423951884], + [33.23430190357505, -107.34312119874491], + ], + numpy.float64, +) + +xyKm = numpy.array([[1.01, 2.02], [2.02, 3.02]], numpy.float64) class TestConverter(unittest.TestCase): def test_geo(self): from spatialdata.geocoords.CSGeo import CSGeo + csNAD27 = CSGeo() csNAD27.inventory.crsString = "EPSG:4267" csNAD27.inventory.spaceDim = 2 @@ -54,16 +58,17 @@ def test_geo(self): csWGS84._configure() from spatialdata.geocoords.Converter import convert + lonlat = numpy.array(lonlatNAD27) convert(lonlat, csWGS84, csNAD27) self.assertEqual(len(lonlatWGS84.shape), len(lonlat.shape)) - for (ll, llT) in zip(numpy.reshape(lonlatWGS84, -1), - numpy.reshape(lonlat, -1)): + for ll, llT in zip(numpy.reshape(lonlatWGS84, -1), numpy.reshape(lonlat, -1)): self.assertAlmostEqual(ll, llT, 4) def test_cart(self): from spatialdata.geocoords.CSCart import CSCart + csKm = CSCart() csKm.inventory.units = "km" csKm.inventory.spaceDim = 2 @@ -75,13 +80,13 @@ def test_cart(self): csM._configure() from spatialdata.geocoords.Converter import convert + xy = numpy.array(xyKm) convert(xy, csM, csKm) - xyM = xyKm * 1.0e+3 + xyM = xyKm * 1.0e3 self.assertEqual(len(xyM.shape), len(xy.shape)) - for (xyE, xyT) in zip(numpy.reshape(xyM, -1), - numpy.reshape(xy, -1)): + for xyE, xyT in zip(numpy.reshape(xyM, -1), numpy.reshape(xy, -1)): self.assertAlmostEqual(xyE, xyT, 4) diff --git a/tests/pytests/geocoords/test_geocoords.py b/tests/pytests/geocoords/test_geocoords.py index 663ffb59..ea4f8344 100755 --- a/tests/pytests/geocoords/test_geocoords.py +++ b/tests/pytests/geocoords/test_geocoords.py @@ -7,7 +7,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import pathlib @@ -20,7 +20,6 @@ import TestCSGeoLocal import TestConverter - TEST_MODULES = [ TestCSCart, TestCSGeo, @@ -29,7 +28,7 @@ ] -if __name__ == '__main__': +if __name__ == "__main__": app = UnitTestApp(test_modules=TEST_MODULES, src_dirs=["spatialdata.geocoords"]) app.run() diff --git a/tests/pytests/spatialdb/TestAnalyticDB.py b/tests/pytests/spatialdb/TestAnalyticDB.py index 5734330f..9d7007b7 100644 --- a/tests/pytests/spatialdb/TestAnalyticDB.py +++ b/tests/pytests/spatialdb/TestAnalyticDB.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest @@ -19,6 +19,7 @@ class TestAnalyticDB(unittest.TestCase): def setUp(self): from spatialdata.spatialdb.AnalyticDB import AnalyticDB + db = AnalyticDB() db.inventory.label = "test" db.inventory.values = ["one", "two", "three"] @@ -30,10 +31,11 @@ def setUp(self): def test_database(self): locs = numpy.array([[1.0, 2.0, 3.0], [5.6, 4.2, 8.6]], numpy.float64) from spatialdata.geocoords.CSCart import CSCart + cs = CSCart() cs._configure() queryVals = ["three", "one"] - dataE = numpy.array([[(1.0+2.0*x+4.0*y)*0.01, (1.0+2.0*x)*1.0] for x,y,z in locs]) + dataE = numpy.array([[(1.0 + 2.0 * x + 4.0 * y) * 0.01, (1.0 + 2.0 * x) * 1.0] for x, y, z in locs]) errE = [0, 0] db = self._db diff --git a/tests/pytests/spatialdb/TestCompositeDB.py b/tests/pytests/spatialdb/TestCompositeDB.py index 57883b03..be7ace97 100644 --- a/tests/pytests/spatialdb/TestCompositeDB.py +++ b/tests/pytests/spatialdb/TestCompositeDB.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest @@ -19,6 +19,7 @@ class TestCompositeDB(unittest.TestCase): def setUp(self): from spatialdata.spatialdb.UniformDB import UniformDB + dbA = UniformDB() dbA.inventory.label = "db A" dbA.inventory.values = ["one", "two", "three"] @@ -32,6 +33,7 @@ def setUp(self): dbB._configure() from spatialdata.spatialdb.CompositeDB import CompositeDB + db = CompositeDB() db.inventory.label = "composite db" db.inventory.dbA = dbA @@ -43,15 +45,13 @@ def setUp(self): self._db = db def test_database(self): - locs = numpy.array([[1.0, 2.0, 3.0], - [5.6, 4.2, 8.6]], - numpy.float64) + locs = numpy.array([[1.0, 2.0, 3.0], [5.6, 4.2, 8.6]], numpy.float64) from spatialdata.geocoords.CSCart import CSCart + cs = CSCart() cs._configure() queryVals = ["three", "one", "five"] - dataE = numpy.array([[3.1, 1.1, 5.1], - [3.1, 1.1, 5.1]], numpy.float64) + dataE = numpy.array([[3.1, 1.1, 5.1], [3.1, 1.1, 5.1]], numpy.float64) errE = [0, 0] db = self._db diff --git a/tests/pytests/spatialdb/TestGenSimpleDBApp.py b/tests/pytests/spatialdb/TestGenSimpleDBApp.py index d54e4f9f..7d1ec188 100644 --- a/tests/pytests/spatialdb/TestGenSimpleDBApp.py +++ b/tests/pytests/spatialdb/TestGenSimpleDBApp.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest @@ -35,12 +35,13 @@ def test(self): db.inventory.queryType = "nearest" db._configure() - qlocs = numpy.array([[-2.0, 2.0], [3.0, -4.0], [0.0, 0.7]], numpy.float64) + qlocs = numpy.array([[-2.0, 2.0], [3.0, -4.0], [0.0, 0.7]], numpy.float64) dataE = numpy.array([[-0.15, 3.45], [2.4, 6.4], [-0.6, 3.45]], numpy.float64) errE = [0, 0, 0] from spatialdata.geocoords.CSCart import CSCart + cs = CSCart() cs.inventory.spaceDim = 2 cs._configure() diff --git a/tests/pytests/spatialdb/TestGravityField.py b/tests/pytests/spatialdb/TestGravityField.py index a0393b78..88b6037b 100644 --- a/tests/pytests/spatialdb/TestGravityField.py +++ b/tests/pytests/spatialdb/TestGravityField.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest @@ -18,6 +18,7 @@ class TestGravityField(unittest.TestCase): def setUp(self): from spatialdata.spatialdb.GravityField import GravityField + db = GravityField() db._configure() self._db = db @@ -25,6 +26,7 @@ def setUp(self): def test_database(self): locs = numpy.array([[1.0, 2.0, 3.0], [5.6, 4.2, 8.6]], numpy.float64) from spatialdata.geocoords.CSCart import CSCart + cs = CSCart() cs._configure() gacc = 9.80665 diff --git a/tests/pytests/spatialdb/TestSimpleDB.py b/tests/pytests/spatialdb/TestSimpleDB.py index 03e76166..dc106b51 100644 --- a/tests/pytests/spatialdb/TestSimpleDB.py +++ b/tests/pytests/spatialdb/TestSimpleDB.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest @@ -19,6 +19,7 @@ class TestSimpleDB(unittest.TestCase): def setUp(self): from spatialdata.spatialdb.SimpleDB import SimpleDB + db = SimpleDB() db.inventory.label = "test" db.inventory.queryType = "nearest" @@ -57,9 +58,7 @@ def test_database(self): self.assertAlmostEqual(vE, v, 6) def test_databasemulti(self): - locs = numpy.array([[1.0, 2.0, 3.0], - [5.6, 4.2, 8.6]], - numpy.float64) + locs = numpy.array([[1.0, 2.0, 3.0], [5.6, 4.2, 8.6]], numpy.float64) cs = CSCart() cs._configure() queryVals = ["two", "one"] diff --git a/tests/pytests/spatialdb/TestSimpleGridDB.py b/tests/pytests/spatialdb/TestSimpleGridDB.py index 08c05b9f..14fc0054 100644 --- a/tests/pytests/spatialdb/TestSimpleGridDB.py +++ b/tests/pytests/spatialdb/TestSimpleGridDB.py @@ -7,7 +7,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest @@ -59,7 +59,7 @@ def test_database(self): self.assertAlmostEqual(vE, v, 6) def test_databasemulti(self): - locs = numpy.array([[2.3, -0.1, 1.8], [2.0, 0.4, -2.0]], numpy.float64) + locs = numpy.array([[2.3, -0.1, 1.8], [2.0, 0.4, -2.0]], numpy.float64) cs = CSCart() cs._configure() queryVals = ["two", "one"] @@ -92,48 +92,94 @@ def test_io_3d(self): y = numpy.array([0.0, 1.0], dtype=numpy.float64) z = numpy.array([-2.0, -1.0, 2.0], dtype=numpy.float64) - points = numpy.array([ - [-2.0, 0.0, -2.0], - [-2.0, 1.0, -2.0], - [-2.0, 0.0, -1.0], - [-2.0, 1.0, -1.0], - [-2.0, 0.0, 2.0], - [-2.0, 1.0, 2.0], - [0.0, 0.0, -2.0], - [0.0, 1.0, -2.0], # query (5.7, 8.2) - [0.0, 0.0, -1.0], - [0.0, 1.0, -1.0], - [0.0, 0.0, 2.0], - [0.0, 1.0, 2.0], - [3.0, 0.0, -2.0], - [3.0, 1.0, -2.0], - [3.0, 0.0, -1.0], - [3.0, 1.0, -1.0], - [3.0, 0.0, 2.0], - [3.0, 1.0, 2.0], - ], dtype=numpy.float64) - one = numpy.array([6.6, 5.5, 2.3, 5.7, 6.3, 3.4, 7.2, 5.7, 3.4, 5.7, 9.4, - 7.2, 4.8, 9.2, 5.8, 4.7, 7.8, 2.9], dtype=numpy.float64) - two = numpy.array([3.4, 6.7, 4.1, 2.0, 6.7, 6.4, 6.8, 8.2, 9.8, 2.3, 8.5, - 9.3, 7.5, 8.3, 8.5, 8.9, 6.2, 8.3], dtype=numpy.float64) + points = numpy.array( + [ + [-2.0, 0.0, -2.0], + [-2.0, 1.0, -2.0], + [-2.0, 0.0, -1.0], + [-2.0, 1.0, -1.0], + [-2.0, 0.0, 2.0], + [-2.0, 1.0, 2.0], + [0.0, 0.0, -2.0], + [0.0, 1.0, -2.0], # query (5.7, 8.2) + [0.0, 0.0, -1.0], + [0.0, 1.0, -1.0], + [0.0, 0.0, 2.0], + [0.0, 1.0, 2.0], + [3.0, 0.0, -2.0], + [3.0, 1.0, -2.0], + [3.0, 0.0, -1.0], + [3.0, 1.0, -1.0], + [3.0, 0.0, 2.0], + [3.0, 1.0, 2.0], + ], + dtype=numpy.float64, + ) + one = numpy.array( + [ + 6.6, + 5.5, + 2.3, + 5.7, + 6.3, + 3.4, + 7.2, + 5.7, + 3.4, + 5.7, + 9.4, + 7.2, + 4.8, + 9.2, + 5.8, + 4.7, + 7.8, + 2.9, + ], + dtype=numpy.float64, + ) + two = numpy.array( + [ + 3.4, + 6.7, + 4.1, + 2.0, + 6.7, + 6.4, + 6.8, + 8.2, + 9.8, + 2.3, + 8.5, + 9.3, + 7.5, + 8.3, + 8.5, + 8.9, + 6.2, + 8.3, + ], + dtype=numpy.float64, + ) cs = CSCart() cs._configure() writer = createWriter(filename) - writer.write({'points': points, - 'x': x, - 'y': y, - 'z': z, - 'coordsys': cs, - 'data_dim': 3, - 'values': [{'name': "one", - 'units': "m", - 'data': one}, - {'name': "two", - 'units': "m", - 'data': two}, - ]}) + writer.write( + { + "points": points, + "x": x, + "y": y, + "z": z, + "coordsys": cs, + "data_dim": 3, + "values": [ + {"name": "one", "units": "m", "data": one}, + {"name": "two", "units": "m", "data": two}, + ], + } + ) db = SimpleGridDB() db.inventory.label = "test" @@ -177,14 +223,17 @@ def test_io_2d(self): x = numpy.array([-2.0, 0.0, 3.0], dtype=numpy.float64) y = numpy.array([0.0, 1.0], dtype=numpy.float64) - points = numpy.array([ - [-2.0, 0.0], - [-2.0, 1.0], - [0.0, 0.0], - [0.0, 1.0], # query (5.7, 8.2) - [3.0, 0.0], - [3.0, 1.0], - ], dtype=numpy.float64) + points = numpy.array( + [ + [-2.0, 0.0], + [-2.0, 1.0], + [0.0, 0.0], + [0.0, 1.0], # query (5.7, 8.2) + [3.0, 0.0], + [3.0, 1.0], + ], + dtype=numpy.float64, + ) one = numpy.array([6.6, 5.5, 7.2, 5.7, 4.8, 9.2], dtype=numpy.float64) two = numpy.array([3.4, 6.7, 6.8, 8.2, 7.5, 8.3], dtype=numpy.float64) @@ -193,18 +242,19 @@ def test_io_2d(self): cs._configure() writer = createWriter(filename) - writer.write({'points': points, - 'x': x, - 'y': y, - 'coordsys': cs, - 'data_dim': 2, - 'values': [{'name': "one", - 'units': "m", - 'data': one}, - {'name': "two", - 'units': "m", - 'data': two}, - ]}) + writer.write( + { + "points": points, + "x": x, + "y": y, + "coordsys": cs, + "data_dim": 2, + "values": [ + {"name": "one", "units": "m", "data": one}, + {"name": "two", "units": "m", "data": two}, + ], + } + ) db = SimpleGridDB() db.inventory.label = "test" diff --git a/tests/pytests/spatialdb/TestSimpleIOAscii.py b/tests/pytests/spatialdb/TestSimpleIOAscii.py index 81fc3876..81c414bc 100644 --- a/tests/pytests/spatialdb/TestSimpleIOAscii.py +++ b/tests/pytests/spatialdb/TestSimpleIOAscii.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest @@ -26,34 +26,38 @@ def test_write(self): cs._configure() filename = "data/test.spatialdb" - data = {'points': numpy.array([[1.0, 2.0, 3.0], - [0.5, 3.0, -3.0]], numpy.float64), - 'coordsys': cs, - 'data_dim': 1, - 'values': [{'name': "One", - 'units': "m", - 'data': numpy.array([2.0, 8.0], numpy.float64)}, - {'name': "Two", - 'units': "m", - 'data': numpy.array([-2.0, 3.0], numpy.float64)}]} + data = { + "points": numpy.array([[1.0, 2.0, 3.0], [0.5, 3.0, -3.0]], numpy.float64), + "coordsys": cs, + "data_dim": 1, + "values": [ + { + "name": "One", + "units": "m", + "data": numpy.array([2.0, 8.0], numpy.float64), + }, + { + "name": "Two", + "units": "m", + "data": numpy.array([-2.0, 3.0], numpy.float64), + }, + ], + } dataDim = 1 - qlocs = numpy.array([[0.875, 2.25, 1.5], - [0.6, 2.8, -1.8], - [1.0, 2.0, 3.0]], - numpy.float64) - valsE = numpy.array([[-0.75, 3.5], - [2.0, 6.8], - [-2.0, 2.0]], numpy.float64) + qlocs = numpy.array([[0.875, 2.25, 1.5], [0.6, 2.8, -1.8], [1.0, 2.0, 3.0]], numpy.float64) + valsE = numpy.array([[-0.75, 3.5], [2.0, 6.8], [-2.0, 2.0]], numpy.float64) errE = [0, 0, 0] # Write database from spatialdata.spatialdb.SimpleIOAscii import createWriter + writer = createWriter(filename) writer.write(data) # Test write using query from spatialdata.spatialdb.SimpleDB import SimpleDB + db = SimpleDB() db.inventory.label = "test" db.inventory.queryType = "linear" diff --git a/tests/pytests/spatialdb/TestTimeHistory.py b/tests/pytests/spatialdb/TestTimeHistory.py index ce64c74d..2c8b4bed 100644 --- a/tests/pytests/spatialdb/TestTimeHistory.py +++ b/tests/pytests/spatialdb/TestTimeHistory.py @@ -7,7 +7,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest @@ -24,6 +24,7 @@ def test_timehistory(self): errE = numpy.array([0, 0, 0, 0, 0, 1, 0], dtype=numpy.float64) from spatialdata.spatialdb.TimeHistory import TimeHistory + th = TimeHistory() th.inventory.label = "test" th.inventory.filename = "data/timehistory.timedb" @@ -35,7 +36,7 @@ def test_timehistory(self): err = numpy.zeros((nlocs,), dtype=numpy.int32) for i in range(nlocs): - (e, amplitude[i]) = th.query(timeQ[i]) + e, amplitude[i] = th.query(timeQ[i]) err[i] = e th.close() diff --git a/tests/pytests/spatialdb/TestTimeHistoryIO.py b/tests/pytests/spatialdb/TestTimeHistoryIO.py index 2cd68bef..1092294d 100644 --- a/tests/pytests/spatialdb/TestTimeHistoryIO.py +++ b/tests/pytests/spatialdb/TestTimeHistoryIO.py @@ -7,7 +7,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest @@ -29,6 +29,7 @@ def test_write(self): # Write database from spatialdata.spatialdb.TimeHistoryIO import write + write(time, amplitude, units, filename) # Test write @@ -44,7 +45,7 @@ def test_write(self): self.assertEqual(len(linesE), len(lines)) iline = 0 - for (lineE, line) in zip(linesE, lines): + for lineE, line in zip(linesE, lines): if lineE != line: print("Error found in line %d in file '%s' is incorrect." % (iline, filename)) self.assertTrue(False) diff --git a/tests/pytests/spatialdb/TestUniformDB.py b/tests/pytests/spatialdb/TestUniformDB.py index e0b0bd36..3ecc8f58 100644 --- a/tests/pytests/spatialdb/TestUniformDB.py +++ b/tests/pytests/spatialdb/TestUniformDB.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest @@ -19,6 +19,7 @@ class TestUniformDB(unittest.TestCase): def setUp(self): from spatialdata.spatialdb.UniformDB import UniformDB + db = UniformDB() db.inventory.label = "test" db.inventory.values = ["one", "two", "three"] @@ -29,6 +30,7 @@ def setUp(self): def test_database(self): locs = numpy.array([[1.0, 2.0, 3.0], [5.6, 4.2, 8.6]], numpy.float64) from spatialdata.geocoords.CSCart import CSCart + cs = CSCart() cs._configure() queryVals = ["three", "one"] diff --git a/tests/pytests/spatialdb/TestUserFunctionDB.py b/tests/pytests/spatialdb/TestUserFunctionDB.py index 3c6bbe3f..55ab63a8 100644 --- a/tests/pytests/spatialdb/TestUserFunctionDB.py +++ b/tests/pytests/spatialdb/TestUserFunctionDB.py @@ -7,7 +7,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest diff --git a/tests/pytests/spatialdb/test_sceccvmh.py b/tests/pytests/spatialdb/test_sceccvmh.py index 80221b14..704d95e5 100755 --- a/tests/pytests/spatialdb/test_sceccvmh.py +++ b/tests/pytests/spatialdb/test_sceccvmh.py @@ -7,20 +7,19 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from spatialdata.testing.UnitTestApp import UnitTestApp import TestSCECCVMH - TEST_MODULES = [ TestSCECCVMH, - ] +] -if __name__ == '__main__': +if __name__ == "__main__": app = UnitTestApp(test_modules=TEST_MODULES, src_dirs=["spatialdata.spatialdb"]) app.run() diff --git a/tests/pytests/spatialdb/test_spatialdb.py b/tests/pytests/spatialdb/test_spatialdb.py index 5976c2b6..3f34090c 100755 --- a/tests/pytests/spatialdb/test_spatialdb.py +++ b/tests/pytests/spatialdb/test_spatialdb.py @@ -7,7 +7,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from spatialdata.testing.UnitTestApp import UnitTestApp @@ -24,7 +24,6 @@ import TestTimeHistory import TestGenSimpleDBApp - TEST_MODULES = [ TestSimpleIOAscii, TestSimpleDB, @@ -40,7 +39,7 @@ ] -if __name__ == '__main__': +if __name__ == "__main__": app = UnitTestApp(test_modules=TEST_MODULES, src_dirs=["spatialdata.spatialdb"]) app.run() diff --git a/tests/pytests/utils/TestSpatialdataVersion.py b/tests/pytests/utils/TestSpatialdataVersion.py index 666d2417..40948a6b 100644 --- a/tests/pytests/utils/TestSpatialdataVersion.py +++ b/tests/pytests/utils/TestSpatialdataVersion.py @@ -5,7 +5,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= import unittest @@ -23,6 +23,7 @@ def test_version(self): version = SpatialdataVersion.version() # Check that version is of the form X.X.X import re + match = re.search("[0-9]+\.[0-9]+\.[0-9]+", version) self.assertFalse(match is None) @@ -33,6 +34,7 @@ def test_gitVersion(self): else: # Check that revision is of the form v2.1.3-16-g9323114 import re + match = re.search("v[0-9]+\.[0-9]+\.[0-9]+", revision) if match is None: match = re.search("v[0-9]+\.[0-9]+\.[0-9]+-[0-9]+-g[0-9,a-z]+", revision) @@ -45,6 +47,7 @@ def test_gitHash(self): else: # Check form of hash import re + match = re.search("[0-9,a-z]+", tag) self.assertFalse(match is None) @@ -55,6 +58,7 @@ def test_gitDate(self): else: # Check form of datetime import datetime + fields = value.split() d = datetime.datetime.strptime(fields[0], "%Y-%m-%d") t = datetime.datetime.strptime(fields[1], "%H:%M:%S") @@ -70,6 +74,7 @@ def test_projVersion(self): version = SpatialdataVersion.projVersion() # Check that version is of the form XXX import re + match = re.search("[0-9]+", version) self.assertFalse(match is None) diff --git a/tests/pytests/utils/test_utils.py b/tests/pytests/utils/test_utils.py index be4b3230..dfa43196 100755 --- a/tests/pytests/utils/test_utils.py +++ b/tests/pytests/utils/test_utils.py @@ -7,7 +7,7 @@ # Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. # All rights reserved. # -# See https://mit-license.org/ and LICENSE.md and for license information. +# See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= from spatialdata.testing.UnitTestApp import UnitTestApp @@ -15,13 +15,12 @@ import TestSpatialdataVersion - TEST_MODULES = [ TestSpatialdataVersion, ] -if __name__ == '__main__': +if __name__ == "__main__": app = UnitTestApp(test_modules=TEST_MODULES, src_dirs=["spatialdata.utils"]) app.run() From b6e338b4da1babe350b8771f3da46604ad42a01a Mon Sep 17 00:00:00 2001 From: Brad Aagaard Date: Sun, 15 Nov 2026 18:36:24 -0700 Subject: [PATCH 03/10] preambles: Fix format of preambles. --- .github/workflows/pr-stage-1.yaml | 10 + .github/workflows/pr-stage-2.yaml | 10 + .github/workflows/pr-stages.yaml | 10 + .readthedocs.yaml | 12 +- Makefile.am | 3 +- applications/gensimpledb.py | 3 +- docs/Makefile.am | 3 +- docs/conf.py | 10 + libsrc/Makefile.am | 3 +- libsrc/spatialdata/Makefile.am | 3 +- libsrc/spatialdata/geocoords/CSCart.cc | 3 +- libsrc/spatialdata/geocoords/CSCart.hh | 3 +- libsrc/spatialdata/geocoords/CSGeo.cc | 3 +- libsrc/spatialdata/geocoords/CSGeo.hh | 3 +- libsrc/spatialdata/geocoords/CSGeoLocal.cc | 3 +- libsrc/spatialdata/geocoords/CSGeoLocal.hh | 3 +- .../spatialdata/geocoords/CSPicklerAscii.cc | 3 +- .../spatialdata/geocoords/CSPicklerAscii.hh | 3 +- libsrc/spatialdata/geocoords/Converter.cc | 3 +- libsrc/spatialdata/geocoords/Converter.hh | 3 +- libsrc/spatialdata/geocoords/CoordSys.cc | 3 +- libsrc/spatialdata/geocoords/CoordSys.hh | 3 +- libsrc/spatialdata/geocoords/Makefile.am | 3 +- libsrc/spatialdata/geocoords/geocoordsfwd.hh | 3 +- libsrc/spatialdata/muparser/Makefile.am | 3 +- libsrc/spatialdata/muparser/muparserfwd.hh | 3 +- libsrc/spatialdata/spatialdb/AnalyticDB.cc | 3 +- libsrc/spatialdata/spatialdb/AnalyticDB.hh | 3 +- libsrc/spatialdata/spatialdb/AnalyticDB.icc | 3 +- libsrc/spatialdata/spatialdb/CompositeDB.cc | 3 +- libsrc/spatialdata/spatialdb/CompositeDB.hh | 3 +- libsrc/spatialdata/spatialdb/Exception.hh | 3 +- libsrc/spatialdata/spatialdb/Exception.icc | 3 +- libsrc/spatialdata/spatialdb/GocadVoxet.cc | 3 +- libsrc/spatialdata/spatialdb/GocadVoxet.hh | 3 +- libsrc/spatialdata/spatialdb/GravityField.cc | 3 +- libsrc/spatialdata/spatialdb/GravityField.hh | 3 +- libsrc/spatialdata/spatialdb/Makefile.am | 3 +- libsrc/spatialdata/spatialdb/SCECCVMH.cc | 3 +- libsrc/spatialdata/spatialdb/SCECCVMH.hh | 3 +- libsrc/spatialdata/spatialdb/SCECCVMH.icc | 3 +- libsrc/spatialdata/spatialdb/SimpleDB.cc | 3 +- libsrc/spatialdata/spatialdb/SimpleDB.hh | 3 +- libsrc/spatialdata/spatialdb/SimpleDBData.cc | 3 +- libsrc/spatialdata/spatialdb/SimpleDBData.hh | 3 +- libsrc/spatialdata/spatialdb/SimpleDBData.icc | 3 +- libsrc/spatialdata/spatialdb/SimpleDBQuery.cc | 3 +- libsrc/spatialdata/spatialdb/SimpleDBQuery.hh | 3 +- .../spatialdata/spatialdb/SimpleGridAscii.cc | 3 +- .../spatialdata/spatialdb/SimpleGridAscii.hh | 3 +- libsrc/spatialdata/spatialdb/SimpleGridDB.cc | 3 +- libsrc/spatialdata/spatialdb/SimpleGridDB.hh | 3 +- libsrc/spatialdata/spatialdb/SimpleGridDB.icc | 3 +- libsrc/spatialdata/spatialdb/SimpleIO.cc | 3 +- libsrc/spatialdata/spatialdb/SimpleIO.hh | 3 +- libsrc/spatialdata/spatialdb/SimpleIO.icc | 3 +- libsrc/spatialdata/spatialdb/SimpleIOAscii.cc | 3 +- libsrc/spatialdata/spatialdb/SimpleIOAscii.hh | 3 +- .../spatialdata/spatialdb/SimpleIOAscii.icc | 3 +- libsrc/spatialdata/spatialdb/SpatialDB.cc | 3 +- libsrc/spatialdata/spatialdb/SpatialDB.hh | 3 +- libsrc/spatialdata/spatialdb/SpatialDB.icc | 3 +- libsrc/spatialdata/spatialdb/TimeHistory.cc | 3 +- libsrc/spatialdata/spatialdb/TimeHistory.hh | 3 +- libsrc/spatialdata/spatialdb/TimeHistory.icc | 3 +- libsrc/spatialdata/spatialdb/TimeHistoryIO.cc | 3 +- libsrc/spatialdata/spatialdb/TimeHistoryIO.hh | 3 +- libsrc/spatialdata/spatialdb/UniformDB.cc | 3 +- libsrc/spatialdata/spatialdb/UniformDB.hh | 3 +- libsrc/spatialdata/spatialdb/UniformDB.icc | 3 +- .../spatialdata/spatialdb/UserFunctionDB.cc | 3 +- .../spatialdata/spatialdb/UserFunctionDB.hh | 3 +- libsrc/spatialdata/spatialdb/cspatialdb.cc | 3 +- libsrc/spatialdata/spatialdb/cspatialdb.h | 3 +- libsrc/spatialdata/spatialdb/f77spatialdb.cc | 3 +- libsrc/spatialdata/spatialdb/f77spatialdb.h | 3 +- libsrc/spatialdata/spatialdb/spatialdbfwd.hh | 3 +- libsrc/spatialdata/units/Makefile.am | 3 +- libsrc/spatialdata/units/Parser.cc | 3 +- libsrc/spatialdata/units/Parser.hh | 3 +- libsrc/spatialdata/units/unitsfwd.hh | 3 +- libsrc/spatialdata/utils/LineParser.cc | 3 +- libsrc/spatialdata/utils/LineParser.hh | 3 +- libsrc/spatialdata/utils/Makefile.am | 3 +- libsrc/spatialdata/utils/PointsStream.cc | 3 +- libsrc/spatialdata/utils/PointsStream.hh | 3 +- libsrc/spatialdata/utils/PointsStream.icc | 3 +- .../spatialdata/utils/SpatialdataVersion.cc | 3 +- .../spatialdata/utils/SpatialdataVersion.hh | 3 +- libsrc/spatialdata/utils/utilsfwd.hh | 3 +- modulesrc/Makefile.am | 3 +- modulesrc/geocoords/CSCart.i | 12 +- modulesrc/geocoords/CSGeo.i | 37 +- modulesrc/geocoords/CSGeoLocal.i | 24 +- modulesrc/geocoords/Converter.i | 22 +- modulesrc/geocoords/CoordSys.i | 19 +- modulesrc/geocoords/Makefile.am | 3 +- modulesrc/geocoords/geocoords.i | 57 ++- modulesrc/include/Makefile.am | 3 +- modulesrc/include/chararray.i | 91 ++-- modulesrc/module.am | 3 +- modulesrc/spatialdb/AnalyticDB.i | 61 ++- modulesrc/spatialdb/CompositeDB.i | 214 ++++----- modulesrc/spatialdb/GravityField.i | 189 ++++---- modulesrc/spatialdb/Makefile.am | 3 +- modulesrc/spatialdb/SCECCVMH.i | 199 ++++----- modulesrc/spatialdb/SimpleDB.i | 221 +++++----- modulesrc/spatialdb/SimpleDBData.i | 250 +++++------ modulesrc/spatialdb/SimpleGridAscii.i | 19 +- modulesrc/spatialdb/SimpleGridDB.i | 409 +++++++++--------- modulesrc/spatialdb/SimpleIO.i | 22 +- modulesrc/spatialdb/SimpleIOAscii.i | 13 +- modulesrc/spatialdb/SpatialDBObj.i | 107 +++-- modulesrc/spatialdb/TimeHistory.i | 17 +- modulesrc/spatialdb/TimeHistoryIO.i | 85 ++-- modulesrc/spatialdb/UniformDB.i | 62 ++- modulesrc/spatialdb/UserFunctionDB.i | 271 ++++++------ modulesrc/spatialdb/spatialdb.i | 87 ++-- modulesrc/utils/Makefile.am | 3 +- modulesrc/utils/SpatialdataVersion.i | 36 +- modulesrc/utils/utils.i | 30 +- setup.py | 10 + spatialdata/Makefile.am | 3 +- spatialdata/__init__.py | 3 +- spatialdata/geocoords/CSCart.py | 3 +- spatialdata/geocoords/CSGeo.py | 3 +- spatialdata/geocoords/CSGeoLocal.py | 3 +- spatialdata/geocoords/Converter.py | 3 +- spatialdata/geocoords/CoordSys.py | 3 +- spatialdata/geocoords/__init__.py | 3 +- spatialdata/spatialdb/AnalyticDB.py | 3 +- spatialdata/spatialdb/CompositeDB.py | 3 +- spatialdata/spatialdb/GravityField.py | 3 +- spatialdata/spatialdb/SCECCVMH.py | 3 +- spatialdata/spatialdb/SimpleDB.py | 3 +- spatialdata/spatialdb/SimpleGridAscii.py | 3 +- spatialdata/spatialdb/SimpleGridDB.py | 3 +- spatialdata/spatialdb/SimpleIO.py | 3 +- spatialdata/spatialdb/SimpleIOAscii.py | 3 +- spatialdata/spatialdb/SpatialDBObj.py | 3 +- spatialdata/spatialdb/TimeHistory.py | 3 +- spatialdata/spatialdb/TimeHistoryIO.py | 3 +- spatialdata/spatialdb/UniformDB.py | 3 +- spatialdata/spatialdb/UserFunctionDB.py | 3 +- spatialdata/spatialdb/__init__.py | 3 +- .../spatialdb/generator/GenSimpleDBApp.py | 3 +- spatialdata/spatialdb/generator/Geometry.py | 3 +- spatialdata/spatialdb/generator/Shaper.py | 3 +- spatialdata/spatialdb/generator/Value.py | 3 +- spatialdata/spatialdb/generator/__init__.py | 3 +- spatialdata/testing/TestCases.py | 3 +- spatialdata/testing/UnitTestApp.py | 3 +- spatialdata/testing/__init__.py | 11 + spatialdata/utils/PointsStream.py | 3 +- spatialdata/utils/__init__.py | 3 +- subpackage.am | 3 +- templates/Makefile.am | 3 +- templates/spatialdb/Makefile.am | 3 +- templates/spatialdb/UniformVelModel.cc | 3 +- templates/spatialdb/UniformVelModel.hh | 3 +- templates/spatialdb/UniformVelModel.i | 23 +- templates/spatialdb/UniformVelModel.py | 3 +- templates/spatialdb/__init__.py | 3 +- templates/spatialdb/configure.ac | 3 +- templates/spatialdb/spatialdbcontrib.i | 42 +- templates/spatialdb/tests/Makefile.am | 3 +- .../spatialdb/tests/TestUniformVelModel.py | 3 +- templates/spatialdb/tests/testcontrib.py | 3 +- tests/Makefile.am | 3 +- tests/check.am | 3 +- tests/libtests/Makefile.am | 3 +- tests/libtests/geocoords/Makefile.am | 3 +- tests/libtests/geocoords/TestCSCart.cc | 3 +- tests/libtests/geocoords/TestCSGeo.cc | 3 +- tests/libtests/geocoords/TestCSGeoLocal.cc | 3 +- .../libtests/geocoords/TestCSPicklerAscii.cc | 3 +- tests/libtests/geocoords/TestConverter.cc | 6 +- tests/libtests/geocoords/TestConverter.hh | 3 +- .../libtests/geocoords/TestConverter_Cases.cc | 3 +- tests/libtests/geocoords/test_driver.cc | 3 +- tests/libtests/spatialdb/Makefile.am | 3 +- tests/libtests/spatialdb/TestAnalyticDB.cc | 3 +- tests/libtests/spatialdb/TestCompositeDB.cc | 3 +- tests/libtests/spatialdb/TestGravityField.cc | 3 +- tests/libtests/spatialdb/TestGravityField.hh | 3 +- .../spatialdb/TestGravityField_Cases.cc | 3 +- tests/libtests/spatialdb/TestSCECCVMH.cc | 3 +- tests/libtests/spatialdb/TestSimpleDB.cc | 3 +- tests/libtests/spatialdb/TestSimpleDB.hh | 3 +- tests/libtests/spatialdb/TestSimpleDBData.cc | 3 +- tests/libtests/spatialdb/TestSimpleDBQuery.cc | 3 +- tests/libtests/spatialdb/TestSimpleDBQuery.hh | 3 +- .../spatialdb/TestSimpleDBQuery_Cases.cc | 3 +- .../libtests/spatialdb/TestSimpleDB_Cases.cc | 3 +- .../libtests/spatialdb/TestSimpleGridAscii.cc | 3 +- tests/libtests/spatialdb/TestSimpleGridDB.cc | 3 +- tests/libtests/spatialdb/TestSimpleGridDB.hh | 3 +- .../spatialdb/TestSimpleGridDB_Cases.cc | 3 +- tests/libtests/spatialdb/TestSimpleIOAscii.cc | 3 +- tests/libtests/spatialdb/TestSpatialDB.cc | 3 +- tests/libtests/spatialdb/TestTimeHistory.cc | 3 +- tests/libtests/spatialdb/TestTimeHistoryIO.cc | 3 +- tests/libtests/spatialdb/TestUniformDB.cc | 3 +- .../libtests/spatialdb/TestUserFunctionDB.cc | 3 +- .../libtests/spatialdb/TestUserFunctionDB.hh | 3 +- .../spatialdb/TestUserFunctionDB_Cases.cc | 3 +- tests/libtests/spatialdb/data/Makefile.am | 3 +- tests/libtests/spatialdb/test_driver.cc | 3 +- tests/libtests/spatialdb/testf77query.h | 3 +- tests/libtests/units/Makefile.am | 3 +- tests/libtests/units/TestParser.cc | 3 +- tests/libtests/utils/Makefile.am | 3 +- tests/libtests/utils/TestPointsStream.cc | 3 +- .../libtests/utils/TestSpatialdataVersion.cc | 3 +- tests/pytests/Makefile.am | 3 +- tests/pytests/geocoords/Makefile.am | 3 +- tests/pytests/geocoords/TestCSCart.py | 3 +- tests/pytests/geocoords/TestCSGeo.py | 3 +- tests/pytests/geocoords/TestCSGeoLocal.py | 3 +- tests/pytests/geocoords/TestConverter.py | 3 +- tests/pytests/geocoords/test_geocoords.py | 3 +- tests/pytests/spatialdb/Makefile.am | 3 +- tests/pytests/spatialdb/TestAnalyticDB.py | 3 +- tests/pytests/spatialdb/TestCompositeDB.py | 3 +- tests/pytests/spatialdb/TestGenSimpleDBApp.py | 3 +- tests/pytests/spatialdb/TestGravityField.py | 3 +- tests/pytests/spatialdb/TestSCECCVMH.py.in | 3 +- tests/pytests/spatialdb/TestSimpleDB.py | 3 +- tests/pytests/spatialdb/TestSimpleGridDB.py | 3 +- tests/pytests/spatialdb/TestSimpleIOAscii.py | 3 +- tests/pytests/spatialdb/TestTimeHistory.py | 3 +- tests/pytests/spatialdb/TestTimeHistoryIO.py | 3 +- tests/pytests/spatialdb/TestUniformDB.py | 3 +- tests/pytests/spatialdb/TestUserFunctionDB.py | 3 +- tests/pytests/spatialdb/data/Makefile.am | 3 +- tests/pytests/spatialdb/test_sceccvmh.py | 3 +- tests/pytests/spatialdb/test_spatialdb.py | 3 +- tests/pytests/spatialdb/testgen1din2d.odb | 3 +- tests/pytests/utils/Makefile.am | 3 +- tests/pytests/utils/TestSpatialdataVersion.py | 3 +- tests/pytests/utils/test_utils.py | 3 +- tests/src/Makefile.am | 3 +- tests/src/driver_catch2.cc | 3 +- 243 files changed, 1571 insertions(+), 1751 deletions(-) diff --git a/.github/workflows/pr-stage-1.yaml b/.github/workflows/pr-stage-1.yaml index dae83d9d..7f10b0c4 100644 --- a/.github/workflows/pr-stage-1.yaml +++ b/.github/workflows/pr-stage-1.yaml @@ -1,3 +1,11 @@ +# ================================================================================================= +# This code is part of PyLith, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/pylith). +# +# Copyright (c) 2010-2026 All rights reserved. +# +# See https://mit-license.org/ and LICENSE.md and for license information. +# ================================================================================================= name: stage-1 on: @@ -38,3 +46,5 @@ jobs: - name: Build Docker image run: docker build -t spatialdata-docenv --build-arg BASE_IMAGE=$IMAGE_REGISTRY/testenv-ubuntu-22.04 -f docker/spatialdata-docenv . + +# End of file diff --git a/.github/workflows/pr-stage-2.yaml b/.github/workflows/pr-stage-2.yaml index 3e9b1e68..982b864c 100644 --- a/.github/workflows/pr-stage-2.yaml +++ b/.github/workflows/pr-stage-2.yaml @@ -1,3 +1,11 @@ +# ================================================================================================= +# This code is part of PyLith, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/pylith). +# +# Copyright (c) 2010-2026 All rights reserved. +# +# See https://mit-license.org/ and LICENSE.md and for license information. +# ================================================================================================= name: stage-2 on: @@ -36,3 +44,5 @@ jobs: - name: Run tests run: docker run spatialdata-testenv ci-config/run_tests.sh + +# End of file diff --git a/.github/workflows/pr-stages.yaml b/.github/workflows/pr-stages.yaml index 8602116b..38cf8435 100644 --- a/.github/workflows/pr-stages.yaml +++ b/.github/workflows/pr-stages.yaml @@ -1,3 +1,11 @@ +# ================================================================================================= +# This code is part of PyLith, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/pylith). +# +# Copyright (c) 2010-2026 All rights reserved. +# +# See https://mit-license.org/ and LICENSE.md and for license information. +# ================================================================================================= name: run-ci concurrency: @@ -18,3 +26,5 @@ jobs: conda: uses: ./.github/workflows/pr-conda.yaml needs: [stage-1] + +# End of file diff --git a/.readthedocs.yaml b/.readthedocs.yaml index d5a686b8..c0685715 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,5 +1,11 @@ -# .readthedocs.yaml -# Read the Docs configuration file +# ================================================================================================= +# This code is part of PyLith, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/pylith). +# +# Copyright (c) 2010-2026 All rights reserved. +# +# See https://mit-license.org/ and LICENSE.md and for license information. +# ================================================================================================= # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details # Required @@ -24,3 +30,5 @@ formats: python: install: - requirements: docs/requirements.txt + +# End of file diff --git a/Makefile.am b/Makefile.am index 84205f5d..1892e664 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/applications/gensimpledb.py b/applications/gensimpledb.py index 606e3b26..6ec4bc93 100644 --- a/applications/gensimpledb.py +++ b/applications/gensimpledb.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/docs/Makefile.am b/docs/Makefile.am index b1c4ee9a..5d51b691 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/docs/conf.py b/docs/conf.py index 13af5f99..6279e1fb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,3 +1,11 @@ +# ================================================================================================= +# This code is part of PyLith, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/pylith). +# +# Copyright (c) 2010-2026 All rights reserved. +# +# See https://mit-license.org/ and LICENSE.md and for license information. +# ================================================================================================= # Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full @@ -99,3 +107,5 @@ "css/custom.css", ] html_last_updated_fmt = "" + +# End of file diff --git a/libsrc/Makefile.am b/libsrc/Makefile.am index 95709558..77e21934 100644 --- a/libsrc/Makefile.am +++ b/libsrc/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/libsrc/spatialdata/Makefile.am b/libsrc/spatialdata/Makefile.am index ad41625b..e2acc1a0 100644 --- a/libsrc/spatialdata/Makefile.am +++ b/libsrc/spatialdata/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/libsrc/spatialdata/geocoords/CSCart.cc b/libsrc/spatialdata/geocoords/CSCart.cc index ad523c5f..2f2108d2 100644 --- a/libsrc/spatialdata/geocoords/CSCart.cc +++ b/libsrc/spatialdata/geocoords/CSCart.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/geocoords/CSCart.hh b/libsrc/spatialdata/geocoords/CSCart.hh index 10472435..678df3fe 100644 --- a/libsrc/spatialdata/geocoords/CSCart.hh +++ b/libsrc/spatialdata/geocoords/CSCart.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/geocoords/CSGeo.cc b/libsrc/spatialdata/geocoords/CSGeo.cc index e61dfbe4..71ddc51f 100644 --- a/libsrc/spatialdata/geocoords/CSGeo.cc +++ b/libsrc/spatialdata/geocoords/CSGeo.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/geocoords/CSGeo.hh b/libsrc/spatialdata/geocoords/CSGeo.hh index d0ba51b0..8a5a0561 100644 --- a/libsrc/spatialdata/geocoords/CSGeo.hh +++ b/libsrc/spatialdata/geocoords/CSGeo.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/geocoords/CSGeoLocal.cc b/libsrc/spatialdata/geocoords/CSGeoLocal.cc index 4aa33930..6914fb77 100644 --- a/libsrc/spatialdata/geocoords/CSGeoLocal.cc +++ b/libsrc/spatialdata/geocoords/CSGeoLocal.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/geocoords/CSGeoLocal.hh b/libsrc/spatialdata/geocoords/CSGeoLocal.hh index a044986f..ed271bc4 100644 --- a/libsrc/spatialdata/geocoords/CSGeoLocal.hh +++ b/libsrc/spatialdata/geocoords/CSGeoLocal.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/geocoords/CSPicklerAscii.cc b/libsrc/spatialdata/geocoords/CSPicklerAscii.cc index 69fc295f..4573db40 100644 --- a/libsrc/spatialdata/geocoords/CSPicklerAscii.cc +++ b/libsrc/spatialdata/geocoords/CSPicklerAscii.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/geocoords/CSPicklerAscii.hh b/libsrc/spatialdata/geocoords/CSPicklerAscii.hh index 15f79f86..082d1100 100644 --- a/libsrc/spatialdata/geocoords/CSPicklerAscii.hh +++ b/libsrc/spatialdata/geocoords/CSPicklerAscii.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/geocoords/Converter.cc b/libsrc/spatialdata/geocoords/Converter.cc index 362b6c26..b841685e 100644 --- a/libsrc/spatialdata/geocoords/Converter.cc +++ b/libsrc/spatialdata/geocoords/Converter.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/geocoords/Converter.hh b/libsrc/spatialdata/geocoords/Converter.hh index 0674b9f3..0866d098 100644 --- a/libsrc/spatialdata/geocoords/Converter.hh +++ b/libsrc/spatialdata/geocoords/Converter.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/geocoords/CoordSys.cc b/libsrc/spatialdata/geocoords/CoordSys.cc index 8b56f081..0ef18775 100644 --- a/libsrc/spatialdata/geocoords/CoordSys.cc +++ b/libsrc/spatialdata/geocoords/CoordSys.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/geocoords/CoordSys.hh b/libsrc/spatialdata/geocoords/CoordSys.hh index 207bd891..d4087886 100644 --- a/libsrc/spatialdata/geocoords/CoordSys.hh +++ b/libsrc/spatialdata/geocoords/CoordSys.hh @@ -1,7 +1,6 @@ // ================================================================================================= // This code is part of SpatialData, developed through the Computational Infrastructure -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/geocoords/Makefile.am b/libsrc/spatialdata/geocoords/Makefile.am index 6fc671f3..c21ea32c 100644 --- a/libsrc/spatialdata/geocoords/Makefile.am +++ b/libsrc/spatialdata/geocoords/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/libsrc/spatialdata/geocoords/geocoordsfwd.hh b/libsrc/spatialdata/geocoords/geocoordsfwd.hh index f3d84e1a..e9d64fb3 100644 --- a/libsrc/spatialdata/geocoords/geocoordsfwd.hh +++ b/libsrc/spatialdata/geocoords/geocoordsfwd.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/muparser/Makefile.am b/libsrc/spatialdata/muparser/Makefile.am index d9c520e1..a21e7dca 100644 --- a/libsrc/spatialdata/muparser/Makefile.am +++ b/libsrc/spatialdata/muparser/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/libsrc/spatialdata/muparser/muparserfwd.hh b/libsrc/spatialdata/muparser/muparserfwd.hh index a2d16a04..238ecdbb 100644 --- a/libsrc/spatialdata/muparser/muparserfwd.hh +++ b/libsrc/spatialdata/muparser/muparserfwd.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/AnalyticDB.cc b/libsrc/spatialdata/spatialdb/AnalyticDB.cc index 8e48c7bf..31c6b816 100644 --- a/libsrc/spatialdata/spatialdb/AnalyticDB.cc +++ b/libsrc/spatialdata/spatialdb/AnalyticDB.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/AnalyticDB.hh b/libsrc/spatialdata/spatialdb/AnalyticDB.hh index dfec3f07..d94002a9 100644 --- a/libsrc/spatialdata/spatialdb/AnalyticDB.hh +++ b/libsrc/spatialdata/spatialdb/AnalyticDB.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/AnalyticDB.icc b/libsrc/spatialdata/spatialdb/AnalyticDB.icc index b6d2024a..7a2b64d0 100644 --- a/libsrc/spatialdata/spatialdb/AnalyticDB.icc +++ b/libsrc/spatialdata/spatialdb/AnalyticDB.icc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/CompositeDB.cc b/libsrc/spatialdata/spatialdb/CompositeDB.cc index 599a4761..cbe24d05 100644 --- a/libsrc/spatialdata/spatialdb/CompositeDB.cc +++ b/libsrc/spatialdata/spatialdb/CompositeDB.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/CompositeDB.hh b/libsrc/spatialdata/spatialdb/CompositeDB.hh index 54229855..ea84be5d 100644 --- a/libsrc/spatialdata/spatialdb/CompositeDB.hh +++ b/libsrc/spatialdata/spatialdb/CompositeDB.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/Exception.hh b/libsrc/spatialdata/spatialdb/Exception.hh index becf3bae..dd91b36a 100644 --- a/libsrc/spatialdata/spatialdb/Exception.hh +++ b/libsrc/spatialdata/spatialdb/Exception.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/Exception.icc b/libsrc/spatialdata/spatialdb/Exception.icc index 4ce7cb86..e9d95512 100644 --- a/libsrc/spatialdata/spatialdb/Exception.icc +++ b/libsrc/spatialdata/spatialdb/Exception.icc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/GocadVoxet.cc b/libsrc/spatialdata/spatialdb/GocadVoxet.cc index 986c9487..2b9c9b4d 100644 --- a/libsrc/spatialdata/spatialdb/GocadVoxet.cc +++ b/libsrc/spatialdata/spatialdb/GocadVoxet.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/GocadVoxet.hh b/libsrc/spatialdata/spatialdb/GocadVoxet.hh index b0d7cab7..7153e3a1 100644 --- a/libsrc/spatialdata/spatialdb/GocadVoxet.hh +++ b/libsrc/spatialdata/spatialdb/GocadVoxet.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/GravityField.cc b/libsrc/spatialdata/spatialdb/GravityField.cc index 8ae626dd..b5332f03 100644 --- a/libsrc/spatialdata/spatialdb/GravityField.cc +++ b/libsrc/spatialdata/spatialdb/GravityField.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/GravityField.hh b/libsrc/spatialdata/spatialdb/GravityField.hh index 57adadff..47c28408 100644 --- a/libsrc/spatialdata/spatialdb/GravityField.hh +++ b/libsrc/spatialdata/spatialdb/GravityField.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/Makefile.am b/libsrc/spatialdata/spatialdb/Makefile.am index 947da991..dce277ca 100644 --- a/libsrc/spatialdata/spatialdb/Makefile.am +++ b/libsrc/spatialdata/spatialdb/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SCECCVMH.cc b/libsrc/spatialdata/spatialdb/SCECCVMH.cc index f5f4ed8b..1c613ed3 100644 --- a/libsrc/spatialdata/spatialdb/SCECCVMH.cc +++ b/libsrc/spatialdata/spatialdb/SCECCVMH.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SCECCVMH.hh b/libsrc/spatialdata/spatialdb/SCECCVMH.hh index 5fb52b65..75c638ab 100644 --- a/libsrc/spatialdata/spatialdb/SCECCVMH.hh +++ b/libsrc/spatialdata/spatialdb/SCECCVMH.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SCECCVMH.icc b/libsrc/spatialdata/spatialdb/SCECCVMH.icc index a9914605..bb2bdaac 100644 --- a/libsrc/spatialdata/spatialdb/SCECCVMH.icc +++ b/libsrc/spatialdata/spatialdb/SCECCVMH.icc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleDB.cc b/libsrc/spatialdata/spatialdb/SimpleDB.cc index 88470706..20fa6731 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDB.cc +++ b/libsrc/spatialdata/spatialdb/SimpleDB.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleDB.hh b/libsrc/spatialdata/spatialdb/SimpleDB.hh index c764ba39..98fa38ef 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDB.hh +++ b/libsrc/spatialdata/spatialdb/SimpleDB.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleDBData.cc b/libsrc/spatialdata/spatialdb/SimpleDBData.cc index 7dedfd72..6f60169f 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBData.cc +++ b/libsrc/spatialdata/spatialdb/SimpleDBData.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleDBData.hh b/libsrc/spatialdata/spatialdb/SimpleDBData.hh index 226650c0..e33e62b6 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBData.hh +++ b/libsrc/spatialdata/spatialdb/SimpleDBData.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleDBData.icc b/libsrc/spatialdata/spatialdb/SimpleDBData.icc index 4fb35be3..eeaef62c 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBData.icc +++ b/libsrc/spatialdata/spatialdb/SimpleDBData.icc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleDBQuery.cc b/libsrc/spatialdata/spatialdb/SimpleDBQuery.cc index a8e822c1..eb562110 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBQuery.cc +++ b/libsrc/spatialdata/spatialdb/SimpleDBQuery.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleDBQuery.hh b/libsrc/spatialdata/spatialdb/SimpleDBQuery.hh index 7e4fd018..a7dfc4ce 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBQuery.hh +++ b/libsrc/spatialdata/spatialdb/SimpleDBQuery.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleGridAscii.cc b/libsrc/spatialdata/spatialdb/SimpleGridAscii.cc index e5823b8b..a9fb24f9 100644 --- a/libsrc/spatialdata/spatialdb/SimpleGridAscii.cc +++ b/libsrc/spatialdata/spatialdb/SimpleGridAscii.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleGridAscii.hh b/libsrc/spatialdata/spatialdb/SimpleGridAscii.hh index 26b0e8e6..fadd056e 100644 --- a/libsrc/spatialdata/spatialdb/SimpleGridAscii.hh +++ b/libsrc/spatialdata/spatialdb/SimpleGridAscii.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleGridDB.cc b/libsrc/spatialdata/spatialdb/SimpleGridDB.cc index 98e9c819..1ab654ec 100644 --- a/libsrc/spatialdata/spatialdb/SimpleGridDB.cc +++ b/libsrc/spatialdata/spatialdb/SimpleGridDB.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleGridDB.hh b/libsrc/spatialdata/spatialdb/SimpleGridDB.hh index 18598ee9..bf18b8fe 100644 --- a/libsrc/spatialdata/spatialdb/SimpleGridDB.hh +++ b/libsrc/spatialdata/spatialdb/SimpleGridDB.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleGridDB.icc b/libsrc/spatialdata/spatialdb/SimpleGridDB.icc index 340a5aa9..7942b508 100644 --- a/libsrc/spatialdata/spatialdb/SimpleGridDB.icc +++ b/libsrc/spatialdata/spatialdb/SimpleGridDB.icc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleIO.cc b/libsrc/spatialdata/spatialdb/SimpleIO.cc index 26b36164..0c6e1d5c 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIO.cc +++ b/libsrc/spatialdata/spatialdb/SimpleIO.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleIO.hh b/libsrc/spatialdata/spatialdb/SimpleIO.hh index c4205b7c..970c9389 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIO.hh +++ b/libsrc/spatialdata/spatialdb/SimpleIO.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleIO.icc b/libsrc/spatialdata/spatialdb/SimpleIO.icc index e0a86378..429a9809 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIO.icc +++ b/libsrc/spatialdata/spatialdb/SimpleIO.icc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleIOAscii.cc b/libsrc/spatialdata/spatialdb/SimpleIOAscii.cc index 1ef2cdb7..d8bfc15f 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIOAscii.cc +++ b/libsrc/spatialdata/spatialdb/SimpleIOAscii.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleIOAscii.hh b/libsrc/spatialdata/spatialdb/SimpleIOAscii.hh index e802aa68..510c2753 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIOAscii.hh +++ b/libsrc/spatialdata/spatialdb/SimpleIOAscii.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SimpleIOAscii.icc b/libsrc/spatialdata/spatialdb/SimpleIOAscii.icc index b87c541a..baa43bc3 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIOAscii.icc +++ b/libsrc/spatialdata/spatialdb/SimpleIOAscii.icc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SpatialDB.cc b/libsrc/spatialdata/spatialdb/SpatialDB.cc index 3df86ae4..0b74c768 100644 --- a/libsrc/spatialdata/spatialdb/SpatialDB.cc +++ b/libsrc/spatialdata/spatialdb/SpatialDB.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SpatialDB.hh b/libsrc/spatialdata/spatialdb/SpatialDB.hh index e8db0151..6c358900 100644 --- a/libsrc/spatialdata/spatialdb/SpatialDB.hh +++ b/libsrc/spatialdata/spatialdb/SpatialDB.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/SpatialDB.icc b/libsrc/spatialdata/spatialdb/SpatialDB.icc index 84d9e89e..c3247d6f 100644 --- a/libsrc/spatialdata/spatialdb/SpatialDB.icc +++ b/libsrc/spatialdata/spatialdb/SpatialDB.icc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/TimeHistory.cc b/libsrc/spatialdata/spatialdb/TimeHistory.cc index b2020348..9a89f70f 100644 --- a/libsrc/spatialdata/spatialdb/TimeHistory.cc +++ b/libsrc/spatialdata/spatialdb/TimeHistory.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/TimeHistory.hh b/libsrc/spatialdata/spatialdb/TimeHistory.hh index d93ec7a0..50c7ae8c 100644 --- a/libsrc/spatialdata/spatialdb/TimeHistory.hh +++ b/libsrc/spatialdata/spatialdb/TimeHistory.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/TimeHistory.icc b/libsrc/spatialdata/spatialdb/TimeHistory.icc index e92a54de..50bdd610 100644 --- a/libsrc/spatialdata/spatialdb/TimeHistory.icc +++ b/libsrc/spatialdata/spatialdb/TimeHistory.icc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/TimeHistoryIO.cc b/libsrc/spatialdata/spatialdb/TimeHistoryIO.cc index af1d1d69..9fec8f50 100644 --- a/libsrc/spatialdata/spatialdb/TimeHistoryIO.cc +++ b/libsrc/spatialdata/spatialdb/TimeHistoryIO.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/TimeHistoryIO.hh b/libsrc/spatialdata/spatialdb/TimeHistoryIO.hh index 4282f6c8..486166f3 100644 --- a/libsrc/spatialdata/spatialdb/TimeHistoryIO.hh +++ b/libsrc/spatialdata/spatialdb/TimeHistoryIO.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/UniformDB.cc b/libsrc/spatialdata/spatialdb/UniformDB.cc index 1d0492cd..436fcba6 100644 --- a/libsrc/spatialdata/spatialdb/UniformDB.cc +++ b/libsrc/spatialdata/spatialdb/UniformDB.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/UniformDB.hh b/libsrc/spatialdata/spatialdb/UniformDB.hh index f636cd26..3e95b956 100644 --- a/libsrc/spatialdata/spatialdb/UniformDB.hh +++ b/libsrc/spatialdata/spatialdb/UniformDB.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/UniformDB.icc b/libsrc/spatialdata/spatialdb/UniformDB.icc index 4c8c7058..eb33991f 100644 --- a/libsrc/spatialdata/spatialdb/UniformDB.icc +++ b/libsrc/spatialdata/spatialdb/UniformDB.icc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/UserFunctionDB.cc b/libsrc/spatialdata/spatialdb/UserFunctionDB.cc index c51be589..5dc67333 100644 --- a/libsrc/spatialdata/spatialdb/UserFunctionDB.cc +++ b/libsrc/spatialdata/spatialdb/UserFunctionDB.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/UserFunctionDB.hh b/libsrc/spatialdata/spatialdb/UserFunctionDB.hh index 3c34b87b..300ecfe9 100644 --- a/libsrc/spatialdata/spatialdb/UserFunctionDB.hh +++ b/libsrc/spatialdata/spatialdb/UserFunctionDB.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/cspatialdb.cc b/libsrc/spatialdata/spatialdb/cspatialdb.cc index 144c0a7a..2e141eed 100644 --- a/libsrc/spatialdata/spatialdb/cspatialdb.cc +++ b/libsrc/spatialdata/spatialdb/cspatialdb.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/cspatialdb.h b/libsrc/spatialdata/spatialdb/cspatialdb.h index 5a961e21..d5df6759 100644 --- a/libsrc/spatialdata/spatialdb/cspatialdb.h +++ b/libsrc/spatialdata/spatialdb/cspatialdb.h @@ -3,8 +3,7 @@ * This code is part of SpatialData, developed through the Computational Infrastructure * for Geodynamics (https://github.com/geodynamics/spatialdata). * - * Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. - * All rights reserved. + * Copyright (c) 2010-2026 All rights reserved. * * See https://mit-license.org/ and LICENSE.md and for license information. * ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/f77spatialdb.cc b/libsrc/spatialdata/spatialdb/f77spatialdb.cc index e296711a..c720a375 100644 --- a/libsrc/spatialdata/spatialdb/f77spatialdb.cc +++ b/libsrc/spatialdata/spatialdb/f77spatialdb.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/f77spatialdb.h b/libsrc/spatialdata/spatialdb/f77spatialdb.h index aae65b27..6d1c4586 100644 --- a/libsrc/spatialdata/spatialdb/f77spatialdb.h +++ b/libsrc/spatialdata/spatialdb/f77spatialdb.h @@ -3,8 +3,7 @@ * This code is part of SpatialData, developed through the Computational Infrastructure * for Geodynamics (https://github.com/geodynamics/spatialdata). * - * Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. - * All rights reserved. + * Copyright (c) 2010-2026 All rights reserved. * * See https://mit-license.org/ and LICENSE.md and for license information. * ================================================================================================= diff --git a/libsrc/spatialdata/spatialdb/spatialdbfwd.hh b/libsrc/spatialdata/spatialdb/spatialdbfwd.hh index 2dc24d2d..1d75277d 100644 --- a/libsrc/spatialdata/spatialdb/spatialdbfwd.hh +++ b/libsrc/spatialdata/spatialdb/spatialdbfwd.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/units/Makefile.am b/libsrc/spatialdata/units/Makefile.am index 28851d44..5aeecea7 100644 --- a/libsrc/spatialdata/units/Makefile.am +++ b/libsrc/spatialdata/units/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/libsrc/spatialdata/units/Parser.cc b/libsrc/spatialdata/units/Parser.cc index baab327e..3588504a 100644 --- a/libsrc/spatialdata/units/Parser.cc +++ b/libsrc/spatialdata/units/Parser.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/units/Parser.hh b/libsrc/spatialdata/units/Parser.hh index e68eadd3..f202c5eb 100644 --- a/libsrc/spatialdata/units/Parser.hh +++ b/libsrc/spatialdata/units/Parser.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/units/unitsfwd.hh b/libsrc/spatialdata/units/unitsfwd.hh index 3742d74a..644a3b92 100644 --- a/libsrc/spatialdata/units/unitsfwd.hh +++ b/libsrc/spatialdata/units/unitsfwd.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/utils/LineParser.cc b/libsrc/spatialdata/utils/LineParser.cc index 1dca2082..573ce57c 100644 --- a/libsrc/spatialdata/utils/LineParser.cc +++ b/libsrc/spatialdata/utils/LineParser.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/utils/LineParser.hh b/libsrc/spatialdata/utils/LineParser.hh index fd8c67ce..7ef3abb7 100644 --- a/libsrc/spatialdata/utils/LineParser.hh +++ b/libsrc/spatialdata/utils/LineParser.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/utils/Makefile.am b/libsrc/spatialdata/utils/Makefile.am index 2c121612..20900184 100644 --- a/libsrc/spatialdata/utils/Makefile.am +++ b/libsrc/spatialdata/utils/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/libsrc/spatialdata/utils/PointsStream.cc b/libsrc/spatialdata/utils/PointsStream.cc index c51b1675..ab9ac417 100644 --- a/libsrc/spatialdata/utils/PointsStream.cc +++ b/libsrc/spatialdata/utils/PointsStream.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/utils/PointsStream.hh b/libsrc/spatialdata/utils/PointsStream.hh index 384ab1df..4155d390 100644 --- a/libsrc/spatialdata/utils/PointsStream.hh +++ b/libsrc/spatialdata/utils/PointsStream.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/utils/PointsStream.icc b/libsrc/spatialdata/utils/PointsStream.icc index 75e76d9f..f5920b6b 100644 --- a/libsrc/spatialdata/utils/PointsStream.icc +++ b/libsrc/spatialdata/utils/PointsStream.icc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/utils/SpatialdataVersion.cc b/libsrc/spatialdata/utils/SpatialdataVersion.cc index 07b1f25a..2c9b1c8d 100644 --- a/libsrc/spatialdata/utils/SpatialdataVersion.cc +++ b/libsrc/spatialdata/utils/SpatialdataVersion.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/utils/SpatialdataVersion.hh b/libsrc/spatialdata/utils/SpatialdataVersion.hh index 228e86e7..68300757 100644 --- a/libsrc/spatialdata/utils/SpatialdataVersion.hh +++ b/libsrc/spatialdata/utils/SpatialdataVersion.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/libsrc/spatialdata/utils/utilsfwd.hh b/libsrc/spatialdata/utils/utilsfwd.hh index bbc5bfaf..4926fe4b 100644 --- a/libsrc/spatialdata/utils/utilsfwd.hh +++ b/libsrc/spatialdata/utils/utilsfwd.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/modulesrc/Makefile.am b/modulesrc/Makefile.am index 65043fdf..7a0963d7 100644 --- a/modulesrc/Makefile.am +++ b/modulesrc/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/modulesrc/geocoords/CSCart.i b/modulesrc/geocoords/CSCart.i index a96747fc..5d8e693c 100644 --- a/modulesrc/geocoords/CSCart.i +++ b/modulesrc/geocoords/CSCart.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -15,9 +14,8 @@ namespace spatialdata { namespace geocoords { - class CSCart:public CoordSys { -public: - + class CSCart : public CoordSys { + public: // PUBLIC METHODS ///////////////////////////////////////////////// /// Default constructor @@ -58,7 +56,7 @@ public: }; // class CSCart - } // geocoords -} // spatialdata + } // namespace geocoords +} // namespace spatialdata // End of file diff --git a/modulesrc/geocoords/CSGeo.i b/modulesrc/geocoords/CSGeo.i index a13ac92b..21ff13ed 100644 --- a/modulesrc/geocoords/CSGeo.i +++ b/modulesrc/geocoords/CSGeo.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -15,26 +14,23 @@ namespace spatialdata { namespace geocoords { - class CSGeo:public CoordSys { + class CSGeo : public CoordSys { friend class TestCSGeo; -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////// /// Default constructor CSGeo(void); /// Default destructor - virtual - ~CSGeo(void); + virtual ~CSGeo(void); /** Clone coordinate system. * * @returns Pointer to copy */ - virtual - CoordSys* clone(void) const; + virtual CoordSys* clone(void) const; /** Set string specifying coordinate system. * @@ -52,8 +48,7 @@ public: * * @param ndims Number of dimensions */ - virtual - void setSpaceDim(const int ndims); + virtual void setSpaceDim(const int ndims); /** Get radial outward direction. * @@ -71,7 +66,7 @@ public: const double* coords, const size_t numLocs, const size_t numDims, - const double dx=1000.0) const; + const double dx = 1000.0) const; /** Convert coordinates from local coordinate system to geographic coordinate system. * @@ -79,10 +74,9 @@ public: * @param[in] numLocs Number of location * @param[in] numDims Number of spatial dimensions in coordinates */ - virtual - void localToGeographic(double* coords, - const size_t numLocs, - const size_t numDims) const; + virtual void localToGeographic(double* coords, + const size_t numLocs, + const size_t numDims) const; /** Convert coordinates from geographic coordinate system to local coordinate system. * @@ -90,10 +84,9 @@ public: * @param[in] numLocs Number of location * @param[in] numDims Number of spatial dimensions in coordinates */ - virtual - void geographicToLocal(double* coords, - const size_t numLocs, - const size_t numDims) const; + virtual void geographicToLocal(double* coords, + const size_t numLocs, + const size_t numDims) const; /** Pickle coordinate system to ascii stream. * @@ -109,7 +102,7 @@ public: }; // class CSGeo - } // geocoords -} // spatialdata + } // namespace geocoords +} // namespace spatialdata // End of file diff --git a/modulesrc/geocoords/CSGeoLocal.i b/modulesrc/geocoords/CSGeoLocal.i index b2d31fa8..4a68d388 100644 --- a/modulesrc/geocoords/CSGeoLocal.i +++ b/modulesrc/geocoords/CSGeoLocal.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -15,11 +14,10 @@ namespace spatialdata { namespace geocoords { - class CSGeoLocal: public CSGeo { + class CSGeoLocal : public CSGeo { friend class TestCSGeoLocal; -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////// /// Default constructor @@ -50,16 +48,16 @@ public: * @param[out] originY Y coordinate of local origin. * @param[out] yAzimuth Azimuth (degrees) of y axis. */ - %apply double* OUTPUT { double* originX }; - %apply double* OUTPUT { double* originY }; - %apply double* OUTPUT { double* yAzimuth }; + % apply double* OUTPUT{double* originX}; + % apply double* OUTPUT{double* originY}; + % apply double* OUTPUT{double* yAzimuth}; void getLocal(double* originX, double* originY, double* yAzimuth) const; - %clear double* originX; - %clear double* originY; - %clear double* yAzimuth; + % clear double* originX; + % clear double* originY; + % clear double* yAzimuth; /** Convert coordinates from local coordinate system to geographic coordinate system. * @@ -95,7 +93,7 @@ public: }; // class CSGeoLocal - } // geocoords -} // spatialdata + } // namespace geocoords +} // namespace spatialdata // End of file diff --git a/modulesrc/geocoords/Converter.i b/modulesrc/geocoords/Converter.i index d01f9ee5..ec86dab6 100644 --- a/modulesrc/geocoords/Converter.i +++ b/modulesrc/geocoords/Converter.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -18,8 +17,7 @@ namespace spatialdata { class CoordSys; // forward declaration class Converter { -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////// /// Default constructor @@ -37,20 +35,24 @@ public: * @param pCSDest Pointer to destination coordinate system * @param pCSSrc Pointer to source coordinate system */ - %apply(double* INPLACE_ARRAY2, int DIM1, int DIM2) { - (double* coords, const size_t numLocs, const size_t numDims) - }; + % apply(double* INPLACE_ARRAY2, + int DIM1, + int DIM2){(double* coords, + const size_t numLocs, + const size_t numDims)}; void convert(double* coords, const size_t numLocs, const size_t numDims, const CoordSys* pCSDest, const CoordSys* pCSSrc); - %clear(double* coords, const size_t numLocs, const size_t numDims); + % clear(double* coords, + const size_t numLocs, + const size_t numDims); }; // class Converter - } // geocoords -} // spatialdata + } // namespace geocoords +} // namespace spatialdata // End of file diff --git a/modulesrc/geocoords/CoordSys.i b/modulesrc/geocoords/CoordSys.i index b5fab1c9..c9246c78 100644 --- a/modulesrc/geocoords/CoordSys.i +++ b/modulesrc/geocoords/CoordSys.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -16,8 +15,7 @@ namespace spatialdata { namespace geocoords { class CoordSys { -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////// /// Type of coordinate system @@ -27,8 +25,7 @@ public: LOCAL_GEOGRAPHIC ///< Local geographic coordinate system }; -public: - + public: // PUBLIC METHODS ///////////////////////////////////////////////// /// Default constructor @@ -41,15 +38,13 @@ public: * * @returns Copy of *this */ - virtual - CoordSys* clone(void) const = 0; + virtual CoordSys* clone(void) const = 0; /** Set number of spatial dimensions in coordinate system. * * @param ndims Number of dimensions */ - virtual - void setSpaceDim(const int ndims); + virtual void setSpaceDim(const int ndims); /** Get number of spatial dimensions in coordinate system. * @@ -74,7 +69,7 @@ public: }; // class CoordSys - } // geocoords -} // spatialdata + } // namespace geocoords +} // namespace spatialdata // End of file diff --git a/modulesrc/geocoords/Makefile.am b/modulesrc/geocoords/Makefile.am index 288e53ba..24be54ac 100644 --- a/modulesrc/geocoords/Makefile.am +++ b/modulesrc/geocoords/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/modulesrc/geocoords/geocoords.i b/modulesrc/geocoords/geocoords.i index ed0fe872..a8d1f90f 100644 --- a/modulesrc/geocoords/geocoords.i +++ b/modulesrc/geocoords/geocoords.i @@ -2,52 +2,51 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= // SWIG interface -%module geocoords +% + module geocoords -// Header files for module C++ code -%{ + // Header files for module C++ code + % + { #include #include // USES std::string // Headers for interfaces -#include "spatialdata/geocoords/CoordSys.hh" #include "spatialdata/geocoords/CSCart.hh" #include "spatialdata/geocoords/CSGeo.hh" #include "spatialdata/geocoords/CSGeoLocal.hh" #include "spatialdata/geocoords/Converter.hh" -%} +#include "spatialdata/geocoords/CoordSys.hh" + % } -%include "exception.i" -%exception { - try { - $action - } catch (const std::exception& err) { - SWIG_exception(SWIG_RuntimeError, err.what()); - } // try/catch - } // exception + % include "exception.i" % exception { + try { + $action + } catch (const std::exception& err) { + SWIG_exception(SWIG_RuntimeError, err.what()); + } // try/catch +} // exception -%include "typemaps.i" +% + include "typemaps.i" -// Numpy interface stuff -%{ + // Numpy interface stuff + % + { #define SWIG_FILE_WITH_INIT -%} -%include "../include/numpy.i" -%init %{ -import_array(); -%} + % } % + include "../include/numpy.i" % init % { + import_array(); + % +} // Interfaces -%include "CoordSys.i" -%include "CSCart.i" -%include "CSGeo.i" -%include "CSGeoLocal.i" -%include "Converter.i" +% include "CoordSys.i" % include "CSCart.i" % include "CSGeo.i" % include "CSGeoLocal.i" % + include "Converter.i" -// End of file + // End of file diff --git a/modulesrc/include/Makefile.am b/modulesrc/include/Makefile.am index 389468af..9df888a0 100644 --- a/modulesrc/include/Makefile.am +++ b/modulesrc/include/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/modulesrc/include/chararray.i b/modulesrc/include/chararray.i index c6c66160..22c54aaf 100644 --- a/modulesrc/include/chararray.i +++ b/modulesrc/include/chararray.i @@ -2,66 +2,67 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= // Treat const char* const* as a special case. -%typemap(in) (const char* const* string_list) { - // Check to make sure input is a list. - if (PyList_Check($input)) { - const int size = PyList_Size($input); - $1 = (size > 0) ? new char*[size] : NULL; - for (int i = 0; i < size; i++) { - PyObject *s = PyList_GetItem($input,i); - if (PyUnicode_Check(s)) - $1[i] = (char*)PyUnicode_AsUTF8(PyList_GetItem($input,i)); - else { - PyErr_SetString(PyExc_TypeError, "List must contain strings."); - delete[] $1; - return NULL; - } // else - } // for - } else { - PyErr_SetString(PyExc_TypeError, "Expected list of strings."); - return NULL; - } // if/else +% typemap(in)(const char* const* string_list) { + // Check to make sure input is a list. + if (PyList_Check($input)) { + const int size = PyList_Size($input); + $1 = (size > 0) ? new char*[size] : NULL; + for (int i = 0; i < size; i++) { + PyObject* s = PyList_GetItem($input, i); + if (PyUnicode_Check(s)) + $1[i] = (char*)PyUnicode_AsUTF8(PyList_GetItem($input, i)); + else { + PyErr_SetString(PyExc_TypeError, "List must contain strings."); + delete[] $1; + return NULL; + } // else + } // for + } else { + PyErr_SetString(PyExc_TypeError, "Expected list of strings."); + return NULL; + } // if/else } // typemap(in) const char* const* // This cleans up the char** array we malloc'd before the function call -%typemap(freearg) (const char* const* string_list) { - delete[] $1; +% typemap(freearg)(const char* const* string_list) { + delete[] $1; } // Treat const char* const* as a special case. -%typemap(in) (const char* const* string_list, const int list_len) { - // Check to make sure input is a list. - if (PyList_Check($input)) { - const int size = PyList_Size($input); - $2 = size; - $1 = (size > 0) ? new char*[size] : 0; - for (int i = 0; i < size; i++) { - PyObject *s = PyList_GetItem($input,i); - if (PyUnicode_Check(s)) - $1[i] = (char*)PyUnicode_AsUTF8(PyList_GetItem($input,i)); - else { - PyErr_SetString(PyExc_TypeError, "List must contain strings."); - delete[] $1; - return NULL; - } // else - } // for - } else { - PyErr_SetString(PyExc_TypeError, "Expected list of strings."); - return NULL; - } // if/else +% typemap(in)(const char* const* string_list, + const int list_len) { + // Check to make sure input is a list. + if (PyList_Check($input)) { + const int size = PyList_Size($input); + $2 = size; + $1 = (size > 0) ? new char*[size] : 0; + for (int i = 0; i < size; i++) { + PyObject* s = PyList_GetItem($input, i); + if (PyUnicode_Check(s)) + $1[i] = (char*)PyUnicode_AsUTF8(PyList_GetItem($input, i)); + else { + PyErr_SetString(PyExc_TypeError, "List must contain strings."); + delete[] $1; + return NULL; + } // else + } // for + } else { + PyErr_SetString(PyExc_TypeError, "Expected list of strings."); + return NULL; + } // if/else } // typemap(in) const char* const* // This cleans up the char** array we malloc'd before the function call -%typemap(freearg) (const char* const* string_list, const int list_len) { - delete[] $1; +% typemap(freearg)(const char* const* string_list, + const int list_len) { + delete[] $1; } diff --git a/modulesrc/module.am b/modulesrc/module.am index b151fe1a..45098a50 100644 --- a/modulesrc/module.am +++ b/modulesrc/module.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/modulesrc/spatialdb/AnalyticDB.i b/modulesrc/spatialdb/AnalyticDB.i index b2fd7b1a..7005b7f4 100644 --- a/modulesrc/spatialdb/AnalyticDB.i +++ b/modulesrc/spatialdb/AnalyticDB.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -15,9 +14,8 @@ namespace spatialdata { namespace spatialdb { - class AnalyticDB: public SpatialDB { -public: - + class AnalyticDB : public SpatialDB { + public: // PUBLIC METHODS ///////////////////////////////////////////////// /// Default constructor. @@ -39,24 +37,20 @@ public: * @param expressions Array of expressions in database. * @param numValues Number of values in database. */ - %apply(const char* const* string_list) { - (const char* const* names) - }; - %apply(const char* const* string_list) { - (const char* const* units) - }; - %apply(const char* const* string_list, const int list_len) { - (const char* const* expressions, - const size_t numValues) - }; + % apply(const char* const* string_list){(const char* const* names)}; + % apply(const char* const* string_list){(const char* const* units)}; + % apply(const char* const* string_list, + const int list_len){(const char* const* expressions, + const size_t numValues)}; void setData(const char* const* names, const char* const* names, const char* const* expressions, const size_t numValues); - %clear(const char* const* names); - %clear(const char* const* units); - %clear(const char* const* expressions, const size_t numValues); + % clear(const char* const* names); + % clear(const char* const* units); + % clear(const char* const* expressions, + const size_t numValues); /** Set coordinate system associated with user functions. * @@ -77,13 +71,14 @@ public: * @param names Names of values to be returned in queries * @param numValues Number of values to be returned in queries */ - %apply(const char* const* string_list, const int list_len) { - (const char* const* names, const size_t numValues) - }; + % apply(const char* const* string_list, + const int list_len){(const char* const* names, + const size_t numValues)}; void setQueryValues(const char* const* names, const size_t numValues); - %clear(const char* const* names, const size_t numValues); + % clear(const char* const* names, + const size_t numValues); /** Query the database. * @@ -99,24 +94,26 @@ public: * @returns 0 on success, 1 on failure (i.e., could not interpolate * so values set to 0) */ - %apply(double* INPLACE_ARRAY1, int DIM1) { - (double* values, const size_t numValues) - }; - %apply(double* IN_ARRAY1, int DIM1) { - (const double* coords, const size_t numDims) - }; + % apply(double* INPLACE_ARRAY1, + int DIM1){(double* values, + const size_t numValues)}; + % apply(double* IN_ARRAY1, + int DIM1){(const double* coords, + const size_t numDims)}; int query(double* values, const size_t numValues, const double* coords, const size_t numDims, const spatialdata::geocoords::CoordSys* pCSQuery); - %clear(double* values, const size_t numValues); - %clear(const double* coords, const size_t numDims); + % clear(double* values, + const size_t numValues); + % clear(const double* coords, + const size_t numDims); }; // class AnalyticDB - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata // End of file diff --git a/modulesrc/spatialdb/CompositeDB.i b/modulesrc/spatialdb/CompositeDB.i index 30645a6c..85480772 100644 --- a/modulesrc/spatialdb/CompositeDB.i +++ b/modulesrc/spatialdb/CompositeDB.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -14,107 +13,110 @@ */ namespace spatialdata { - namespace spatialdb { - - class CompositeDB : public SpatialDB - { // class CompositeDB - - public : - // PUBLIC METHODS ///////////////////////////////////////////////// - - /// Default constructor. - CompositeDB(void); - - /** Constructor with label. - * - * @param label Label of database - */ - CompositeDB(const char* label); - - /// Default destructor. - ~CompositeDB(void); - - /** Set database A. - * - * @param db Pointer to database. - * @param names Array of names of values to use with database. - * @param numNames Size of array of names. - */ - %apply(const char* const* string_list, const int list_len){ - (const char* const* names, const size_t numNames) - }; - void setDBA(SpatialDB* db, - const char* const* names, - const size_t numNames); - %clear(const char* const* names, const size_t numNames); - - /** Set database B. - * - * @param db Pointer to database. - * @param names Array of names of values to use with database. - * @param numNames Size of array of names. - */ - %apply(const char* const* string_list, const int list_len){ - (const char* const* names, const size_t numNames) - }; - void setDBB(SpatialDB* db, - const char* const* names, - const size_t numNames); - %clear(const char* const* names, const size_t numNames); - - /// Open the database and prepare for querying. - void open(void); - - /// Close the database. - void close(void); - - /** Set values to be returned by queries. - * - * @pre Must call open() before setQueryValues() - * - * @param names Names of values to be returned in queries - * @param numVals Number of values to be returned in queries - */ - %apply(const char* const* string_list, const int list_len){ - (const char* const* names, const size_t numVals) - }; - void setQueryValues(const char* const* names, - const size_t numVals); - %clear(const char* const* names, const size_t numVals); - - /** Query the database. - * - * @pre Must call open() before query() - * - * @param vals Array for computed values (output from query), vals - * must be allocated BEFORE calling query(). - * @param numVals Number of values expected (size of pVals array) - * @param coords Coordinates of point for query - * @param numDims Number of dimensions for coordinates - * @param pCSQuery Coordinate system of coordinates - * - * @returns 0 on success, 1 on failure (i.e., could not interpolate - * so values set to 0) - */ - %apply(double* INPLACE_ARRAY1, int DIM1) { - (double* vals, const size_t numVals) - }; - %apply(double* IN_ARRAY1, int DIM1) { - (const double* coords, - const size_t numDims) - }; - int query(double* vals, - const size_t numVals, - const double* coords, - const size_t numDims, - const spatialdata::geocoords::CoordSys* pCSQuery); - %clear(double* vals, const size_t numVals); - %clear(const double* coords, const size_t numDims); - - }; // class CompositeDB - - } // spatialdb -} // spatialdata - - -// End of file + namespace spatialdb { + + class CompositeDB : public SpatialDB { // class CompositeDB + + public: + // PUBLIC METHODS ///////////////////////////////////////////////// + + /// Default constructor. + CompositeDB(void); + + /** Constructor with label. + * + * @param label Label of database + */ + CompositeDB(const char* label); + + /// Default destructor. + ~CompositeDB(void); + + /** Set database A. + * + * @param db Pointer to database. + * @param names Array of names of values to use with database. + * @param numNames Size of array of names. + */ + % apply(const char* const* string_list, + const int list_len){(const char* const* names, + const size_t numNames)}; + void setDBA(SpatialDB* db, + const char* const* names, + const size_t numNames); + % clear(const char* const* names, + const size_t numNames); + + /** Set database B. + * + * @param db Pointer to database. + * @param names Array of names of values to use with database. + * @param numNames Size of array of names. + */ + % apply(const char* const* string_list, + const int list_len){(const char* const* names, + const size_t numNames)}; + void setDBB(SpatialDB* db, + const char* const* names, + const size_t numNames); + % clear(const char* const* names, + const size_t numNames); + + /// Open the database and prepare for querying. + void open(void); + + /// Close the database. + void close(void); + + /** Set values to be returned by queries. + * + * @pre Must call open() before setQueryValues() + * + * @param names Names of values to be returned in queries + * @param numVals Number of values to be returned in queries + */ + % apply(const char* const* string_list, + const int list_len){(const char* const* names, + const size_t numVals)}; + void setQueryValues(const char* const* names, + const size_t numVals); + % clear(const char* const* names, + const size_t numVals); + + /** Query the database. + * + * @pre Must call open() before query() + * + * @param vals Array for computed values (output from query), vals + * must be allocated BEFORE calling query(). + * @param numVals Number of values expected (size of pVals array) + * @param coords Coordinates of point for query + * @param numDims Number of dimensions for coordinates + * @param pCSQuery Coordinate system of coordinates + * + * @returns 0 on success, 1 on failure (i.e., could not interpolate + * so values set to 0) + */ + % apply(double* INPLACE_ARRAY1, + int DIM1){(double* vals, + const size_t numVals)}; + % apply(double* IN_ARRAY1, + int DIM1){(const double* coords, + const size_t numDims)}; + int query(double* vals, + const size_t numVals, + const double* coords, + const size_t numDims, + const spatialdata::geocoords::CoordSys* pCSQuery); + % clear(double* vals, + const size_t numVals); + % clear(const double* coords, + const size_t numDims); + + }; // class CompositeDB + + } // namespace spatialdb +} // namespace spatialdata + + +// End of file diff --git a/modulesrc/spatialdb/GravityField.i b/modulesrc/spatialdb/GravityField.i index 26edd942..fff0bb07 100644 --- a/modulesrc/spatialdb/GravityField.i +++ b/modulesrc/spatialdb/GravityField.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -14,95 +13,97 @@ */ namespace spatialdata { - namespace geocoords { - class CSGeo; // USES CSGeo - } // geocoords - - namespace spatialdb { - - class GravityField : public SpatialDB - { // class GravityField - - public : - // PUBLIC METHODS ///////////////////////////////////////////////// - - /// Default constructor. - GravityField(void); - - /// Default destructor. - ~GravityField(void); - - /** Set direction of gravitational body force. Used only with - * Cartesian coordinate system. - * - * @param x X component of direction - * @param y Y component of direction - * @param z Z component of direction - */ - void setGravityDir(const double x, - const double y, - const double z); - - /** Set gravitational acceleration. - * - * @param acceleration Gravitational acceleration. - */ - void setGravityAcc(const double acceleration); - - /// Open the database and prepare for querying. - void open(void); - - /// Close the database. - void close(void); - - /** Set values to be returned by queries. - * - * Valid values for use in names are {'x', 'y', 'z'}. - * - * @pre Must call open() before setQueryValues() - * - * @param names Names of values to be returned in queries - * @param numVals Number of values to be returned in queries - */ - %apply(const char* const* string_list, const int list_len){ - (const char* const* names, const size_t numVals) - }; - void setQueryValues(const char* const* names, - const size_t numVals); - %clear(const char* const* names, const size_t numVals); - - /** Query the database. - * - * @pre Must call open() before query() - * - * @param vals Array for computed values (output from query), vals - * must be allocated BEFORE calling query(). - * @param numVals Number of values expected (size of pVals array) - * @param coords Coordinates of point for query - * @param numDims Number of dimensions for coordinates - * @param cs Coordinate system of coordinates - * - * @returns 0 on success, 1 on failure (i.e., could not interpolate - * so values set to 0) - */ - %apply(double* INPLACE_ARRAY1, int DIM1) { - (double* vals, const size_t numVals) - }; - %apply(double* IN_ARRAY1, int DIM1) { - (const double* coords, const size_t numDims) - }; - int query(double* vals, - const size_t numVals, - const double* coords, - const size_t numDims, - const spatialdata::geocoords::CoordSys* cs); - %clear(double* vals, const size_t numVals); - %clear(const double* coords, const size_t numDims); - - }; // class GravityField - - } // spatialdb -} // spatialdata - - -// End of file + namespace geocoords { + class CSGeo; // USES CSGeo + } // namespace geocoords + + namespace spatialdb { + + class GravityField : public SpatialDB { // class GravityField + + public: + // PUBLIC METHODS ///////////////////////////////////////////////// + + /// Default constructor. + GravityField(void); + + /// Default destructor. + ~GravityField(void); + + /** Set direction of gravitational body force. Used only with + * Cartesian coordinate system. + * + * @param x X component of direction + * @param y Y component of direction + * @param z Z component of direction + */ + void setGravityDir(const double x, + const double y, + const double z); + + /** Set gravitational acceleration. + * + * @param acceleration Gravitational acceleration. + */ + void setGravityAcc(const double acceleration); + + /// Open the database and prepare for querying. + void open(void); + + /// Close the database. + void close(void); + + /** Set values to be returned by queries. + * + * Valid values for use in names are {'x', 'y', 'z'}. + * + * @pre Must call open() before setQueryValues() + * + * @param names Names of values to be returned in queries + * @param numVals Number of values to be returned in queries + */ + % apply(const char* const* string_list, + const int list_len){(const char* const* names, + const size_t numVals)}; + void setQueryValues(const char* const* names, + const size_t numVals); + % clear(const char* const* names, + const size_t numVals); + + /** Query the database. + * + * @pre Must call open() before query() + * + * @param vals Array for computed values (output from query), vals + * must be allocated BEFORE calling query(). + * @param numVals Number of values expected (size of pVals array) + * @param coords Coordinates of point for query + * @param numDims Number of dimensions for coordinates + * @param cs Coordinate system of coordinates + * + * @returns 0 on success, 1 on failure (i.e., could not interpolate + * so values set to 0) + */ + % apply(double* INPLACE_ARRAY1, + int DIM1){(double* vals, + const size_t numVals)}; + % apply(double* IN_ARRAY1, + int DIM1){(const double* coords, + const size_t numDims)}; + int query(double* vals, + const size_t numVals, + const double* coords, + const size_t numDims, + const spatialdata::geocoords::CoordSys* cs); + % clear(double* vals, + const size_t numVals); + % clear(const double* coords, + const size_t numDims); + + }; // class GravityField + + } // namespace spatialdb +} // namespace spatialdata + + +// End of file diff --git a/modulesrc/spatialdb/Makefile.am b/modulesrc/spatialdb/Makefile.am index 5c925a2e..0b305721 100644 --- a/modulesrc/spatialdb/Makefile.am +++ b/modulesrc/spatialdb/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/modulesrc/spatialdb/SCECCVMH.i b/modulesrc/spatialdb/SCECCVMH.i index e1c490e8..9208d917 100644 --- a/modulesrc/spatialdb/SCECCVMH.i +++ b/modulesrc/spatialdb/SCECCVMH.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -14,100 +13,102 @@ */ namespace spatialdata { - namespace geocoords { - class CSGeoProj; // HASA CSGeoProj - } // geocoords - - namespace spatialdb { - - class SCECCVMH : public SpatialDB - { // SCECCVMH - - public : - // PUBLIC MEMBERS ///////////////////////////////////////////////// - - /// Constructor - SCECCVMH(void); - - /// Destructor - ~SCECCVMH(void); - - /** Set directory containing SCEC CVM-H data files. - * - * @param dir Directory containing data files. - */ - void setDataDir(const char* dir); - - /** Set minimum shear wave speed. Corresponding minima for Vp and - * density are enforced using nominal Vp->Vs relation and - * Vp->density relations. - * - * @param value Minimum shear wave speed. - */ - void setMinVs(const double value); - - /** Set squashed topography/bathymetry flag and minimum - * elevation of squashing. - * - * @param flag True if squashing, false otherwise. - * @param limit Minimum elevation for squashing. - */ - void setSquashFlag(const bool flag, - const double limit =-2000.0); - - /// Open the database and prepare for querying. - void open(void); - - /// Close the database. - void close(void); - - /** Set values to be returned by queries. - * - * @pre Must call open() before setQueryValues() - * - * @param names Names of values to be returned in queries - * @param numVals Number of values to be returned in queries - */ - %apply(const char* const* string_list, const int list_len){ - (const char* const* names, const size_t numVals) - }; - void setQueryValues(const char* const* names, - const size_t numVals); - %clear(const char* const* names, const size_t numVals); - - /** Query the database. - * - * @note pVals should be preallocated to accommodate numVals values. - * - * @pre Must call open() before query() - * - * @param vals Array for computed values (output from query), must be - * allocated BEFORE calling query(). - * @param numVals Number of values expected (size of pVals array) - * @param coords Coordinates of point for query - * @param numDims Number of dimensions for coordinates - * @param pCSQuery Coordinate system of coordinates - * - * @returns 0 on success, 1 on failure (i.e., could not interpolate) - */ - %apply(double* INPLACE_ARRAY1, int DIM1) { - (double* vals, const size_t numVals) - }; - %apply(double* IN_ARRAY1, int DIM1) { - (const double* coords, const size_t numDims) - }; - int query(double* vals, - const size_t numVals, - const double* coords, - const size_t numDims, - const spatialdata::geocoords::CoordSys* pCSQuery); - %clear(double* vals, const size_t numVals); - %clear(const double* coords, const size_t numDims); - - }; // SCECCVMH - - } // spatialdb -} // spatialdata - - -// End of file + namespace geocoords { + class CSGeoProj; // HASA CSGeoProj + } // namespace geocoords + + namespace spatialdb { + + class SCECCVMH : public SpatialDB { // SCECCVMH + + public: + // PUBLIC MEMBERS ///////////////////////////////////////////////// + + /// Constructor + SCECCVMH(void); + + /// Destructor + ~SCECCVMH(void); + + /** Set directory containing SCEC CVM-H data files. + * + * @param dir Directory containing data files. + */ + void setDataDir(const char* dir); + + /** Set minimum shear wave speed. Corresponding minima for Vp and + * density are enforced using nominal Vp->Vs relation and + * Vp->density relations. + * + * @param value Minimum shear wave speed. + */ + void setMinVs(const double value); + + /** Set squashed topography/bathymetry flag and minimum + * elevation of squashing. + * + * @param flag True if squashing, false otherwise. + * @param limit Minimum elevation for squashing. + */ + void setSquashFlag(const bool flag, + const double limit = -2000.0); + + /// Open the database and prepare for querying. + void open(void); + + /// Close the database. + void close(void); + + /** Set values to be returned by queries. + * + * @pre Must call open() before setQueryValues() + * + * @param names Names of values to be returned in queries + * @param numVals Number of values to be returned in queries + */ + % apply(const char* const* string_list, + const int list_len){(const char* const* names, + const size_t numVals)}; + void setQueryValues(const char* const* names, + const size_t numVals); + % clear(const char* const* names, + const size_t numVals); + + /** Query the database. + * + * @note pVals should be preallocated to accommodate numVals values. + * + * @pre Must call open() before query() + * + * @param vals Array for computed values (output from query), must be + * allocated BEFORE calling query(). + * @param numVals Number of values expected (size of pVals array) + * @param coords Coordinates of point for query + * @param numDims Number of dimensions for coordinates + * @param pCSQuery Coordinate system of coordinates + * + * @returns 0 on success, 1 on failure (i.e., could not interpolate) + */ + % apply(double* INPLACE_ARRAY1, + int DIM1){(double* vals, + const size_t numVals)}; + % apply(double* IN_ARRAY1, + int DIM1){(const double* coords, + const size_t numDims)}; + int query(double* vals, + const size_t numVals, + const double* coords, + const size_t numDims, + const spatialdata::geocoords::CoordSys* pCSQuery); + % clear(double* vals, + const size_t numVals); + % clear(const double* coords, + const size_t numDims); + + }; // SCECCVMH + + } // namespace spatialdb +} // namespace spatialdata + + +// End of file diff --git a/modulesrc/spatialdb/SimpleDB.i b/modulesrc/spatialdb/SimpleDB.i index 39cd845f..6355be3c 100644 --- a/modulesrc/spatialdb/SimpleDB.i +++ b/modulesrc/spatialdb/SimpleDB.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -14,112 +13,112 @@ */ namespace spatialdata { - namespace spatialdb { - class SimpleIO; // USES SimpleIO - - class SimpleDB : public SpatialDB - { // class SimpleDB - - public : - // PUBLIC ENUM //////////////////////////////////////////////////// - - /** Topology of spatial data */ - enum TopoEnum { - POINT=0, - LINE=1, - AREA=2, - VOLUME=3 - }; - - /** Type of query */ - enum QueryEnum { - NEAREST=0, - LINEAR=1 - }; - - public : - // PUBLIC METHODS ///////////////////////////////////////////////// - - /// Default constructor. - SimpleDB(void); - - /** Constructor with label. - * - * @param label Label of database - */ - SimpleDB(const char* label); - - /// Default destructor. - ~SimpleDB(void); - - /// Open the database and prepare for querying. - void open(void); - - /// Close the database. - void close(void); - - /** Set query type. - * - * @pre Must call Open() before QueryType() - * - * @param queryType Set type of query - */ - void setQueryType(const SimpleDB::QueryEnum queryType); - - /** Set the I/O handler. - * - * @param iohandler - */ - void setIOHandler(const SimpleIO* iohandler); - - /** Set values to be returned by queries. - * - * @pre Must call open() before setQueryValues() - * - * @param names Names of values to be returned in queries - * @param numVals Number of values to be returned in queries - */ - %apply(const char* const* string_list, const int list_len){ - (const char* const* names, const size_t numVals) - }; - void setQueryValues(const char* const* names, - const size_t numVals); - %clear(const char* const* names, const size_t numVals); - - /** Query the database. - * - * @pre Must call open() before query() - * - * @param vals Array for computed values (output from query), vals - * must be allocated BEFORE calling query(). - * @param numVals Number of values expected (size of pVals array) - * @param coords Coordinates of point for query - * @param numDims Number of dimensions for coordinates - * @param pCSQuery Coordinate system of coordinates - * - * @returns 0 on success, 1 on failure (i.e., could not interpolate - * so values set to 0) - */ - %apply(double* INPLACE_ARRAY1, int DIM1) { - (double* vals, - const size_t numVals) - }; - %apply(double* IN_ARRAY1, int DIM1) { - (const double* coords, - const size_t numDims) - }; - int query(double* vals, - const size_t numVals, - const double* coords, - const size_t numDims, - const spatialdata::geocoords::CoordSys* pCSQuery); - %clear(double* vals, const size_t numVals); - %clear(const double* coords, const size_t numDims); - - }; // class SimpleDB - - } // spatialdb -} // spatialdata - - -// End of file + namespace spatialdb { + class SimpleIO; // USES SimpleIO + + class SimpleDB : public SpatialDB { // class SimpleDB + + public: + // PUBLIC ENUM //////////////////////////////////////////////////// + + /** Topology of spatial data */ + enum TopoEnum { + POINT = 0, + LINE = 1, + AREA = 2, + VOLUME = 3 + }; + + /** Type of query */ + enum QueryEnum { + NEAREST = 0, + LINEAR = 1 + }; + + public: + // PUBLIC METHODS ///////////////////////////////////////////////// + + /// Default constructor. + SimpleDB(void); + + /** Constructor with label. + * + * @param label Label of database + */ + SimpleDB(const char* label); + + /// Default destructor. + ~SimpleDB(void); + + /// Open the database and prepare for querying. + void open(void); + + /// Close the database. + void close(void); + + /** Set query type. + * + * @pre Must call Open() before QueryType() + * + * @param queryType Set type of query + */ + void setQueryType(const SimpleDB::QueryEnum queryType); + + /** Set the I/O handler. + * + * @param iohandler + */ + void setIOHandler(const SimpleIO* iohandler); + + /** Set values to be returned by queries. + * + * @pre Must call open() before setQueryValues() + * + * @param names Names of values to be returned in queries + * @param numVals Number of values to be returned in queries + */ + % apply(const char* const* string_list, + const int list_len){(const char* const* names, + const size_t numVals)}; + void setQueryValues(const char* const* names, + const size_t numVals); + % clear(const char* const* names, + const size_t numVals); + + /** Query the database. + * + * @pre Must call open() before query() + * + * @param vals Array for computed values (output from query), vals + * must be allocated BEFORE calling query(). + * @param numVals Number of values expected (size of pVals array) + * @param coords Coordinates of point for query + * @param numDims Number of dimensions for coordinates + * @param pCSQuery Coordinate system of coordinates + * + * @returns 0 on success, 1 on failure (i.e., could not interpolate + * so values set to 0) + */ + % apply(double* INPLACE_ARRAY1, + int DIM1){(double* vals, + const size_t numVals)}; + % apply(double* IN_ARRAY1, + int DIM1){(const double* coords, + const size_t numDims)}; + int query(double* vals, + const size_t numVals, + const double* coords, + const size_t numDims, + const spatialdata::geocoords::CoordSys* pCSQuery); + % clear(double* vals, + const size_t numVals); + % clear(const double* coords, + const size_t numDims); + + }; // class SimpleDB + + } // namespace spatialdb +} // namespace spatialdata + + +// End of file diff --git a/modulesrc/spatialdb/SimpleDBData.i b/modulesrc/spatialdb/SimpleDBData.i index 8cf2cf85..1cd0b7f6 100644 --- a/modulesrc/spatialdb/SimpleDBData.i +++ b/modulesrc/spatialdb/SimpleDBData.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -14,124 +13,129 @@ */ namespace spatialdata { - namespace spatialdb { - - class SimpleDBData - { // SimpleDBData - - public : - // PUBLIC METHODS ///////////////////////////////////////////////// - - /// Default constructor - SimpleDBData(void); - - /// Default destructor - ~SimpleDBData(void); - - /** Allocate data structues. - * - * @param numLocs Number of locations. - * @param numValues Number of values. - * @param spaceDim Spatial dimension of domain. - * @param dataDim Spatial dimension of data distribution. - */ - void allocate(const int numLocs, - const int numValues, - const int spaceDim, - const int dataDim); - - /** Set data values. - * - * @pre Must call allocate() before setData(). - * - * @param values Array of data values [numLocs*numValues]. - * @param numLocs Number of locations. - * @param numValues Number of values. - */ - %apply(double* IN_ARRAY2, int DIM1, int DIM2) { - (const double* values, - const size_t numLocs, - const size_t numValues) - }; - void setData(const double* values, - const size_t numLocs, - const size_t numValues); - %clear(const double* values, const size_t numLocs, const size_t numValues); - - /** Set coordinates of locations. - * - * @pre Must call allocate() before setLocations(). - * - * @param values Array of coordinates of locations [numLocs*spaceDim]. - * @param numLocs Number of locations. - * @param spaceDim Spatial dimension of coordinates. - */ - %apply(double* IN_ARRAY2, int DIM1, int DIM2) { - (const double* values, - const size_t numLocs, - const size_t spaceDim) - }; - void setCoordinates(const double* values, - const size_t numLocs, - const size_t spaceDim); - %clear(const double* values, const size_t numLocs, const size_t numValues); - - /** Set names of values. - * - * @pre Must call allocate() before setNames(). - * - * @param values Array of names of values [numValues]. - * @param numValues Number of values. - */ - %apply(const char* const* string_list, const int list_len){ - (const char* const* values, const size_t numValues) - }; - void setNames(const char* const* values, - const size_t numValues); - %clear(const char* const* values, const size_t numValues); - - /** Set units of values. - * - * @pre Must call allocate() before setUnits(). - * - * @param values Array of units of values [numValues]. - * @param numValues Number of values. - */ - %apply(const char* const* string_list, const int list_len){ - (const char* const* values, const int numValues) - }; - void setUnits(const char* const* values, - const int numValues); - %clear(const char* const* values, const int numValues); - - /** Get number of locations for data. - * - * @returns Number of locations. - */ - size_t getNumLocs(void) const; - - /** Get number of values for data. - * - * @returns Number of values. - */ - size_t getNumValues(void) const; - - /** Get spatial dimension of data distribution. - * - * @returns Spatial dimension. - */ - size_t getDataDim(void) const; - - /** Get spatial dimension of locations. - * - * @returns Spatial dimension. - */ - size_t getSpaceDim(void) const; - - }; // class SpatialDBData - - } // spatialdb -} // spatialdata - - -// End of file + namespace spatialdb { + + class SimpleDBData { // SimpleDBData + + public: + // PUBLIC METHODS ///////////////////////////////////////////////// + + /// Default constructor + SimpleDBData(void); + + /// Default destructor + ~SimpleDBData(void); + + /** Allocate data structues. + * + * @param numLocs Number of locations. + * @param numValues Number of values. + * @param spaceDim Spatial dimension of domain. + * @param dataDim Spatial dimension of data distribution. + */ + void allocate(const int numLocs, + const int numValues, + const int spaceDim, + const int dataDim); + + /** Set data values. + * + * @pre Must call allocate() before setData(). + * + * @param values Array of data values [numLocs*numValues]. + * @param numLocs Number of locations. + * @param numValues Number of values. + */ + % apply(double* IN_ARRAY2, + int DIM1, + int DIM2){(const double* values, + const size_t numLocs, + const size_t numValues)}; + void setData(const double* values, + const size_t numLocs, + const size_t numValues); + % clear(const double* values, + const size_t numLocs, + const size_t numValues); + + /** Set coordinates of locations. + * + * @pre Must call allocate() before setLocations(). + * + * @param values Array of coordinates of locations [numLocs*spaceDim]. + * @param numLocs Number of locations. + * @param spaceDim Spatial dimension of coordinates. + */ + % apply(double* IN_ARRAY2, + int DIM1, + int DIM2){(const double* values, + const size_t numLocs, + const size_t spaceDim)}; + void setCoordinates(const double* values, + const size_t numLocs, + const size_t spaceDim); + % clear(const double* values, + const size_t numLocs, + const size_t numValues); + + /** Set names of values. + * + * @pre Must call allocate() before setNames(). + * + * @param values Array of names of values [numValues]. + * @param numValues Number of values. + */ + % apply(const char* const* string_list, + const int list_len){(const char* const* values, + const size_t numValues)}; + void setNames(const char* const* values, + const size_t numValues); + % clear(const char* const* values, + const size_t numValues); + + /** Set units of values. + * + * @pre Must call allocate() before setUnits(). + * + * @param values Array of units of values [numValues]. + * @param numValues Number of values. + */ + % apply(const char* const* string_list, + const int list_len){(const char* const* values, + const int numValues)}; + void setUnits(const char* const* values, + const int numValues); + % clear(const char* const* values, + const int numValues); + + /** Get number of locations for data. + * + * @returns Number of locations. + */ + size_t getNumLocs(void) const; + + /** Get number of values for data. + * + * @returns Number of values. + */ + size_t getNumValues(void) const; + + /** Get spatial dimension of data distribution. + * + * @returns Spatial dimension. + */ + size_t getDataDim(void) const; + + /** Get spatial dimension of locations. + * + * @returns Spatial dimension. + */ + size_t getSpaceDim(void) const; + + }; // class SpatialDBData + + } // namespace spatialdb +} // namespace spatialdata + + +// End of file diff --git a/modulesrc/spatialdb/SimpleGridAscii.i b/modulesrc/spatialdb/SimpleGridAscii.i index 0d135e99..cdf16985 100644 --- a/modulesrc/spatialdb/SimpleGridAscii.i +++ b/modulesrc/spatialdb/SimpleGridAscii.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -15,10 +14,8 @@ namespace spatialdata { namespace spatialdb { - class spatialdata::spatialdb::SimpleGridAscii - { // SimpleGridAscii -public: - + class spatialdata::spatialdb::SimpleGridAscii { // SimpleGridAscii + public: // PUBLIC METHODS ///////////////////////////////////////////////// // Using default constructor. @@ -31,19 +28,17 @@ public: * * @param db Spatial database. */ - static - void read(SimpleGridDB* db); + static void read(SimpleGridDB* db); /** Write the database. * * @param db Spatial database. */ - static - void write(const SimpleGridDB& db); + static void write(const SimpleGridDB& db); }; // class SimpleGridAscii - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata // End of file diff --git a/modulesrc/spatialdb/SimpleGridDB.i b/modulesrc/spatialdb/SimpleGridDB.i index cf9df4ef..843ce7f6 100644 --- a/modulesrc/spatialdb/SimpleGridDB.i +++ b/modulesrc/spatialdb/SimpleGridDB.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -14,203 +13,217 @@ */ namespace spatialdata { - namespace spatialdb { - class SimpleIO; // USES SimpleIO - - class SimpleGridDB : public SpatialDB - { // class SimpleGridDB - - public : - // PUBLIC ENUM //////////////////////////////////////////////////// - - /** Type of query */ - enum QueryEnum { - NEAREST=0, - LINEAR=1 - }; - - public : - // PUBLIC METHODS ///////////////////////////////////////////////// - - /// Default constructor. - SimpleGridDB(void); - - /// Default destructor. - ~SimpleGridDB(void); - - /** Set filename containing data. - * - * @param dir Directory containing data files. - */ - void setFilename(const char* value); - - /** Set query type. - * - * @pre Must call open() before setQueryType() - * - * @param queryType Set type of query - */ - void setQueryType(const SimpleGridDB::QueryEnum queryType); - - /// Open the database and prepare for querying. - void open(void); - - /// Close the database. - void close(void); - - /** Set values to be returned by queries. - * - * @pre Must call open() before setQueryValues() - * - * @param names Names of values to be returned in queries - * @param numVals Number of values to be returned in queries - */ - %apply(const char* const* string_list, const int list_len){ - (const char* const* names, const size_t numVals) - }; - void setQueryValues(const char* const* names, - const size_t numVals); - %clear(const char* const* names, const size_t numVals); - - /** Query the database. - * - * @pre Must call open() before query() - * - * @param vals Array for computed values (output from query), vals - * must be allocated BEFORE calling query(). - * @param numVals Number of values expected (size of pVals array) - * @param coords Coordinates of point for query - * @param numDims Number of dimensions for coordinates - * @param pCSQuery Coordinate system of coordinates - * - * @returns 0 on success, 1 on failure (i.e., could not interpolate - * so values set to 0) - */ - %apply(double* INPLACE_ARRAY1, int DIM1) { - (double* vals, const size_t numVals) - }; - %apply(double* IN_ARRAY1, int DIM1) { - (const double* coords, const size_t numDims) - }; - int query(double* vals, - const size_t numVals, - const double* coords, - const size_t numDims, - const spatialdata::geocoords::CoordSys* pCSQuery); - %clear(double* vals, const size_t numVals); - %clear(const double* coords, const size_t numDims); - - /** Allocate room for data. - * - * @param numX Number of locations along x-axis. - * @param numY Number of locations along y-axis. - * @param numZ Number of locations along z-axis. - * @param numValues Number of values at each location. - * @param spaceDim Spatial dimension. - * @param dataDim Spatial dimension of topology. - */ - void allocate(const size_t numX, - const size_t numY, - const size_t numZ, - const size_t numValues, - const size_t spaceDim, - const size_t dataDim); - - /** Set coordinates along x-axis; - * - * @param values Values along x-axis. - * @param size Number of values along x-axis. - */ - %apply(double* IN_ARRAY1, int DIM1) { - (const double* values, const size_t size) - }; - void setX(const double* values, - const size_t size); - %clear(double* values, const size_t size); - - /** Set coordinates along y-axis; - * - * @param values Values along y-axis. - * @param size Number of values along y-axis. - */ - %apply(double* IN_ARRAY1, int DIM1) { - (const double* values, const size_t size) - }; - void setY(const double* values, - const size_t size); - %clear(double* values, const size_t size); - - /** Set coordinates along z-axis; - * - * @param values Values along z-axis. - * @param size Number of values along z-axis. - */ - %apply(double* IN_ARRAY1, int DIM1) { - (const double* values, - const size_t size) - }; - void setZ(const double* values, - const size_t size); - %clear(double* values, const size_t size); - - /** Set data values. - * - * @param coords Coordinates of locations. - * @param numLocs Number of locations. - * @param spaceDim Coordinate dimension. - * @param values Data values. - * @param numLocs2 Number of locations. - * @param numValues Number of values per location. - */ - %apply(double* IN_ARRAY2, int DIM1, int DIM2) { - (const double* coords, const size_t numLocs, const size_t spaceDim) - }; - %apply(double* IN_ARRAY2, int DIM1, int DIM2) { - (const double* values, const size_t numLocs2, const size_t numValues) - }; - void setData(const double* coords, - const size_t numLocs, - const size_t spaceDim, - const double* values, - const size_t numLocs2, - const size_t numValues); - %clear(double* coords, const size_t size, const size_t spaceDim); - %clear(double* values, const size_t numLocs2, const size_t numValues); - - /** Set names of data values. - * - * @param values Names of values. - * @param numValues Number of values. - */ - %apply(const char* const* string_list, const int list_len){ - (const char* const* values, const size_t numValues) - }; - void setNames(const char* const* values, + namespace spatialdb { + class SimpleIO; // USES SimpleIO + + class SimpleGridDB : public SpatialDB { // class SimpleGridDB + + public: + // PUBLIC ENUM //////////////////////////////////////////////////// + + /** Type of query */ + enum QueryEnum { + NEAREST = 0, + LINEAR = 1 + }; + + public: + // PUBLIC METHODS ///////////////////////////////////////////////// + + /// Default constructor. + SimpleGridDB(void); + + /// Default destructor. + ~SimpleGridDB(void); + + /** Set filename containing data. + * + * @param dir Directory containing data files. + */ + void setFilename(const char* value); + + /** Set query type. + * + * @pre Must call open() before setQueryType() + * + * @param queryType Set type of query + */ + void setQueryType(const SimpleGridDB::QueryEnum queryType); + + /// Open the database and prepare for querying. + void open(void); + + /// Close the database. + void close(void); + + /** Set values to be returned by queries. + * + * @pre Must call open() before setQueryValues() + * + * @param names Names of values to be returned in queries + * @param numVals Number of values to be returned in queries + */ + % apply(const char* const* string_list, + const int list_len){(const char* const* names, + const size_t numVals)}; + void setQueryValues(const char* const* names, + const size_t numVals); + % clear(const char* const* names, + const size_t numVals); + + /** Query the database. + * + * @pre Must call open() before query() + * + * @param vals Array for computed values (output from query), vals + * must be allocated BEFORE calling query(). + * @param numVals Number of values expected (size of pVals array) + * @param coords Coordinates of point for query + * @param numDims Number of dimensions for coordinates + * @param pCSQuery Coordinate system of coordinates + * + * @returns 0 on success, 1 on failure (i.e., could not interpolate + * so values set to 0) + */ + % apply(double* INPLACE_ARRAY1, + int DIM1){(double* vals, + const size_t numVals)}; + % apply(double* IN_ARRAY1, + int DIM1){(const double* coords, + const size_t numDims)}; + int query(double* vals, + const size_t numVals, + const double* coords, + const size_t numDims, + const spatialdata::geocoords::CoordSys* pCSQuery); + % clear(double* vals, + const size_t numVals); + % clear(const double* coords, + const size_t numDims); + + /** Allocate room for data. + * + * @param numX Number of locations along x-axis. + * @param numY Number of locations along y-axis. + * @param numZ Number of locations along z-axis. + * @param numValues Number of values at each location. + * @param spaceDim Spatial dimension. + * @param dataDim Spatial dimension of topology. + */ + void allocate(const size_t numX, + const size_t numY, + const size_t numZ, + const size_t numValues, + const size_t spaceDim, + const size_t dataDim); + + /** Set coordinates along x-axis; + * + * @param values Values along x-axis. + * @param size Number of values along x-axis. + */ + % apply(double* IN_ARRAY1, + int DIM1){(const double* values, + const size_t size)}; + void setX(const double* values, + const size_t size); + % clear(double* values, + const size_t size); + + /** Set coordinates along y-axis; + * + * @param values Values along y-axis. + * @param size Number of values along y-axis. + */ + % apply(double* IN_ARRAY1, + int DIM1){(const double* values, + const size_t size)}; + void setY(const double* values, + const size_t size); + % clear(double* values, + const size_t size); + + /** Set coordinates along z-axis; + * + * @param values Values along z-axis. + * @param size Number of values along z-axis. + */ + % apply(double* IN_ARRAY1, + int DIM1){(const double* values, + const size_t size)}; + void setZ(const double* values, + const size_t size); + % clear(double* values, + const size_t size); + + /** Set data values. + * + * @param coords Coordinates of locations. + * @param numLocs Number of locations. + * @param spaceDim Coordinate dimension. + * @param values Data values. + * @param numLocs2 Number of locations. + * @param numValues Number of values per location. + */ + % apply(double* IN_ARRAY2, + int DIM1, + int DIM2){(const double* coords, + const size_t numLocs, + const size_t spaceDim)}; + % apply(double* IN_ARRAY2, + int DIM1, + int DIM2){(const double* values, + const size_t numLocs2, + const size_t numValues)}; + void setData(const double* coords, + const size_t numLocs, + const size_t spaceDim, + const double* values, + const size_t numLocs2, + const size_t numValues); + % clear(double* coords, + const size_t size, + const size_t spaceDim); + % clear(double* values, + const size_t numLocs2, const size_t numValues); - %clear(const char* const* values, const size_t numValues); - - /** Set units of data values. - * - * @param values Units of values. - * @param numValues Number of values. - */ - %apply(const char* const* string_list, const int list_len){ - (const char* const* values, const size_t numValues) - }; - void setUnits(const char* const* values, - const size_t numValues); - %clear(const char* const* values, const size_t numValues); - - /** Set filename containing data. - * - * @param dir Directory containing data files. - */ - void setCoordSys(const spatialdata::geocoords::CoordSys& cs); - - }; // class SimpleGridDB - - } // spatialdb -} // spatialdata + + /** Set names of data values. + * + * @param values Names of values. + * @param numValues Number of values. + */ + % apply(const char* const* string_list, + const int list_len){(const char* const* values, + const size_t numValues)}; + void setNames(const char* const* values, + const size_t numValues); + % clear(const char* const* values, + const size_t numValues); + + /** Set units of data values. + * + * @param values Units of values. + * @param numValues Number of values. + */ + % apply(const char* const* string_list, + const int list_len){(const char* const* values, + const size_t numValues)}; + void setUnits(const char* const* values, + const size_t numValues); + % clear(const char* const* values, + const size_t numValues); + + /** Set filename containing data. + * + * @param dir Directory containing data files. + */ + void setCoordSys(const spatialdata::geocoords::CoordSys& cs); + + }; // class SimpleGridDB + + } // namespace spatialdb +} // namespace spatialdata // End of file diff --git a/modulesrc/spatialdb/SimpleIO.i b/modulesrc/spatialdb/SimpleIO.i index e8ccb163..706e447c 100644 --- a/modulesrc/spatialdb/SimpleIO.i +++ b/modulesrc/spatialdb/SimpleIO.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -17,18 +16,15 @@ namespace spatialdata { namespace spatialdb { class SimpleDBData; // forward declaration - class SimpleIO - { // class SimpleIO -public: - + class SimpleIO { // class SimpleIO + public: // PUBLIC METHODS ///////////////////////////////////////////////// /// Default constructor. SimpleIO(void); /// Default destructor. - virtual - ~SimpleIO(void); + virtual ~SimpleIO(void); /** Set filename for database. * @@ -47,18 +43,16 @@ public: * @param pData Database data * @param ppCS Pointer to coordinate system */ - virtual - void read(SimpleDBData* pData, - spatialdata::geocoords::CoordSys** ppCS) = 0; + virtual void read(SimpleDBData* pData, + spatialdata::geocoords::CoordSys** ppCS) = 0; /** Write the database. * * @param data Database data * @param pCS Pointer to coordinate system */ - virtual - void write(const SimpleDBData& data, - const spatialdata::geocoords::CoordSys* pCS) = 0; + virtual void write(const SimpleDBData& data, + const spatialdata::geocoords::CoordSys* pCS) = 0; }; // class SimpleIO diff --git a/modulesrc/spatialdb/SimpleIOAscii.i b/modulesrc/spatialdb/SimpleIOAscii.i index 11400ba8..a1431ff5 100644 --- a/modulesrc/spatialdb/SimpleIOAscii.i +++ b/modulesrc/spatialdb/SimpleIOAscii.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -17,10 +16,8 @@ namespace spatialdata { namespace spatialdb { class SimpleDBData; // forward declaration - class SimpleIOAscii: public SimpleIO - { // SimpleIOAscii -public: - + class SimpleIOAscii : public SimpleIO { // SimpleIOAscii + public: // PUBLIC METHODS ///////////////////////////////////////////////// /// Default constructor. @@ -47,7 +44,7 @@ public: }; // class SimpleIOAscii - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata // End of file diff --git a/modulesrc/spatialdb/SpatialDBObj.i b/modulesrc/spatialdb/SpatialDBObj.i index 37fc0345..78d3ed67 100644 --- a/modulesrc/spatialdb/SpatialDBObj.i +++ b/modulesrc/spatialdb/SpatialDBObj.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -16,13 +15,11 @@ namespace spatialdata { namespace geocoords { class CoordSys; // forward declaration - } // geocoords + } // namespace geocoords namespace spatialdb { - class SpatialDB - { // class SpatialDB -public: - + class SpatialDB { // class SpatialDB + public: // PUBLIC METHODS ///////////////////////////////////////////////// /// Default constructor. @@ -35,8 +32,7 @@ public: SpatialDB(const char* description); /// Default destructor. - virtual - ~SpatialDB(void); + virtual ~SpatialDB(void); /** Set description of spatial database. * @@ -51,12 +47,10 @@ public: const char* getDescription(void) const; /// Open the database and prepare for querying. - virtual - void open(void) = 0; + virtual void open(void) = 0; /// Close the database. - virtual - void close(void) = 0; + virtual void close(void) = 0; /** Set values to be returned by queries. * @@ -65,14 +59,14 @@ public: * @param names Names of values to be returned in queries * @param numVals Number of values to be returned in queries */ - %apply(const char* const* string_list, const int list_len) { - (const char* const* names, const size_t numVals) - }; - virtual - void setQueryValues(const char* const* names, - const size_t numVals) = 0; + % apply(const char* const* string_list, + const int list_len){(const char* const* names, + const size_t numVals)}; + virtual void setQueryValues(const char* const* names, + const size_t numVals) = 0; - %clear(const char* const* names, const size_t numVals); + % clear(const char* const* names, + const size_t numVals); /** Query the database. * @@ -89,21 +83,22 @@ public: * * @returns 0 on success, 1 on failure (i.e., could not interpolate) */ - %apply(double* INPLACE_ARRAY1, int DIM1) { - (double* vals, const size_t numVals) - }; - %apply(double* IN_ARRAY1, int DIM1) { - (const double* coords, const size_t numDims) - }; - virtual - int query(double* vals, - const size_t numVals, - const double* coords, - const size_t numDims, - const spatialdata::geocoords::CoordSys* csQuery) = 0; - - %clear(double* vals, const size_t numVals); - %clear(const double* coords, const size_t numDims); + % apply(double* INPLACE_ARRAY1, + int DIM1){(double* vals, + const size_t numVals)}; + % apply(double* IN_ARRAY1, + int DIM1){(const double* coords, + const size_t numDims)}; + virtual int query(double* vals, + const size_t numVals, + const double* coords, + const size_t numDims, + const spatialdata::geocoords::CoordSys* csQuery) = 0; + + % clear(double* vals, + const size_t numVals); + % clear(const double* coords, + const size_t numDims); /** Perform multiple queries of the database. * @@ -126,20 +121,19 @@ public: * @param numDimsC Number of dimensions for coordinates. * @param csQuery Coordinate system of coordinates. */ - %apply(double* INPLACE_ARRAY2, int DIM1, int DIM2) { - (double* vals, - const size_t numLocsV, - const size_t numValsV) - }; - %apply(int* INPLACE_ARRAY1, int DIM1) { - (int* err, - const size_t numLocsE) - }; - %apply(double* IN_ARRAY2, int DIM1, int DIM2) { - (const double* coords, - const size_t numLocsC, - const size_t numDimsC) - }; + % apply(double* INPLACE_ARRAY2, + int DIM1, + int DIM2){(double* vals, + const size_t numLocsV, + const size_t numValsV)}; + % apply(int* INPLACE_ARRAY1, + int DIM1){(int* err, + const size_t numLocsE)}; + % apply(double* IN_ARRAY2, + int DIM1, + int DIM2){(const double* coords, + const size_t numLocsC, + const size_t numDimsC)}; void multiquery(double* vals, const size_t numLocsV, const size_t numValsV, @@ -150,13 +144,18 @@ public: const size_t numDimsC, const spatialdata::geocoords::CoordSys* csQuery); - %clear(double* vals, const size_t numLocsV, const size_t numValsV); - %clear(int* err, const size_t numLocsE); - %clear(const double* coords, const size_t numLocsC, const size_t numDimsC); + % clear(double* vals, + const size_t numLocsV, + const size_t numValsV); + % clear(int* err, + const size_t numLocsE); + % clear(const double* coords, + const size_t numLocsC, + const size_t numDimsC); }; // class SpatialDB - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata // End of file diff --git a/modulesrc/spatialdb/TimeHistory.i b/modulesrc/spatialdb/TimeHistory.i index 0eccb45d..c93e5e07 100644 --- a/modulesrc/spatialdb/TimeHistory.i +++ b/modulesrc/spatialdb/TimeHistory.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -15,10 +14,8 @@ namespace spatialdata { namespace spatialdb { - class TimeHistory - { // class TimeHistory -public: - + class TimeHistory { // class TimeHistory + public: // PUBLIC METHODS ///////////////////////////////////////////////// /// Default constructor. @@ -72,15 +69,15 @@ public: * * @returns 0 on success, 1 on failure (i.e., could not interpolate) */ - %apply double* OUTPUT { double* value }; + % apply double* OUTPUT{double* value}; int query(double* value, const double t); - %clear(double* value); + % clear(double* value); }; // class TimeHistory - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata // End of file diff --git a/modulesrc/spatialdb/TimeHistoryIO.i b/modulesrc/spatialdb/TimeHistoryIO.i index a36b0310..a9fe9f83 100644 --- a/modulesrc/spatialdb/TimeHistoryIO.i +++ b/modulesrc/spatialdb/TimeHistoryIO.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -14,44 +13,44 @@ */ namespace spatialdata { - namespace spatialdb { - - class TimeHistoryIO - { // class TimeHistoryIO - - public : - // PUBLIC METHODS ///////////////////////////////////////////////// - - /** Read time history file. Number of time history points given by - * nptsT must equal nptsA. - * - * @param time Time stamps. - * @param nptsT Number of points in time history. - * @param amplitude Amplitude values in time history. - * @param nptsA Number of points in time history. - * @param timeUnits Units associated with time stamps. - * @param filename Filename for time history. - */ - %apply(double* IN_ARRAY1, int DIM1) { - (const double* time, const size_t nptsT) - }; - %apply(double* IN_ARRAY1, int DIM1) { - (const double* amplitude, const size_t nptsA) - }; - static - void write(const double* time, - const size_t nptsT, - const double* amplitude, - const size_t nptsA, - const char* timeUnits, - const char* filename); - %clear(const double* time, const size_t nptsT); - %clear(const double* amplitude, const size_t nptsA); - - }; // class TimeHistoryIO - - } // spatialdb -} // spatialdata - - -// End of file + namespace spatialdb { + + class TimeHistoryIO { // class TimeHistoryIO + + public: + // PUBLIC METHODS ///////////////////////////////////////////////// + + /** Read time history file. Number of time history points given by + * nptsT must equal nptsA. + * + * @param time Time stamps. + * @param nptsT Number of points in time history. + * @param amplitude Amplitude values in time history. + * @param nptsA Number of points in time history. + * @param timeUnits Units associated with time stamps. + * @param filename Filename for time history. + */ + % apply(double* IN_ARRAY1, + int DIM1){(const double* time, + const size_t nptsT)}; + % apply(double* IN_ARRAY1, + int DIM1){(const double* amplitude, + const size_t nptsA)}; + static void write(const double* time, + const size_t nptsT, + const double* amplitude, + const size_t nptsA, + const char* timeUnits, + const char* filename); + % clear(const double* time, + const size_t nptsT); + % clear(const double* amplitude, + const size_t nptsA); + + }; // class TimeHistoryIO + + } // namespace spatialdb +} // namespace spatialdata + + +// End of file diff --git a/modulesrc/spatialdb/UniformDB.i b/modulesrc/spatialdb/UniformDB.i index b9cecee0..df221b77 100644 --- a/modulesrc/spatialdb/UniformDB.i +++ b/modulesrc/spatialdb/UniformDB.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -15,10 +14,8 @@ namespace spatialdata { namespace spatialdb { - class UniformDB: public SpatialDB - { // class UniformDB -public: - + class UniformDB : public SpatialDB { // class UniformDB + public: // PUBLIC METHODS ///////////////////////////////////////////////// /// Default constructor. @@ -40,24 +37,20 @@ public: * @param values Array of values in database. * @param numValues Number of values in database. */ - %apply(const char* const* string_list) { - (const char* const* names) - }; - %apply(const char* const* string_list) { - (const char* const* units) - }; - %apply(double* IN_ARRAY1, int DIM1) { - (const double* values, - const size_t numValues) - }; + % apply(const char* const* string_list){(const char* const* names)}; + % apply(const char* const* string_list){(const char* const* units)}; + % apply(double* IN_ARRAY1, + int DIM1){(const double* values, + const size_t numValues)}; void setData(const char* const* names, const char* const* names, const double* values, const size_t numValues); - %clear(const char* const* names); - %clear(const char* const* units); - %clear(const double* values, const size_t numValues); + % clear(const char* const* names); + % clear(const char* const* units); + % clear(const double* values, + const size_t numValues); /// Open the database and prepare for querying. void open(void); @@ -72,13 +65,14 @@ public: * @param names Names of values to be returned in queries * @param numVals Number of values to be returned in queries */ - %apply(const char* const* string_list, const int list_len) { - (const char* const* names, const size_t numVals) - }; + % apply(const char* const* string_list, + const int list_len){(const char* const* names, + const size_t numVals)}; void setQueryValues(const char* const* names, const size_t numVals); - %clear(const char* const* names, const size_t numVals); + % clear(const char* const* names, + const size_t numVals); /** Query the database. * @@ -94,24 +88,26 @@ public: * @returns 0 on success, 1 on failure (i.e., could not interpolate * so values set to 0) */ - %apply(double* INPLACE_ARRAY1, int DIM1) { - (double* vals, const size_t numVals) - }; - %apply(double* IN_ARRAY1, int DIM1) { - (const double* coords, const size_t numDims) - }; + % apply(double* INPLACE_ARRAY1, + int DIM1){(double* vals, + const size_t numVals)}; + % apply(double* IN_ARRAY1, + int DIM1){(const double* coords, + const size_t numDims)}; int query(double* vals, const size_t numVals, const double* coords, const size_t numDims, const spatialdata::geocoords::CoordSys* pCSQuery); - %clear(double* vals, const size_t numVals); - %clear(const double* coords, const size_t numDims); + % clear(double* vals, + const size_t numVals); + % clear(const double* coords, + const size_t numDims); }; // class UniformDB - } // spatialdb -} // spatialdata + } // namespace spatialdb +} // namespace spatialdata // End of file diff --git a/modulesrc/spatialdb/UserFunctionDB.i b/modulesrc/spatialdb/UserFunctionDB.i index 7bc737eb..af728b4f 100644 --- a/modulesrc/spatialdb/UserFunctionDB.i +++ b/modulesrc/spatialdb/UserFunctionDB.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -15,136 +14,138 @@ namespace spatialdata { namespace spatialdb { - - class UserFunctionDB : public SpatialDB { - - public : - // PUBLIC TYPEDEF////////////////////////////////////////////////////// - - /** User function prototype in 1-D. - * - * @param x X coordinate. - * @returns Value of user-defined function. - */ - typedef double (*userfn1D_type)(const double x); - - /** User function prototype in 2-D. - * - * @param x X coordinate. - * @param y Y coordinate. - * @returns Value of user-defined function. - */ - typedef double (*userfn2D_type)(const double x, - const double y); - - /** User function prototype in 3-D. - * - * @param x X coordinate. - * @param y Y coordinate. - * @param z Z coordinate. - * @returns Value of user-defined function. - */ - typedef double (*userfn3D_type)(const double x, - const double y, - const double z); - - // PUBLIC MEMBERS /////////////////////////////////////////////////////// - public : - - /// Constructor - UserFunctionDB(void); - - /// Destructor - ~UserFunctionDB(void); - - /** Add function/value to database in 1-D. - * - * @param name Name of value for function. - * @param fn User function for value. - * @param units Units associated with function value. - */ - void addValue(const char* name, - userfn1D_type fn, - const char* units); - - /** Add function/value to database in 2-D. - * - * @param name Name of value for function. - * @param fn User function for value. - * @param units Units associated with function value. - */ - void addValue(const char* name, - userfn2D_type fn, - const char* units); - - /** Add function/value to database in 3-D. - * - * @param name Name of value for function. - * @param fn User function for value. - * @param units Units associated with function value. - */ - void addValue(const char* name, - userfn3D_type fn, - const char* units); - - /// Open the database and prepare for querying. - void open(void); - - /// Close the database. - void close(void); - - /** Set values to be returned by queries. - * - * @pre Must call open() before setQueryValues() - * - * @param names Names of values to be returned in queries - * @param numVals Number of values to be returned in queries - */ - %apply(const char* const* string_list, const int list_len){ - (const char* const* names, const size_t numVals) - }; - void setQueryValues(const char* const* names, - const size_t numVals); - %clear(const char* const* names, const size_t numVals); - - /** Query the database. - * - * @pre Must call open() before query() - * - * @param vals Array for computed values (output from query), vals - * must be allocated BEFORE calling query(). - * @param numVals Number of values expected (size of pVals array) - * @param coords Coordinates of point for query - * @param numDims Number of dimensions for coordinates - * @param pCSQuery Coordinate system of coordinates - * - * @returns 0 on success, 1 on failure (i.e., could not interpolate - * so values set to 0) - */ - %apply(double* INPLACE_ARRAY1, int DIM1) { - (double* vals, const size_t numVals) - }; - %apply(double* IN_ARRAY1, int DIM1) { - (const double* coords, const size_t numDims) - }; - int query(double* vals, - const size_t numVals, - const double* coords, - const size_t numDims, - const spatialdata::geocoords::CoordSys* pCSQuery); - %clear(double* vals, const size_t numVals); - %clear(const double* coords, const size_t numDims); - - /** Set coordinate system associated with user functions. - * - * @param cs Coordinate system. - */ - void setCoordSys(const geocoords::CoordSys& cs); - - }; // class UserFunctionDB - - } // spatialdb -} // spatialdata - - -// End of file + + class UserFunctionDB : public SpatialDB { + + public: + // PUBLIC TYPEDEF////////////////////////////////////////////////////// + + /** User function prototype in 1-D. + * + * @param x X coordinate. + * @returns Value of user-defined function. + */ + typedef double (*userfn1D_type)(const double x); + + /** User function prototype in 2-D. + * + * @param x X coordinate. + * @param y Y coordinate. + * @returns Value of user-defined function. + */ + typedef double (*userfn2D_type)(const double x, + const double y); + + /** User function prototype in 3-D. + * + * @param x X coordinate. + * @param y Y coordinate. + * @param z Z coordinate. + * @returns Value of user-defined function. + */ + typedef double (*userfn3D_type)(const double x, + const double y, + const double z); + + // PUBLIC MEMBERS /////////////////////////////////////////////////////// + public: + /// Constructor + UserFunctionDB(void); + + /// Destructor + ~UserFunctionDB(void); + + /** Add function/value to database in 1-D. + * + * @param name Name of value for function. + * @param fn User function for value. + * @param units Units associated with function value. + */ + void addValue(const char* name, + userfn1D_type fn, + const char* units); + + /** Add function/value to database in 2-D. + * + * @param name Name of value for function. + * @param fn User function for value. + * @param units Units associated with function value. + */ + void addValue(const char* name, + userfn2D_type fn, + const char* units); + + /** Add function/value to database in 3-D. + * + * @param name Name of value for function. + * @param fn User function for value. + * @param units Units associated with function value. + */ + void addValue(const char* name, + userfn3D_type fn, + const char* units); + + /// Open the database and prepare for querying. + void open(void); + + /// Close the database. + void close(void); + + /** Set values to be returned by queries. + * + * @pre Must call open() before setQueryValues() + * + * @param names Names of values to be returned in queries + * @param numVals Number of values to be returned in queries + */ + % apply(const char* const* string_list, + const int list_len){(const char* const* names, + const size_t numVals)}; + void setQueryValues(const char* const* names, + const size_t numVals); + % clear(const char* const* names, + const size_t numVals); + + /** Query the database. + * + * @pre Must call open() before query() + * + * @param vals Array for computed values (output from query), vals + * must be allocated BEFORE calling query(). + * @param numVals Number of values expected (size of pVals array) + * @param coords Coordinates of point for query + * @param numDims Number of dimensions for coordinates + * @param pCSQuery Coordinate system of coordinates + * + * @returns 0 on success, 1 on failure (i.e., could not interpolate + * so values set to 0) + */ + % apply(double* INPLACE_ARRAY1, + int DIM1){(double* vals, + const size_t numVals)}; + % apply(double* IN_ARRAY1, + int DIM1){(const double* coords, + const size_t numDims)}; + int query(double* vals, + const size_t numVals, + const double* coords, + const size_t numDims, + const spatialdata::geocoords::CoordSys* pCSQuery); + % clear(double* vals, + const size_t numVals); + % clear(const double* coords, + const size_t numDims); + + /** Set coordinate system associated with user functions. + * + * @param cs Coordinate system. + */ + void setCoordSys(const geocoords::CoordSys& cs); + + }; // class UserFunctionDB + + } // namespace spatialdb +} // namespace spatialdata + + +// End of file diff --git a/modulesrc/spatialdb/spatialdb.i b/modulesrc/spatialdb/spatialdb.i index 3a682f81..b5ff1ad8 100644 --- a/modulesrc/spatialdb/spatialdb.i +++ b/modulesrc/spatialdb/spatialdb.i @@ -2,78 +2,69 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= // SWIG interface -%module spatialdb +% + module spatialdb -// Header files for module C++ code -%{ + // Header files for module C++ code + % + { #include #include // USES std::string #include "spatialdata/geocoords/CoordSys.hh" -#include "spatialdata/spatialdb/SpatialDB.hh" +#include "spatialdata/spatialdb/AnalyticDB.hh" +#include "spatialdata/spatialdb/CompositeDB.hh" +#include "spatialdata/spatialdb/GravityField.hh" +#include "spatialdata/spatialdb/SCECCVMH.hh" #include "spatialdata/spatialdb/SimpleDB.hh" #include "spatialdata/spatialdb/SimpleDBData.hh" +#include "spatialdata/spatialdb/SimpleGridAscii.hh" +#include "spatialdata/spatialdb/SimpleGridDB.hh" #include "spatialdata/spatialdb/SimpleIO.hh" #include "spatialdata/spatialdb/SimpleIOAscii.hh" -#include "spatialdata/spatialdb/UniformDB.hh" -#include "spatialdata/spatialdb/AnalyticDB.hh" -#include "spatialdata/spatialdb/SimpleGridDB.hh" -#include "spatialdata/spatialdb/SimpleGridAscii.hh" -#include "spatialdata/spatialdb/UserFunctionDB.hh" -#include "spatialdata/spatialdb/CompositeDB.hh" -#include "spatialdata/spatialdb/SCECCVMH.hh" -#include "spatialdata/spatialdb/GravityField.hh" +#include "spatialdata/spatialdb/SpatialDB.hh" #include "spatialdata/spatialdb/TimeHistory.hh" #include "spatialdata/spatialdb/TimeHistoryIO.hh" +#include "spatialdata/spatialdb/UniformDB.hh" +#include "spatialdata/spatialdb/UserFunctionDB.hh" -%} + % } -%include "exception.i" -%exception { - try { - $action - } catch (const std::exception& err) { - SWIG_exception(SWIG_RuntimeError, err.what()); - } // try/catch - } // exception + % include "exception.i" % exception { + try { + $action + } catch (const std::exception& err) { + SWIG_exception(SWIG_RuntimeError, err.what()); + } // try/catch +} // exception -%include "typemaps.i" -%include "../include/chararray.i" +% include "typemaps.i" % + include "../include/chararray.i" -// Numpy interface stuff -%{ + // Numpy interface stuff + % + { #define SWIG_FILE_WITH_INIT -%} -%include "../include/numpy.i" -%init %{ -import_array(); -%} + % } % + include "../include/numpy.i" % init % { + import_array(); + % +} // Interfaces -%include "SpatialDBObj.i" -%include "SimpleDB.i" -%include "SimpleDBData.i" -%include "SimpleIO.i" -%include "SimpleIOAscii.i" -%include "UniformDB.i" -%include "AnalyticDB.i" -%include "SimpleGridDB.i" -%include "SimpleGridAscii.i" -%include "UserFunctionDB.i" -%include "CompositeDB.i" -%include "SCECCVMH.i" -%include "GravityField.i" -%include "TimeHistory.i" -%include "TimeHistoryIO.i" +% include "SpatialDBObj.i" % include "SimpleDB.i" % include "SimpleDBData.i" % include "SimpleIO.i" % + include "SimpleIOAscii.i" % include "UniformDB.i" % include "AnalyticDB.i" % include "SimpleGridDB.i" % + include "SimpleGridAscii.i" % include "UserFunctionDB.i" % include "CompositeDB.i" % include "SCECCVMH.i" % + include "GravityField.i" % include "TimeHistory.i" % + include "TimeHistoryIO.i" -// End of file + // End of file diff --git a/modulesrc/utils/Makefile.am b/modulesrc/utils/Makefile.am index aba063b8..45af90c4 100644 --- a/modulesrc/utils/Makefile.am +++ b/modulesrc/utils/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/modulesrc/utils/SpatialdataVersion.i b/modulesrc/utils/SpatialdataVersion.i index 6c927ed6..ec923832 100644 --- a/modulesrc/utils/SpatialdataVersion.i +++ b/modulesrc/utils/SpatialdataVersion.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -16,11 +15,9 @@ namespace spatialdata { namespace utils { - class SpatialdataVersion - { // SpatialdataVersion - // PUBLIC MEMBERS /////////////////////////////////////////////////////// -public: - + class SpatialdataVersion { // SpatialdataVersion + // PUBLIC MEMBERS /////////////////////////////////////////////////////// + public: /// Default constructor. SpatialdataVersion(void); @@ -31,54 +28,47 @@ public: * * @returns True if source code comes from a release? */ - static - bool isRelease(void); + static bool isRelease(void); /** Get version number. * * @returns Version number. */ - static - const char* version(void); + static const char* version(void); /** Get GIT revision. * * @returns GIT revision. */ - static - const char* gitRevision(void); + static const char* gitRevision(void); /** Get GIT hash. * * @returns GIT hash. */ - static - const char* gitHash(void); + static const char* gitHash(void); /** Get date of GIT revision. * * @returns Date of GIT revision. */ - static - const char* gitDate(void); + static const char* gitDate(void); /** Get GIT branch. * * @returns GIT branch. */ - static - const char* gitBranch(void); + static const char* gitBranch(void); /** Get Proj.4 version number. * * @returns Version number. */ - static - const char* projVersion(void); + static const char* projVersion(void); }; // SpatialdataVersion - } // utils -} // spatialdata + } // namespace utils +} // namespace spatialdata // End of file diff --git a/modulesrc/utils/utils.i b/modulesrc/utils/utils.i index 6371d58d..b88bfd55 100644 --- a/modulesrc/utils/utils.i +++ b/modulesrc/utils/utils.i @@ -2,30 +2,30 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= // SWIG interface -%module utils +% + module utils -// Header files for module C++ code -%{ + // Header files for module C++ code + % + { #include "spatialdata/utils/SpatialdataVersion.hh" -%} + % } -%include "exception.i" -%exception { - try { - $action - } catch (const std::exception& err) { - SWIG_exception(SWIG_RuntimeError, err.what()); - } // try/catch + % include "exception.i" % exception { + try { + $action + } catch (const std::exception& err) { + SWIG_exception(SWIG_RuntimeError, err.what()); + } // try/catch } // exception // Interfaces -%include "SpatialdataVersion.i" +% include "SpatialdataVersion.i" -// End of file + // End of file diff --git a/setup.py b/setup.py index 6a3aa6db..259b086b 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,15 @@ +# ================================================================================================= +# This code is part of PyLith, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/pylith). +# +# Copyright (c) 2010-2026 All rights reserved. +# +# See https://mit-license.org/ and LICENSE.md and for license information. +# ================================================================================================= # Setup configuration is in setup.cfg. import setuptools setuptools.setup() + +# End of file diff --git a/spatialdata/Makefile.am b/spatialdata/Makefile.am index 771a1b25..a7d03f95 100644 --- a/spatialdata/Makefile.am +++ b/spatialdata/Makefile.am @@ -3,8 +3,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/__init__.py b/spatialdata/__init__.py index 288b6ada..adaa0a65 100644 --- a/spatialdata/__init__.py +++ b/spatialdata/__init__.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/geocoords/CSCart.py b/spatialdata/geocoords/CSCart.py index ba01406d..c06871c6 100644 --- a/spatialdata/geocoords/CSCart.py +++ b/spatialdata/geocoords/CSCart.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/geocoords/CSGeo.py b/spatialdata/geocoords/CSGeo.py index 05014e09..4be3500c 100644 --- a/spatialdata/geocoords/CSGeo.py +++ b/spatialdata/geocoords/CSGeo.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/geocoords/CSGeoLocal.py b/spatialdata/geocoords/CSGeoLocal.py index c6be4d15..c271dd06 100644 --- a/spatialdata/geocoords/CSGeoLocal.py +++ b/spatialdata/geocoords/CSGeoLocal.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/geocoords/Converter.py b/spatialdata/geocoords/Converter.py index 2cdaa456..b280c071 100644 --- a/spatialdata/geocoords/Converter.py +++ b/spatialdata/geocoords/Converter.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/geocoords/CoordSys.py b/spatialdata/geocoords/CoordSys.py index 272444b5..a72d54dc 100644 --- a/spatialdata/geocoords/CoordSys.py +++ b/spatialdata/geocoords/CoordSys.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/geocoords/__init__.py b/spatialdata/geocoords/__init__.py index 872b5824..c19dbfe0 100644 --- a/spatialdata/geocoords/__init__.py +++ b/spatialdata/geocoords/__init__.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/AnalyticDB.py b/spatialdata/spatialdb/AnalyticDB.py index bdfa6861..1883ef80 100644 --- a/spatialdata/spatialdb/AnalyticDB.py +++ b/spatialdata/spatialdb/AnalyticDB.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/CompositeDB.py b/spatialdata/spatialdb/CompositeDB.py index c08cda22..f7e91e55 100644 --- a/spatialdata/spatialdb/CompositeDB.py +++ b/spatialdata/spatialdb/CompositeDB.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/GravityField.py b/spatialdata/spatialdb/GravityField.py index c912dee3..f6377407 100644 --- a/spatialdata/spatialdb/GravityField.py +++ b/spatialdata/spatialdb/GravityField.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/SCECCVMH.py b/spatialdata/spatialdb/SCECCVMH.py index b89402b9..84180758 100644 --- a/spatialdata/spatialdb/SCECCVMH.py +++ b/spatialdata/spatialdb/SCECCVMH.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/SimpleDB.py b/spatialdata/spatialdb/SimpleDB.py index afe00d32..b831bd58 100644 --- a/spatialdata/spatialdb/SimpleDB.py +++ b/spatialdata/spatialdb/SimpleDB.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/SimpleGridAscii.py b/spatialdata/spatialdb/SimpleGridAscii.py index 58d0b271..3d462d78 100644 --- a/spatialdata/spatialdb/SimpleGridAscii.py +++ b/spatialdata/spatialdb/SimpleGridAscii.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/SimpleGridDB.py b/spatialdata/spatialdb/SimpleGridDB.py index 590ac6f6..5d1f5873 100644 --- a/spatialdata/spatialdb/SimpleGridDB.py +++ b/spatialdata/spatialdb/SimpleGridDB.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/SimpleIO.py b/spatialdata/spatialdb/SimpleIO.py index cda7e73f..e8b303a4 100644 --- a/spatialdata/spatialdb/SimpleIO.py +++ b/spatialdata/spatialdb/SimpleIO.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/SimpleIOAscii.py b/spatialdata/spatialdb/SimpleIOAscii.py index f2f7d117..367d8799 100644 --- a/spatialdata/spatialdb/SimpleIOAscii.py +++ b/spatialdata/spatialdb/SimpleIOAscii.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/SpatialDBObj.py b/spatialdata/spatialdb/SpatialDBObj.py index 2c644c40..13a6b1ee 100644 --- a/spatialdata/spatialdb/SpatialDBObj.py +++ b/spatialdata/spatialdb/SpatialDBObj.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/TimeHistory.py b/spatialdata/spatialdb/TimeHistory.py index 8e8a7ca4..55950e72 100644 --- a/spatialdata/spatialdb/TimeHistory.py +++ b/spatialdata/spatialdb/TimeHistory.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/TimeHistoryIO.py b/spatialdata/spatialdb/TimeHistoryIO.py index 2e30b8bb..9d350d2f 100644 --- a/spatialdata/spatialdb/TimeHistoryIO.py +++ b/spatialdata/spatialdb/TimeHistoryIO.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/UniformDB.py b/spatialdata/spatialdb/UniformDB.py index 45f8a2b1..f42bc647 100644 --- a/spatialdata/spatialdb/UniformDB.py +++ b/spatialdata/spatialdb/UniformDB.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/UserFunctionDB.py b/spatialdata/spatialdb/UserFunctionDB.py index d8f9594a..bc20905b 100644 --- a/spatialdata/spatialdb/UserFunctionDB.py +++ b/spatialdata/spatialdb/UserFunctionDB.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/__init__.py b/spatialdata/spatialdb/__init__.py index d6daf6c3..1ad61a57 100644 --- a/spatialdata/spatialdb/__init__.py +++ b/spatialdata/spatialdb/__init__.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/generator/GenSimpleDBApp.py b/spatialdata/spatialdb/generator/GenSimpleDBApp.py index e08b927f..b60b992c 100644 --- a/spatialdata/spatialdb/generator/GenSimpleDBApp.py +++ b/spatialdata/spatialdb/generator/GenSimpleDBApp.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/generator/Geometry.py b/spatialdata/spatialdb/generator/Geometry.py index f05f1ab8..6968f812 100644 --- a/spatialdata/spatialdb/generator/Geometry.py +++ b/spatialdata/spatialdb/generator/Geometry.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/generator/Shaper.py b/spatialdata/spatialdb/generator/Shaper.py index 7ad4a09e..b68a2666 100644 --- a/spatialdata/spatialdb/generator/Shaper.py +++ b/spatialdata/spatialdb/generator/Shaper.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/generator/Value.py b/spatialdata/spatialdb/generator/Value.py index 14665c3a..9d1f280a 100644 --- a/spatialdata/spatialdb/generator/Value.py +++ b/spatialdata/spatialdb/generator/Value.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/spatialdb/generator/__init__.py b/spatialdata/spatialdb/generator/__init__.py index 1d4c44d3..880c4fca 100644 --- a/spatialdata/spatialdb/generator/__init__.py +++ b/spatialdata/spatialdb/generator/__init__.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/testing/TestCases.py b/spatialdata/testing/TestCases.py index 1b4d8f34..55a11b55 100644 --- a/spatialdata/testing/TestCases.py +++ b/spatialdata/testing/TestCases.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/testing/UnitTestApp.py b/spatialdata/testing/UnitTestApp.py index 8744a448..eb66a8e7 100644 --- a/spatialdata/testing/UnitTestApp.py +++ b/spatialdata/testing/UnitTestApp.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/testing/__init__.py b/spatialdata/testing/__init__.py index e69de29b..0411dc5b 100644 --- a/spatialdata/testing/__init__.py +++ b/spatialdata/testing/__init__.py @@ -0,0 +1,11 @@ +# ================================================================================================= +# This code is part of PyLith, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/pylith). +# +# Copyright (c) 2010-2026 All rights reserved. +# +# See https://mit-license.org/ and LICENSE.md and for license information. +# ================================================================================================= + + +# End of file diff --git a/spatialdata/utils/PointsStream.py b/spatialdata/utils/PointsStream.py index 17eb05e8..85e83278 100644 --- a/spatialdata/utils/PointsStream.py +++ b/spatialdata/utils/PointsStream.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/spatialdata/utils/__init__.py b/spatialdata/utils/__init__.py index cf2bd942..70b0f8ba 100644 --- a/spatialdata/utils/__init__.py +++ b/spatialdata/utils/__init__.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/subpackage.am b/subpackage.am index 09c6bb3f..1f00920f 100644 --- a/subpackage.am +++ b/subpackage.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/templates/Makefile.am b/templates/Makefile.am index 8d12f176..d5960403 100644 --- a/templates/Makefile.am +++ b/templates/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/templates/spatialdb/Makefile.am b/templates/spatialdb/Makefile.am index 2dfa2895..8516ebad 100644 --- a/templates/spatialdb/Makefile.am +++ b/templates/spatialdb/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/templates/spatialdb/UniformVelModel.cc b/templates/spatialdb/UniformVelModel.cc index c438c268..c7cd4cbf 100644 --- a/templates/spatialdb/UniformVelModel.cc +++ b/templates/spatialdb/UniformVelModel.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/templates/spatialdb/UniformVelModel.hh b/templates/spatialdb/UniformVelModel.hh index de555457..06ae1b84 100644 --- a/templates/spatialdb/UniformVelModel.hh +++ b/templates/spatialdb/UniformVelModel.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/templates/spatialdb/UniformVelModel.i b/templates/spatialdb/UniformVelModel.i index f6096024..3d3c10aa 100644 --- a/templates/spatialdb/UniformVelModel.i +++ b/templates/spatialdb/UniformVelModel.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -22,11 +21,11 @@ namespace contrib { namespace spatialdb { - class UniformVelModel: public spatialdata::spatialdb::SpatialDB - { // UniformVelModel - // PUBLIC MEMBERS /////////////////////////////////////////////////// -public: - + class UniformVelModel + : public spatialdata::spatialdb::SpatialDB { // UniformVelModel + // PUBLIC MEMBERS + // /////////////////////////////////////////////////// + public: /// Constructor UniformVelModel(void); @@ -34,8 +33,7 @@ public: ~UniformVelModel(void); // PUBLIC METHODS /////////////////////////////////////////////////// -public: - + public: // Functions required to satisfy the SpatialDB interface. /// Open the database and prepare for querying. @@ -78,8 +76,7 @@ public: const spatialdata::geocoords::CoordSys* csQuery); // PUBLIC METHODS /////////////////////////////////////////////////// -public: - + public: // Functions specific to this type of spatial database. /** Set the P wave speed. @@ -102,7 +99,7 @@ public: }; // UniformVelModel - } // spatialdb -} // contrib + } // namespace spatialdb +} // namespace contrib // End of file diff --git a/templates/spatialdb/UniformVelModel.py b/templates/spatialdb/UniformVelModel.py index df51c981..57fc086e 100644 --- a/templates/spatialdb/UniformVelModel.py +++ b/templates/spatialdb/UniformVelModel.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/templates/spatialdb/__init__.py b/templates/spatialdb/__init__.py index c933f8e6..40f4849f 100644 --- a/templates/spatialdb/__init__.py +++ b/templates/spatialdb/__init__.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/templates/spatialdb/configure.ac b/templates/spatialdb/configure.ac index 2488ccd3..77286f92 100644 --- a/templates/spatialdb/configure.ac +++ b/templates/spatialdb/configure.ac @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/templates/spatialdb/spatialdbcontrib.i b/templates/spatialdb/spatialdbcontrib.i index 1995c7f3..28633fa3 100644 --- a/templates/spatialdb/spatialdbcontrib.i +++ b/templates/spatialdb/spatialdbcontrib.i @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -11,40 +10,39 @@ // Define the spatialdatacontrib SWIG interface module. // Set module name -%module spatialdbcontrib +% + module spatialdbcontrib -// Header files for module C++ code. -%{ -#include "UniformVelModel.hh" + // Header files for module C++ code. % -} + { +#include "UniformVelModel.hh" + % } -// Convert standard C++ exceptions to Python exceptions. -%include "exception.i" -%exception { + // Convert standard C++ exceptions to Python exceptions. + % include "exception.i" % exception { try { $ action } catch (const std::exception& err) { - SWIG_exception (SWIG_RuntimeError, err.what ()); + SWIG_exception(SWIG_RuntimeError, err.what()); } // try/catch } // exception -%include "typemaps.i" -%include "include/chararray.i" +% include "typemaps.i" % + include "include/chararray.i" -// Numpy interface stuff -%{ -#define SWIG_FILE_WITH_INIT + // Numpy interface stuff % -} -%include "include/numpy.i" -%init %{ + { +#define SWIG_FILE_WITH_INIT + % } % + include "include/numpy.i" % init % { import_array(); % } // Interface files. -%include "spatialdb/SpatialDBObj.i" -%include "UniformVelModel.i" +% include "spatialdb/SpatialDBObj.i" % + include "UniformVelModel.i" -// End of file + // End of file diff --git a/templates/spatialdb/tests/Makefile.am b/templates/spatialdb/tests/Makefile.am index 9a72831c..bd90f525 100644 --- a/templates/spatialdb/tests/Makefile.am +++ b/templates/spatialdb/tests/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/templates/spatialdb/tests/TestUniformVelModel.py b/templates/spatialdb/tests/TestUniformVelModel.py index 47e02f6a..b036752e 100644 --- a/templates/spatialdb/tests/TestUniformVelModel.py +++ b/templates/spatialdb/tests/TestUniformVelModel.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/templates/spatialdb/tests/testcontrib.py b/templates/spatialdb/tests/testcontrib.py index eae9eee3..d9626987 100644 --- a/templates/spatialdb/tests/testcontrib.py +++ b/templates/spatialdb/tests/testcontrib.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/Makefile.am b/tests/Makefile.am index 3c112ec5..a028173d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/check.am b/tests/check.am index 75724b5a..3016b6e6 100644 --- a/tests/check.am +++ b/tests/check.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/libtests/Makefile.am b/tests/libtests/Makefile.am index c9f713d4..b3245bd5 100644 --- a/tests/libtests/Makefile.am +++ b/tests/libtests/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/libtests/geocoords/Makefile.am b/tests/libtests/geocoords/Makefile.am index b202a845..93d43e6c 100644 --- a/tests/libtests/geocoords/Makefile.am +++ b/tests/libtests/geocoords/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/libtests/geocoords/TestCSCart.cc b/tests/libtests/geocoords/TestCSCart.cc index 4bf676ed..ce98251c 100644 --- a/tests/libtests/geocoords/TestCSCart.cc +++ b/tests/libtests/geocoords/TestCSCart.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/geocoords/TestCSGeo.cc b/tests/libtests/geocoords/TestCSGeo.cc index 7c1c9b76..934b9b06 100644 --- a/tests/libtests/geocoords/TestCSGeo.cc +++ b/tests/libtests/geocoords/TestCSGeo.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/geocoords/TestCSGeoLocal.cc b/tests/libtests/geocoords/TestCSGeoLocal.cc index 7218c4d4..e715527f 100644 --- a/tests/libtests/geocoords/TestCSGeoLocal.cc +++ b/tests/libtests/geocoords/TestCSGeoLocal.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/geocoords/TestCSPicklerAscii.cc b/tests/libtests/geocoords/TestCSPicklerAscii.cc index cfa10fd4..432e0f83 100644 --- a/tests/libtests/geocoords/TestCSPicklerAscii.cc +++ b/tests/libtests/geocoords/TestCSPicklerAscii.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/geocoords/TestConverter.cc b/tests/libtests/geocoords/TestConverter.cc index 3a99a1a3..85470d31 100644 --- a/tests/libtests/geocoords/TestConverter.cc +++ b/tests/libtests/geocoords/TestConverter.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= @@ -93,3 +92,6 @@ spatialdata::geocoords::TestConverter_Data::TestConverter_Data(void) : spatialdata::geocoords::TestConverter_Data::~TestConverter_Data(void) { } // destructor + + +// End of file diff --git a/tests/libtests/geocoords/TestConverter.hh b/tests/libtests/geocoords/TestConverter.hh index 33a8f918..50ae963b 100644 --- a/tests/libtests/geocoords/TestConverter.hh +++ b/tests/libtests/geocoords/TestConverter.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/geocoords/TestConverter_Cases.cc b/tests/libtests/geocoords/TestConverter_Cases.cc index e9dd049d..66ebf030 100644 --- a/tests/libtests/geocoords/TestConverter_Cases.cc +++ b/tests/libtests/geocoords/TestConverter_Cases.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/geocoords/test_driver.cc b/tests/libtests/geocoords/test_driver.cc index e961c13e..2fa649e6 100644 --- a/tests/libtests/geocoords/test_driver.cc +++ b/tests/libtests/geocoords/test_driver.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/Makefile.am b/tests/libtests/spatialdb/Makefile.am index 332569fb..de5d64e3 100644 --- a/tests/libtests/spatialdb/Makefile.am +++ b/tests/libtests/spatialdb/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/libtests/spatialdb/TestAnalyticDB.cc b/tests/libtests/spatialdb/TestAnalyticDB.cc index fa8c8143..ad817ac0 100644 --- a/tests/libtests/spatialdb/TestAnalyticDB.cc +++ b/tests/libtests/spatialdb/TestAnalyticDB.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestCompositeDB.cc b/tests/libtests/spatialdb/TestCompositeDB.cc index 60ce19fa..18890e8f 100644 --- a/tests/libtests/spatialdb/TestCompositeDB.cc +++ b/tests/libtests/spatialdb/TestCompositeDB.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestGravityField.cc b/tests/libtests/spatialdb/TestGravityField.cc index e1cabde2..eb5c9745 100644 --- a/tests/libtests/spatialdb/TestGravityField.cc +++ b/tests/libtests/spatialdb/TestGravityField.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestGravityField.hh b/tests/libtests/spatialdb/TestGravityField.hh index 55b8ce43..e97975d6 100644 --- a/tests/libtests/spatialdb/TestGravityField.hh +++ b/tests/libtests/spatialdb/TestGravityField.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestGravityField_Cases.cc b/tests/libtests/spatialdb/TestGravityField_Cases.cc index 8ee61937..b36d16d4 100644 --- a/tests/libtests/spatialdb/TestGravityField_Cases.cc +++ b/tests/libtests/spatialdb/TestGravityField_Cases.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestSCECCVMH.cc b/tests/libtests/spatialdb/TestSCECCVMH.cc index 196c74e7..5247c7c6 100644 --- a/tests/libtests/spatialdb/TestSCECCVMH.cc +++ b/tests/libtests/spatialdb/TestSCECCVMH.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestSimpleDB.cc b/tests/libtests/spatialdb/TestSimpleDB.cc index 395ee352..264a517b 100644 --- a/tests/libtests/spatialdb/TestSimpleDB.cc +++ b/tests/libtests/spatialdb/TestSimpleDB.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestSimpleDB.hh b/tests/libtests/spatialdb/TestSimpleDB.hh index e83083e5..4c1f866d 100644 --- a/tests/libtests/spatialdb/TestSimpleDB.hh +++ b/tests/libtests/spatialdb/TestSimpleDB.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestSimpleDBData.cc b/tests/libtests/spatialdb/TestSimpleDBData.cc index 8ec1e316..696a5471 100644 --- a/tests/libtests/spatialdb/TestSimpleDBData.cc +++ b/tests/libtests/spatialdb/TestSimpleDBData.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestSimpleDBQuery.cc b/tests/libtests/spatialdb/TestSimpleDBQuery.cc index 99a5491f..5ab5eb01 100644 --- a/tests/libtests/spatialdb/TestSimpleDBQuery.cc +++ b/tests/libtests/spatialdb/TestSimpleDBQuery.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestSimpleDBQuery.hh b/tests/libtests/spatialdb/TestSimpleDBQuery.hh index 40d28aca..a5d5df6d 100644 --- a/tests/libtests/spatialdb/TestSimpleDBQuery.hh +++ b/tests/libtests/spatialdb/TestSimpleDBQuery.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestSimpleDBQuery_Cases.cc b/tests/libtests/spatialdb/TestSimpleDBQuery_Cases.cc index 032ef0a8..c51fac3a 100644 --- a/tests/libtests/spatialdb/TestSimpleDBQuery_Cases.cc +++ b/tests/libtests/spatialdb/TestSimpleDBQuery_Cases.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestSimpleDB_Cases.cc b/tests/libtests/spatialdb/TestSimpleDB_Cases.cc index 520e39bc..a60ca2fe 100644 --- a/tests/libtests/spatialdb/TestSimpleDB_Cases.cc +++ b/tests/libtests/spatialdb/TestSimpleDB_Cases.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestSimpleGridAscii.cc b/tests/libtests/spatialdb/TestSimpleGridAscii.cc index 95acc7ca..bb63c15c 100644 --- a/tests/libtests/spatialdb/TestSimpleGridAscii.cc +++ b/tests/libtests/spatialdb/TestSimpleGridAscii.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestSimpleGridDB.cc b/tests/libtests/spatialdb/TestSimpleGridDB.cc index ca50e9ba..e2e6d9f8 100644 --- a/tests/libtests/spatialdb/TestSimpleGridDB.cc +++ b/tests/libtests/spatialdb/TestSimpleGridDB.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestSimpleGridDB.hh b/tests/libtests/spatialdb/TestSimpleGridDB.hh index a874c086..9972e690 100644 --- a/tests/libtests/spatialdb/TestSimpleGridDB.hh +++ b/tests/libtests/spatialdb/TestSimpleGridDB.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc b/tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc index a35efb14..b0e6256c 100644 --- a/tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc +++ b/tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestSimpleIOAscii.cc b/tests/libtests/spatialdb/TestSimpleIOAscii.cc index afdbc51b..7b11e2fa 100644 --- a/tests/libtests/spatialdb/TestSimpleIOAscii.cc +++ b/tests/libtests/spatialdb/TestSimpleIOAscii.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestSpatialDB.cc b/tests/libtests/spatialdb/TestSpatialDB.cc index a2be6882..da8a9067 100644 --- a/tests/libtests/spatialdb/TestSpatialDB.cc +++ b/tests/libtests/spatialdb/TestSpatialDB.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestTimeHistory.cc b/tests/libtests/spatialdb/TestTimeHistory.cc index b4f10483..115919bb 100644 --- a/tests/libtests/spatialdb/TestTimeHistory.cc +++ b/tests/libtests/spatialdb/TestTimeHistory.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestTimeHistoryIO.cc b/tests/libtests/spatialdb/TestTimeHistoryIO.cc index 19ae3109..f29f2d0e 100644 --- a/tests/libtests/spatialdb/TestTimeHistoryIO.cc +++ b/tests/libtests/spatialdb/TestTimeHistoryIO.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestUniformDB.cc b/tests/libtests/spatialdb/TestUniformDB.cc index 5ddf1983..f4ce96da 100644 --- a/tests/libtests/spatialdb/TestUniformDB.cc +++ b/tests/libtests/spatialdb/TestUniformDB.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestUserFunctionDB.cc b/tests/libtests/spatialdb/TestUserFunctionDB.cc index 24524300..13f19c82 100644 --- a/tests/libtests/spatialdb/TestUserFunctionDB.cc +++ b/tests/libtests/spatialdb/TestUserFunctionDB.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestUserFunctionDB.hh b/tests/libtests/spatialdb/TestUserFunctionDB.hh index f81d2a10..f3414742 100644 --- a/tests/libtests/spatialdb/TestUserFunctionDB.hh +++ b/tests/libtests/spatialdb/TestUserFunctionDB.hh @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/TestUserFunctionDB_Cases.cc b/tests/libtests/spatialdb/TestUserFunctionDB_Cases.cc index c282f045..a42e121b 100644 --- a/tests/libtests/spatialdb/TestUserFunctionDB_Cases.cc +++ b/tests/libtests/spatialdb/TestUserFunctionDB_Cases.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/data/Makefile.am b/tests/libtests/spatialdb/data/Makefile.am index 164a4b4f..954eaec7 100644 --- a/tests/libtests/spatialdb/data/Makefile.am +++ b/tests/libtests/spatialdb/data/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/libtests/spatialdb/test_driver.cc b/tests/libtests/spatialdb/test_driver.cc index e961c13e..2fa649e6 100644 --- a/tests/libtests/spatialdb/test_driver.cc +++ b/tests/libtests/spatialdb/test_driver.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/spatialdb/testf77query.h b/tests/libtests/spatialdb/testf77query.h index 5f652f7b..d20254de 100644 --- a/tests/libtests/spatialdb/testf77query.h +++ b/tests/libtests/spatialdb/testf77query.h @@ -3,8 +3,7 @@ * This code is part of SpatialData, developed through the Computational Infrastructure * for Geodynamics (https://github.com/geodynamics/spatialdata). * - * Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. - * All rights reserved. + * Copyright (c) 2010-2026 All rights reserved. * * See https://mit-license.org/ and LICENSE.md and for license information. * ================================================================================================= diff --git a/tests/libtests/units/Makefile.am b/tests/libtests/units/Makefile.am index 75dfae36..c1605260 100644 --- a/tests/libtests/units/Makefile.am +++ b/tests/libtests/units/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/libtests/units/TestParser.cc b/tests/libtests/units/TestParser.cc index b54f0264..1f62ebc6 100644 --- a/tests/libtests/units/TestParser.cc +++ b/tests/libtests/units/TestParser.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/utils/Makefile.am b/tests/libtests/utils/Makefile.am index 6293a992..3d1b4aec 100644 --- a/tests/libtests/utils/Makefile.am +++ b/tests/libtests/utils/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/libtests/utils/TestPointsStream.cc b/tests/libtests/utils/TestPointsStream.cc index db7fd851..95ceac24 100644 --- a/tests/libtests/utils/TestPointsStream.cc +++ b/tests/libtests/utils/TestPointsStream.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/libtests/utils/TestSpatialdataVersion.cc b/tests/libtests/utils/TestSpatialdataVersion.cc index d5b53822..a1553381 100644 --- a/tests/libtests/utils/TestSpatialdataVersion.cc +++ b/tests/libtests/utils/TestSpatialdataVersion.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= diff --git a/tests/pytests/Makefile.am b/tests/pytests/Makefile.am index 75449c2c..2a972e9c 100644 --- a/tests/pytests/Makefile.am +++ b/tests/pytests/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/geocoords/Makefile.am b/tests/pytests/geocoords/Makefile.am index ed1a2689..c127d2e8 100644 --- a/tests/pytests/geocoords/Makefile.am +++ b/tests/pytests/geocoords/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/geocoords/TestCSCart.py b/tests/pytests/geocoords/TestCSCart.py index fd17c63f..ad1c54a2 100644 --- a/tests/pytests/geocoords/TestCSCart.py +++ b/tests/pytests/geocoords/TestCSCart.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/geocoords/TestCSGeo.py b/tests/pytests/geocoords/TestCSGeo.py index d82f7925..22112cd3 100644 --- a/tests/pytests/geocoords/TestCSGeo.py +++ b/tests/pytests/geocoords/TestCSGeo.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/geocoords/TestCSGeoLocal.py b/tests/pytests/geocoords/TestCSGeoLocal.py index f864ce05..0e156100 100644 --- a/tests/pytests/geocoords/TestCSGeoLocal.py +++ b/tests/pytests/geocoords/TestCSGeoLocal.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/geocoords/TestConverter.py b/tests/pytests/geocoords/TestConverter.py index 11769cce..6c9bab76 100644 --- a/tests/pytests/geocoords/TestConverter.py +++ b/tests/pytests/geocoords/TestConverter.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/geocoords/test_geocoords.py b/tests/pytests/geocoords/test_geocoords.py index ea4f8344..5cdba643 100755 --- a/tests/pytests/geocoords/test_geocoords.py +++ b/tests/pytests/geocoords/test_geocoords.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/Makefile.am b/tests/pytests/spatialdb/Makefile.am index f2fd2591..122a8735 100644 --- a/tests/pytests/spatialdb/Makefile.am +++ b/tests/pytests/spatialdb/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/TestAnalyticDB.py b/tests/pytests/spatialdb/TestAnalyticDB.py index 9d7007b7..720067a1 100644 --- a/tests/pytests/spatialdb/TestAnalyticDB.py +++ b/tests/pytests/spatialdb/TestAnalyticDB.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/TestCompositeDB.py b/tests/pytests/spatialdb/TestCompositeDB.py index be7ace97..fb3e0a53 100644 --- a/tests/pytests/spatialdb/TestCompositeDB.py +++ b/tests/pytests/spatialdb/TestCompositeDB.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/TestGenSimpleDBApp.py b/tests/pytests/spatialdb/TestGenSimpleDBApp.py index 7d1ec188..f747ad44 100644 --- a/tests/pytests/spatialdb/TestGenSimpleDBApp.py +++ b/tests/pytests/spatialdb/TestGenSimpleDBApp.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/TestGravityField.py b/tests/pytests/spatialdb/TestGravityField.py index 88b6037b..40b91679 100644 --- a/tests/pytests/spatialdb/TestGravityField.py +++ b/tests/pytests/spatialdb/TestGravityField.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/TestSCECCVMH.py.in b/tests/pytests/spatialdb/TestSCECCVMH.py.in index 9ee90ecf..3a96ff69 100644 --- a/tests/pytests/spatialdb/TestSCECCVMH.py.in +++ b/tests/pytests/spatialdb/TestSCECCVMH.py.in @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/TestSimpleDB.py b/tests/pytests/spatialdb/TestSimpleDB.py index dc106b51..72441612 100644 --- a/tests/pytests/spatialdb/TestSimpleDB.py +++ b/tests/pytests/spatialdb/TestSimpleDB.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/TestSimpleGridDB.py b/tests/pytests/spatialdb/TestSimpleGridDB.py index 14fc0054..3140b740 100644 --- a/tests/pytests/spatialdb/TestSimpleGridDB.py +++ b/tests/pytests/spatialdb/TestSimpleGridDB.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/TestSimpleIOAscii.py b/tests/pytests/spatialdb/TestSimpleIOAscii.py index 81c414bc..78d2cea6 100644 --- a/tests/pytests/spatialdb/TestSimpleIOAscii.py +++ b/tests/pytests/spatialdb/TestSimpleIOAscii.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/TestTimeHistory.py b/tests/pytests/spatialdb/TestTimeHistory.py index 2c8b4bed..341c6c89 100644 --- a/tests/pytests/spatialdb/TestTimeHistory.py +++ b/tests/pytests/spatialdb/TestTimeHistory.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/TestTimeHistoryIO.py b/tests/pytests/spatialdb/TestTimeHistoryIO.py index 1092294d..5b9047fc 100644 --- a/tests/pytests/spatialdb/TestTimeHistoryIO.py +++ b/tests/pytests/spatialdb/TestTimeHistoryIO.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/TestUniformDB.py b/tests/pytests/spatialdb/TestUniformDB.py index 3ecc8f58..bae285bd 100644 --- a/tests/pytests/spatialdb/TestUniformDB.py +++ b/tests/pytests/spatialdb/TestUniformDB.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/TestUserFunctionDB.py b/tests/pytests/spatialdb/TestUserFunctionDB.py index 55ab63a8..3e5fee99 100644 --- a/tests/pytests/spatialdb/TestUserFunctionDB.py +++ b/tests/pytests/spatialdb/TestUserFunctionDB.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/data/Makefile.am b/tests/pytests/spatialdb/data/Makefile.am index 3e53c691..110ab9b3 100644 --- a/tests/pytests/spatialdb/data/Makefile.am +++ b/tests/pytests/spatialdb/data/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/test_sceccvmh.py b/tests/pytests/spatialdb/test_sceccvmh.py index 704d95e5..227cde3c 100755 --- a/tests/pytests/spatialdb/test_sceccvmh.py +++ b/tests/pytests/spatialdb/test_sceccvmh.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/test_spatialdb.py b/tests/pytests/spatialdb/test_spatialdb.py index 3f34090c..bca04b2e 100755 --- a/tests/pytests/spatialdb/test_spatialdb.py +++ b/tests/pytests/spatialdb/test_spatialdb.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/spatialdb/testgen1din2d.odb b/tests/pytests/spatialdb/testgen1din2d.odb index 322d6e74..139432f9 100644 --- a/tests/pytests/spatialdb/testgen1din2d.odb +++ b/tests/pytests/spatialdb/testgen1din2d.odb @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/utils/Makefile.am b/tests/pytests/utils/Makefile.am index 1860ddf2..cec664d3 100644 --- a/tests/pytests/utils/Makefile.am +++ b/tests/pytests/utils/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/utils/TestSpatialdataVersion.py b/tests/pytests/utils/TestSpatialdataVersion.py index 40948a6b..34427c1e 100644 --- a/tests/pytests/utils/TestSpatialdataVersion.py +++ b/tests/pytests/utils/TestSpatialdataVersion.py @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/pytests/utils/test_utils.py b/tests/pytests/utils/test_utils.py index dfa43196..2f04c33a 100755 --- a/tests/pytests/utils/test_utils.py +++ b/tests/pytests/utils/test_utils.py @@ -4,8 +4,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/src/Makefile.am b/tests/src/Makefile.am index a44526b8..ba31f5da 100644 --- a/tests/src/Makefile.am +++ b/tests/src/Makefile.am @@ -2,8 +2,7 @@ # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -# All rights reserved. +# Copyright (c) 2010-2026 All rights reserved. # # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= diff --git a/tests/src/driver_catch2.cc b/tests/src/driver_catch2.cc index 03aacbcc..64b8d4ce 100644 --- a/tests/src/driver_catch2.cc +++ b/tests/src/driver_catch2.cc @@ -2,8 +2,7 @@ // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -// All rights reserved. +// Copyright (c) 2010-2026 All rights reserved. // // See https://mit-license.org/ and LICENSE.md and for license information. // ================================================================================================= From dc1094d8e453af2ec99ad2999bf2419cc5292ca0 Mon Sep 17 00:00:00 2001 From: Brad Aagaard Date: Sun, 15 Nov 2026 18:45:36 -0700 Subject: [PATCH 04/10] configure: Update m4. --- m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/m4 b/m4 index b165f408..943eaf65 160000 --- a/m4 +++ b/m4 @@ -1 +1 @@ -Subproject commit b165f40884e58e4f1ca40036787c8eeb61787adb +Subproject commit 943eaf65d2f8cfa6f939047cc670f729e6c4a441 From 8bc07d995eda0facefe6ba5b87a61c39deb6fde1 Mon Sep 17 00:00:00 2001 From: Brad Aagaard Date: Sun, 15 Nov 2026 18:45:08 -0700 Subject: [PATCH 05/10] ci: Add conventions check to CI pipeline. --- .github/workflows/pr-conventions.yaml | 73 +++++ .github/workflows/pr-stages.yaml | 8 +- etc/ci/conventions/check.py | 333 +++++++++++++++++++++ etc/ci/conventions/requirements.txt | 13 + etc/ci/conventions/selftest.py | 405 ++++++++++++++++++++++++++ 5 files changed, 830 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/pr-conventions.yaml create mode 100644 etc/ci/conventions/check.py create mode 100644 etc/ci/conventions/requirements.txt create mode 100644 etc/ci/conventions/selftest.py diff --git a/.github/workflows/pr-conventions.yaml b/.github/workflows/pr-conventions.yaml new file mode 100644 index 00000000..8ee0dcdc --- /dev/null +++ b/.github/workflows/pr-conventions.yaml @@ -0,0 +1,73 @@ +# ================================================================================================= +# This code is part of PyLith, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/pylith). +# +# Copyright (c) 2010-2026 All rights reserved. +# +# See https://mit-license.org/ and LICENSE.md and for license information. +# ================================================================================================= +# Adapted from pyre. +# +# check a pull request against the conventions of the repository: spelling, the formatting of +# python and c++ sources, file preambles and closing markers, and the commits it adds; the +# checks are the ones in {etc/ci/conventions/check.py}, which contributors run locally too +name: pr-conventions +on: + - workflow_call + # and manually + - workflow_dispatch + +jobs: + conventions: + name: conventions + runs-on: ubuntu-latest + steps: + # the pull request itself, rather than its merge with the base, with the whole history, + # so the commits it adds can be told apart from the ones it is based on + - name: checkout + uses: actions/checkout@v7 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + # the tools, pinned so the verdict matches a local run + - name: python setup + uses: actions/setup-python@v7 + with: + python-version: "3.14" + + - name: install the tools + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -r etc/ci/conventions/requirements.txt + + # make sure the checker still catches what it is meant to catch + - name: selftest + run: python3 etc/ci/conventions/selftest.py + + # each check reports on its own, and they all run whatever the others found + - name: spelling + if: ${{ !cancelled() }} + run: python3 etc/ci/conventions/check.py --only spelling + + - name: python + if: ${{ !cancelled() }} + run: python3 etc/ci/conventions/check.py --only python + + - name: c++ + if: ${{ !cancelled() }} + run: python3 etc/ci/conventions/check.py --only cxx + + - name: preambles + if: ${{ !cancelled() }} + run: python3 etc/ci/conventions/check.py --only preambles --base "origin/${BASE}" + env: + BASE: ${{ github.base_ref }} + + - name: commits + if: ${{ !cancelled() }} + run: python3 etc/ci/conventions/check.py --only commits --base "origin/${BASE}" + env: + BASE: ${{ github.base_ref }} + +# end of file diff --git a/.github/workflows/pr-stages.yaml b/.github/workflows/pr-stages.yaml index 38cf8435..1cfe4d0b 100644 --- a/.github/workflows/pr-stages.yaml +++ b/.github/workflows/pr-stages.yaml @@ -8,9 +8,11 @@ # ================================================================================================= name: run-ci +# a new push to a pull request replaces the runs of the commits it supersedes, so they stop +# holding runners; runs for any other event are never cancelled concurrency: - group: ${{ github.actor }}-${{ github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} on: pull_request: @@ -18,6 +20,8 @@ on: - main jobs: + conventions: + uses: ./.github/workflows/pr-conventions.yaml stage-1: uses: ./.github/workflows/pr-stage-1.yaml stage-2: diff --git a/etc/ci/conventions/check.py b/etc/ci/conventions/check.py new file mode 100644 index 00000000..f8330841 --- /dev/null +++ b/etc/ci/conventions/check.py @@ -0,0 +1,333 @@ +#!/usr/bin/env python3 +# ================================================================================================= +# This code is part of PyLith, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/pylith). +# +# Copyright (c) 2010-2026 All rights reserved. +# +# See https://mit-license.org/ and LICENSE.md and for license information. +# ================================================================================================= +# Based on corresponding code in Pyre. + + +# externals +import argparse +import datetime +import os +import re +import subprocess +import sys + +# the description of the program, for the help screen +DESCRIPTION = """Check a code checkout against the conventions of the repository: + (1) spelling, + (2) the formatting of Python and C++ sources, + (3) file preambles and closing markers, and + (4) commit messages, +The same checks also run on every pull request. +""" + +# the checks, in the order they run +CHECKS = ("spelling", "python", "cxx", "preambles", "commits") + +# black formatting options +BLACK_OPTIONS = ( + "--line-length", + "120", +) + +# the sources whose preambles and closing markers are checked, by extension +SOURCES = ( + ".py", + ".h", + ".icc", + ".cc", + ".cpp", + ".cu", + ".js", + ".ts", + ".tsx", + ".mm", + ".yaml", + ".cmake", +) +# the c++ sources clang-format looks after +CXX = (".h", ".hh", ".icc", ".cc", ".cpp", ".cu") +# the trees that are exempt from the preamble and c++ formatting checks: project templates hold +# substitution markers that are not valid c++ until they are expanded +EXEMPT = ("templates/", "libsrc/spatialdata/muparser/") + +# a commit subject names the area it touches, then says what the commit does: an area is a +# path, a package, or a c++ namespace, and several can be listed separated by commas +AREA = r"[A-Za-z0-9_.{}/+\-]+(::[A-Za-z0-9_.{}/+\-]+)*" +SUBJECT = re.compile(rf"^{AREA}(, ?{AREA})*: \S") +# the authors whose commits the commit check leaves alone: bots whose messages are beyond our +# control, such as the dependency updates dependabot proposes +BOTS = ("dependabot[bot]",) +# the copyright line, with any closing year +COPYRIGHT = re.compile(r"\(c\) 2010-(\d{4}) All rights reserved.") + + +class ConventionError(Exception): + """The base class of the reasons a check could not run.""" + + +class ToolError(ConventionError): + """A tool a check relies on is missing.""" + + +def run(*, command: list, cwd: str) -> subprocess.CompletedProcess: + """Run {command} in {cwd} and capture what it says, complaining if the tool is missing.""" + # attempt to + try: + # run the command + return subprocess.run(command, cwd=cwd, capture_output=True, text=True) + # if the tool is not installed + except FileNotFoundError as error: + # say which one, and where to get it + raise ToolError(f"'{command[0]}' is not installed; see etc/ci/conventions/requirements.txt") from error + # if the tool is not installed + except UnicodeDecodeError as error: + # say which one, and where to get it + raise ToolError(f"'{" ".join(command)}' failed due to decoding error") from error + + +def tracked(*, root: str, extensions: tuple = (), exempt: tuple = ()) -> list: + """The files git tracks under {root}, narrowed to {extensions} and outside the {exempt} trees.""" + # ask git + names = run(command=["git", "ls-files"], cwd=root).stdout.split("\n") + # keep the ones of interest + return [ + name + for name in names + if name + and (not extensions or name.endswith(extensions)) + and not name.startswith(exempt) + and os.path.isfile(os.path.join(root, name)) + ] + + +def spelling(*, root: str, base: str | None) -> list: + """Spell check the prose of every tracked file, with the exclusions in {pyproject.toml}.""" + # the files + files = tracked(root=root) + # check them + result = run(command=["codespell", "--toml", "pyproject.toml", *files], cwd=root) + # every line of output is a misspelling + problems = [line for line in result.stdout.split("\n") if line.strip()] + # add the advice, if there is anything to advise about + if problems: + # a word codespell does not know is either a typo or belongs on the reviewed lists + problems.append( + "Fix the typos; a real word goes in etc/ci/conventions/codespell-words.txt, and a " + "line that is right as it is goes in etc/ci/conventions/codespell-lines.txt" + ) + # hand off the complaints + return problems + + +def python(*, root: str, base: str | None) -> list: + """Check that every tracked python source is formatted by black.""" + # the files + files = tracked(root=root, extensions=(".py",)) + # check them + # the exclusions in {pyproject.toml} apply even to files named on the command line + result = run(command=["black", *BLACK_OPTIONS, "--check", *files], cwd=root) + # black names each file it would change + problems = [line for line in result.stderr.split("\n") if line.startswith("would reformat")] + # a failure that named no file is a failure of black itself + if result.returncode != 0 and not problems: + # so report what it said, or at least that it failed + problems = [line for line in result.stderr.split("\n") if line.strip()] or [ + f"black exited with status {result.returncode}" + ] + # hand off the complaints + return problems + + +def cxx(*, root: str, base: str | None) -> list: + """Check that every tracked c++ source is formatted by clang-format.""" + # the files + files = tracked(root=root, extensions=CXX, exempt=EXEMPT) + # check them + if not files: + return [] + result = run(command=["clang-format", "--dry-run", *files], cwd=root) + # clang-format warns once per change it would make; one complaint per file is enough + names = sorted({line.split(":")[0] for line in result.stderr.split("\n") if ": warning:" in line}) + # hand off the complaints + return [f"{name}: not formatted by clang-format" for name in names] + + +def preambles(*, root: str, base: str | None) -> list: + """Check that every tracked source opens with a copyright line and closes with an end of file + marker, and that the files touched since {base} carry the current year. + """ + # the complaints + problems = [] + # the files + files = tracked(root=root, extensions=SOURCES, exempt=EXEMPT) + # the files touched since the base, when there is one + touched = set(changed(root=root, base=base)) if base else set() + # the current year + year = str(datetime.date.today().year) + # go through the files + for name in files: + # read the file + with open(os.path.join(root, name), encoding="utf-8") as stream: + # as lines + lines = stream.read().split("\n") + # the copyright line sits in the preamble, near the top + copyright = next( + (COPYRIGHT.search(line) for line in lines[:12] if COPYRIGHT.search(line)), + None, + ) + # a file without one + if copyright is None: + # is missing its preamble + problems.append(f"{name}: no '(c) 2010-{year} All rights reserved.' in its preamble") + # a file touched by the work + elif name in touched and copyright.group(1) != year: + # carries the current year + problems.append(f"{name}: touched, but its copyright ends in {copyright.group(1)}") + # the last line that says anything + last = next((line.strip() for line in reversed(lines) if line.strip()), "") + # is the closing marker, in the comment syntax of the file + if not last.lower().removesuffix("*/").strip().endswith("end of file"): + # or else the file is not closed + problems.append(f"{name}: does not end with an 'End of file' marker.") + # hand off the complaints + return problems + + +def commits(*, root: str, base: str | None) -> list: + """Check the commits since {base}: a subject that names its area and says what the commit does, + and nothing after it; the commits of the bots in {BOTS}, whose messages are beyond our + control, are left out. + """ + # without a base there is nothing to check + if not base: + # so say nothing + return [] + # the commits since the base, oldest first, as hash, author, subject, and body, merges left out + log = run( + command=[ + "git", + "log", + "--no-merges", + "--reverse", + "--format=%h%x00%an%x00%s%x00%b%x01", + f"{base}..HEAD", + ], + cwd=root, + ).stdout + # the complaints + problems = [] + # go through the commits + for record in log.split("\x01"): + # skip the separator after the last one + if not record.strip(): + # by moving on + continue + # unpack + sha, author, subject, body = record.strip("\n").split("\x00") + # a bot writes its messages its own way, and that way may change without notice + if author in BOTS: + # so its commits are not held to the conventions + continue + # the subject names its area and says what the commit does + if not SUBJECT.match(subject): + # or else it does not read like the rest of the history + problems.append(f"{sha}: '{subject}' is not of the form 'area: what the commit does'") + # and the subject is all there is + if body.strip(): + # the narrative belongs in the pull request, not the commit + problems.append(f"{sha}: has a body; the subject line is the whole message") + # hand off the complaints + return problems + + +def changed(*, root: str, base: str) -> list: + """ + The files added or modified since {base} + """ + # ask git + result = run( + command=["git", "diff", "--name-only", "--diff-filter=AM", f"{base}...HEAD"], + cwd=root, + ) + # hand off the names + return [name for name in result.stdout.split("\n") if name] + + +def parse() -> argparse.Namespace: + """ + Read the command line + """ + # make a parser + parser = argparse.ArgumentParser(description=DESCRIPTION) + # the base of the work + parser.add_argument( + "--base", + default=None, + help="The branch the work is based on, e.g. origin/main; enables the commit and year checks", + ) + # a subset of the checks + parser.add_argument( + "--only", + default=",".join(CHECKS), + help=f"A comma separated subset of the checks: {', '.join(CHECKS)}", + ) + # parse and hand off + return parser.parse_args() + + +def main() -> int: + """Run the requested checks and report what each one found.""" + # read the command line + options = parse() + # the top of the checkout + root = run(command=["git", "rev-parse", "--show-toplevel"], cwd=os.getcwd()).stdout.strip() + # the checks, by name + table = {name: globals()[name] for name in CHECKS} + # the requested ones + requested = [name for name in options.only.split(",") if name] + # a name that is not a check is a mistake + unknown = [name for name in requested if name not in table] + # so refuse it + if unknown: + # say which + print(f"Unknown checks: {', '.join(unknown)}; the checks are {', '.join(CHECKS)}") + # and bail + return 2 + # the number of checks that found something + failed = 0 + # go through them + for name in requested: + # attempt to + try: + # run the check + problems = table[name](root=root, base=options.base) + # if it could not run + except ConventionError as error: + # it counts as a failure + problems = [str(error)] + # report the verdict + print(f"{name}: {'OK' if not problems else f'{len(problems)} problems'}") + # and the details + for problem in problems: + # one per line + print(f" {problem}") + # tally + failed += 1 if problems else 0 + # the exit status says whether everything passed + return 1 if failed else 0 + + +# entry point +if __name__ == "__main__": + # run the checks and report their verdict + sys.exit(main()) + + +# End of file diff --git a/etc/ci/conventions/requirements.txt b/etc/ci/conventions/requirements.txt new file mode 100644 index 00000000..b25d667d --- /dev/null +++ b/etc/ci/conventions/requirements.txt @@ -0,0 +1,13 @@ +# -*- conf -*- +# -*- coding: utf-8 -*- +# +# michael a.g. aïvázis +# (c) 1998-2026 all rights reserved + +# the tools the convention checks run, pinned so that a local run and the one on a pull request +# agree; formatters change their output from one release to the next +black==26.5.1 +clang-format==23.1.1 +codespell==2.4.3 + +# end of file diff --git a/etc/ci/conventions/selftest.py b/etc/ci/conventions/selftest.py new file mode 100644 index 00000000..481617cf --- /dev/null +++ b/etc/ci/conventions/selftest.py @@ -0,0 +1,405 @@ +# ================================================================================================= +# This code is part of PyLith, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/pylith). +# +# Copyright (c) 2010-2026 All rights reserved.. +# +# See https://mit-license.org/ and LICENSE.md and for license information. +# ================================================================================================= + + +# externals +import datetime +import pathlib +import shutil +import subprocess +import sys +import tempfile + +# the checker under test, next to this file +CHECKER = pathlib.Path(__file__).parent / "check.py" +# the c++ formatting rules of the repository, which the scratch repositories borrow +CLANG_FORMAT = CHECKER.parent.parent.parent.parent / ".clang-format" +# the current year, which the preamble of a touched file must carry +YEAR = datetime.date.today().year +# a misspelling for the spell checker to catch, assembled here so the source that plants it +# does not trip the spell check of this repository +MISSPELLING = "t" + "eh" + + +class SelfTestError(Exception): + """ + The checker did not report what it should have + """ + + +def preamble(*, comment: str, language: str) -> str: + """ + The standard preamble of a source file, in the given {comment} syntax + """ + # assemble it line by line + return ( + f"{comment} -*- {language} -*-\n" + f"{comment} -*- coding: utf-8 -*-\n" + f"{comment}\n" + f"{comment} michael a.g. aïvázis \n" + f"{comment} Copyright (c) 2010-{YEAR} All rights reserved.\n" + ) + + +def git(*args: str, cwd: str) -> str: + """ + Run git in {cwd} and hand back what it says + """ + # run it, failing loudly, since a scratch repository that cannot be built tests nothing + result = subprocess.run(["git", *args], cwd=cwd, capture_output=True, text=True, check=True) + # hand off its output + return result.stdout + + +def write(*, root: str, name: str, text: str) -> None: + """ + Write {text} to the file {name} under {root} + """ + # make room for it + local_dir = pathlib.Path(root) + local_dir.mkdir(exist_ok=True, parents=True) + # and write it + with open(local_dir / name, mode="w", encoding="utf-8") as stream: + # all at once + stream.write(text) + # all done + return + + +def scaffold(*, root: str) -> None: + """ + Lay out a scratch repository whose single commit satisfies every convention + """ + # make the repository + git("init", "--quiet", "--initial-branch=main", cwd=root) + # with an identity for its commits + git("config", "user.name", "self test", cwd=root) + git("config", "user.email", "selftest@example.com", cwd=root) + # the configuration the checks read + write( + root=root, + name="pyproject.toml", + text=preamble(comment="#", language="toml") + + '\n\n[tool.black]\nline-length = 100\n\n[tool.codespell]\nignore-words = "words.txt"\n' + + '\n[tool.conventions]\nexempt = ["vendor/*"]\n' + + "\n\n# End of file\n", + ) + # an empty list of known good words + write(root=root, name="words.txt", text="") + # the c++ formatting rules + shutil.copy(CLANG_FORMAT, pathlib.Path(root) / ".clang-format") + # a python source that follows the conventions + write( + root=root, + name="good.py", + text=preamble(comment="#", language="python") + + '\n\ndef answer():\n """\n The answer\n """\n # hand it off\n return 42\n' + + "\n\n# End of file\n", + ) + # and a c++ one + write( + root=root, + name="good.cc", + text=preamble(comment="//", language="c++") + + "\n\n// the answer\nint\nanswer() {\n // hand it off\n return 42;\n}\n\n\n// End of file\n", + ) + # commit them + git( + "add", + "pyproject.toml", + "words.txt", + ".clang-format", + "good.py", + "good.cc", + cwd=root, + ) + git("commit", "--quiet", "-m", "base: the starting point", cwd=root) + # all done + return + + +def check(*, root: str, base: str | None = None) -> tuple: + """ + Run the checker in {root} and hand back its exit status and report + """ + # the command line + command = [sys.executable, CHECKER] + (["--base", base] if base else []) + # run it + result = subprocess.run(command, cwd=root, capture_output=True, text=True) + # hand off the verdict + return result.returncode, result.stdout + + +def expect(*, report: str, check: str, needle: str) -> None: + """ + Make sure the {check} section of {report} mentions {needle} + """ + # find the section of the check + lines = report.split("\n") + # its header + start = next((i for i, line in enumerate(lines) if line.startswith(f"{check}:")), None) + # a check that did not report at all + if start is None: + # is a failure + raise SelfTestError(f"'{check}' did not report:\n{report}") + # its details are the indented lines that follow + details = [] + # collect them + for line in lines[start + 1 :]: + # until the next section + if not line.startswith(" "): + # which ends this one + break + # otherwise, keep it + details.append(line) + # the needle has to be among them + if not any(needle in line for line in details): + # or else the check missed what it was supposed to catch + raise SelfTestError(f"'{check}' did not mention '{needle}':\n{report}") + # all done + return + + +def clean() -> None: + """ + A repository that follows the conventions passes every check + """ + # in a scratch directory + with tempfile.TemporaryDirectory() as root: + # lay out the repository + scaffold(root=root) + # and check it + status, report = check(root=root, base="main") + # everything passed + if status != 0: + # or else the checker complains about good work + raise SelfTestError(f"a clean repository failed:\n{report}") + # all done + return + + +def violations() -> None: + """ + Each kind of violation is caught by the check that looks for it + """ + # in a scratch directory + with tempfile.TemporaryDirectory() as root: + # lay out the repository + scaffold(root=root) + # work on a branch + git("switch", "--quiet", "-c", "work", cwd=root) + # a python source with a misspelling, bad formatting, and no closing marker + write( + root=root, + name="bad.py", + text=preamble(comment="#", language="python") + f"\n\n# {MISSPELLING} answer\nx=[1,2 ,3]\n", + ) + # a c++ source that is not formatted + write( + root=root, + name="bad.cc", + text=preamble(comment="//", language="c++") + "\nint answer(){return 42;}\n\n\n// End of file\n", + ) + # an existing file touched without bringing its year up to date + with open(pathlib.Path(root) / "good.cc", encoding="utf-8") as stream: + # read it + text = stream.read() + # age its copyright, and change something in it + write( + root=root, + name="good.cc", + text=text.replace(f"1998-{YEAR}", "1998-2000").replace("the answer", "the reply"), + ) + # commit it all with a subject that names no area, and a body + git("add", "bad.py", "bad.cc", "good.cc", cwd=root) + git("commit", "--quiet", "-m", "fixed some things", "-m", "a body", cwd=root) + # check + status, report = check(root=root, base="main") + # the checker failed + if status == 0: + # or else it let everything through + raise SelfTestError(f"violations passed:\n{report}") + # and every check caught its violation + expect(report=report, check="spelling", needle=MISSPELLING) + expect(report=report, check="python", needle="bad.py") + expect(report=report, check="cxx", needle="bad.cc") + expect(report=report, check="preambles", needle="bad.py: does not end") + expect(report=report, check="preambles", needle="good.cc: touched") + expect(report=report, check="commits", needle="is not of the form") + expect(report=report, check="commits", needle="has a body") + # all done + return + + +def layouts() -> None: + """ + Each departure from the standard preamble and postamble layout is caught, and the files the + repository exempts are left alone + """ + # the departures, by file, with what the checker says about each + cases = { + # a mode in mixed case + "upper.py": ( + preamble(comment="#", language="Python") + "\n\nx = 1\n\n\n# End of file\n", + "lower case mode line", + ), + # no coding line + "coding.sh": ( + "# -*- bash -*-\n#\n# michael a.g. aïvázis\n# (c) 1998-2026 All rights reserved.\n" + + "\n\necho\n\n\n# End of file\n", + "mode, coding, spacer, author, and copyright", + ), + # a single blank line after the preamble + "tight.yaml": ( + preamble(comment="#", language="yaml") + "\nkey: value\n\n\n# End of file\n", + "1 blank lines after the preamble", + ), + # a single blank line before the closing marker of a c++ source + "short.cc": ( + preamble(comment="//", language="c++") + "\n\nint x = 0;\n\n// End of file\n", + "1 blank lines before the End of file marker", + ), + # two blank lines between the preamble and the code guard of a header + "guard.h": ( + preamble(comment="//", language="c++") + "\n\n// code guard\n#pragma once\n\n\n// End of file\n", + "2 blank lines after the preamble, instead of 1", + ), + # a makefile named for the data it builds, whose extension is otherwise left alone + "build.data": ( + preamble(comment="#", language="makefile") + "\nall:\n\n\n# End of file\n", + "1 blank lines after the preamble", + ), + # extra blank lines at the end + "trail.toml": ( + preamble(comment="#", language="toml") + "\n\nkey = 1\n\n\n# End of file\n\n", + "exactly one newline", + ), + } + # the departures the checker must not flag: a header with its code guard, a markdown + # document, a dockerfile, a script, a stylesheet, and a file the repository exempts + fine = { + "guard.icc": preamble(comment="//", language="c++") + "\n// code guard\n#pragma once\n\n\n// End of file\n", + "doc.md": "\n\n# title\n\n\n\n", + "Dockerfile": '## -*- docker-image-name: "x:y" -*-\n' + + preamble(comment="#", language="x").split("\n", 1)[1] + + "\n\nFROM ubuntu\n\n\n# End of file\n", + "run.sh": "#!/bin/bash\n" + preamble(comment="#", language="bash") + "\n\necho\n\n\n# End of file\n", + "look.css": "/* -*- css -*- */\n/*\n * -*- coding: utf-8 -*-\n *\n" + + " * PyLith code\n" + + f" * Copyright (c) 2010-{YEAR} All rights reserved.\n */\n\n\na {{\n}}\n\n\n/* End of file */\n", + "_complete": "#compdef complete\n" + + preamble(comment="#", language="zsh") + + "\n\n_arguments\n\n\n# End of file\n", + "page.html": "\n\n\n\n\n\n\n\n\n\n", + "vendor/theirs.js": "// no preamble here\n", + "values.csv": "1,2,3\n", + } + # in a scratch directory + with tempfile.TemporaryDirectory() as root: + # lay out the repository + scaffold(root=root) + # add the files + for name, text in [(name, text) for name, (text, _) in cases.items()] + list(fine.items()): + # one by one + write(root=root, name=name, text=text) + # and let git know about them + git("add", *cases, *fine, cwd=root) + # check the preambles + result = subprocess.run( + [sys.executable, CHECKER, "--only", "preambles"], + cwd=root, + capture_output=True, + text=True, + ) + # every departure was caught + for name, (_, needle) in cases.items(): + # with the right complaint on its own line + if not any(f"{name}: " in line and needle in line for line in result.stdout.split("\n")): + # or else the checker missed it + raise SelfTestError(f"'{name}' was not flagged for '{needle}':\n{result.stdout}") + # and nothing else was + for name in fine: + # by name + if f"{name}: " in result.stdout: + # or else the checker complains about good work + raise SelfTestError(f"'{name}' was flagged:\n{result.stdout}") + # all done + return + + +def bots() -> None: + """ + The commits of a bot are not held to the commit conventions, and the same message from a + person still is + """ + # in a scratch directory + with tempfile.TemporaryDirectory() as root: + # lay out the repository + scaffold(root=root) + # work on a branch + git("switch", "--quiet", "-c", "work", cwd=root) + # the message a dependency update comes with: no area, and a body + message = ["-m", "Bump black from 26.5.1 to 26.6.0", "-m", "the release notes"] + # a bot commits a change with it + write(root=root, name="words.txt", text="tread\n") + git("add", "words.txt", cwd=root) + git("-c", "user.name=dependabot[bot]", "commit", "--quiet", *message, cwd=root) + # which passes + status, report = check(root=root, base="main") + # every check + if status != 0: + # or else the bot is held to conventions it cannot follow + raise SelfTestError(f"a bot commit failed:\n{report}") + # a person commits another change with the same message + write(root=root, name="words.txt", text="tread\nraison\n") + git("add", "words.txt", cwd=root) + git("commit", "--quiet", *message, cwd=root) + # which does not pass + status, report = check(root=root, base="main") + # the commit check catches it + expect(report=report, check="commits", needle="is not of the form") + # all done + return + + +def main() -> int: + """ + Run the self tests + """ + # attempt to + try: + # check a clean repository + clean() + # one full of violations + violations() + # one with every kind of preamble departure + layouts() + # and one with commits by a bot + bots() + # if the checker misbehaved + except SelfTestError as error: + # say how + print(f"selftest: {error}") + # and fail + return 1 + # all good + return 0 + + +# entry point +if __name__ == "__main__": + # run the self tests and report their verdict + sys.exit(main()) + + +# End of file From 5eff4ff647f6af6e791ae87f2e3a292321260a84 Mon Sep 17 00:00:00 2001 From: Brad Aagaard Date: Sun, 15 Nov 2026 21:12:00 -0700 Subject: [PATCH 06/10] conventions: Update check and selftest. --- .clang-format | 17 +- etc/ci/conventions/check.py | 570 +++++++++++++++++++++++++++++---- etc/ci/conventions/selftest.py | 237 +++++++++++--- 3 files changed, 714 insertions(+), 110 deletions(-) diff --git a/.clang-format b/.clang-format index f10f0a3d..117314c6 100644 --- a/.clang-format +++ b/.clang-format @@ -1,3 +1,13 @@ +# -*- yaml -*- +# -*- coding: utf-8 -*- +# +# This code is part of PyLith, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/pylith). +# +# Copyright (c) 2010-2026 All rights reserved. +# +# See https://mit-license.org/ and LICENSE.md and for license information. + --- Language: Cpp AlignAfterOpenBracket: true @@ -161,11 +171,11 @@ IfMacros: - KJ_IF_MAYBE IncludeBlocks: Preserve IncludeCategories: - - Regex: "^\"(llvm|llvm-c|clang|clang-c)/" + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' Priority: 2 SortPriority: 0 CaseSensitive: false - - Regex: "^(<|\"(gtest|gmock|isl|json)/)" + - Regex: '^(<|"(gtest|gmock|isl|json)/)' Priority: 3 SortPriority: 0 CaseSensitive: false @@ -317,4 +327,5 @@ WhitespaceSensitiveMacros: - PP_STRINGIZE - STRINGIZE WrapNamespaceBodyWithEmptyLines: Leave -... + +# End of file diff --git a/etc/ci/conventions/check.py b/etc/ci/conventions/check.py index f8330841..ebc4b327 100644 --- a/etc/ci/conventions/check.py +++ b/etc/ci/conventions/check.py @@ -12,11 +12,16 @@ # externals import argparse +import ast import datetime +import fnmatch +import io import os import re import subprocess import sys +import tokenize +import tomllib # the description of the program, for the help screen DESCRIPTION = """Check a code checkout against the conventions of the repository: @@ -36,30 +41,55 @@ "120", ) -# the sources whose preambles and closing markers are checked, by extension -SOURCES = ( - ".py", - ".h", - ".icc", - ".cc", - ".cpp", - ".cu", - ".js", - ".ts", - ".tsx", - ".mm", - ".yaml", - ".cmake", +# the files whose preambles and closing markers are not checked, by extension, unless they carry +# a preamble anyway: binaries, and formats that cannot carry comments +OPAQUE = ( + ".png", + ".jpg", + ".gif", + ".ico", + ".svg", + ".pdf", + ".graffle", + ".numbers", + ".nb", + ".odb", + ".ttf", + ".woff", + ".woff2", + ".dylib", + ".json", + ".ipynb", + ".csv", + ".txt", + ".dict", + ".dat", + ".data", + ".pub", + ".plist", ) # the c++ sources clang-format looks after CXX = (".h", ".hh", ".icc", ".cc", ".cpp", ".cu") -# the trees that are exempt from the preamble and c++ formatting checks: project templates hold -# substitution markers that are not valid c++ until they are expanded -EXEMPT = ("templates/", "libsrc/spatialdata/muparser/") +# the yaml files, whose formatter keeps a single blank line wherever it finds more +YAML = (".yml", ".yaml", ".clang-format") +# the copyright line, with whatever comment marker precedes it +COPYRIGHT_LINE = re.compile(r"^(?P.*?)Copyright \(c\) 2010-\d{4} All rights reserved.$") +# the lines that open a block comment preamble +OPENERS = ("", "*/}", "*/") +# the lines that may precede the preamble: interpreters, xml declarations and doctypes, along +# with their indented continuations, the magic lines of environment modules and zsh completion +# functions, and the mode line of a stylesheet, which sits outside its block +PRELUDE = re.compile(r"^(#!|<\?xml |(?i:.*?)-\*- (?P[a-z0-9+\-]+|[a-z\-]+: .+) -\*-$") # a commit subject names the area it touches, then says what the commit does: an area is a # path, a package, or a c++ namespace, and several can be listed separated by commas AREA = r"[A-Za-z0-9_.{}/+\-]+(::[A-Za-z0-9_.{}/+\-]+)*" +# so a subject is one or more areas, a colon, and what the commit does SUBJECT = re.compile(rf"^{AREA}(, ?{AREA})*: \S") # the authors whose commits the commit check leaves alone: bots whose messages are beyond our # control, such as the dependency updates dependabot proposes @@ -69,15 +99,21 @@ class ConventionError(Exception): - """The base class of the reasons a check could not run.""" + """ + The base class of the reasons a check could not run + """ class ToolError(ConventionError): - """A tool a check relies on is missing.""" + """ + A tool a check relies on is missing + """ def run(*, command: list, cwd: str) -> subprocess.CompletedProcess: - """Run {command} in {cwd} and capture what it says, complaining if the tool is missing.""" + """ + Run {command} in {cwd} and capture what it says, complaining if the tool is missing + """ # attempt to try: # run the command @@ -86,14 +122,12 @@ def run(*, command: list, cwd: str) -> subprocess.CompletedProcess: except FileNotFoundError as error: # say which one, and where to get it raise ToolError(f"'{command[0]}' is not installed; see etc/ci/conventions/requirements.txt") from error - # if the tool is not installed - except UnicodeDecodeError as error: - # say which one, and where to get it - raise ToolError(f"'{" ".join(command)}' failed due to decoding error") from error def tracked(*, root: str, extensions: tuple = (), exempt: tuple = ()) -> list: - """The files git tracks under {root}, narrowed to {extensions} and outside the {exempt} trees.""" + """ + The files git tracks under {root}, narrowed to {extensions} and outside the {exempt} patterns + """ # ask git names = run(command=["git", "ls-files"], cwd=root).stdout.split("\n") # keep the ones of interest @@ -102,15 +136,76 @@ def tracked(*, root: str, extensions: tuple = (), exempt: tuple = ()) -> list: for name in names if name and (not extensions or name.endswith(extensions)) - and not name.startswith(exempt) + and not any(fnmatch.fnmatch(name, pattern) for pattern in exempt) and os.path.isfile(os.path.join(root, name)) ] +def exemptions(*, root: str) -> tuple: + """ + The patterns of the files the preamble and c++ formatting checks leave alone, as listed in + the {exempt} table of {tool.conventions} in {pyproject.toml} + """ + # the configuration of the repository + path = os.path.join(root, "pyproject.toml") + # a repository without one + if not os.path.isfile(path): + # exempts nothing + return () + # read it + with open(path, mode="rb") as stream: + # all of it + configuration = tomllib.load(stream) + # hand off the patterns + return tuple(configuration.get("tool", {}).get("conventions", {}).get("exempt", [])) + + +def skips(*, root: str) -> tuple: + """ + The patterns of the files the spell check leaves alone, as listed in {skip} of + {tool.codespell} in {pyproject.toml} + """ + # the configuration of the repository + path = os.path.join(root, "pyproject.toml") + # a repository without one + if not os.path.isfile(path): + # skips nothing + return () + # read it + with open(path, mode="rb") as stream: + # all of it + configuration = tomllib.load(stream) + # the patterns are a single string, separated by commas + patterns = configuration.get("tool", {}).get("codespell", {}).get("skip", "") + # split them, and hand off the ones that are not blank + return tuple(pattern.strip() for pattern in patterns.split(",") if pattern.strip()) + + +def skipped(*, name: str, patterns: tuple) -> bool: + """ + Check whether the tracked file {name} matches any of the skip {patterns}, the way codespell + matches them when it walks a directory: against the name of the file and of each directory + above it, and against each of their paths, with and without a leading './' + """ + # the directories above the file, and the file itself + parts = name.split("/") + # the paths that lead to each of them + paths = ["/".join(parts[: n + 1]) for n in range(len(parts))] + # every spelling a pattern may be written against + candidates = parts + paths + [f"./{path}" for path in paths] + # the file is skipped when any pattern matches any of them + return any(fnmatch.fnmatch(candidate, pattern) for candidate in candidates for pattern in patterns) + + def spelling(*, root: str, base: str | None) -> list: - """Spell check the prose of every tracked file, with the exclusions in {pyproject.toml}.""" + """ + Spell check the prose of every tracked file, with the exclusions in {pyproject.toml} + """ + # the files codespell would skip if it walked the tree; named on the command line, it + # checks them regardless, so they are left out here + patterns = skips(root=root) # the files - files = tracked(root=root) + files = [name for name in tracked(root=root) if not skipped(name=name, patterns=patterns)] # check them result = run(command=["codespell", "--toml", "pyproject.toml", *files], cwd=root) # every line of output is a misspelling @@ -119,7 +214,7 @@ def spelling(*, root: str, base: str | None) -> list: if problems: # a word codespell does not know is either a typo or belongs on the reviewed lists problems.append( - "Fix the typos; a real word goes in etc/ci/conventions/codespell-words.txt, and a " + "fix the typos; a real word goes in etc/ci/conventions/codespell-words.txt, and a " "line that is right as it is goes in etc/ci/conventions/codespell-lines.txt" ) # hand off the complaints @@ -127,9 +222,11 @@ def spelling(*, root: str, base: str | None) -> list: def python(*, root: str, base: str | None) -> list: - """Check that every tracked python source is formatted by black.""" + """ + Check that every tracked python source and stub is formatted by black + """ # the files - files = tracked(root=root, extensions=(".py",)) + files = tracked(root=root, extensions=(".py", ".pyi")) # check them # the exclusions in {pyproject.toml} apply even to files named on the command line result = run(command=["black", *BLACK_OPTIONS, "--check", *files], cwd=root) @@ -146,12 +243,12 @@ def python(*, root: str, base: str | None) -> list: def cxx(*, root: str, base: str | None) -> list: - """Check that every tracked c++ source is formatted by clang-format.""" + """ + Check that every tracked c++ source is formatted by clang-format + """ # the files - files = tracked(root=root, extensions=CXX, exempt=EXEMPT) + files = tracked(root=root, extensions=CXX, exempt=exemptions(root=root)) # check them - if not files: - return [] result = run(command=["clang-format", "--dry-run", *files], cwd=root) # clang-format warns once per change it would make; one complaint per file is enough names = sorted({line.split(":")[0] for line in result.stderr.split("\n") if ": warning:" in line}) @@ -160,50 +257,392 @@ def cxx(*, root: str, base: str | None) -> list: def preambles(*, root: str, base: str | None) -> list: - """Check that every tracked source opens with a copyright line and closes with an end of file - marker, and that the files touched since {base} carry the current year. + """ + Check that every tracked file opens with the standard preamble and closes with an end of + file marker, and that the files touched since {base} carry the current year """ # the complaints problems = [] - # the files - files = tracked(root=root, extensions=SOURCES, exempt=EXEMPT) + # the files, minus the exemptions of the repository + files = tracked(root=root, exempt=exemptions(root=root)) # the files touched since the base, when there is one touched = set(changed(root=root, base=base)) if base else set() # the current year year = str(datetime.date.today().year) # go through the files for name in files: - # read the file - with open(os.path.join(root, name), encoding="utf-8") as stream: - # as lines - lines = stream.read().split("\n") + # attempt to + try: + # read the file + with open(os.path.join(root, name), encoding="utf-8") as stream: + # all of it + text = stream.read() + # a file that is not text + except UnicodeDecodeError: + # has no preamble to check + continue + # an opaque format is checked only when the file carries a preamble anyway, as a + # makefile named for the data it builds or a python source named for its role does + if name.endswith(OPAQUE) and not any(COPYRIGHT_LINE.match(line) for line in text.split("\n")[:15]): + # the rest are left alone + continue + # check its layout + problems.extend(f"{name}: {problem}" for problem in layout(name=name, text=text)) # the copyright line sits in the preamble, near the top copyright = next( - (COPYRIGHT.search(line) for line in lines[:12] if COPYRIGHT.search(line)), + (COPYRIGHT.search(line) for line in text.split("\n")[:15] if COPYRIGHT.search(line)), None, ) - # a file without one - if copyright is None: - # is missing its preamble - problems.append(f"{name}: no '(c) 2010-{year} All rights reserved.' in its preamble") # a file touched by the work - elif name in touched and copyright.group(1) != year: + if copyright is not None and name in touched and copyright.group(1) != year: # carries the current year problems.append(f"{name}: touched, but its copyright ends in {copyright.group(1)}") - # the last line that says anything - last = next((line.strip() for line in reversed(lines) if line.strip()), "") - # is the closing marker, in the comment syntax of the file - if not last.lower().removesuffix("*/").strip().endswith("end of file"): - # or else the file is not closed - problems.append(f"{name}: does not end with an 'End of file' marker.") # hand off the complaints return problems +def layout(*, name: str, text: str) -> list: + """ + Check the preamble and postamble of the file {name}, whose contents are {text}: the mode, + coding, spacer, author and copyright lines, then the blank lines the kind of file calls for + before the body and before the end of file marker + """ + # an empty file + if not text: + # has no preamble to speak of + return ["no preamble"] + # the complaints + problems = [] + # the file ends with a single newline + if not text.endswith("\n") or text.endswith("\n\n"): + # or else its last line is not where it should be + problems.append("does not end with exactly one newline") + # split into lines, without the empty one after the final newline + lines = text.rstrip("\n").split("\n") + # the copyright line sits in the preamble, near the top + idx, copyright = next( + ((i, match) for i, line in enumerate(lines[:15]) if (match := COPYRIGHT_LINE.match(line))), + (None, None), + ) + # a file without one + if idx is None or copyright is None: + # is missing its preamble, and nothing else can be said about it + return problems + ["no 'Copyright (c) 2010-YYYY All rights reserved.' in its preamble"] + # the comment marker is whatever precedes the copyright + prefix = copyright.group("prefix") + # a block comment preamble opens on a line of its own + opener = next((i for i in range(idx - 1, -1, -1) if lines[i].strip() in OPENERS), None) + # the comment lines start right after the opener, or with the first line that carries the + # marker, past the lines that may precede the preamble + start = opener + 1 if opener is not None else 0 + # skip the prelude of a line comment preamble + while opener is None and start < idx and PRELUDE.match(lines[start]): + # one line at a time + start += 1 + # every line before the comment, other than the opener, belongs in the prelude + prelude = [line for line in lines[: opener if opener is not None else start] if line] + # so anything else + if not all(PRELUDE.match(line) for line in prelude): + # is out of place + problems.append("unexpected lines above the preamble") + # the comment lines, through the copyright + comment = lines[start : idx + 1] + # the marker, without its trailing space + marker = prefix.rstrip() + # the mode line can sit in the prelude of a stylesheet + moded = any("-*-" in line for line in prelude) + # otherwise, it opens the comment + if not moded: + # get it + mode = MODE.match(comment[0]) if comment else None + # it must be there, in lower case + if not mode or not comment[0].startswith(marker): + # or else the language of the file is not recorded + problems.append("the preamble does not open with a lower case mode line") + # move on + comment = comment[1:] + # the rest of the comment: coding, spacer, at least one author, and the copyright + expected = [f"{prefix}-*- coding: utf-8 -*-", marker] + # compare + if comment[:2] != expected or len(comment) < 4 or any(not line.strip() for line in comment[2:]): + # the preamble has lines missing, extra, or out of order + problems.append("the preamble is not mode, coding, spacer, author, and copyright") + # past the copyright + nxt = idx + 1 + # an optional license pointer, set off from the copyright by a spacer, belongs to the preamble + if ( + nxt + 1 < len(lines) + and lines[nxt] == marker + and lines[nxt + 1].startswith(f"{prefix}See https://mit-license.org/") + ): + # so move past it + nxt += 2 + # a block comment closes on the next line + if opener is not None: + # make sure it does + if nxt >= len(lines) or lines[nxt].strip() not in CLOSERS: + # or else the preamble runs on + problems.append("the preamble block does not close after the copyright") + # and move past it + nxt += 1 + # count the blank lines after the preamble + blanks = 0 + # by walking down + while nxt + blanks < len(lines) and not lines[nxt + blanks]: + # one at a time + blanks += 1 + # the first line of the body + body = lines[nxt + blanks] if nxt + blanks < len(lines) else "" + # a c++ header keeps its code guard next to the preamble, as does a markdown document, and + # black keeps the body of a python stub one line away from it + gap = 1 if body.startswith("// code guard") or name.endswith((".md", ".pyi", *YAML)) else 2 + # check + if blanks != gap: + # and complain + problems.append(f"{blanks} blank lines after the preamble, instead of {gap}") + # the last line + last = lines[-1] + # is the closing marker + if "End of file" not in last: + # or else the file is not closed + problems.append("does not end with an 'End of file' marker") + # and its spacing means nothing + return problems + # count the blank lines before it + blanks = 0 + # by walking up + while blanks < len(lines) - 1 and not lines[-2 - blanks]: + # one at a time + blanks += 1 + # black puts a single blank line after imports, so python decides for itself, and a single + # one at the end of a python stub + allowed = (1, 2) if name.endswith(".py") else (1,) if name.endswith((".pyi", *YAML)) else (2,) + # a file with no body shares the blank lines after the preamble + if len(lines) - 1 - blanks == nxt: + # so its count is the one that matters + allowed = (blanks,) + # check + if blanks not in allowed: + # and complain + problems.append(f"{blanks} blank lines before the End of file marker, instead of {allowed[-1]}") + # hand off the complaints + return problems + + +def narrative(*, root: str, base: str | None) -> list: + """ + Check that every statement of the python sources touched since {base} has a comment on the + line above it, so the comments read as the specification of the code + """ + # without a base there is nothing to check + if not base: + # so say nothing + return [] + # the exemptions of the repository + exempt = exemptions(root=root) + # the complaints + problems = [] + # go through the python sources touched by the work + for name in changed(root=root, base=base): + # skip the ones that are not python, or that the repository exempts + if not name.endswith(".py") or any(fnmatch.fnmatch(name, pattern) for pattern in exempt): + # by moving on + continue + # read the file + with open(os.path.join(root, name), encoding="utf-8") as stream: + # all of it + text = stream.read() + # attempt to + try: + # parse it + tree = ast.parse(text, filename=name) + # a file that does not parse + except SyntaxError as error: + # cannot be checked, which is a problem of its own + problems.append(f"{name}:{error.lineno}: does not parse") + # so move on + continue + # the lines that end with a comment of their own, as class attributes often do + trailing = { + token.start[0] + for token in tokenize.generate_tokens(io.StringIO(text).readline) + if token.type == tokenize.COMMENT and token.line.strip()[0] != "#" + } + # check its statements + problems.extend( + f"{name}:{line}: no comment above this statement" + for line in uncommented(lines=text.split("\n"), trailing=trailing, body=tree.body) + ) + # hand off the complaints + return problems + + +def uncommented(*, lines: list, trailing: set, body: list) -> list: + """ + The line numbers of the statements in {body}, and in the blocks nested in them, that have no + comment on the line above them, or one of their own at the end of their first line; {lines} + is the text of the file, and {trailing} the numbers of the lines that end with a comment + """ + # nothing comes before the first statement of a block + previous = None + # the line numbers of the offenders + offenders = [] + # go through the statements, remembering the one before + for statement in body: + # a docstring documents its block + if isinstance(statement, ast.Expr) and isinstance(getattr(statement, "value", None), ast.Constant): + # and needs no comment + pass + # a function or a class carries a docstring + elif isinstance(statement, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)): + # instead of a comment + pass + # an import that follows another + elif isinstance(statement, (ast.Import, ast.ImportFrom)) and isinstance(previous, (ast.Import, ast.ImportFrom)): + # shares its comment, if the two are adjacent + if not adjacent(statement=statement, previous=previous): + # otherwise it starts a group that needs one of its own + offenders.extend(missing(lines=lines, trailing=trailing, statement=statement)) + # the metadata of a declaration, such as the documentation of a trait, that follows it + elif annotates(statement=statement, previous=previous): + # shares its comment + pass + # everything else + else: + # needs a comment of its own + offenders.extend(missing(lines=lines, trailing=trailing, statement=statement)) + # the blocks nested in the statement + for field in ("body", "orelse", "finalbody"): + # are checked the same way + offenders.extend(uncommented(lines=lines, trailing=trailing, body=getattr(statement, field, None) or [])) + # and so are the handlers of a {try} + for handler in getattr(statement, "handlers", None) or []: + # each with its own block + offenders.extend(uncommented(lines=lines, trailing=trailing, body=handler.body)) + # and the cases of a {match} + for case in getattr(statement, "cases", None) or []: + # each with its own block + offenders.extend(uncommented(lines=lines, trailing=trailing, body=case.body)) + # remember this one + previous = statement + # hand off the offenders + return offenders + + +def subject(*, statement: ast.stmt | None) -> str | None: + """ + The name that {statement} declares, as in {t = pyre.properties.str()}, or annotates, as in + {t.doc = "..."} or {t.aliases |= {"a"}}; {None} for any other statement + """ + # an augmented assignment has a single target + if isinstance(statement, ast.AugAssign): + # which is the one to look at + target = statement.target + # so does a simple assignment that sets one name + elif isinstance(statement, ast.Assign) and len(statement.targets) == 1: + # get it + target = statement.targets[0] + # nothing else has a subject + else: + # so say so + return None + # a declaration names its subject + if isinstance(target, ast.Name): + # directly + return target.id + # an annotation sets an attribute of it + if isinstance(target, ast.Attribute) and isinstance(target.value, ast.Name): + # so the subject is the owner of the attribute + return target.value.id + # anything else has no subject + return None + + +def annotates(*, statement: ast.stmt, previous: ast.stmt | None) -> bool: + """ + Check whether {statement} sets an attribute of the subject of {previous}, on the line right + after it, the way the metadata of a trait follows its declaration + """ + # the statement must set an attribute, or add to one + if isinstance(statement, ast.AugAssign): + # in which case its single target + target = statement.target + # a simple assignment + elif isinstance(statement, ast.Assign): + # sets its first one + target = statement.targets[0] + # and nothing else + else: + # is an annotation + return False + # the target must be an attribute + if not isinstance(target, ast.Attribute): + # or it is not an annotation + return False + # of the subject of the statement right above it + return ( + adjacent(statement=statement, previous=previous) + and subject(statement=statement) is not None + and subject(statement=statement) == subject(statement=previous) + ) + + +def adjacent(*, statement: ast.stmt, previous: ast.stmt | None) -> bool: + """ + Check whether {statement} starts on the line right after the end of {previous} + """ + # a statement with nothing before it, or after one whose extent is unknown + if previous is None or previous.end_lineno is None: + # has no neighbor + return False + # otherwise, the two are neighbors when no line separates them + return statement.lineno - previous.end_lineno == 1 + + +def missing(*, lines: list, trailing: set, statement: ast.stmt) -> list: + """ + The line number of {statement}, if the line above it, or above its decorators, is not a + comment, and its first line does not end with one either + """ + # a statement that carries its comment at the end of its line + if statement.lineno in trailing: + # is commented + return [] + # a decorated statement starts with its first decorator + first = min([statement.lineno, *(d.lineno for d in getattr(statement, "decorator_list", []))]) + # the line above it, counting from one + above = lines[first - 2].strip() if first > 1 else "" + # is a comment, unless it is code that was commented out, or the statement is an offender + return [] if above.startswith("#") and not disabled(comment=above) else [statement.lineno] + + +def disabled(*, comment: str) -> bool: + """ + Check whether {comment} is a line of code that was commented out, rather than prose + """ + # the text of the comment + text = comment.lstrip("#").strip() + # prose rarely carries the punctuation of a call, an assignment, or a subscript + if not any(mark in text for mark in "(=["): + # so this is prose + return False + # attempt to + try: + # parse it as python + ast.parse(text) + # if it does not parse + except SyntaxError: + # it is prose + return False + # otherwise, it is code + return True + + def commits(*, root: str, base: str | None) -> list: - """Check the commits since {base}: a subject that names its area and says what the commit does, + """ + Check the commits since {base}: a subject that names its area and says what the commit does, and nothing after it; the commits of the bots in {BOTS}, whose messages are beyond our - control, are left out. + control, are left out """ # without a base there is nothing to check if not base: @@ -252,10 +691,7 @@ def changed(*, root: str, base: str) -> list: The files added or modified since {base} """ # ask git - result = run( - command=["git", "diff", "--name-only", "--diff-filter=AM", f"{base}...HEAD"], - cwd=root, - ) + result = run(command=["git", "diff", "--name-only", "--diff-filter=AM", f"{base}...HEAD"], cwd=root) # hand off the names return [name for name in result.stdout.split("\n") if name] @@ -270,20 +706,22 @@ def parse() -> argparse.Namespace: parser.add_argument( "--base", default=None, - help="The branch the work is based on, e.g. origin/main; enables the commit and year checks", + help="the branch the work is based on, e.g. origin/main; enables the commit and year checks", ) # a subset of the checks parser.add_argument( "--only", default=",".join(CHECKS), - help=f"A comma separated subset of the checks: {', '.join(CHECKS)}", + help=f"a comma separated subset of the checks: {', '.join(CHECKS)}", ) # parse and hand off return parser.parse_args() def main() -> int: - """Run the requested checks and report what each one found.""" + """ + Run the requested checks and report what each one found + """ # read the command line options = parse() # the top of the checkout @@ -297,7 +735,7 @@ def main() -> int: # so refuse it if unknown: # say which - print(f"Unknown checks: {', '.join(unknown)}; the checks are {', '.join(CHECKS)}") + print(f"unknown checks: {', '.join(unknown)}; the checks are {', '.join(CHECKS)}") # and bail return 2 # the number of checks that found something @@ -313,7 +751,7 @@ def main() -> int: # it counts as a failure problems = [str(error)] # report the verdict - print(f"{name}: {'OK' if not problems else f'{len(problems)} problems'}") + print(f"{name}: {'ok' if not problems else f'{len(problems)} problems'}") # and the details for problem in problems: # one per line diff --git a/etc/ci/conventions/selftest.py b/etc/ci/conventions/selftest.py index 481617cf..2cdfed47 100644 --- a/etc/ci/conventions/selftest.py +++ b/etc/ci/conventions/selftest.py @@ -1,25 +1,23 @@ -# ================================================================================================= -# This code is part of PyLith, developed through the Computational Infrastructure -# for Geodynamics (https://github.com/geodynamics/pylith). +#!/usr/bin/env python3 +# -*- python -*- +# -*- coding: utf-8 -*- # -# Copyright (c) 2010-2026 All rights reserved.. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# michael a.g. aïvázis +# Copyright (c) 2010-2026 all rights reserved # externals import datetime -import pathlib +import os import shutil import subprocess import sys import tempfile # the checker under test, next to this file -CHECKER = pathlib.Path(__file__).parent / "check.py" +CHECKER = os.path.join(os.path.dirname(os.path.abspath(__file__)), "check.py") # the c++ formatting rules of the repository, which the scratch repositories borrow -CLANG_FORMAT = CHECKER.parent.parent.parent.parent / ".clang-format" +CLANG_FORMAT = os.path.join(os.path.dirname(CHECKER), "..", "..", "..", ".clang-format") # the current year, which the preamble of a touched file must carry YEAR = datetime.date.today().year # a misspelling for the spell checker to catch, assembled here so the source that plants it @@ -62,10 +60,9 @@ def write(*, root: str, name: str, text: str) -> None: Write {text} to the file {name} under {root} """ # make room for it - local_dir = pathlib.Path(root) - local_dir.mkdir(exist_ok=True, parents=True) + os.makedirs(os.path.dirname(os.path.join(root, name)) or root, exist_ok=True) # and write it - with open(local_dir / name, mode="w", encoding="utf-8") as stream: + with open(os.path.join(root, name), mode="w", encoding="utf-8") as stream: # all at once stream.write(text) # all done @@ -78,8 +75,9 @@ def scaffold(*, root: str) -> None: """ # make the repository git("init", "--quiet", "--initial-branch=main", cwd=root) - # with an identity for its commits + # with an identity for its commits: a name git("config", "user.name", "self test", cwd=root) + # and an address git("config", "user.email", "selftest@example.com", cwd=root) # the configuration the checks read write( @@ -93,7 +91,7 @@ def scaffold(*, root: str) -> None: # an empty list of known good words write(root=root, name="words.txt", text="") # the c++ formatting rules - shutil.copy(CLANG_FORMAT, pathlib.Path(root) / ".clang-format") + shutil.copy(CLANG_FORMAT, os.path.join(root, ".clang-format")) # a python source that follows the conventions write( root=root, @@ -109,16 +107,9 @@ def scaffold(*, root: str) -> None: text=preamble(comment="//", language="c++") + "\n\n// the answer\nint\nanswer() {\n // hand it off\n return 42;\n}\n\n\n// End of file\n", ) - # commit them - git( - "add", - "pyproject.toml", - "words.txt", - ".clang-format", - "good.py", - "good.cc", - cwd=root, - ) + # stage them + git("add", "pyproject.toml", "words.txt", ".clang-format", "good.py", "good.cc", cwd=root) + # and commit them git("commit", "--quiet", "-m", "base: the starting point", cwd=root) # all done return @@ -207,17 +198,18 @@ def violations() -> None: text=preamble(comment="//", language="c++") + "\nint answer(){return 42;}\n\n\n// End of file\n", ) # an existing file touched without bringing its year up to date - with open(pathlib.Path(root) / "good.cc", encoding="utf-8") as stream: + with open(os.path.join(root, "good.cc"), encoding="utf-8") as stream: # read it text = stream.read() # age its copyright, and change something in it write( root=root, name="good.cc", - text=text.replace(f"1998-{YEAR}", "1998-2000").replace("the answer", "the reply"), + text=text.replace(f"2010-{YEAR}", "2010-2000").replace("the answer", "the reply"), ) - # commit it all with a subject that names no area, and a body + # stage it all git("add", "bad.py", "bad.cc", "good.cc", cwd=root) + # and commit it with a subject that names no area, and a body git("commit", "--quiet", "-m", "fixed some things", "-m", "a body", cwd=root) # check status, report = check(root=root, base="main") @@ -225,13 +217,19 @@ def violations() -> None: if status == 0: # or else it let everything through raise SelfTestError(f"violations passed:\n{report}") - # and every check caught its violation + # and every check caught its violation: the misspelling expect(report=report, check="spelling", needle=MISSPELLING) + # the python formatting expect(report=report, check="python", needle="bad.py") + # the c++ formatting expect(report=report, check="cxx", needle="bad.cc") + # the missing closing marker expect(report=report, check="preambles", needle="bad.py: does not end") + # the stale copyright year expect(report=report, check="preambles", needle="good.cc: touched") + # the subject that names no area expect(report=report, check="commits", needle="is not of the form") + # and the body expect(report=report, check="commits", needle="has a body") # all done return @@ -251,14 +249,14 @@ def layouts() -> None: ), # no coding line "coding.sh": ( - "# -*- bash -*-\n#\n# michael a.g. aïvázis\n# (c) 1998-2026 All rights reserved.\n" + "# -*- bash -*-\n#\n# michael a.g. aïvázis\n# Copyright (c) 2010-2026 All rights reserved.\n" + "\n\necho\n\n\n# End of file\n", "mode, coding, spacer, author, and copyright", ), - # a single blank line after the preamble - "tight.yaml": ( - preamble(comment="#", language="yaml") + "\nkey: value\n\n\n# End of file\n", - "1 blank lines after the preamble", + # two blank lines after the preamble of a yaml file, whose formatter keeps one + "loose.yaml": ( + preamble(comment="#", language="yaml") + "\n\nkey: value\n\n\n# End of file\n", + "2 blank lines after the preamble, instead of 1", ), # a single blank line before the closing marker of a c++ source "short.cc": ( @@ -275,6 +273,11 @@ def layouts() -> None: preamble(comment="#", language="makefile") + "\nall:\n\n\n# End of file\n", "1 blank lines after the preamble", ), + # a python stub spaced like a python source + "loose.pyi": ( + preamble(comment="#", language="python") + "\n\nx: int\n\n\n# End of file\n", + "2 blank lines after the preamble, instead of 1", + ), # extra blank lines at the end "trail.toml": ( preamble(comment="#", language="toml") + "\n\nkey = 1\n\n\n# End of file\n\n", @@ -282,24 +285,27 @@ def layouts() -> None: ), } # the departures the checker must not flag: a header with its code guard, a markdown - # document, a dockerfile, a script, a stylesheet, and a file the repository exempts + # document, a python stub as black lays it out, a dockerfile, a script, a stylesheet, and a + # file the repository exempts fine = { + "tight.yaml": preamble(comment="#", language="yaml") + "\nkey: value\n\n# End of file\n", + "tight.pyi": preamble(comment="#", language="python") + "\nx: int\n\n# End of file\n", "guard.icc": preamble(comment="//", language="c++") + "\n// code guard\n#pragma once\n\n\n// End of file\n", "doc.md": "\n\n# title\n\n\n\n", "Dockerfile": '## -*- docker-image-name: "x:y" -*-\n' + preamble(comment="#", language="x").split("\n", 1)[1] + "\n\nFROM ubuntu\n\n\n# End of file\n", "run.sh": "#!/bin/bash\n" + preamble(comment="#", language="bash") + "\n\necho\n\n\n# End of file\n", "look.css": "/* -*- css -*- */\n/*\n * -*- coding: utf-8 -*-\n *\n" - + " * PyLith code\n" + + " * michael a.g. aïvázis \n" + f" * Copyright (c) 2010-{YEAR} All rights reserved.\n */\n\n\na {{\n}}\n\n\n/* End of file */\n", "_complete": "#compdef complete\n" + preamble(comment="#", language="zsh") + "\n\n_arguments\n\n\n# End of file\n", "page.html": "\n\n\n\n\n\n\n\n\n\n", "vendor/theirs.js": "// no preamble here\n", "values.csv": "1,2,3\n", @@ -337,6 +343,74 @@ def layouts() -> None: return +def narratives() -> None: + """ + A statement without a comment above it is caught in the python sources the work touches, + and the forms the conventions allow are left alone + """ + # in a scratch directory + with tempfile.TemporaryDirectory() as root: + # lay out the repository + scaffold(root=root) + # work on a branch + git("switch", "--quiet", "-c", "work", cwd=root) + # the body of a python source, one line per entry, with what the check must say + body = [ + ("# support", None), + ("import os", None), + ("import sys", None), + ("", None), + ("", None), + ("class gadget:", None), + (' """a gadget"""', None), + ("", None), + (" # the size of the gadget", None), + (" size = os.sep", None), + (' size.doc = "how big"', None), + (" color = sys.platform # the color of the gadget", None), + ("", None), + ("", None), + ("def run():", None), + (' """', None), + (" Run", None), + (' """', None), + (" # print(os.sep)", None), + (" value = 1", "flag"), + (" total = value + 1", "flag"), + (" # all done", None), + (" return total", None), + ] + # the lines of the body start right after the preamble and the two blank lines + first = len(preamble(comment="#", language="python").split("\n")) + 2 + # write the source + write( + root=root, + name="story.py", + text=preamble(comment="#", language="python") + + "\n\n" + + "\n".join(line for line, _ in body) + + "\n\n\n# End of file\n", + ) + # stage it + git("add", "story.py", cwd=root) + # and commit it + git("commit", "--quiet", "-m", "story: a source with gaps in its narrative", cwd=root) + # check + status, report = check(root=root, base="main") + # go through the body + for offset, (line, verdict) in enumerate(body): + # the statements the check must catch + if verdict == "flag": + # are named by their line + expect(report=report, check="narrative", needle=f"story.py:{first + offset}:") + # and the rest + elif f"story.py:{first + offset}:" in report: + # are not + raise SelfTestError(f"'narrative' flagged '{line.strip()}':\n{report}") + # all done + return + + def bots() -> None: """ The commits of a bot are not held to the commit conventions, and the same message from a @@ -350,9 +424,11 @@ def bots() -> None: git("switch", "--quiet", "-c", "work", cwd=root) # the message a dependency update comes with: no area, and a body message = ["-m", "Bump black from 26.5.1 to 26.6.0", "-m", "the release notes"] - # a bot commits a change with it + # a bot makes a change write(root=root, name="words.txt", text="tread\n") + # stages it git("add", "words.txt", cwd=root) + # and commits it with that message git("-c", "user.name=dependabot[bot]", "commit", "--quiet", *message, cwd=root) # which passes status, report = check(root=root, base="main") @@ -360,9 +436,11 @@ def bots() -> None: if status != 0: # or else the bot is held to conventions it cannot follow raise SelfTestError(f"a bot commit failed:\n{report}") - # a person commits another change with the same message + # a person makes another change write(root=root, name="words.txt", text="tread\nraison\n") + # stages it git("add", "words.txt", cwd=root) + # and commits it with the same message git("commit", "--quiet", *message, cwd=root) # which does not pass status, report = check(root=root, base="main") @@ -372,6 +450,81 @@ def bots() -> None: return +def skips() -> None: + """ + The spell check leaves alone the files its skip patterns match, by the name of the file or of + a directory above it, or by their paths, and still checks the rest + """ + # the files with misspellings that the patterns cover, by the pattern that covers each + covered = { + # the name of the file, anywhere in the tree + "web/package-lock.json": "package-lock.json", + # the name of a directory above it + "src/generated/notes.txt": "generated", + # its path, the way the codespell documentation writes it + "share/data/notes.txt": "./share/data/*", + } + # in a scratch directory + with tempfile.TemporaryDirectory() as root: + # lay out the repository + scaffold(root=root) + # skip the files the patterns cover + with open(os.path.join(root, "pyproject.toml"), encoding="utf-8") as stream: + # read the configuration + text = stream.read() + # and add the patterns to it + write( + root=root, + name="pyproject.toml", + text=text.replace( + 'ignore-words = "words.txt"\n', + f'ignore-words = "words.txt"\nskip = "{",".join(covered.values())}"\n', + ), + ) + # plant a misspelling in each of the covered files + for name in covered: + # one by one + write(root=root, name=name, text=f"{MISSPELLING}\n") + # and in one that no pattern covers + write(root=root, name="src/notes.txt", text=f"{MISSPELLING}\n") + # let git know about them + git("add", "pyproject.toml", *covered, "src/notes.txt", cwd=root) + # check the spelling + result = subprocess.run( + [sys.executable, CHECKER, "--only", "spelling"], + cwd=root, + capture_output=True, + text=True, + ) + # the file no pattern covers was checked + expect(report=result.stdout, check="spelling", needle="src/notes.txt") + # and the covered ones were not + for name in covered: + # by name + if f"{name}:" in result.stdout: + # or else the skip patterns were ignored + raise SelfTestError(f"'{name}' was not skipped:\n{result.stdout}") + # the files the checker reported, from the details of its spelling section + checked = {line.strip().split(":")[0] for line in result.stdout.split("\n") if "==>" in line} + # every file in the repository is tracked, so codespell walking it applies the same + # patterns itself, and must report the same files; a release of codespell that matches + # its patterns differently fails here, rather than in the spell check of a repository + walk = subprocess.run( + ["codespell", "--toml", "pyproject.toml", "."], + cwd=root, + capture_output=True, + text=True, + ) + # the files the walk reported, without the leading './' of its paths + walked = {line.split(":")[0].removeprefix("./") for line in walk.stdout.split("\n") if "==>" in line} + # the two must agree + if checked != walked: + # or else the checker no longer skips what codespell skips + raise SelfTestError(f"the checker reported {sorted(checked)}, codespell walking the tree {sorted(walked)}") + # all done + return + + def main() -> int: """ Run the self tests @@ -384,8 +537,10 @@ def main() -> int: violations() # one with every kind of preamble departure layouts() - # and one with commits by a bot + # one with commits by a bot bots() + # and one with files the spell check skips + skips() # if the checker misbehaved except SelfTestError as error: # say how From 91165ad7a0c5f3e234692ce638f91f93a5cbc90d Mon Sep 17 00:00:00 2001 From: Brad Aagaard Date: Thu, 19 Nov 2026 08:30:19 -0700 Subject: [PATCH 07/10] tidy: Clean up preambles. - Add missing preambles. - Update to a standard preamble. - Add developer/fix-preamples-tails.py for fixing preamble and trailer errors. --- .clang-format | 9 +- .dockerignore | 13 + .github/configs/conda-ubuntu.yaml | 13 +- .github/workflows/pr-conda.yaml | 14 +- .github/workflows/pr-conventions.yaml | 15 +- .github/workflows/pr-stage-1.yaml | 13 +- .github/workflows/pr-stage-2.yaml | 13 +- .github/workflows/pr-stages.yaml | 13 +- .gitignore | 13 + .gitlab-ci.yml | 11 + .gitmodules | 13 + .jsbeautifyrc | 87 --- .readthedocs.yaml | 13 +- .travis.yml | 12 +- CHANGES.md | 11 + LICENSE.md | 13 +- Makefile.am | 11 +- README.md | 11 + TODO | 6 - applications/gensimpledb.py | 15 +- azure-pipelines.yml | 11 +- ci-config/codecov.yml | 11 + ci-config/run_tests.sh | 12 + configure.ac | 12 +- developer/autopep8.cfg | 2 - developer/fix-preambles-tails.py | 688 ++++++++++++++++++ developer/headers.txt | 43 -- developer/uncrustify.cfg | 129 ---- developer/updatecopyright.sh | 7 - docker/spatialdata-docenv | 13 + docker/spatialdata-testenv | 13 + docs/Makefile.am | 12 +- docs/_static/css/custom.css | 15 + docs/_templates/sidebar-cig.html | 15 + docs/build.sh | 12 + docs/conf.py | 26 +- docs/developer/index.md | 11 + docs/index.md | 10 + docs/intro/development-plan.md | 13 +- docs/intro/index.md | 11 + docs/intro/preface.md | 11 + docs/intro/quickstart.md | 11 + docs/intro/release-notes.md | 11 + docs/tikz-styles/figcolors.tex | 13 + docs/user/components/geocoords/CSCart.md | 10 + docs/user/components/geocoords/CSGeo.md | 10 + docs/user/components/geocoords/CSGeoLocal.md | 10 + docs/user/components/geocoords/CoordSys.md | 10 + docs/user/components/geocoords/index.md | 11 + docs/user/components/implementations.md | 10 + docs/user/components/index.md | 11 + docs/user/components/spatialdb/AnalyticDB.md | 10 + docs/user/components/spatialdb/CompositeDB.md | 10 + .../user/components/spatialdb/GravityField.md | 10 + docs/user/components/spatialdb/SCECCVMH.md | 10 + docs/user/components/spatialdb/SimpleDB.md | 10 + .../components/spatialdb/SimpleGridAscii.md | 10 + .../user/components/spatialdb/SimpleGridDB.md | 10 + .../components/spatialdb/SimpleIOAscii.md | 10 + .../user/components/spatialdb/SpatialDBObj.md | 10 + docs/user/components/spatialdb/TimeHistory.md | 10 + docs/user/components/spatialdb/UniformDB.md | 10 + .../components/spatialdb/UserFunctionDB.md | 10 + .../spatialdb/generator/GenSimpleDBApp.md | 10 + .../spatialdb/generator/Geometry.md | 10 + .../components/spatialdb/generator/Shaper.md | 10 + .../components/spatialdb/generator/Value.md | 10 + .../components/spatialdb/generator/index.md | 11 + docs/user/components/spatialdb/index.md | 11 + .../components/units/DynamicElasticity.md | 10 + .../components/units/QuasistaticElasticity.md | 10 + docs/user/components/units/Scales.md | 10 + docs/user/components/units/index.md | 11 + docs/user/components/update_components.sh | 16 +- docs/user/components/utils/PointsStream.md | 10 + docs/user/components/utils/UnitTestApp.md | 10 + docs/user/components/utils/index.md | 11 + docs/user/coordsys.md | 13 +- docs/user/figs/csgeolocal.tex | 13 + docs/user/figs/generate.sh | 13 + docs/user/file-formats/index.md | 11 + docs/user/file-formats/simple-ascii.md | 11 + docs/user/file-formats/simple-grid.md | 13 +- docs/user/file-formats/time-history.md | 11 + docs/user/index.md | 11 + docs/user/spatialdb/analyticdb.md | 11 + docs/user/spatialdb/compositedb.md | 13 +- docs/user/spatialdb/gravity-field.md | 11 + docs/user/spatialdb/index.md | 11 + docs/user/spatialdb/overview.md | 11 + docs/user/spatialdb/simpledb.md | 13 +- docs/user/spatialdb/simplegriddb.md | 11 + docs/user/spatialdb/uniformdb.md | 11 + docs/user/timedb/index.md | 11 + etc/ci/conventions/check.py | 50 +- etc/ci/conventions/selftest.py | 29 +- libsrc/Makefile.am | 11 +- libsrc/spatialdata/Makefile.am | 12 +- libsrc/spatialdata/geocoords/CSCart.cc | 11 +- libsrc/spatialdata/geocoords/CSCart.hh | 13 +- libsrc/spatialdata/geocoords/CSGeo.cc | 11 +- libsrc/spatialdata/geocoords/CSGeo.hh | 13 +- libsrc/spatialdata/geocoords/CSGeoLocal.cc | 11 +- libsrc/spatialdata/geocoords/CSGeoLocal.hh | 13 +- .../spatialdata/geocoords/CSPicklerAscii.cc | 11 +- .../spatialdata/geocoords/CSPicklerAscii.hh | 13 +- libsrc/spatialdata/geocoords/Converter.cc | 11 +- libsrc/spatialdata/geocoords/Converter.hh | 13 +- libsrc/spatialdata/geocoords/CoordSys.cc | 11 +- libsrc/spatialdata/geocoords/CoordSys.hh | 13 +- libsrc/spatialdata/geocoords/Makefile.am | 12 +- libsrc/spatialdata/geocoords/geocoordsfwd.hh | 13 +- libsrc/spatialdata/muparser/Makefile.am | 11 +- libsrc/spatialdata/muparser/muparserfwd.hh | 13 +- libsrc/spatialdata/spatialdb/AnalyticDB.cc | 11 +- libsrc/spatialdata/spatialdb/AnalyticDB.hh | 13 +- libsrc/spatialdata/spatialdb/AnalyticDB.icc | 12 +- libsrc/spatialdata/spatialdb/CompositeDB.cc | 11 +- libsrc/spatialdata/spatialdb/CompositeDB.hh | 13 +- libsrc/spatialdata/spatialdb/Exception.hh | 13 +- libsrc/spatialdata/spatialdb/Exception.icc | 13 +- libsrc/spatialdata/spatialdb/GocadVoxet.cc | 11 +- libsrc/spatialdata/spatialdb/GocadVoxet.hh | 13 +- libsrc/spatialdata/spatialdb/GravityField.cc | 11 +- libsrc/spatialdata/spatialdb/GravityField.hh | 13 +- libsrc/spatialdata/spatialdb/Makefile.am | 11 +- libsrc/spatialdata/spatialdb/SCECCVMH.cc | 11 +- libsrc/spatialdata/spatialdb/SCECCVMH.hh | 13 +- libsrc/spatialdata/spatialdb/SCECCVMH.icc | 12 +- libsrc/spatialdata/spatialdb/SimpleDB.cc | 11 +- libsrc/spatialdata/spatialdb/SimpleDB.hh | 13 +- libsrc/spatialdata/spatialdb/SimpleDBData.cc | 11 +- libsrc/spatialdata/spatialdb/SimpleDBData.hh | 13 +- libsrc/spatialdata/spatialdb/SimpleDBData.icc | 12 +- libsrc/spatialdata/spatialdb/SimpleDBQuery.cc | 11 +- libsrc/spatialdata/spatialdb/SimpleDBQuery.hh | 13 +- .../spatialdata/spatialdb/SimpleGridAscii.cc | 11 +- .../spatialdata/spatialdb/SimpleGridAscii.hh | 13 +- libsrc/spatialdata/spatialdb/SimpleGridDB.cc | 11 +- libsrc/spatialdata/spatialdb/SimpleGridDB.hh | 13 +- libsrc/spatialdata/spatialdb/SimpleGridDB.icc | 12 +- libsrc/spatialdata/spatialdb/SimpleIO.cc | 12 +- libsrc/spatialdata/spatialdb/SimpleIO.hh | 13 +- libsrc/spatialdata/spatialdb/SimpleIO.icc | 12 +- libsrc/spatialdata/spatialdb/SimpleIOAscii.cc | 11 +- libsrc/spatialdata/spatialdb/SimpleIOAscii.hh | 13 +- .../spatialdata/spatialdb/SimpleIOAscii.icc | 12 +- libsrc/spatialdata/spatialdb/SpatialDB.cc | 11 +- libsrc/spatialdata/spatialdb/SpatialDB.hh | 13 +- libsrc/spatialdata/spatialdb/SpatialDB.icc | 12 +- libsrc/spatialdata/spatialdb/TimeHistory.cc | 11 +- libsrc/spatialdata/spatialdb/TimeHistory.hh | 13 +- libsrc/spatialdata/spatialdb/TimeHistory.icc | 12 +- libsrc/spatialdata/spatialdb/TimeHistoryIO.cc | 11 +- libsrc/spatialdata/spatialdb/TimeHistoryIO.hh | 13 +- libsrc/spatialdata/spatialdb/UniformDB.cc | 11 +- libsrc/spatialdata/spatialdb/UniformDB.hh | 13 +- libsrc/spatialdata/spatialdb/UniformDB.icc | 12 +- .../spatialdata/spatialdb/UserFunctionDB.cc | 11 +- .../spatialdata/spatialdb/UserFunctionDB.hh | 13 +- libsrc/spatialdata/spatialdb/cspatialdb.cc | 11 +- libsrc/spatialdata/spatialdb/cspatialdb.h | 23 +- libsrc/spatialdata/spatialdb/f77spatialdb.cc | 14 +- libsrc/spatialdata/spatialdb/f77spatialdb.h | 21 +- libsrc/spatialdata/spatialdb/spatialdbfwd.hh | 13 +- libsrc/spatialdata/units/Makefile.am | 11 +- libsrc/spatialdata/units/Parser.cc | 11 +- libsrc/spatialdata/units/Parser.hh | 13 +- libsrc/spatialdata/units/unitsfwd.hh | 13 +- libsrc/spatialdata/utils/LineParser.cc | 11 +- libsrc/spatialdata/utils/LineParser.hh | 13 +- libsrc/spatialdata/utils/Makefile.am | 11 +- libsrc/spatialdata/utils/PointsStream.cc | 11 +- libsrc/spatialdata/utils/PointsStream.hh | 13 +- libsrc/spatialdata/utils/PointsStream.icc | 12 +- .../spatialdata/utils/SpatialdataVersion.cc | 11 +- .../spatialdata/utils/SpatialdataVersion.hh | 13 +- libsrc/spatialdata/utils/utilsfwd.hh | 13 +- modulesrc/Makefile.am | 11 +- modulesrc/geocoords/CSCart.i | 12 +- modulesrc/geocoords/CSGeo.i | 12 +- modulesrc/geocoords/CSGeoLocal.i | 27 +- modulesrc/geocoords/Converter.i | 19 +- modulesrc/geocoords/CoordSys.i | 12 +- modulesrc/geocoords/Makefile.am | 11 +- modulesrc/geocoords/geocoords.i | 76 +- modulesrc/include/Makefile.am | 11 +- modulesrc/include/chararray.i | 99 ++- modulesrc/include/numpy.i | 13 +- modulesrc/module.am | 12 +- modulesrc/spatialdb/AnalyticDB.i | 36 +- modulesrc/spatialdb/CompositeDB.i | 31 +- modulesrc/spatialdb/GravityField.i | 23 +- modulesrc/spatialdb/Makefile.am | 11 +- modulesrc/spatialdb/SCECCVMH.i | 23 +- modulesrc/spatialdb/SimpleDB.i | 23 +- modulesrc/spatialdb/SimpleDBData.i | 27 +- modulesrc/spatialdb/SimpleGridAscii.i | 12 +- modulesrc/spatialdb/SimpleGridDB.i | 51 +- modulesrc/spatialdb/SimpleIO.i | 12 +- modulesrc/spatialdb/SimpleIOAscii.i | 12 +- modulesrc/spatialdb/SpatialDBObj.i | 39 +- modulesrc/spatialdb/TimeHistory.i | 16 +- modulesrc/spatialdb/TimeHistoryIO.i | 19 +- modulesrc/spatialdb/UniformDB.i | 36 +- modulesrc/spatialdb/UserFunctionDB.i | 23 +- modulesrc/spatialdb/spatialdb.i | 95 +-- modulesrc/utils/Makefile.am | 11 +- modulesrc/utils/SpatialdataVersion.i | 12 +- modulesrc/utils/utils.i | 39 +- setup.cfg | 13 + setup.py | 15 +- spatialdata/Makefile.am | 12 +- spatialdata/__init__.py | 15 +- spatialdata/geocoords/CSCart.py | 11 +- spatialdata/geocoords/CSGeo.py | 11 +- spatialdata/geocoords/CSGeoLocal.py | 11 +- spatialdata/geocoords/Converter.py | 10 +- spatialdata/geocoords/CoordSys.py | 11 +- spatialdata/geocoords/__init__.py | 14 +- spatialdata/spatialdb/AnalyticDB.py | 10 +- spatialdata/spatialdb/CompositeDB.py | 11 +- spatialdata/spatialdb/GravityField.py | 11 +- spatialdata/spatialdb/SCECCVMH.py | 11 +- spatialdata/spatialdb/SimpleDB.py | 11 +- spatialdata/spatialdb/SimpleGridAscii.py | 10 +- spatialdata/spatialdb/SimpleGridDB.py | 11 +- spatialdata/spatialdb/SimpleIO.py | 11 +- spatialdata/spatialdb/SimpleIOAscii.py | 11 +- spatialdata/spatialdb/SpatialDBObj.py | 10 +- spatialdata/spatialdb/TimeHistory.py | 11 +- spatialdata/spatialdb/TimeHistoryIO.py | 10 +- spatialdata/spatialdb/UniformDB.py | 10 +- spatialdata/spatialdb/UserFunctionDB.py | 11 +- spatialdata/spatialdb/__init__.py | 15 +- .../spatialdb/generator/GenSimpleDBApp.py | 11 +- spatialdata/spatialdb/generator/Geometry.py | 11 +- spatialdata/spatialdb/generator/Shaper.py | 11 +- spatialdata/spatialdb/generator/Value.py | 11 +- spatialdata/spatialdb/generator/__init__.py | 14 +- spatialdata/testing/TestCases.py | 12 +- spatialdata/testing/UnitTestApp.py | 12 +- spatialdata/testing/__init__.py | 13 +- spatialdata/utils/PointsStream.py | 11 +- spatialdata/utils/__init__.py | 12 +- subpackage.am | 11 +- templates/Makefile.am | 12 +- templates/README | 4 - templates/README.md | 15 + templates/spatialdb/Makefile.am | 11 +- templates/spatialdb/UniformVelModel.cc | 14 +- templates/spatialdb/UniformVelModel.hh | 13 +- templates/spatialdb/UniformVelModel.i | 12 +- templates/spatialdb/UniformVelModel.py | 14 +- templates/spatialdb/__init__.py | 13 +- templates/spatialdb/configure.ac | 37 +- templates/spatialdb/spatialdbcontrib.i | 51 +- templates/spatialdb/tests/Makefile.am | 11 +- .../spatialdb/tests/TestUniformVelModel.py | 10 +- templates/spatialdb/tests/testcontrib.py | 10 +- tests/Makefile.am | 11 +- tests/check.am | 11 +- tests/libtests/Makefile.am | 11 +- tests/libtests/geocoords/Makefile.am | 11 +- tests/libtests/geocoords/TestCSCart.cc | 11 +- tests/libtests/geocoords/TestCSGeo.cc | 11 +- tests/libtests/geocoords/TestCSGeoLocal.cc | 11 +- .../libtests/geocoords/TestCSPicklerAscii.cc | 11 +- tests/libtests/geocoords/TestConverter.cc | 11 +- tests/libtests/geocoords/TestConverter.hh | 13 +- .../libtests/geocoords/TestConverter_Cases.cc | 11 +- tests/libtests/geocoords/test_driver.cc | 11 +- tests/libtests/spatialdb/Makefile.am | 12 +- tests/libtests/spatialdb/TestAnalyticDB.cc | 11 +- tests/libtests/spatialdb/TestCompositeDB.cc | 11 +- tests/libtests/spatialdb/TestGravityField.cc | 11 +- tests/libtests/spatialdb/TestGravityField.hh | 13 +- .../spatialdb/TestGravityField_Cases.cc | 11 +- tests/libtests/spatialdb/TestSCECCVMH.cc | 12 +- tests/libtests/spatialdb/TestSimpleDB.cc | 11 +- tests/libtests/spatialdb/TestSimpleDB.hh | 13 +- tests/libtests/spatialdb/TestSimpleDBData.cc | 11 +- tests/libtests/spatialdb/TestSimpleDBQuery.cc | 11 +- tests/libtests/spatialdb/TestSimpleDBQuery.hh | 13 +- .../spatialdb/TestSimpleDBQuery_Cases.cc | 11 +- .../libtests/spatialdb/TestSimpleDB_Cases.cc | 11 +- .../libtests/spatialdb/TestSimpleGridAscii.cc | 11 +- tests/libtests/spatialdb/TestSimpleGridDB.cc | 11 +- tests/libtests/spatialdb/TestSimpleGridDB.hh | 13 +- .../spatialdb/TestSimpleGridDB_Cases.cc | 11 +- tests/libtests/spatialdb/TestSimpleIOAscii.cc | 11 +- tests/libtests/spatialdb/TestSpatialDB.cc | 11 +- tests/libtests/spatialdb/TestTimeHistory.cc | 11 +- tests/libtests/spatialdb/TestTimeHistoryIO.cc | 11 +- tests/libtests/spatialdb/TestUniformDB.cc | 11 +- .../libtests/spatialdb/TestUserFunctionDB.cc | 11 +- .../libtests/spatialdb/TestUserFunctionDB.hh | 13 +- .../spatialdb/TestUserFunctionDB_Cases.cc | 12 +- tests/libtests/spatialdb/data/Makefile.am | 12 +- tests/libtests/spatialdb/test_driver.cc | 11 +- tests/libtests/spatialdb/testf77query.h | 24 +- tests/libtests/units/Makefile.am | 11 +- tests/libtests/units/TestParser.cc | 11 +- tests/libtests/utils/Makefile.am | 12 +- tests/libtests/utils/TestPointsStream.cc | 11 +- .../libtests/utils/TestSpatialdataVersion.cc | 11 +- tests/pytests/Makefile.am | 11 +- tests/pytests/geocoords/Makefile.am | 12 +- tests/pytests/geocoords/TestCSCart.py | 10 +- tests/pytests/geocoords/TestCSGeo.py | 10 +- tests/pytests/geocoords/TestCSGeoLocal.py | 10 +- tests/pytests/geocoords/TestConverter.py | 10 +- tests/pytests/geocoords/test_geocoords.py | 11 +- tests/pytests/spatialdb/Makefile.am | 12 +- tests/pytests/spatialdb/TestAnalyticDB.py | 11 +- tests/pytests/spatialdb/TestCompositeDB.py | 11 +- tests/pytests/spatialdb/TestGenSimpleDBApp.py | 11 +- tests/pytests/spatialdb/TestGravityField.py | 11 +- tests/pytests/spatialdb/TestSCECCVMH.py.in | 11 +- tests/pytests/spatialdb/TestSimpleDB.py | 11 +- tests/pytests/spatialdb/TestSimpleGridDB.py | 10 +- tests/pytests/spatialdb/TestSimpleIOAscii.py | 11 +- tests/pytests/spatialdb/TestTimeHistory.py | 10 +- tests/pytests/spatialdb/TestTimeHistoryIO.py | 10 +- tests/pytests/spatialdb/TestUniformDB.py | 11 +- tests/pytests/spatialdb/TestUserFunctionDB.py | 10 +- tests/pytests/spatialdb/data/Makefile.am | 11 +- tests/pytests/spatialdb/gensimpledb.cfg | 13 + tests/pytests/spatialdb/test_sceccvmh.py | 10 +- tests/pytests/spatialdb/test_spatialdb.py | 10 +- tests/pytests/spatialdb/testgen1din2d.odb | 1 + tests/pytests/utils/Makefile.am | 11 +- tests/pytests/utils/TestSpatialdataVersion.py | 11 +- tests/pytests/utils/test_utils.py | 10 +- tests/src/Makefile.am | 11 +- tests/src/driver_catch2.cc | 12 +- 336 files changed, 3501 insertions(+), 1917 deletions(-) delete mode 100644 .jsbeautifyrc delete mode 100644 TODO delete mode 100644 developer/autopep8.cfg create mode 100755 developer/fix-preambles-tails.py delete mode 100644 developer/headers.txt delete mode 100644 developer/uncrustify.cfg delete mode 100644 developer/updatecopyright.sh mode change 100644 => 100755 etc/ci/conventions/check.py delete mode 100644 templates/README create mode 100644 templates/README.md diff --git a/.clang-format b/.clang-format index 117314c6..a0b82781 100644 --- a/.clang-format +++ b/.clang-format @@ -1,12 +1,11 @@ # -*- yaml -*- # -*- coding: utf-8 -*- # -# This code is part of PyLith, developed through the Computational Infrastructure -# for Geodynamics (https://github.com/geodynamics/pylith). +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT --- Language: Cpp diff --git a/.dockerignore b/.dockerignore index dfc995e7..c1149b19 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,19 @@ +# -*- gitignore -*- +# -*- coding: utf-8 -*- +# +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + .dockerignore .git .git* autom4te.cache aux-config docker + + +# End of file diff --git a/.github/configs/conda-ubuntu.yaml b/.github/configs/conda-ubuntu.yaml index bbc1e9df..37ddb1c0 100644 --- a/.github/configs/conda-ubuntu.yaml +++ b/.github/configs/conda-ubuntu.yaml @@ -1,11 +1,12 @@ -# ================================================================================================= -# This code is part of PyLith, developed through the Computational Infrastructure -# for Geodynamics (https://github.com/geodynamics/pylith). +# -*- yaml -*- +# -*- coding: utf-8 -*- # -# Copyright (c) 2010-2026 All rights reserved. +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). # -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + # micromamba environment for Ubuntu with the pylith build dependencies name: ci-conda diff --git a/.github/workflows/pr-conda.yaml b/.github/workflows/pr-conda.yaml index 22448c0a..ee239107 100644 --- a/.github/workflows/pr-conda.yaml +++ b/.github/workflows/pr-conda.yaml @@ -1,11 +1,11 @@ -# ================================================================================================= -# This code is part of PyLith, developed through the Computational Infrastructure -# for Geodynamics (https://github.com/geodynamics/pylith). +# -*- yaml -*- +# -*- coding: utf-8 -*- # -# Copyright (c) 2010-2026 All rights reserved. +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). # -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT name: pr-conda @@ -136,4 +136,4 @@ jobs: echo " -- running spatialdata tests" make -j$(nproc) check VERBOSE=1 -# end of file +# End of file diff --git a/.github/workflows/pr-conventions.yaml b/.github/workflows/pr-conventions.yaml index 8ee0dcdc..1cb40d7d 100644 --- a/.github/workflows/pr-conventions.yaml +++ b/.github/workflows/pr-conventions.yaml @@ -1,11 +1,12 @@ -# ================================================================================================= -# This code is part of PyLith, developed through the Computational Infrastructure -# for Geodynamics (https://github.com/geodynamics/pylith). +# -*- yaml -*- +# -*- coding: utf-8 -*- # -# Copyright (c) 2010-2026 All rights reserved. +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). # -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + # Adapted from pyre. # # check a pull request against the conventions of the repository: spelling, the formatting of @@ -70,4 +71,4 @@ jobs: env: BASE: ${{ github.base_ref }} -# end of file +# End of file diff --git a/.github/workflows/pr-stage-1.yaml b/.github/workflows/pr-stage-1.yaml index 7f10b0c4..73142c43 100644 --- a/.github/workflows/pr-stage-1.yaml +++ b/.github/workflows/pr-stage-1.yaml @@ -1,11 +1,12 @@ -# ================================================================================================= -# This code is part of PyLith, developed through the Computational Infrastructure -# for Geodynamics (https://github.com/geodynamics/pylith). +# -*- yaml -*- +# -*- coding: utf-8 -*- # -# Copyright (c) 2010-2026 All rights reserved. +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). # -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + name: stage-1 on: diff --git a/.github/workflows/pr-stage-2.yaml b/.github/workflows/pr-stage-2.yaml index 982b864c..57bc87ac 100644 --- a/.github/workflows/pr-stage-2.yaml +++ b/.github/workflows/pr-stage-2.yaml @@ -1,11 +1,12 @@ -# ================================================================================================= -# This code is part of PyLith, developed through the Computational Infrastructure -# for Geodynamics (https://github.com/geodynamics/pylith). +# -*- yaml -*- +# -*- coding: utf-8 -*- # -# Copyright (c) 2010-2026 All rights reserved. +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). # -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + name: stage-2 on: diff --git a/.github/workflows/pr-stages.yaml b/.github/workflows/pr-stages.yaml index 1cfe4d0b..6f8c414e 100644 --- a/.github/workflows/pr-stages.yaml +++ b/.github/workflows/pr-stages.yaml @@ -1,11 +1,12 @@ -# ================================================================================================= -# This code is part of PyLith, developed through the Computational Infrastructure -# for Geodynamics (https://github.com/geodynamics/pylith). +# -*- yaml -*- +# -*- coding: utf-8 -*- # -# Copyright (c) 2010-2026 All rights reserved. +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). # -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + name: run-ci # a new push to a pull request replaces the runs of the commits it supersedes, so they stop diff --git a/.gitignore b/.gitignore index 82f22870..67ac09e1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,13 @@ +# -*- gitignore -*- +# -*- coding: utf-8 -*- +# +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + /modulesrc/utils/utils.py /modulesrc/utils/utils_wrap.cxx /tests/pytests/spatialdb/TestSCECCVMH.py @@ -32,3 +42,6 @@ stamp-h1 *.o *~ *.pyc + + +# End of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 897e89a2..387cf873 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,12 @@ +# -*- yaml -*- +# -*- coding: utf-8 -*- +# +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + image: docker:latest stages: @@ -109,3 +118,5 @@ manual-doc-job: extends: .doc only: - main + +# End of file diff --git a/.gitmodules b/.gitmodules index 606312d3..62a803ba 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,19 @@ +# -*- config -*- +# -*- coding: utf-8 -*- +# +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + [submodule "m4"] path = m4 url = https://github.com/geodynamics/autoconf_cig.git [submodule "templates/spatialdb/m4"] path = templates/spatialdb/m4 url = ../autoconf_cig.git + + +# End of file diff --git a/.jsbeautifyrc b/.jsbeautifyrc deleted file mode 100644 index e44130ba..00000000 --- a/.jsbeautifyrc +++ /dev/null @@ -1,87 +0,0 @@ -{ - "code_width": 240, - - "input_tab_size": 4, - "output_tab_size": 4, - - "indent_columns": 4, - "indent_with_tabs": 0, - "indent_namespace": True, - "indent_class": True, - "indent_relative_single_line_comments": True, - "indent_col1_comment": True, - "indent_align_string": True, - - "sp_arith": "Ignore", - "sp_assign": "Force", - "sp_assign_default": "Remove", - "sp_enum_assign": "Remove", - "sp_bool": "Add", - "sp_compare": "Add", - "sp_before_byref": "Ignore", - - "sp_before_sparen": "Add", - "sp_inside_sparen": "Remove", - "sp_after_sparen": "Add", - "sp_sparen_brace": "Add", - - "sp_sizeof_paren": "Remove", - "sp_inside_fparens": "Remove", - "sp_inside_fparen": "Remove", - "sp_func_call_paren": "Remove", - "sp_defined_paren": "Remove", - "sp_throw_paren": "Add", - "sp_catch_paren": "Add", - "sp_after_semi": "Ignore", - "sp_else_brace": "Add", - "sp_brace_else": "Add", - "sp_try_brace": "Add", - "sp_before_dc": "Remove", - "sp_after_dc": "Remove", - "sp_cond_colon": "Add", - "sp_cond_question": "Add", - "sp_cmt_cpp_start": "Ignore", - "sp_after_new": "Add", - - "nl_collapse_empty_body": True, - "nl_end_of_file": "Add", - "nl_enum_brace": "Remove", - "nl_struct_brace": "Remove", - "nl_if_brace": "Remove", - "nl_else_brace": "Remove", - "nl_brace_else": "Remove", - "nl_elseif_brace": "Remove", - "nl_else_if": "Remove", - "nl_try_brace": "Remove", - "nl_for_brace": "Remove", - "nl_catch_brace": "Remove", - "nl_brace_catch": "Remove", - "nl_while_brace": "Remove", - "nl_do_brace": "Remove", - "nl_brace_while": "Remove", - "nl_switch_brace": "Remove", - "nl_namespace_brace": "Remove", - "nl_class_brace": "Remove", - "nl_class_init_args": "Add", - "nl_func_type_name": "Add", - "nl_func_type_name_class": "Remove", - "nl_func_proto_type_name": "Remove", - "nl_func_paren": "Remove", - "nl_func_def_paren": "Remove", - "nl_func_decl_start_single": "Remove", - "nl_func_def_start_single": "Remove", - "nl_func_decl_args": "Add", - "nl_func_def_args": "Add", - "nl_func_decl_end": "Remove", - "nl_func_def_end": "Remove", - "nl_create_if_one_liner": True, - "nl_if_leave_one_liners": True, - "nl_after_brace_open": False, - "nl_after_brace_close": False, - "nl_after_brace_open_cmt": False, - - "mod_full_brace_if": "Add", - "mod_full_brace_while": "Add", - "mod_full_paren_if_bool": True - -} diff --git a/.readthedocs.yaml b/.readthedocs.yaml index c0685715..e08cf4fb 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,11 +1,12 @@ -# ================================================================================================= -# This code is part of PyLith, developed through the Computational Infrastructure -# for Geodynamics (https://github.com/geodynamics/pylith). +# -*- yaml -*- +# -*- coding: utf-8 -*- # -# Copyright (c) 2010-2026 All rights reserved. +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). # -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details # Required diff --git a/.travis.yml b/.travis.yml index 23b77e37..7cf7a85b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,13 @@ -# Travis-CI configuration +# -*- yaml -*- +# -*- coding: utf-8 -*- +# +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT +# Travis-CI configuration dist: focal services: @@ -51,3 +59,5 @@ install: script: - ci_env=`bash <(curl -s https://codecov.io/env)` - docker run $ci_env spatialdata-testenv ci-config/run_tests.sh + +# End of file diff --git a/CHANGES.md b/CHANGES.md index b54945e6..4e266db5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + ## main * **Changed** @@ -179,3 +188,5 @@ WKT. ## 2007/01/07 * Changed interfaces to allow spatial dimension of coordinate systems to be 1-D and 2-D instead of just 3-D. + +% End of file diff --git a/LICENSE.md b/LICENSE.md index d6b7aa5a..bb872fdf 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,13 @@ -Copyright (c) 2010-2026 University of California, Davis +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + +Copyright (c) 2010-2026 The SpatialData authors and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -18,3 +27,5 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +% End of file diff --git a/Makefile.am b/Makefile.am index 1892e664..15adf638 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + ACLOCAL_AMFLAGS = -I m4 diff --git a/README.md b/README.md index 6a70854a..cb3d6577 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Spatialdata [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/geodynamics/spatialdata/blob/master/COPYING) @@ -28,3 +37,5 @@ discretization. ## Author * Brad Aagaard, Geologic Hazards Science Center, USGS, USA + +# End of file diff --git a/TODO b/TODO deleted file mode 100644 index 6b3a1763..00000000 --- a/TODO +++ /dev/null @@ -1,6 +0,0 @@ -GEOCOORDS - - Add local origin and rotation to projected coordinate systems. - Update libtest. - - Make it possible to pickle/unpickle to/from file like in C++? diff --git a/applications/gensimpledb.py b/applications/gensimpledb.py index 6ec4bc93..020ce871 100644 --- a/applications/gensimpledb.py +++ b/applications/gensimpledb.py @@ -1,16 +1,15 @@ #!/usr/bin/env nemesis +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= -# @file spatialdata/applications/gensimpledb.py -# -# @brief Generic use of GenSimpleDBApp. +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + +"""Generic use of GenSimpleDBApp.""" # ---------------------------------------------------------------------- if __name__ == "__main__": diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fb2cc7ad..9825c9d8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,4 +1,11 @@ -# Docker +# -*- makefile -*- +# -*- coding: utf-8 -*- +# +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT trigger: - main @@ -74,3 +81,5 @@ stages: addBaseImageData: false - script: docker run spatialdata-testenv ci-config/run_tests.sh displayName: Test + +# End of file diff --git a/ci-config/codecov.yml b/ci-config/codecov.yml index ebedc629..d681079b 100644 --- a/ci-config/codecov.yml +++ b/ci-config/codecov.yml @@ -1,3 +1,12 @@ +# -*- yaml -*- +# -*- coding: utf-8 -*- +# +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + codecov: require_ci_to_pass: yes @@ -16,3 +25,5 @@ parsers: fixes: - "/home/spatialdata-user/src/::" + +# End of file diff --git a/ci-config/run_tests.sh b/ci-config/run_tests.sh index 14e78e9b..c4cd30fe 100755 --- a/ci-config/run_tests.sh +++ b/ci-config/run_tests.sh @@ -1,5 +1,14 @@ #!/bin/bash +# -*- sh -*- +# -*- coding: utf-8 -*- # +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + # WARNING: If test coverage is enabled, this script downlaods the # CodeCov uploader for Linux. # @@ -50,3 +59,6 @@ fi exit 0 + + +# End of file diff --git a/configure.ac b/configure.ac index 93bb1c70..57356bab 100644 --- a/configure.ac +++ b/configure.ac @@ -1,12 +1,12 @@ -dnl ================================================================================================ +dnl -*- autoconf -*- +dnl -*- coding: utf-8 -*- +dnl dnl This code is part of SpatialData, developed through the Computational Infrastructure dnl for Geodynamics (https://github.com/geodynamics/spatialdata). dnl -dnl Copyright (c) 2010-2026, University of California, Davis and the SpatialData Development Team. -dnl All rights reserved. -dnl -dnl See https://mit-license.org/ and LICENSE.md and for license information. -dnl ================================================================================================ +dnl Copyright (c) 2010-2026 The SpatialData authors and contributors +dnl SPDX-License-Identifier: MIT + AC_PREREQ(2.59) AC_INIT([spatialdata], [4.0.1], [baagaard@usgs.gov]) diff --git a/developer/autopep8.cfg b/developer/autopep8.cfg deleted file mode 100644 index 6224f314..00000000 --- a/developer/autopep8.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[pycodestyle] -max-line-length = 120 diff --git a/developer/fix-preambles-tails.py b/developer/fix-preambles-tails.py new file mode 100755 index 00000000..672ea34c --- /dev/null +++ b/developer/fix-preambles-tails.py @@ -0,0 +1,688 @@ +#!/usr/bin/env python3 +# -*- python -*- +# -*- coding: utf-8 -*- +# +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + +"""Fix the preamble and the `End of file` marker in source files. + +The fixes mirror the checks in etc/ci/conventions/check.py: + + * Every file opens with the standard preamble (mode line, coding line, project text, + copyright line, and SPDX license line), written with the comment syntax of the language + of the file. A missing preamble is added, and a preamble with the standard text but a wrong + layout is rewritten, using PREAMBLE_TEMPLATE. A preamble with other text (such as a + legacy copyright notice) is reported and left unchanged. + * The preamble is followed by the number of blank lines the language calls for. + * The file closes with a single `End of file` marker, preceded by the number of blank lines + the language calls for, and followed by exactly one newline. + +By default, files are fixed in place. Use --dry-run to only list files that need changes. + +Example: + fix-preambles-tails.py --path libsrc --regex '.*\\.(cc|hh|icc)$' --dry-run + +A missing marker is added. Files with more than one marker, or with text after the marker, +cannot have their marker fixed automatically. They are reported as errors; any other fix to +them is still applied. + +Files matching the patterns in the `exempt` list of [tool.conventions] in pyproject.toml are +skipped, like check.py skips them. The file is looked for in --path and the directories above it. + +Exit status is 0 if no file needs changes (or all were fixed) and 1 if any file needs changes in +--dry-run mode or could not be fixed. +""" + +import argparse +import dataclasses +import datetime +import fnmatch +import pathlib +import re +import sys +import tomllib +from collections.abc import Iterator, Sequence + +# The standard preamble. Each line is formatted with {c} (the comment character of the +# language), {mode} (the editor mode of the language), {year} (the last year of the copyright), +# and {LICENSE_TAG} (the SPDX identifier of the license). A line holding only {c} is a spacer. +PREAMBLE_TEMPLATE = """\ +{c} -*- {mode} -*- +{c} -*- coding: utf-8 -*- +{c} +{c} This code is part of SpatialData, developed through the Computational Infrastructure +{c} for Geodynamics (https://github.com/geodynamics/spatialdata). +{c} +{c} Copyright (c) 2010-{year} The SpatialData authors and contributors +{c} SPDX-License-Identifier: {LICENSE_TAG} +""" + +# The license written in a new preamble. +DEFAULT_LICENSE = "MIT" +# The text of the end of file marker, after the comment character. +MARKER_TEXT = "End of file" +# The number of lines, from the top of a file, searched for the copyright line. +WINDOW = 15 +# The name of the file that lists the exempt patterns, in the `exempt` list of [tool.conventions]. +CONFIG_NAME = "pyproject.toml" +# The license line, which ends a preamble, with the SPDX identifier of the license. +LICENSE_RE = re.compile(r"SPDX-License-Identifier:(?:\s*(?P\S.*?))?\s*$") +# The longest comment block that is taken to be a preamble, so that a long comment that happens +# to follow the copyright line is never swallowed. +MAX_PREAMBLE = 20 +# The copyright line, with any text before it and any closing year. +COPYRIGHT_RE = re.compile(r"Copyright \(c\) 2010-(?P\d{4})\b") +# Any copyright line, including the legacy forms that do not match the standard text. +LEGACY_COPYRIGHT_RE = re.compile(r"Copyright \(c\)") +# The mode line a stylesheet keeps above its comment block. +OUTER_MODE_RE = re.compile(r"^/\*\s+-\*- .+ -\*-\s+\*/$") +# The text that marks an editor variable line, such as the mode and coding lines. +EDITOR_VARIABLES = "-*-" +# The lines that stay above the preamble in a file with a shebang line. +SHEBANG = r"#!" +# The lines that stay above the preamble in a web page. +WEB_PRELUDE = r"(?i: str: + """Return the end of file marker of the language, with its comment syntax.""" + if self.block: + return f"{self.block[0]} {MARKER_TEXT} {self.block[1]}" + return f"{self.comment} {MARKER_TEXT}" + + def matches(self, path: pathlib.Path) -> bool: + """Return whether the file at {path} is written in this language.""" + return path.name in self.names or path.suffix in self.suffixes or path.parent.name in self.directories + + def is_comment(self, line: str) -> bool: + """Return whether the {line} is a line comment, or a spacer holding only the comment character.""" + return line.rstrip() == self.comment or line.startswith(self.comment + " ") + + +# The languages, in the order they are tried. Black keeps one blank line after imports, so a +# python file may close with one or two; the formatters of markdown, yaml, and python stubs +# keep a single blank line. Dockerfiles are recognized last, since any file in a docker +# directory is taken for one if it is not another language. +LANGUAGES = ( + Language("c++", "//", suffixes=(".h", ".hh", ".icc", ".cc", ".cpp", ".cu", ".i")), + Language("c", " *", suffixes=(".c",), block=("/*", "*/")), + Language("css", " *", suffixes=(".css",), block=("/*", "*/"), outer_mode="/* -*- {mode} -*- */"), + Language("html", "", suffixes=(".html", ".htm"), block=(""), prelude=WEB_PRELUDE), + Language("python", "#", suffixes=(".py",), blank_before_marker=(2, 1)), + Language("python", "#", suffixes=(".pyi",), blank_after_preamble=1, blank_before_marker=(1,)), + Language("makefile", "#", suffixes=(".am",), names=("Makefile",)), + Language("config", "#", suffixes=(".cfg",)), + Language( + "yaml", + "#", + suffixes=(".yml", ".yaml"), + names=(".clang-format",), + blank_after_preamble=1, + blank_before_marker=(1,), + ), + Language("markdown", "%", suffixes=(".md",), blank_after_preamble=1, blank_before_marker=(1,)), + Language("autoconf", "dnl", suffixes=(".ac", ".m4")), + Language("sh", "#", suffixes=(".sh",)), + Language("dockerfile", "#", suffixes=(".dockerfile",), names=("Dockerfile",), directories=("docker",)), +) + + +def find_language(path: pathlib.Path) -> Language | None: + """Return the language of the file at {path}, or None if it is not one of the LANGUAGES.""" + return next((language for language in LANGUAGES if language.matches(path)), None) + + +@dataclasses.dataclass(frozen=True) +class PreambleSpan: + """The place of an existing preamble in the lines of a file. + + The preamble occupies the lines from {start} up to, but not including, {end}. It records + the closing {year} of its copyright and the SPDX identifier of its {license}, either of + which may be None. + """ + + start: int + end: int + year: str | None + license: str | None = None + + +class PreambleTemplate: + """The standard preamble, as text that is formatted for a language and a year.""" + + def __init__(self, text: str = PREAMBLE_TEMPLATE) -> None: + """Create the template from the {text}, one preamble line per line of text.""" + self.text = text + + def render(self, language: Language, year: str, license_tag: str = DEFAULT_LICENSE) -> list[str]: + """Return the lines of the preamble for the {language}, with a copyright ending in {year} and the {license_tag}. + + The comment syntax and editor mode are those of the language. Trailing space is + removed, so spacer lines hold only the comment character. A block language has its + delimiters around the lines, and a stylesheet its mode line above the block. + """ + values = {"c": language.comment, "mode": language.mode, "year": year, "LICENSE_TAG": license_tag} + lines = [] + outer = [] + for template in self.text.splitlines(): + line = template.format(**values).rstrip() + # a comment of nothing starts no line, so the space after it goes too + line = line[1:] if not language.comment and line.startswith(" ") else line + if language.outer_mode and "{mode}" in template: + outer.append(language.outer_mode.format(**values)) + else: + lines.append(line) + if language.block: + # a closer lines up with the stars of a comment that has them + indent = " " if language.comment.startswith(" ") else "" + lines = [language.block[0], *lines, indent + language.block[1]] + return outer + lines + + +class PreambleLocator: + """The search for an existing preamble in the lines of a file.""" + + def __init__(self, language: Language) -> None: + """Create the locator for files written in the {language}.""" + self.language = language + self.prelude_re = re.compile(language.prelude) + + def prelude(self, lines: Sequence[str]) -> int: + """Return the number of lines at the top of the {lines} that stay above the preamble.""" + count = 0 + while count < len(lines) and self.prelude_re.match(lines[count]): + count += 1 + return count + + def locate(self, lines: Sequence[str]) -> PreambleSpan | None: + """Return the span of the preamble in the {lines}, or None if the file has none. + + A line comment preamble is the run of comment lines around the first copyright line in + the top of the file, below the lines that stay above it. A block comment preamble is + the block around the copyright line, with the mode line of a stylesheet above it. A + copyright line in any form counts, so a legacy preamble is found and not duplicated. A + preamble that is too long, or a block that cannot be delimited, raises FixError. + """ + top = self.prelude(lines) + found = next( + ( + index + for index in range(top, min(len(lines), WINDOW)) + if LEGACY_COPYRIGHT_RE.search(lines[index]) + and (self.language.block or self.language.is_comment(lines[index])) + ), + None, + ) + if found is None: + return None + start, end = self._block(lines, found, top) if self.language.block else self._run(lines, found, top) + if end - start > MAX_PREAMBLE: + raise FixError(f"comment of {end - start} lines around the copyright is too long to be a preamble") + year = next((match["year"] for line in lines[start:end] if (match := COPYRIGHT_RE.search(line))), None) + license = next((match["tag"] for line in lines[start:end] if (match := LICENSE_RE.search(line))), None) + return PreambleSpan(start, end, year, license) + + def _run(self, lines: Sequence[str], found: int, top: int) -> tuple[int, int]: + """Return the start and end of the run of line comments in the {lines} around the line {found}, below {top}.""" + start = found + while start > top and self.language.is_comment(lines[start - 1]): + start -= 1 + end = found + 1 + while end < len(lines) and self.language.is_comment(lines[end]): + end += 1 + # the preamble ends with the license, and any spacers after it, and not with the comments that follow + license = next((i for i in range(found, end) if LICENSE_RE.search(lines[i])), None) + if license is not None: + stop = license + 1 + while stop < end and lines[stop].rstrip() == self.language.comment: + stop += 1 + end = stop + return start, end + + def _block(self, lines: Sequence[str], found: int, top: int) -> tuple[int, int]: + """Return the start and end of the block comment in the {lines} around the line {found}, below {top}. + + The delimiters must each be on a line of their own, or FixError is raised. The mode + line of a stylesheet is part of the block when it is on the line above. + """ + opener, closer = self.language.block + start = next((i for i in range(found - 1, top - 1, -1) if lines[i].strip() == opener), None) + end = next((i for i in range(found + 1, len(lines)) if lines[i].strip() == closer), None) + if start is None or end is None: + raise FixError(f"copyright is not in a block comment with '{opener}' and '{closer}' on lines of their own") + if self.language.outer_mode and start > top and OUTER_MODE_RE.match(lines[start - 1]): + start -= 1 + return start, end + 1 + + +@dataclasses.dataclass +class Fix: + """The outcome of fixing the text of one file. + + The fixed {lines} replace the original, {changes} describes what was changed, and the + {errors} describe what could not be fixed. + """ + + lines: list[str] + changes: list[str] = dataclasses.field(default_factory=list) + errors: list[str] = dataclasses.field(default_factory=list) + + +class SourceFixer: + """The fixes for the files written in one language.""" + + def __init__( + self, + language: Language, + template: PreambleTemplate, + year: str, + update_year: bool = False, + ) -> None: + """Create the fixer for the {language}, writing preambles from the {template}. + + A new preamble ends its copyright in {year}. The year of an existing preamble is kept, + unless {update_year} is set. + """ + self.language = language + self.template = template + self.year = year + self.update_year = update_year + self.locator = PreambleLocator(language) + self.marker_re = re.compile(r"^[ \t]*" + re.escape(language.marker) + r"[ \t]*$") + + def fix_preamble(self, lines: list[str]) -> Fix: + """Return the {lines} with the standard preamble, and the blank lines that follow it. + + A missing preamble is added below the lines that stay above it. A preamble with the + standard text is rewritten when it differs from the template in anything but trailing + space; the editor variable lines (mode and coding) are not part of the text, and the + license, whatever it is, is kept. A preamble with any other text is kept, reported as an error, and only its blank lines are fixed. + """ + span = self.locator.locate(lines) + if span is None: + start = end = self.locator.prelude(lines) + year, license = self.year, DEFAULT_LICENSE + else: + start, end = span.start, span.end + year = self.year if self.update_year or not span.year else span.year + license = span.license or DEFAULT_LICENSE + preamble = self.template.render(self.language, year, license) + body = lines[end:] + while body and not body[0].strip(): + body.pop(0) + blanks = self.language.blank_after_preamble + if body and body[0].startswith(f"{self.language.comment} {CODE_GUARD}"): + blanks = 1 + head = lines[:start] + # a block sits a blank line below the lines above it + if span is None and head and self.language.block: + head = head + [""] + current = lines[start:end] + fix = Fix([]) + if span is None: + middle = preamble + fix.changes.append("added preamble") + else: + # the text is standard, whatever the year of the copyright and the editor variables + shown = [line.rstrip() for line in current] + # spacers after the license are not part of the text + while shown and shown[-1] == self.language.comment and not self.language.block: + shown.pop() + existing = self.template.render(self.language, span.year or year, license) + standard = self._text(shown) == self._text(existing) + if not standard: + middle = current + fix.errors.append("non-standard preamble text; preamble left unchanged") + elif shown != preamble or len(shown) != len(current): + middle = preamble + fix.changes.append("rewrote preamble") + else: + # differing only in trailing space, it is left as it is + middle = current + fix.lines = head + middle + [""] * blanks + body + if not fix.changes and lines[end : end + blanks + 1] != [""] * blanks + body[:1]: + fix.changes.append("fixed blank lines after preamble") + return fix + + @staticmethod + def _text(lines: Sequence[str]) -> list[str]: + """Return the {lines} of a preamble without its editor variable lines.""" + return [line for line in lines if EDITOR_VARIABLES not in line] + + def _locate(self, lines: Sequence[str]) -> PreambleSpan | None: + """Return the span of the preamble in the {lines}, or None if there is none or it cannot be delimited.""" + try: + return self.locator.locate(lines) + except FixError: + return None + + def fix_marker(self, lines: list[str]) -> Fix: + """Return the {lines} with the blank lines before the end of file marker that the language calls for. + + A file with no marker gets one. A file with more than one marker, or text after the + marker, is returned with an error. The blank lines are left alone when the file has no + body, since then they are the ones that follow the preamble, and when their count is one + the language allows. + """ + fix = Fix(list(lines)) + marks = [index for index, line in enumerate(lines) if self.marker_re.match(line)] + if not marks: + return self.add_marker(lines) + if len(marks) > 1: + fix.errors.append(f"multiple '{self.language.marker}' markers") + return fix + body = lines[: marks[0]] + if any(line.strip() for line in lines[marks[0] + 1 :]): + fix.errors.append(f"text found after '{self.language.marker}' marker") + return fix + span = self._locate(lines) + floor = span.end if span else 0 + blanks = len(body) - len(list(self._strip(body))) + if not any(line.strip() for line in body[floor:]): + # no body: the blank lines belong to the preamble + return fix + if blanks in self.language.blank_before_marker: + kept = lines[: marks[0]] + else: + kept = list(self._strip(body)) + [""] * self.language.blank_before_marker[0] + fix.changes.append("fixed blank lines before end of file marker") + fix.lines = kept + [self.language.marker] + return fix + + def add_marker(self, lines: list[str]) -> Fix: + """Return the {lines} with the end of file marker added at the end. + + The marker follows the blank lines the language calls for. They are those before the + marker when the file has a body, and those after the preamble when it has none. + """ + kept = list(self._strip(lines)) + span = self._locate(kept) + has_body = any(line.strip() for line in kept[span.end if span else 0 :]) + if has_body: + blanks = self.language.blank_before_marker[0] + else: + blanks = self.language.blank_after_preamble if span else 0 + fix = Fix(kept + [""] * blanks + [self.language.marker]) + fix.changes.append("added end of file marker") + return fix + + @staticmethod + def _strip(lines: Sequence[str]) -> Iterator[str]: + """Yield the {lines} without the blank lines at the end.""" + end = len(lines) + while end and not lines[end - 1].strip(): + end -= 1 + yield from lines[:end] + + def fix_text(self, text: str, preamble: bool = True, marker: bool = True) -> tuple[str, Fix]: + """Return the fixed {text} of a file, and the account of the fixes. + + The preamble is fixed when {preamble} is set, and the end of file marker is fixed when + {marker} is set. The line endings of the text are kept. + """ + newline = "\r\n" if "\r\n" in text else "\n" + lines = text.replace("\r\n", "\n").split("\n") + if lines and lines[-1] == "": + lines.pop() + total = Fix(lines) + if preamble: + try: + step = self.fix_preamble(total.lines) + except FixError as err: + total.errors.append(str(err)) + else: + total.lines = step.lines + total.changes += step.changes + total.errors += step.errors + if marker: + step = self.fix_marker(total.lines) + total.lines = step.lines + total.changes += step.changes + total.errors += step.errors + fixed = newline.join(total.lines) + newline if total.lines else "" + if fixed != text and not total.changes and not total.errors: + total.changes.append("fixed trailing newlines") + return fixed, total + + +def find_config(path: pathlib.Path) -> pathlib.Path | None: + """Return the pyproject.toml in the directory {path} or the nearest directory above it, or None if there is none.""" + start = path.resolve() + return next((d / CONFIG_NAME for d in (start, *start.parents) if (d / CONFIG_NAME).is_file()), None) + + +def load_exemptions(config: pathlib.Path) -> tuple[str, ...]: + """Return the patterns of the exempt files listed in the {exempt} list of [tool.conventions] in the file {config}.""" + with config.open("rb") as stream: + table = tomllib.load(stream) + return tuple(table.get("tool", {}).get("conventions", {}).get("exempt", [])) + + +@dataclasses.dataclass +class Tally: + """The count of the files checked, changed, and in error.""" + + checked: int = 0 + changed: int = 0 + errors: int = 0 + + +class Runner: + """The fixing of every file under a directory.""" + + def __init__( + self, + path: pathlib.Path, + pattern: re.Pattern[str], + root: pathlib.Path, + exclude: Sequence[str], + fixers: dict[Language, SourceFixer], + dry_run: bool, + preamble: bool, + marker: bool, + ) -> None: + """Create the runner for the files under {path} whose full path matches {pattern}. + + Files whose path relative to the repository {root} matches a glob in {exclude} are + skipped; these are the exempt patterns of the repository and any given on the command + line. Each file + is fixed by the fixer of its language in {fixers}; the files are only reported when + {dry_run} is set, and the {preamble} and {marker} fixes can each be turned off. + """ + self.path = path + self.pattern = pattern + self.root = root.resolve() + self.exclude = exclude + self.fixers = fixers + self.dry_run = dry_run + self.preamble = preamble + self.marker = marker + self.tally = Tally() + + def find_files(self) -> Iterator[pathlib.Path]: + """Yield the files under the path to fix: those that match the pattern, are not excluded, and are not in .git.""" + for filename in sorted(self.path.rglob("*")): + if ( + filename.is_file() + and ".git" not in filename.relative_to(self.path).parts + and self.pattern.search(str(filename)) + and not self.excluded(filename) + ): + yield filename + + def excluded(self, filename: pathlib.Path) -> bool: + """Return whether the file at {filename} matches an exclude pattern, by its path relative to the root.""" + try: + relative = filename.resolve().relative_to(self.root) + except ValueError: + relative = filename.relative_to(self.path) + return any(fnmatch.fnmatch(relative.as_posix(), glob) for glob in self.exclude) + + def process(self, filename: pathlib.Path) -> None: + """Fix the file at {filename}, report what was done, and update the tally. + + Files in a language that is not known, and files that are not text, are skipped. + """ + language = find_language(filename) + if language is None: + return + try: + # newline="" preserves existing line endings. + with filename.open("r", newline="", encoding="utf-8") as f: + text = f.read() + except UnicodeDecodeError: + return + self.tally.checked += 1 + new_text, fix = self.fixers[language].fix_text(text, self.preamble, self.marker) + for error in fix.errors: + print(f"{filename}: ERROR: {error}") + if fix.errors: + self.tally.errors += 1 + if new_text == text: + return + self.tally.changed += 1 + details = ", ".join(fix.changes) + if self.dry_run: + print(f"{filename}: needs fix ({details})") + else: + with filename.open("w", newline="", encoding="utf-8") as f: + f.write(new_text) + print(f"{filename}: fixed ({details})") + + def run(self) -> int: + """Fix every file, print the summary, and return the exit status: 1 if any file needs changes or is in error.""" + for filename in self.find_files(): + self.process(filename) + verb = "need changes" if self.dry_run else "fixed" + print(f"Checked {self.tally.checked} file(s): {self.tally.changed} {verb}, {self.tally.errors} error(s).") + return 1 if (self.tally.errors or (self.dry_run and self.tally.changed)) else 0 + + +def build_parser() -> argparse.ArgumentParser: + """Return the parser of the command line arguments.""" + parser = argparse.ArgumentParser( + description=f"Fix the preamble and the '{MARKER_TEXT}' marker of source files.", + ) + parser.add_argument( + "--regex", + default=".", + help="Regular expression matched (re.search) against file paths. Default: %(default)s", + ) + parser.add_argument( + "--path", + default=pathlib.Path("."), + type=pathlib.Path, + help="Directory to search recursively. Default: %(default)s", + ) + parser.add_argument( + "--exclude", + action="append", + default=[], + metavar="GLOB", + help="Glob matched against the path relative to the repository root; matching files are skipped, " + "in addition to the exempt patterns in pyproject.toml. May be repeated.", + ) + parser.add_argument( + "--config", + type=pathlib.Path, + help=f"The {CONFIG_NAME} with the exempt patterns; its directory is the repository root. " + "Default: the first one in --path or the directories above it.", + ) + parser.add_argument( + "--only", + choices=("preamble", "marker"), + help="Fix only the preamble or only the end of file marker. Default: both.", + ) + parser.add_argument( + "--year", + default=str(datetime.date.today().year), + help="Last year of the copyright in new preambles. Default: %(default)s", + ) + parser.add_argument( + "--update-year", + action="store_true", + help="Also set the year of existing preambles to --year.", + ) + parser.add_argument( + "--dry-run", + action="store_true", + help="Only show files needing changes; do not modify them.", + ) + return parser + + +def main(argv: Sequence[str] | None = None) -> int: + """Fix the files named by the command line {argv}, or by sys.argv, and return the exit status.""" + parser = build_parser() + args = parser.parse_args(argv) + try: + pattern = re.compile(args.regex) + except re.error as err: + parser.error(f"invalid regular expression: {err}") + if not re.fullmatch(r"\d{4}", args.year): + parser.error(f"year must have four digits: {args.year}") + if not args.path.is_dir(): + parser.error(f"search path is not a directory: {args.path}") + + config = args.config or find_config(args.path) + if config is not None and not config.is_file(): + parser.error(f"configuration file not found: {config}") + exempt = load_exemptions(config) if config else () + root = config.parent if config else args.path + + template = PreambleTemplate() + fixers = {language: SourceFixer(language, template, args.year, args.update_year) for language in LANGUAGES} + runner = Runner( + path=args.path, + pattern=pattern, + root=root, + exclude=[*exempt, *args.exclude], + fixers=fixers, + dry_run=args.dry_run, + preamble=args.only != "marker", + marker=args.only != "preamble", + ) + return runner.run() + + +if __name__ == "__main__": + sys.exit(main()) + + +# End of file diff --git a/developer/headers.txt b/developer/headers.txt deleted file mode 100644 index aabf4d3a..00000000 --- a/developer/headers.txt +++ /dev/null @@ -1,43 +0,0 @@ -// ================================================================================================= -// This code is part of SpatialData, developed through the Computational Infrastructure -// for Geodynamics (https://github.com/geodynamics/spatialdata). -// -// Copyright (c) 2010-2023, University of California, Davis and the SpatialData Development Team. -// All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= - -# ================================================================================================= -# This code is part of SpatialData, developed through the Computational Infrastructure -# for Geodynamics (https://github.com/geodynamics/spatialdata). -# -# Copyright (c) 2010-2023, University of California, Davis and the SpatialData Development Team. -# All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= - - -/* - * ================================================================================================ - * This code is part of SpatialData, developed through the Computational Infrastructure - * for Geodynamics (https://github.com/geodynamics/spatialdata). - * - * Copyright (c) 2010-2023, University of California, Davis and the SpatialData Development Team. - * All rights reserved. - * - * See https://mit-license.org/ and LICENSE.md and for license information. - * ================================================================================================= - */ - - -dnl ================================================================================================ -dnl This code is part of SpatialData, developed through the Computational Infrastructure -dnl for Geodynamics (https://github.com/geodynamics/spatialdata). -dnl -dnl Copyright (c) 2010-2023, University of California, Davis and the SpatialData Development Team. -dnl All rights reserved. -dnl -dnl See https://mit-license.org/ and LICENSE.md and for license information. -dnl ================================================================================================ diff --git a/developer/uncrustify.cfg b/developer/uncrustify.cfg deleted file mode 100644 index 9eb18da2..00000000 --- a/developer/uncrustify.cfg +++ /dev/null @@ -1,129 +0,0 @@ -# Uncrustify 0.59 -# -# General options -# -newlines = lf -input_tab_size = 4 -output_tab_size = 4 - -indent_columns = 4 -indent_with_tabs = 0 -indent_namespace = True -indent_class = True -indent_relative_single_line_comments = True -indent_col1_comment = True -indent_align_string = True -indent_extern = True - -# Space -sp_arith = Ignore -sp_assign = Force -sp_assign_default = Remove -sp_enum_assign = Remove -sp_bool = Add -sp_compare = Add -sp_before_byref = Ignore - -sp_before_sparen = Add -sp_inside_sparen = Remove -sp_after_sparen = Add -sp_sparen_brace = Add - -sp_sizeof_paren = Remove -sp_inside_fparens = Remove -sp_inside_fparen = Remove -sp_func_call_paren = Remove -sp_return_paren = Add -sp_defined_paren = Remove -sp_throw_paren = Add -sp_catch_paren = Add -sp_after_semi = Remove -sp_else_brace = Add -sp_brace_else = Add -sp_try_brace = Add -sp_before_dc = Remove -sp_after_dc = Remove -sp_cond_colon = Add -sp_cond_question = Add -sp_cmt_cpp_start = Add -sp_cmt_cpp_doxygen = true -sp_endif_cmt = Add -sp_after_new = Add -sp_paren_brace = Add -sp_fparen_brace = Add -sp_before_tr_emb_cmt = Force -sp_num_before_tr_emb_cmt = 1 - -# Align -align_left_shift = True - -# Newline -nl_collapse_empty_body = True -nl_end_of_file = Add -nl_end_of_file_min = 1 -nl_enum_brace = Remove -nl_struct_brace = Remove -nl_if_brace = Remove -nl_else_brace = Remove -nl_brace_else = Remove -nl_elseif_brace = Remove -nl_elseif_brace = Remove -nl_else_if = Remove -nl_try_brace = Remove -nl_for_brace = Remove -nl_catch_brace = Remove -nl_brace_catch = Remove -nl_while_brace = Remove -nl_do_brace = Remove -nl_brace_while = Remove -nl_switch_brace = Remove -nl_namespace_brace = Remove -nl_class_brace = Remove -nl_class_init_args = Add -nl_func_type_name = Add -nl_func_type_name_class = Remove -nl_func_proto_type_name = Remove -nl_func_paren = Remove -nl_func_def_paren = Remove -nl_func_decl_start_single = Remove -nl_func_def_start_single = Remove -nl_func_decl_args = Add -nl_func_def_args = Add -nl_func_decl_end = Remove -nl_func_def_end = Remove -nl_func_scope_name = Remove -nl_fdef_brace = Remove -nl_create_if_one_liner = True -nl_if_leave_one_liners = True -nl_after_brace_open = False -nl_after_brace_close = False -nl_after_brace_open_cmt = False -nl_max = 2 -nl_after_func_proto = 2 -nl_after_func_body = 3 -nl_after_func_body_class = 2 -nl_after_func_body_one_liner = 3 -nl_after_struct = 1 -#nl_after_class = 2 # (if enabled, adds nweline between }; and //) -nl_before_access_spec = 0 -nl_after_access_spec = 2 -eat_blanks_after_open_brace = True - -# -mod_full_brace_do = Add -mod_full_brace_for = Add -mod_full_brace_if = Add -mod_full_brace_while = Add -mod_full_paren_if_bool = True -mod_remove_extra_semicolon = True -mod_remove_empty_return = True - -# Comments -cmt_width = 120 -cmt_c_nl_end = True -cmt_cpp_nl_end =True -cmt_star_cont = True -cmt_sp_after_star_cont = 0 - -# Preprocessor -pp_indent = Remove diff --git a/developer/updatecopyright.sh b/developer/updatecopyright.sh deleted file mode 100644 index c4426484..00000000 --- a/developer/updatecopyright.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -for suffix in .cc .icc .hh .h .am .py .i .odb .dat .in *.ac; do - for f in `find . -name "*$suffix"` aclocal.m4 CHANGES README COPYING; do - sed -e "s/Copyright (c) 2010-2017 University of California, Davis/Copyright (c) 2010-2017 University of California, Davis/g" $f > tmp && mv -f tmp $f - done -done diff --git a/docker/spatialdata-docenv b/docker/spatialdata-docenv index 87eea7fa..ffd071aa 100644 --- a/docker/spatialdata-docenv +++ b/docker/spatialdata-docenv @@ -1,3 +1,13 @@ +# -*- dockerfile -*- +# -*- coding: utf-8 -*- +# +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + # docker build --build-arg BASE_IMAGE=${VARIABLE_NAME} -f DOCKERFILE . -t IMAGE_NAME . ARG BASE_IMAGE @@ -16,3 +26,6 @@ RUN python3 -m pip install -r requirements.txt RUN ./build.sh CMD /bin/bash + + +# End of file diff --git a/docker/spatialdata-testenv b/docker/spatialdata-testenv index 07adef75..ba3e5dc8 100644 --- a/docker/spatialdata-testenv +++ b/docker/spatialdata-testenv @@ -1,3 +1,13 @@ +# -*- dockerfile -*- +# -*- coding: utf-8 -*- +# +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + # docker build --build-arg BASE_IMAGE=${VARIABLE_NAME} --build-arg TEST_COVERAGE=yes/no --build-arg PYTHON_COVERAGE=${COVERAGE_EXECUTABLE} -f DOCKERFILE . -t IMAGE_NAME . # BUILD CIG DEPENDENCIES ---------- @@ -55,3 +65,6 @@ RUN make coverage-libtests RUN make coverage-pytests CMD /bin/bash + + +# End of file diff --git a/docs/Makefile.am b/docs/Makefile.am index 5d51b691..2a05c878 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -1,12 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= -# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + dist_noinst_DATA = \ conf.py \ diff --git a/docs/_static/css/custom.css b/docs/_static/css/custom.css index b090bf70..33663b48 100644 --- a/docs/_static/css/custom.css +++ b/docs/_static/css/custom.css @@ -1,3 +1,15 @@ +/* -*- css -*- */ +/* + * -*- coding: utf-8 -*- + * + * This code is part of SpatialData, developed through the Computational Infrastructure + * for Geodynamics (https://github.com/geodynamics/spatialdata). + * + * Copyright (c) 2010-2026 The SpatialData authors and contributors + * SPDX-License-Identifier: MIT + */ + + html { /* Heading font sizes */ --pst-font-size-h1: 28px; /* 36 */ @@ -26,3 +38,6 @@ html { flex: 10; max-width: 100%; } + + +/* End of file */ diff --git a/docs/_templates/sidebar-cig.html b/docs/_templates/sidebar-cig.html index 820be59f..c397b4c9 100644 --- a/docs/_templates/sidebar-cig.html +++ b/docs/_templates/sidebar-cig.html @@ -1,3 +1,18 @@ + + +
CIG Logo
+ + + diff --git a/docs/build.sh b/docs/build.sh index f2f7afa7..625c3974 100755 --- a/docs/build.sh +++ b/docs/build.sh @@ -1,4 +1,13 @@ #!/bin/bash +# -*- sh -*- +# -*- coding: utf-8 -*- +# +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + formats=("html") if [ $# -gt 0 ]; then @@ -13,3 +22,6 @@ for format in ${formats[*]}; do done exit 0 + + +# End of file diff --git a/docs/conf.py b/docs/conf.py index 6279e1fb..1ea31ee3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,16 +1,20 @@ -# ================================================================================================= -# This code is part of PyLith, developed through the Computational Infrastructure -# for Geodynamics (https://github.com/geodynamics/pylith). +#!/usr/bin/env python3 +# -*- python -*- +# -*- coding: utf-8 -*- # -# Copyright (c) 2010-2026 All rights reserved. +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). # -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= -# Configuration file for the Sphinx documentation builder. -# -# This file only contains a selection of the most common options. For a full -# list see the documentation: -# https://www.sphinx-doc.org/en/master/usage/configuration.html +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + +"""Configuration file for the Sphinx documentation builder. + +This file only contains a selection of the most common options. For a full +list see the documentation: +https://www.sphinx-doc.org/en/master/usage/configuration.html +""" # -- Path setup -------------------------------------------------------------- diff --git a/docs/developer/index.md b/docs/developer/index.md index 4d13c028..7fb58c94 100644 --- a/docs/developer/index.md +++ b/docs/developer/index.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Developer Guide :::{admonition} Under construction. @@ -10,3 +19,5 @@ Placeholder for developer guide. %contributing.md %testing.md %::: + +% End of file diff --git a/docs/index.md b/docs/index.md index 115e6b5a..84af601f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # SpatialData SpatialData is a Python and C++ library for @@ -31,3 +40,4 @@ user/index.md developer/index.md ``` +% End of file diff --git a/docs/intro/development-plan.md b/docs/intro/development-plan.md index 96f6c3a4..7882ad72 100644 --- a/docs/intro/development-plan.md +++ b/docs/intro/development-plan.md @@ -1,7 +1,18 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Development Plan ## Version 3.x.xdev List of new features currently available in the `main` branch. -No new features. \ No newline at end of file +No new features. + +% End of file diff --git a/docs/intro/index.md b/docs/intro/index.md index b374c2e8..2ae6903d 100644 --- a/docs/intro/index.md +++ b/docs/intro/index.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Introduction ```{toctree} @@ -9,3 +18,5 @@ quickstart.md release-notes.md development-plan.md ``` + +% End of file diff --git a/docs/intro/preface.md b/docs/intro/preface.md index a8b93c72..8cfeb102 100644 --- a/docs/intro/preface.md +++ b/docs/intro/preface.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Preface ## Conventions @@ -64,3 +73,5 @@ Any opinions, findings, and conclusions or recommendations expressed in this mat Your suggestions and corrections can only improve this documentation. Please report any errors, inaccuracies, or typos to the PyLith section of the CIG Community Forum or create a GitHub pull request. + +% End of file diff --git a/docs/intro/quickstart.md b/docs/intro/quickstart.md index d003d731..483af9ce 100644 --- a/docs/intro/quickstart.md +++ b/docs/intro/quickstart.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Quickstart ```{admonition} Under construction @@ -5,3 +14,5 @@ Placeholder for quick start information. ``` + +% End of file diff --git a/docs/intro/release-notes.md b/docs/intro/release-notes.md index 32273a01..46872179 100644 --- a/docs/intro/release-notes.md +++ b/docs/intro/release-notes.md @@ -1,4 +1,15 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Release Notes ```{include} ../../CHANGES.md ``` + +% End of file diff --git a/docs/tikz-styles/figcolors.tex b/docs/tikz-styles/figcolors.tex index 677feb8f..f1e7d385 100644 --- a/docs/tikz-styles/figcolors.tex +++ b/docs/tikz-styles/figcolors.tex @@ -1,3 +1,13 @@ +% -*- tex -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + + \definecolor{yellow}{rgb}{1.0, 1.0, 0.45} % 255/255/115 \definecolor{dkyellow}{rgb}{0.9, 0.9, 0.0} % % 230/230/0 @@ -20,3 +30,6 @@ \definecolor{dkslate}{rgb}{0.18, 0.21, 0.28} % 47/53/72 \definecolor{mdslate}{rgb}{0.45, 0.50, 0.68} % 114/127/173 \definecolor{ltslate}{rgb}{0.85, 0.88, 0.95} % 216/225/229 + + +% End of file diff --git a/docs/user/components/geocoords/CSCart.md b/docs/user/components/geocoords/CSCart.md index b2e374f3..003c4a97 100644 --- a/docs/user/components/geocoords/CSCart.md +++ b/docs/user/components/geocoords/CSCart.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # CSCart % WARNING: Do not edit; this is a generated file! @@ -27,3 +36,4 @@ units = meter space_dim = 3 ::: +% End of file diff --git a/docs/user/components/geocoords/CSGeo.md b/docs/user/components/geocoords/CSGeo.md index 5f8eee65..e4f13928 100644 --- a/docs/user/components/geocoords/CSGeo.md +++ b/docs/user/components/geocoords/CSGeo.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # CSGeo % WARNING: Do not edit; this is a generated file! @@ -28,3 +37,4 @@ crs_string = EPSG:4326 space_dim = 2 ::: +% End of file diff --git a/docs/user/components/geocoords/CSGeoLocal.md b/docs/user/components/geocoords/CSGeoLocal.md index 4e615a49..3c098db7 100644 --- a/docs/user/components/geocoords/CSGeoLocal.md +++ b/docs/user/components/geocoords/CSGeoLocal.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # CSGeoLocal % WARNING: Do not edit; this is a generated file! @@ -40,3 +49,4 @@ origin_y = 4000000.0 y_azimuth = -25.0 ::: +% End of file diff --git a/docs/user/components/geocoords/CoordSys.md b/docs/user/components/geocoords/CoordSys.md index 6d1f2e02..33b0e00c 100644 --- a/docs/user/components/geocoords/CoordSys.md +++ b/docs/user/components/geocoords/CoordSys.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # CoordSys % WARNING: Do not edit; this is a generated file! @@ -6,3 +15,4 @@ Python abstract base class for coordinate systems. +% End of file diff --git a/docs/user/components/geocoords/index.md b/docs/user/components/geocoords/index.md index 83f05c7d..7e04146c 100644 --- a/docs/user/components/geocoords/index.md +++ b/docs/user/components/geocoords/index.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # geocoords % WARNING: Do not edit; this is a generated file. @@ -11,3 +20,5 @@ CSGeo.md CSGeoLocal.md CoordSys.md ::: + +% End of file diff --git a/docs/user/components/implementations.md b/docs/user/components/implementations.md index 84b39e57..94401399 100644 --- a/docs/user/components/implementations.md +++ b/docs/user/components/implementations.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Component Implementations ## Coordinate systems @@ -39,3 +48,4 @@ [`TimeHistory`](spatialdb/TimeHistory.md) : User-specified time history using a file. +% End of file diff --git a/docs/user/components/index.md b/docs/user/components/index.md index ac16d310..96f48e5e 100644 --- a/docs/user/components/index.md +++ b/docs/user/components/index.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + (sec-user-components)= # SpatialData Components @@ -14,3 +23,5 @@ spatialdb/generator/index.md units/index.md utils/index.md ::: + +% End of file diff --git a/docs/user/components/spatialdb/AnalyticDB.md b/docs/user/components/spatialdb/AnalyticDB.md index a4f10065..755be7be 100644 --- a/docs/user/components/spatialdb/AnalyticDB.md +++ b/docs/user/components/spatialdb/AnalyticDB.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # AnalyticDB % WARNING: Do not edit; this is a generated file! @@ -44,3 +53,4 @@ cs = spatialdata.geocoords.CSCart cs.space_dim = 3 ::: +% End of file diff --git a/docs/user/components/spatialdb/CompositeDB.md b/docs/user/components/spatialdb/CompositeDB.md index 43171fe0..ccf58c39 100644 --- a/docs/user/components/spatialdb/CompositeDB.md +++ b/docs/user/components/spatialdb/CompositeDB.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # CompositeDB % WARNING: Do not edit; this is a generated file! @@ -50,3 +59,4 @@ db_B.description = Wave speed spatial database. db_B.iohandler.filename = vpvs.spatialdb ::: +% End of file diff --git a/docs/user/components/spatialdb/GravityField.md b/docs/user/components/spatialdb/GravityField.md index 1a1c06b1..5005fc5f 100644 --- a/docs/user/components/spatialdb/GravityField.md +++ b/docs/user/components/spatialdb/GravityField.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # GravityField % WARNING: Do not edit; this is a generated file! @@ -32,3 +41,4 @@ gravity_dir = [0, -1] acceleration = 9.80665*meter/second**2 ::: +% End of file diff --git a/docs/user/components/spatialdb/SCECCVMH.md b/docs/user/components/spatialdb/SCECCVMH.md index 1c2d45ba..d6ec542c 100644 --- a/docs/user/components/spatialdb/SCECCVMH.md +++ b/docs/user/components/spatialdb/SCECCVMH.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # SCECCVMH % WARNING: Do not edit; this is a generated file! @@ -42,3 +51,4 @@ squash = False squash_limit = -20.0*km ::: +% End of file diff --git a/docs/user/components/spatialdb/SimpleDB.md b/docs/user/components/spatialdb/SimpleDB.md index 8ce7d2ec..e41981a7 100644 --- a/docs/user/components/spatialdb/SimpleDB.md +++ b/docs/user/components/spatialdb/SimpleDB.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # SimpleDB % WARNING: Do not edit; this is a generated file! @@ -37,3 +46,4 @@ query_type = linear iohandler.filename = mat_elastic.spatialdb ::: +% End of file diff --git a/docs/user/components/spatialdb/SimpleGridAscii.md b/docs/user/components/spatialdb/SimpleGridAscii.md index 9023c597..1e9d30ab 100644 --- a/docs/user/components/spatialdb/SimpleGridAscii.md +++ b/docs/user/components/spatialdb/SimpleGridAscii.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # SimpleGridAscii % WARNING: Do not edit; this is a generated file! @@ -22,3 +31,4 @@ Example of setting `SimpleGridAscii` Pyre properties and facilities in a paramet dbio.filename = mat_elastic.spatialdb ::: +% End of file diff --git a/docs/user/components/spatialdb/SimpleGridDB.md b/docs/user/components/spatialdb/SimpleGridDB.md index 80668794..14527427 100644 --- a/docs/user/components/spatialdb/SimpleGridDB.md +++ b/docs/user/components/spatialdb/SimpleGridDB.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # SimpleGridDB % WARNING: Do not edit; this is a generated file! @@ -35,3 +44,4 @@ filename = mat_elastic.spatialdb query_type = linear ::: +% End of file diff --git a/docs/user/components/spatialdb/SimpleIOAscii.md b/docs/user/components/spatialdb/SimpleIOAscii.md index dc145f79..65acc66f 100644 --- a/docs/user/components/spatialdb/SimpleIOAscii.md +++ b/docs/user/components/spatialdb/SimpleIOAscii.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # SimpleIOAscii % WARNING: Do not edit; this is a generated file! @@ -24,3 +33,4 @@ Example of setting `SimpleIOAscii` Pyre properties and facilities in a parameter filename = mat_elastic.spatialdb ::: +% End of file diff --git a/docs/user/components/spatialdb/SpatialDBObj.md b/docs/user/components/spatialdb/SpatialDBObj.md index fa9537c7..0c6d8286 100644 --- a/docs/user/components/spatialdb/SpatialDBObj.md +++ b/docs/user/components/spatialdb/SpatialDBObj.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # SpatialDBObj % WARNING: Do not edit; this is a generated file! @@ -13,3 +22,4 @@ Python abstract base class for spatial database. - **current value**: '', from {default} - **validator**: +% End of file diff --git a/docs/user/components/spatialdb/TimeHistory.md b/docs/user/components/spatialdb/TimeHistory.md index c08efddc..a4248610 100644 --- a/docs/user/components/spatialdb/TimeHistory.md +++ b/docs/user/components/spatialdb/TimeHistory.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # TimeHistory % WARNING: Do not edit; this is a generated file! @@ -26,3 +35,4 @@ description = Time history for Dirichlet boundary condition filename = displacement.timedb ::: +% End of file diff --git a/docs/user/components/spatialdb/UniformDB.md b/docs/user/components/spatialdb/UniformDB.md index d64f7117..10092f85 100644 --- a/docs/user/components/spatialdb/UniformDB.md +++ b/docs/user/components/spatialdb/UniformDB.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # UniformDB % WARNING: Do not edit; this is a generated file! @@ -32,3 +41,4 @@ values = [density, vp, vs] data = [2000*kg/m**3, 2.0*km/s, 1000*m/s] ::: +% End of file diff --git a/docs/user/components/spatialdb/UserFunctionDB.md b/docs/user/components/spatialdb/UserFunctionDB.md index daa2bd4b..f65355bb 100644 --- a/docs/user/components/spatialdb/UserFunctionDB.md +++ b/docs/user/components/spatialdb/UserFunctionDB.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # UserFunctionDB % WARNING: Do not edit; this is a generated file! @@ -34,3 +43,4 @@ cs = spatialdata.geocoords.CSCart cs.space_dim = 2 ::: +% End of file diff --git a/docs/user/components/spatialdb/generator/GenSimpleDBApp.md b/docs/user/components/spatialdb/generator/GenSimpleDBApp.md index 028dcc17..ea7433c0 100644 --- a/docs/user/components/spatialdb/generator/GenSimpleDBApp.md +++ b/docs/user/components/spatialdb/generator/GenSimpleDBApp.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # GenSimpleDBApp % WARNING: Do not edit; this is a generated file! @@ -92,3 +101,4 @@ db.query_type = linear db.iohandler.filename = vs_scaling.spatialdb ::: +% End of file diff --git a/docs/user/components/spatialdb/generator/Geometry.md b/docs/user/components/spatialdb/generator/Geometry.md index 58b19187..96d5f4bc 100644 --- a/docs/user/components/spatialdb/generator/Geometry.md +++ b/docs/user/components/spatialdb/generator/Geometry.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Geometry % WARNING: Do not edit; this is a generated file! @@ -33,3 +42,4 @@ reader = read_geometry coordsys = spatialdata.geocoords.CSCart ::: +% End of file diff --git a/docs/user/components/spatialdb/generator/Shaper.md b/docs/user/components/spatialdb/generator/Shaper.md index cb5594dd..ccc8a470 100644 --- a/docs/user/components/spatialdb/generator/Shaper.md +++ b/docs/user/components/spatialdb/generator/Shaper.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Shaper % WARNING: Do not edit; this is a generated file! @@ -49,3 +58,4 @@ db = spatialdata.spatialdb.SimpleGridDB db.filename = density_perturbation.spatialdb ::: +% End of file diff --git a/docs/user/components/spatialdb/generator/Value.md b/docs/user/components/spatialdb/generator/Value.md index fb6678ac..301d19bb 100644 --- a/docs/user/components/spatialdb/generator/Value.md +++ b/docs/user/components/spatialdb/generator/Value.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Value % WARNING: Do not edit; this is a generated file! @@ -35,3 +44,4 @@ units = m/s shapers = [bg, perturbation] ::: +% End of file diff --git a/docs/user/components/spatialdb/generator/index.md b/docs/user/components/spatialdb/generator/index.md index a7c7dea5..99f589af 100644 --- a/docs/user/components/spatialdb/generator/index.md +++ b/docs/user/components/spatialdb/generator/index.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # spatialdb/generator % WARNING: Do not edit; this is a generated file. @@ -11,3 +20,5 @@ Geometry.md Shaper.md Value.md ::: + +% End of file diff --git a/docs/user/components/spatialdb/index.md b/docs/user/components/spatialdb/index.md index 28fe181e..637d3605 100644 --- a/docs/user/components/spatialdb/index.md +++ b/docs/user/components/spatialdb/index.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # spatialdb % WARNING: Do not edit; this is a generated file. @@ -19,3 +28,5 @@ TimeHistory.md UniformDB.md UserFunctionDB.md ::: + +% End of file diff --git a/docs/user/components/units/DynamicElasticity.md b/docs/user/components/units/DynamicElasticity.md index 0d92bbaa..fe2e720a 100644 --- a/docs/user/components/units/DynamicElasticity.md +++ b/docs/user/components/units/DynamicElasticity.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # DynamicElasticity % WARNING: Do not edit; this is a generated file! @@ -34,3 +43,4 @@ mass_density = 3.0*kg/m**3 wave_period = 2.0*s ::: +% End of file diff --git a/docs/user/components/units/QuasistaticElasticity.md b/docs/user/components/units/QuasistaticElasticity.md index 572fc595..abc89ec1 100644 --- a/docs/user/components/units/QuasistaticElasticity.md +++ b/docs/user/components/units/QuasistaticElasticity.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # QuasistaticElasticity % WARNING: Do not edit; this is a generated file! @@ -34,3 +43,4 @@ shear_modulus = 30.0*GPa relaxation_time = 200.0*year ::: +% End of file diff --git a/docs/user/components/units/Scales.md b/docs/user/components/units/Scales.md index f32388a5..b16a58e3 100644 --- a/docs/user/components/units/Scales.md +++ b/docs/user/components/units/Scales.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Scales % WARNING: Do not edit; this is a generated file! @@ -6,3 +15,4 @@ Abstract base class for nondimensionalizing problems. +% End of file diff --git a/docs/user/components/units/index.md b/docs/user/components/units/index.md index 3b1a1773..dc4cd532 100644 --- a/docs/user/components/units/index.md +++ b/docs/user/components/units/index.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # units % WARNING: Do not edit; this is a generated file. @@ -10,3 +19,5 @@ DynamicElasticity.md QuasistaticElasticity.md Scales.md ::: + +% End of file diff --git a/docs/user/components/update_components.sh b/docs/user/components/update_components.sh index 1c443a74..a02226c8 100755 --- a/docs/user/components/update_components.sh +++ b/docs/user/components/update_components.sh @@ -1,2 +1,16 @@ -~/src/cig/pythia/bin/pyre_doc_components.py --package=SpatialData --src-path=$PYENV/pylith-debug/lib/python3.12/site-packages/spatialdata --output-path=./ --manual-toc=toc.json +#!/bin/bash +# -*- sh -*- +# -*- coding: utf-8 -*- +# +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + +~/src/cig/pythia/bin/pyre_doc_components.py --package=SpatialData --src-path=$PYLITH_DIR/lib/python$PYTHON_VERSION/site-packages/spatialdata --output-path=./ --manual-toc=toc.json cat index.md | sed -e "s#apps/index.md#implementations.md\\napps/index.md#g" > tmp.md && mv -f tmp.md index.md + + +# End of file diff --git a/docs/user/components/utils/PointsStream.md b/docs/user/components/utils/PointsStream.md index 597e46ad..7e9bdcb9 100644 --- a/docs/user/components/utils/PointsStream.md +++ b/docs/user/components/utils/PointsStream.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # PointsStream % WARNING: Do not edit; this is a generated file! @@ -29,3 +38,4 @@ comment_flag = # number_format = %14.5e ::: +% End of file diff --git a/docs/user/components/utils/UnitTestApp.md b/docs/user/components/utils/UnitTestApp.md index 8944eaad..cb607e47 100644 --- a/docs/user/components/utils/UnitTestApp.md +++ b/docs/user/components/utils/UnitTestApp.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # UnitTestApp % WARNING: Do not edit; this is a generated file! @@ -19,3 +28,4 @@ Test application. - **current value**: 'strict', from {default} - **validator**: (in ['relaxed', 'strict', 'pedantic']) +% End of file diff --git a/docs/user/components/utils/index.md b/docs/user/components/utils/index.md index fd71b4a2..aa422d6e 100644 --- a/docs/user/components/utils/index.md +++ b/docs/user/components/utils/index.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # utils % WARNING: Do not edit; this is a generated file. @@ -8,3 +17,5 @@ maxdepth: 1 --- PointsStream.md ::: + +% End of file diff --git a/docs/user/coordsys.md b/docs/user/coordsys.md index 45f0153a..4a9dd0f9 100644 --- a/docs/user/coordsys.md +++ b/docs/user/coordsys.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Coordinate Systems SpatialData provides two types of coordinate systems: Cartesian (`CSCart`) and georeferenced (`CSGeo`). @@ -319,4 +328,6 @@ convert(points, csDest, csSrc) ::: -:::: \ No newline at end of file +:::: + +% End of file diff --git a/docs/user/figs/csgeolocal.tex b/docs/user/figs/csgeolocal.tex index 76f8ba19..5e0fdbd3 100644 --- a/docs/user/figs/csgeolocal.tex +++ b/docs/user/figs/csgeolocal.tex @@ -1,3 +1,13 @@ +% -*- tex -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + + \documentclass[crop,tikz]{standalone} \usepackage{tikz} \usepackage[scaled]{helvet} @@ -51,3 +61,6 @@ \end{tikzpicture} \end{document} + + +% End of file diff --git a/docs/user/figs/generate.sh b/docs/user/figs/generate.sh index e2e79fc8..3c83c8fe 100755 --- a/docs/user/figs/generate.sh +++ b/docs/user/figs/generate.sh @@ -1,3 +1,13 @@ +# -*- sh -*- +# -*- coding: utf-8 -*- +# +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + pdflatex csgeolocal.tex for fin in *.pdf; do @@ -5,3 +15,6 @@ for fin in *.pdf; do fout=`echo $fin | sed -e s/\.pdf/\.svg/g` mutool convert -F svg -o $fout $fin && mv -f $fout1 $fout done + + +# End of file diff --git a/docs/user/file-formats/index.md b/docs/user/file-formats/index.md index 3ae96f12..2fa7553e 100644 --- a/docs/user/file-formats/index.md +++ b/docs/user/file-formats/index.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # File Formats :::{toctree} @@ -5,3 +14,5 @@ simple-ascii.md simple-grid.md time-history.md ::: + +% End of file diff --git a/docs/user/file-formats/simple-ascii.md b/docs/user/file-formats/simple-ascii.md index 8d2d7635..e7794d56 100644 --- a/docs/user/file-formats/simple-ascii.md +++ b/docs/user/file-formats/simple-ascii.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + (sec-file-formats-SimpleIOAscii)= # SimpleDB ASCII Format @@ -51,3 +60,5 @@ SimpleDB { // start specifying the database parameters 0.0 0.0 -2.0 -2.00 0.00 0.00 0.0 0.0 -4.0 0.00 0.00 0.00 ``` + +% End of file diff --git a/docs/user/file-formats/simple-grid.md b/docs/user/file-formats/simple-grid.md index 2bb2e7b1..05bcbb45 100644 --- a/docs/user/file-formats/simple-grid.md +++ b/docs/user/file-formats/simple-grid.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + (sec-file-formats-SimpleGridDB)= # SimpleGridDB Format @@ -58,4 +67,6 @@ SimpleGridDB { // start specifying the database parameters -3.0 8.0 4.0 6.1 4.1 2500.0 1.0 8.0 4.0 5.9 3.8 2450.0 2.0 8.0 4.0 5.7 3.7 2400.0 -``` \ No newline at end of file +``` + +% End of file diff --git a/docs/user/file-formats/time-history.md b/docs/user/file-formats/time-history.md index 6e822058..dac29352 100644 --- a/docs/user/file-formats/time-history.md +++ b/docs/user/file-formats/time-history.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + (sec-file-formats-TimeHistoryDB)= # TimeHistoryDB Format @@ -29,3 +38,5 @@ TimeHistory { // start specifying the database parameters 10.0 2.00 11.0 0.00 ``` + +% End of file diff --git a/docs/user/index.md b/docs/user/index.md index 05c09c5e..abf11776 100644 --- a/docs/user/index.md +++ b/docs/user/index.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # User Guide :::{toctree} @@ -7,3 +16,5 @@ timedb/index.md components/index.md file-formats/index.md ::: + +% End of file diff --git a/docs/user/spatialdb/analyticdb.md b/docs/user/spatialdb/analyticdb.md index 52213011..eb443661 100644 --- a/docs/user/spatialdb/analyticdb.md +++ b/docs/user/spatialdb/analyticdb.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # AnalyticDB :::{note} @@ -63,3 +72,5 @@ db._configure() ::: :::: + +% End of file diff --git a/docs/user/spatialdb/compositedb.md b/docs/user/spatialdb/compositedb.md index fd00fa55..24080fa3 100644 --- a/docs/user/spatialdb/compositedb.md +++ b/docs/user/spatialdb/compositedb.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # CompositeDB For some use cases, it is advantageous to combine two spatial databases into one. @@ -83,4 +92,6 @@ dbCompsite._configure() ::: -:::: \ No newline at end of file +:::: + +% End of file diff --git a/docs/user/spatialdb/gravity-field.md b/docs/user/spatialdb/gravity-field.md index 984d974f..430a42a6 100644 --- a/docs/user/spatialdb/gravity-field.md +++ b/docs/user/spatialdb/gravity-field.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Gravity Field The `GravityField` spatial database is a specialized spatial database for specifying gravitational body forces. @@ -45,3 +54,5 @@ gravity._configure() ::: :::: + +% End of file diff --git a/docs/user/spatialdb/index.md b/docs/user/spatialdb/index.md index d5521004..4ceaa95f 100644 --- a/docs/user/spatialdb/index.md +++ b/docs/user/spatialdb/index.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Spatial Databases :::{toctree} @@ -9,3 +18,5 @@ simplegriddb.md compositedb.md gravity-field.md ::: + +% End of file diff --git a/docs/user/spatialdb/overview.md b/docs/user/spatialdb/overview.md index 148f43bd..13b755bd 100644 --- a/docs/user/spatialdb/overview.md +++ b/docs/user/spatialdb/overview.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Overview A spatial database defines how values for some field (scalar, vector, tensor) vary spatially, and they can be quite complex. @@ -19,3 +28,5 @@ Examples of compatible coordinate systems include geographic coordinates (longit Spatial database queries use the [Proj Cartographic Projections library](https://proj.maptools.org) to convert between coordinate systems, so a large number of geographic projections are available with support for converting between NAD27 and WGS84 horizontal datums as well as several other frequently used datums. Because the interpolation is done in the coordinate system of the spatial database, geographic coordinates should only be used for very simple datasets, or undesirable results will occur. This is especially true when the spatial database coordinate system combines latitude, longitude, and elevation in meters; longitude and latitude in degrees are often much smaller than elevations in meters leading to distorted ``distance'' between locations and interpolation. + +% End of file diff --git a/docs/user/spatialdb/simpledb.md b/docs/user/spatialdb/simpledb.md index 40f59d14..928e869c 100644 --- a/docs/user/spatialdb/simpledb.md +++ b/docs/user/spatialdb/simpledb.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # SimpleDB In most cases we set the default type of spatial database to `SimpleDB`. @@ -106,4 +115,6 @@ writer.write(data) ::: -:::: \ No newline at end of file +:::: + +% End of file diff --git a/docs/user/spatialdb/simplegriddb.md b/docs/user/spatialdb/simplegriddb.md index c42e88ec..f8521de4 100644 --- a/docs/user/spatialdb/simplegriddb.md +++ b/docs/user/spatialdb/simplegriddb.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # SimpleGridDB The `SimpleGridDB` is very similar to the `SimpleDB` but the values must be provided at locations on a logically rectangular grid aligned with the coordinate axes. @@ -144,3 +153,5 @@ writer.write(data) ::: :::: + +% End of file diff --git a/docs/user/spatialdb/uniformdb.md b/docs/user/spatialdb/uniformdb.md index d76061b5..18c9fbc2 100644 --- a/docs/user/spatialdb/uniformdb.md +++ b/docs/user/spatialdb/uniformdb.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # UniformDB If the values for a field a uniform (same everywhere), then a `UniformDB` or `SimpleDB` should be used. @@ -55,3 +64,5 @@ db._configure() ::: :::: + +% End of file diff --git a/docs/user/timedb/index.md b/docs/user/timedb/index.md index f1bd1126..498cf61f 100644 --- a/docs/user/timedb/index.md +++ b/docs/user/timedb/index.md @@ -1,3 +1,12 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + # Time History Database In many cases you will want to specify both a spatial and temporal variation in values. @@ -66,3 +75,5 @@ write(times, amplitude, "year", "amplitude.timedb") ::: :::: + +% End of file diff --git a/etc/ci/conventions/check.py b/etc/ci/conventions/check.py old mode 100644 new mode 100755 index ebc4b327..c4ee61a1 --- a/etc/ci/conventions/check.py +++ b/etc/ci/conventions/check.py @@ -1,13 +1,12 @@ #!/usr/bin/env python3 -# ================================================================================================= -# This code is part of PyLith, developed through the Computational Infrastructure -# for Geodynamics (https://github.com/geodynamics/pylith). +# -*- python -*- +# -*- coding: utf-8 -*- # -# Copyright (c) 2010-2026 All rights reserved. +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). # -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= -# Based on corresponding code in Pyre. +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT # externals @@ -73,7 +72,9 @@ # the yaml files, whose formatter keeps a single blank line wherever it finds more YAML = (".yml", ".yaml", ".clang-format") # the copyright line, with whatever comment marker precedes it -COPYRIGHT_LINE = re.compile(r"^(?P.*?)Copyright \(c\) 2010-\d{4} All rights reserved.$") +COPYRIGHT_LINE = re.compile(r"^(?P.*?)Copyright \(c\) 2010-\d{4} The SpatialData authors and contributors$") +# the license line, which follows the copyright; the license itself is any text +LICENSE_LINE = re.compile(r"SPDX-License-Identifier: \S.*$") # the lines that open a block comment preamble OPENERS = ("\n\n# title\n\n\n\n", + + "text\n\n" + + f"Copyright (c) 2010-{YEAR} The SpatialData authors and contributors\nSPDX-License-Identifier: MIT\n-->\n\n# title\n\n\n", "Dockerfile": '## -*- docker-image-name: "x:y" -*-\n' + preamble(comment="#", language="x").split("\n", 1)[1] + "\n\nFROM ubuntu\n\n\n# End of file\n", "run.sh": "#!/bin/bash\n" + preamble(comment="#", language="bash") + "\n\necho\n\n\n# End of file\n", "look.css": "/* -*- css -*- */\n/*\n * -*- coding: utf-8 -*-\n *\n" - + " * michael a.g. aïvázis \n" - + f" * Copyright (c) 2010-{YEAR} All rights reserved.\n */\n\n\na {{\n}}\n\n\n/* End of file */\n", + + " * text\n *\n" + + f" * Copyright (c) 2010-{YEAR} The SpatialData authors and contributors\n * SPDX-License-Identifier: MIT\n */\n\n\na {{\n}}\n\n\n/* End of file */\n", "_complete": "#compdef complete\n" + preamble(comment="#", language="zsh") + "\n\n_arguments\n\n\n# End of file\n", "page.html": "\n\n\n\n\n\n\n\n\n\n", + + "text\n\n" + + f"Copyright (c) 2010-{YEAR} The SpatialData authors and contributors\nSPDX-License-Identifier: MIT\n-->\n\n\n\n\n\n\n\n", "vendor/theirs.js": "// no preamble here\n", "values.csv": "1,2,3\n", } diff --git a/libsrc/Makefile.am b/libsrc/Makefile.am index 77e21934..22c77d0a 100644 --- a/libsrc/Makefile.am +++ b/libsrc/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + SUBDIRS = \ spatialdata diff --git a/libsrc/spatialdata/Makefile.am b/libsrc/spatialdata/Makefile.am index e2acc1a0..9bc12f48 100644 --- a/libsrc/spatialdata/Makefile.am +++ b/libsrc/spatialdata/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + SUBDIRS = \ geocoords \ @@ -67,4 +68,5 @@ dist_noinstall = \ README.rst \ LICENSE + # End of file diff --git a/libsrc/spatialdata/geocoords/CSCart.cc b/libsrc/spatialdata/geocoords/CSCart.cc index 2f2108d2..4b569557 100644 --- a/libsrc/spatialdata/geocoords/CSCart.cc +++ b/libsrc/spatialdata/geocoords/CSCart.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/geocoords/CSCart.hh b/libsrc/spatialdata/geocoords/CSCart.hh index 678df3fe..63a7938a 100644 --- a/libsrc/spatialdata/geocoords/CSCart.hh +++ b/libsrc/spatialdata/geocoords/CSCart.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "CoordSys.hh" // ISA CoordSys @@ -69,4 +71,5 @@ class spatialdata::geocoords::CSCart : public CoordSys { }; // class CSCart + // End of file diff --git a/libsrc/spatialdata/geocoords/CSGeo.cc b/libsrc/spatialdata/geocoords/CSGeo.cc index 71ddc51f..932ed6ec 100644 --- a/libsrc/spatialdata/geocoords/CSGeo.cc +++ b/libsrc/spatialdata/geocoords/CSGeo.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/geocoords/CSGeo.hh b/libsrc/spatialdata/geocoords/CSGeo.hh index 8a5a0561..6cd9749c 100644 --- a/libsrc/spatialdata/geocoords/CSGeo.hh +++ b/libsrc/spatialdata/geocoords/CSGeo.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "CoordSys.hh" // ISA CoordSys @@ -119,4 +121,5 @@ class spatialdata::geocoords::CSGeo : public CoordSys { }; // class CSGeo + // End of file diff --git a/libsrc/spatialdata/geocoords/CSGeoLocal.cc b/libsrc/spatialdata/geocoords/CSGeoLocal.cc index 6914fb77..c584e037 100644 --- a/libsrc/spatialdata/geocoords/CSGeoLocal.cc +++ b/libsrc/spatialdata/geocoords/CSGeoLocal.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/geocoords/CSGeoLocal.hh b/libsrc/spatialdata/geocoords/CSGeoLocal.hh index ed271bc4..6a808a1b 100644 --- a/libsrc/spatialdata/geocoords/CSGeoLocal.hh +++ b/libsrc/spatialdata/geocoords/CSGeoLocal.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "CSGeo.hh" // ISA CSGeo @@ -103,4 +105,5 @@ class spatialdata::geocoords::CSGeoLocal : public CSGeo { }; // class CSGeoLocal + // End of file diff --git a/libsrc/spatialdata/geocoords/CSPicklerAscii.cc b/libsrc/spatialdata/geocoords/CSPicklerAscii.cc index 4573db40..5581e73a 100644 --- a/libsrc/spatialdata/geocoords/CSPicklerAscii.cc +++ b/libsrc/spatialdata/geocoords/CSPicklerAscii.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/geocoords/CSPicklerAscii.hh b/libsrc/spatialdata/geocoords/CSPicklerAscii.hh index 082d1100..3a2a751e 100644 --- a/libsrc/spatialdata/geocoords/CSPicklerAscii.hh +++ b/libsrc/spatialdata/geocoords/CSPicklerAscii.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "geocoordsfwd.hh" @@ -34,4 +36,5 @@ class spatialdata::geocoords::CSPicklerAscii { }; // class CSPicklerAscii + // End of file diff --git a/libsrc/spatialdata/geocoords/Converter.cc b/libsrc/spatialdata/geocoords/Converter.cc index b841685e..71f1b03b 100644 --- a/libsrc/spatialdata/geocoords/Converter.cc +++ b/libsrc/spatialdata/geocoords/Converter.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/geocoords/Converter.hh b/libsrc/spatialdata/geocoords/Converter.hh index 0866d098..feec6da1 100644 --- a/libsrc/spatialdata/geocoords/Converter.hh +++ b/libsrc/spatialdata/geocoords/Converter.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "geocoordsfwd.hh" @@ -87,4 +89,5 @@ class spatialdata::geocoords::Converter { }; // class Converter + // End of file diff --git a/libsrc/spatialdata/geocoords/CoordSys.cc b/libsrc/spatialdata/geocoords/CoordSys.cc index 0ef18775..24b4c59d 100644 --- a/libsrc/spatialdata/geocoords/CoordSys.cc +++ b/libsrc/spatialdata/geocoords/CoordSys.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/geocoords/CoordSys.hh b/libsrc/spatialdata/geocoords/CoordSys.hh index d4087886..a8f7f679 100644 --- a/libsrc/spatialdata/geocoords/CoordSys.hh +++ b/libsrc/spatialdata/geocoords/CoordSys.hh @@ -1,9 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure -// Copyright (c) 2010-2026 All rights reserved. +// for Geodynamics (https://github.com/geodynamics/spatialdata). // -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "geocoordsfwd.hh" @@ -87,4 +91,5 @@ class spatialdata::geocoords::CoordSys { }; // class CoordSys + // End of file diff --git a/libsrc/spatialdata/geocoords/Makefile.am b/libsrc/spatialdata/geocoords/Makefile.am index c21ea32c..f490b8ae 100644 --- a/libsrc/spatialdata/geocoords/Makefile.am +++ b/libsrc/spatialdata/geocoords/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + subpackage = geocoords include $(top_srcdir)/subpackage.am @@ -21,4 +22,5 @@ subpkginclude_HEADERS = \ noinst_HEADERS = + # End of file diff --git a/libsrc/spatialdata/geocoords/geocoordsfwd.hh b/libsrc/spatialdata/geocoords/geocoordsfwd.hh index e9d64fb3..63b31418 100644 --- a/libsrc/spatialdata/geocoords/geocoordsfwd.hh +++ b/libsrc/spatialdata/geocoords/geocoordsfwd.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once namespace spatialdata { @@ -19,4 +21,5 @@ namespace spatialdata { } // namespace geocoords } // namespace spatialdata + // End of file diff --git a/libsrc/spatialdata/muparser/Makefile.am b/libsrc/spatialdata/muparser/Makefile.am index a21e7dca..a0578420 100644 --- a/libsrc/spatialdata/muparser/Makefile.am +++ b/libsrc/spatialdata/muparser/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + subpackage = muparser include $(top_srcdir)/subpackage.am diff --git a/libsrc/spatialdata/muparser/muparserfwd.hh b/libsrc/spatialdata/muparser/muparserfwd.hh index 238ecdbb..572322f1 100644 --- a/libsrc/spatialdata/muparser/muparserfwd.hh +++ b/libsrc/spatialdata/muparser/muparserfwd.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #define MUP_BASETYPE double @@ -17,4 +19,5 @@ namespace mu { } // namespace mu + // End of file diff --git a/libsrc/spatialdata/spatialdb/AnalyticDB.cc b/libsrc/spatialdata/spatialdb/AnalyticDB.cc index 31c6b816..a8c632d8 100644 --- a/libsrc/spatialdata/spatialdb/AnalyticDB.cc +++ b/libsrc/spatialdata/spatialdb/AnalyticDB.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/AnalyticDB.hh b/libsrc/spatialdata/spatialdb/AnalyticDB.hh index d94002a9..bfbcd87d 100644 --- a/libsrc/spatialdata/spatialdb/AnalyticDB.hh +++ b/libsrc/spatialdata/spatialdb/AnalyticDB.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "SpatialDB.hh" @@ -122,4 +124,5 @@ class spatialdata::spatialdb::AnalyticDB : public SpatialDB { #include "AnalyticDB.icc" + // End of file diff --git a/libsrc/spatialdata/spatialdb/AnalyticDB.icc b/libsrc/spatialdata/spatialdb/AnalyticDB.icc index 7a2b64d0..4ba6f863 100644 --- a/libsrc/spatialdata/spatialdb/AnalyticDB.icc +++ b/libsrc/spatialdata/spatialdb/AnalyticDB.icc @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once // Open the database and prepare for querying. diff --git a/libsrc/spatialdata/spatialdb/CompositeDB.cc b/libsrc/spatialdata/spatialdb/CompositeDB.cc index cbe24d05..081068af 100644 --- a/libsrc/spatialdata/spatialdb/CompositeDB.cc +++ b/libsrc/spatialdata/spatialdb/CompositeDB.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/CompositeDB.hh b/libsrc/spatialdata/spatialdb/CompositeDB.hh index ea84be5d..14d343de 100644 --- a/libsrc/spatialdata/spatialdb/CompositeDB.hh +++ b/libsrc/spatialdata/spatialdb/CompositeDB.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "SpatialDB.hh" @@ -143,4 +145,5 @@ class spatialdata::spatialdb::CompositeDB : public SpatialDB { // class Composit DBInfo* _infoB; ///< Information for database B }; // class CompositeDB + // End of file diff --git a/libsrc/spatialdata/spatialdb/Exception.hh b/libsrc/spatialdata/spatialdb/Exception.hh index dd91b36a..b8be3325 100644 --- a/libsrc/spatialdata/spatialdb/Exception.hh +++ b/libsrc/spatialdata/spatialdb/Exception.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "spatialdbfwd.hh" // forward declarations @@ -30,4 +32,5 @@ class spatialdata::spatialdb::OutOfBounds : public std::runtime_error { // class // version // $Id$ + // End of file diff --git a/libsrc/spatialdata/spatialdb/Exception.icc b/libsrc/spatialdata/spatialdb/Exception.icc index e9d95512..45cd0392 100644 --- a/libsrc/spatialdata/spatialdb/Exception.icc +++ b/libsrc/spatialdata/spatialdb/Exception.icc @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once // Constructor. @@ -16,4 +18,5 @@ inline spatialdata::spatialdb::OutOfBounds::OutOfBounds(const std::string& msg) // version // $Id$ + // End of file diff --git a/libsrc/spatialdata/spatialdb/GocadVoxet.cc b/libsrc/spatialdata/spatialdb/GocadVoxet.cc index 2b9c9b4d..19bcb662 100644 --- a/libsrc/spatialdata/spatialdb/GocadVoxet.cc +++ b/libsrc/spatialdata/spatialdb/GocadVoxet.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/GocadVoxet.hh b/libsrc/spatialdata/spatialdb/GocadVoxet.hh index 7153e3a1..b9fa717d 100644 --- a/libsrc/spatialdata/spatialdb/GocadVoxet.hh +++ b/libsrc/spatialdata/spatialdb/GocadVoxet.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "spatialdbfwd.hh" // forward declarations @@ -116,4 +118,5 @@ class spatialdata::spatialdb::GocadVoxet { // GocadVoxet }; // GocadVoxet + // End of file diff --git a/libsrc/spatialdata/spatialdb/GravityField.cc b/libsrc/spatialdata/spatialdb/GravityField.cc index b5332f03..8f7253ee 100644 --- a/libsrc/spatialdata/spatialdb/GravityField.cc +++ b/libsrc/spatialdata/spatialdb/GravityField.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/GravityField.hh b/libsrc/spatialdata/spatialdb/GravityField.hh index 47c28408..357ec614 100644 --- a/libsrc/spatialdata/spatialdb/GravityField.hh +++ b/libsrc/spatialdata/spatialdb/GravityField.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "SpatialDB.hh" @@ -101,4 +103,5 @@ class spatialdata::spatialdb::GravityField : public SpatialDB { size_t _querySize; ///< Number of values requested to be returned in queries. }; // class GravityField + // End of file diff --git a/libsrc/spatialdata/spatialdb/Makefile.am b/libsrc/spatialdata/spatialdb/Makefile.am index dce277ca..632b301b 100644 --- a/libsrc/spatialdata/spatialdb/Makefile.am +++ b/libsrc/spatialdata/spatialdb/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + subpackage = spatialdb include $(top_srcdir)/subpackage.am diff --git a/libsrc/spatialdata/spatialdb/SCECCVMH.cc b/libsrc/spatialdata/spatialdb/SCECCVMH.cc index 1c613ed3..abca547a 100644 --- a/libsrc/spatialdata/spatialdb/SCECCVMH.cc +++ b/libsrc/spatialdata/spatialdb/SCECCVMH.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/SCECCVMH.hh b/libsrc/spatialdata/spatialdb/SCECCVMH.hh index 75c638ab..492aee02 100644 --- a/libsrc/spatialdata/spatialdb/SCECCVMH.hh +++ b/libsrc/spatialdata/spatialdb/SCECCVMH.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "SpatialDB.hh" // ISA SpatialDB @@ -171,4 +173,5 @@ class spatialdata::spatialdb::SCECCVMH : SpatialDB { #include "SCECCVMH.icc" // inline methods + // End of file diff --git a/libsrc/spatialdata/spatialdb/SCECCVMH.icc b/libsrc/spatialdata/spatialdb/SCECCVMH.icc index bb2bdaac..58423e79 100644 --- a/libsrc/spatialdata/spatialdb/SCECCVMH.icc +++ b/libsrc/spatialdata/spatialdb/SCECCVMH.icc @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once // Set directory containing SCEC CVM-H data files. diff --git a/libsrc/spatialdata/spatialdb/SimpleDB.cc b/libsrc/spatialdata/spatialdb/SimpleDB.cc index 20fa6731..2f88940d 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDB.cc +++ b/libsrc/spatialdata/spatialdb/SimpleDB.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/SimpleDB.hh b/libsrc/spatialdata/spatialdb/SimpleDB.hh index 98fa38ef..52315e12 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDB.hh +++ b/libsrc/spatialdata/spatialdb/SimpleDB.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "SpatialDB.hh" // ISA Spatialdb @@ -122,4 +124,5 @@ class spatialdata::spatialdb::SimpleDB : public SpatialDB { // class SimpleDB }; // class SimpleDB + // End of file diff --git a/libsrc/spatialdata/spatialdb/SimpleDBData.cc b/libsrc/spatialdata/spatialdb/SimpleDBData.cc index 6f60169f..7dedca0e 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBData.cc +++ b/libsrc/spatialdata/spatialdb/SimpleDBData.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/SimpleDBData.hh b/libsrc/spatialdata/spatialdb/SimpleDBData.hh index e33e62b6..cdbe9731 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBData.hh +++ b/libsrc/spatialdata/spatialdb/SimpleDBData.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "spatialdbfwd.hh" // forward declarations @@ -162,4 +164,5 @@ class spatialdata::spatialdb::SimpleDBData { // SimpleDBData #include "SimpleDBData.icc" // inline methods + // End of file diff --git a/libsrc/spatialdata/spatialdb/SimpleDBData.icc b/libsrc/spatialdata/spatialdb/SimpleDBData.icc index eeaef62c..2da7bd79 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBData.icc +++ b/libsrc/spatialdata/spatialdb/SimpleDBData.icc @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include // USES assert() diff --git a/libsrc/spatialdata/spatialdb/SimpleDBQuery.cc b/libsrc/spatialdata/spatialdb/SimpleDBQuery.cc index eb562110..2ae88fb3 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBQuery.cc +++ b/libsrc/spatialdata/spatialdb/SimpleDBQuery.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/SimpleDBQuery.hh b/libsrc/spatialdata/spatialdb/SimpleDBQuery.hh index a7dfc4ce..5c7d8e4d 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBQuery.hh +++ b/libsrc/spatialdata/spatialdb/SimpleDBQuery.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "SimpleDB.hh" // USES SimpleDB @@ -190,4 +192,5 @@ class spatialdata::spatialdb::SimpleDBQuery { // class SimpleDBQuery }; // class SimpleDBQuery + // End of file diff --git a/libsrc/spatialdata/spatialdb/SimpleGridAscii.cc b/libsrc/spatialdata/spatialdb/SimpleGridAscii.cc index a9fb24f9..2ed7d551 100644 --- a/libsrc/spatialdata/spatialdb/SimpleGridAscii.cc +++ b/libsrc/spatialdata/spatialdb/SimpleGridAscii.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/SimpleGridAscii.hh b/libsrc/spatialdata/spatialdb/SimpleGridAscii.hh index fadd056e..0ea887cf 100644 --- a/libsrc/spatialdata/spatialdb/SimpleGridAscii.hh +++ b/libsrc/spatialdata/spatialdb/SimpleGridAscii.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "SimpleGridDB.hh" // ISA SimpleGridDB @@ -78,4 +80,5 @@ class spatialdata::spatialdb::SimpleGridAscii { // SimpleGridAscii }; // class SimpleGridAscii + // End of file diff --git a/libsrc/spatialdata/spatialdb/SimpleGridDB.cc b/libsrc/spatialdata/spatialdb/SimpleGridDB.cc index 1ab654ec..dcc48356 100644 --- a/libsrc/spatialdata/spatialdb/SimpleGridDB.cc +++ b/libsrc/spatialdata/spatialdb/SimpleGridDB.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/SimpleGridDB.hh b/libsrc/spatialdata/spatialdb/SimpleGridDB.hh index bf18b8fe..1d4ea3aa 100644 --- a/libsrc/spatialdata/spatialdb/SimpleGridDB.hh +++ b/libsrc/spatialdata/spatialdb/SimpleGridDB.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "SpatialDB.hh" // ISA SpatialDB @@ -333,4 +335,5 @@ class spatialdata::spatialdb::SimpleGridDB : public SpatialDB { // SimpleGridDB #include "SimpleGridDB.icc" // inline methods + // End of file diff --git a/libsrc/spatialdata/spatialdb/SimpleGridDB.icc b/libsrc/spatialdata/spatialdb/SimpleGridDB.icc index 7942b508..14669e4b 100644 --- a/libsrc/spatialdata/spatialdb/SimpleGridDB.icc +++ b/libsrc/spatialdata/spatialdb/SimpleGridDB.icc @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include // USES assert() diff --git a/libsrc/spatialdata/spatialdb/SimpleIO.cc b/libsrc/spatialdata/spatialdb/SimpleIO.cc index 0c6e1d5c..d93aea8c 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIO.cc +++ b/libsrc/spatialdata/spatialdb/SimpleIO.cc @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #include #include "SimpleIO.hh" // Implementation of class methods diff --git a/libsrc/spatialdata/spatialdb/SimpleIO.hh b/libsrc/spatialdata/spatialdb/SimpleIO.hh index 970c9389..b5f4a5d5 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIO.hh +++ b/libsrc/spatialdata/spatialdb/SimpleIO.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "spatialdata/geocoords/geocoordsfwd.hh" // forward declarations @@ -97,4 +99,5 @@ class spatialdata::spatialdb::SimpleIO { // class SimpleIO #include "SimpleIO.icc" + // End of file diff --git a/libsrc/spatialdata/spatialdb/SimpleIO.icc b/libsrc/spatialdata/spatialdb/SimpleIO.icc index 429a9809..e38d0376 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIO.icc +++ b/libsrc/spatialdata/spatialdb/SimpleIO.icc @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once // Set filename for database. diff --git a/libsrc/spatialdata/spatialdb/SimpleIOAscii.cc b/libsrc/spatialdata/spatialdb/SimpleIOAscii.cc index d8bfc15f..6de7160d 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIOAscii.cc +++ b/libsrc/spatialdata/spatialdb/SimpleIOAscii.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/SimpleIOAscii.hh b/libsrc/spatialdata/spatialdb/SimpleIOAscii.hh index 510c2753..eef19f10 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIOAscii.hh +++ b/libsrc/spatialdata/spatialdb/SimpleIOAscii.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "SimpleIO.hh" // ISA SimpleIO @@ -71,4 +73,5 @@ class spatialdata::spatialdb::SimpleIOAscii : public SimpleIO { // SimpleIOAscii // version // $Id$ + // End of file diff --git a/libsrc/spatialdata/spatialdb/SimpleIOAscii.icc b/libsrc/spatialdata/spatialdb/SimpleIOAscii.icc index baa43bc3..678fa780 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIOAscii.icc +++ b/libsrc/spatialdata/spatialdb/SimpleIOAscii.icc @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once // ---------------------------------------------------------------------- diff --git a/libsrc/spatialdata/spatialdb/SpatialDB.cc b/libsrc/spatialdata/spatialdb/SpatialDB.cc index 0b74c768..fa03e94f 100644 --- a/libsrc/spatialdata/spatialdb/SpatialDB.cc +++ b/libsrc/spatialdata/spatialdb/SpatialDB.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/SpatialDB.hh b/libsrc/spatialdata/spatialdb/SpatialDB.hh index 6c358900..dc662853 100644 --- a/libsrc/spatialdata/spatialdb/SpatialDB.hh +++ b/libsrc/spatialdata/spatialdb/SpatialDB.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "spatialdata/geocoords/geocoordsfwd.hh" @@ -198,4 +200,5 @@ class spatialdata::spatialdb::SpatialDB { #include "SpatialDB.icc" // inline methods + // End of file diff --git a/libsrc/spatialdata/spatialdb/SpatialDB.icc b/libsrc/spatialdata/spatialdb/SpatialDB.icc index c3247d6f..d10aa089 100644 --- a/libsrc/spatialdata/spatialdb/SpatialDB.icc +++ b/libsrc/spatialdata/spatialdb/SpatialDB.icc @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once // Set description of spatial database. diff --git a/libsrc/spatialdata/spatialdb/TimeHistory.cc b/libsrc/spatialdata/spatialdb/TimeHistory.cc index 9a89f70f..6f3f64b5 100644 --- a/libsrc/spatialdata/spatialdb/TimeHistory.cc +++ b/libsrc/spatialdata/spatialdb/TimeHistory.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/TimeHistory.hh b/libsrc/spatialdata/spatialdb/TimeHistory.hh index 50c7ae8c..3888e89d 100644 --- a/libsrc/spatialdata/spatialdb/TimeHistory.hh +++ b/libsrc/spatialdata/spatialdb/TimeHistory.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "spatialdbfwd.hh" @@ -105,4 +107,5 @@ class spatialdata::spatialdb::TimeHistory { // class TimeHistory #include "TimeHistory.icc" // inline methods + // End of file diff --git a/libsrc/spatialdata/spatialdb/TimeHistory.icc b/libsrc/spatialdata/spatialdb/TimeHistory.icc index 50bdd610..f9fe2eec 100644 --- a/libsrc/spatialdata/spatialdb/TimeHistory.icc +++ b/libsrc/spatialdata/spatialdb/TimeHistory.icc @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once // Set description of time history. diff --git a/libsrc/spatialdata/spatialdb/TimeHistoryIO.cc b/libsrc/spatialdata/spatialdb/TimeHistoryIO.cc index 9fec8f50..ac54242b 100644 --- a/libsrc/spatialdata/spatialdb/TimeHistoryIO.cc +++ b/libsrc/spatialdata/spatialdb/TimeHistoryIO.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/TimeHistoryIO.hh b/libsrc/spatialdata/spatialdb/TimeHistoryIO.hh index 486166f3..ce8d7e7c 100644 --- a/libsrc/spatialdata/spatialdb/TimeHistoryIO.hh +++ b/libsrc/spatialdata/spatialdb/TimeHistoryIO.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "spatialdbfwd.hh" @@ -53,4 +55,5 @@ class spatialdata::spatialdb::TimeHistoryIO { // class TimeHistoryIO }; // class TimeHistoryIO + // End of file diff --git a/libsrc/spatialdata/spatialdb/UniformDB.cc b/libsrc/spatialdata/spatialdb/UniformDB.cc index 436fcba6..312c4f95 100644 --- a/libsrc/spatialdata/spatialdb/UniformDB.cc +++ b/libsrc/spatialdata/spatialdb/UniformDB.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/UniformDB.hh b/libsrc/spatialdata/spatialdb/UniformDB.hh index 3e95b956..000d1b0c 100644 --- a/libsrc/spatialdata/spatialdb/UniformDB.hh +++ b/libsrc/spatialdata/spatialdb/UniformDB.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "SpatialDB.hh" @@ -105,4 +107,5 @@ class spatialdata::spatialdb::UniformDB : public SpatialDB { // class UniformDB #include "UniformDB.icc" + // End of file diff --git a/libsrc/spatialdata/spatialdb/UniformDB.icc b/libsrc/spatialdata/spatialdb/UniformDB.icc index eb33991f..d9b99be9 100644 --- a/libsrc/spatialdata/spatialdb/UniformDB.icc +++ b/libsrc/spatialdata/spatialdb/UniformDB.icc @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once // Open the database and prepare for querying. diff --git a/libsrc/spatialdata/spatialdb/UserFunctionDB.cc b/libsrc/spatialdata/spatialdb/UserFunctionDB.cc index 5dc67333..f358d1dc 100644 --- a/libsrc/spatialdata/spatialdb/UserFunctionDB.cc +++ b/libsrc/spatialdata/spatialdb/UserFunctionDB.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/UserFunctionDB.hh b/libsrc/spatialdata/spatialdb/UserFunctionDB.hh index 300ecfe9..81761b97 100644 --- a/libsrc/spatialdata/spatialdb/UserFunctionDB.hh +++ b/libsrc/spatialdata/spatialdb/UserFunctionDB.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "SpatialDB.hh" // ISA SpatialDB @@ -208,4 +210,5 @@ class spatialdata::spatialdb::UserFunctionDB : public SpatialDB { }; // UserFunctionDB + // End of file diff --git a/libsrc/spatialdata/spatialdb/cspatialdb.cc b/libsrc/spatialdata/spatialdb/cspatialdb.cc index 2e141eed..dd8ac9c3 100644 --- a/libsrc/spatialdata/spatialdb/cspatialdb.cc +++ b/libsrc/spatialdata/spatialdb/cspatialdb.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/spatialdb/cspatialdb.h b/libsrc/spatialdata/spatialdb/cspatialdb.h index d5df6759..73fd4b71 100644 --- a/libsrc/spatialdata/spatialdb/cspatialdb.h +++ b/libsrc/spatialdata/spatialdb/cspatialdb.h @@ -1,13 +1,13 @@ -/* - * ================================================================================================ - * This code is part of SpatialData, developed through the Computational Infrastructure - * for Geodynamics (https://github.com/geodynamics/spatialdata). - * - * Copyright (c) 2010-2026 All rights reserved. - * - * See https://mit-license.org/ and LICENSE.md and for license information. - * ================================================================================================= - */ +// -*- c++ -*- +// -*- coding: utf-8 -*- +// +// This code is part of SpatialData, developed through the Computational Infrastructure +// for Geodynamics (https://github.com/geodynamics/spatialdata). +// +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once /** Call SpatialDB:Query(). @@ -29,4 +29,5 @@ int spatialdb_query(void* db, const int numDims, const void* cs); -/* End of file */ + +// End of file diff --git a/libsrc/spatialdata/spatialdb/f77spatialdb.cc b/libsrc/spatialdata/spatialdb/f77spatialdb.cc index c720a375..16c77471 100644 --- a/libsrc/spatialdata/spatialdb/f77spatialdb.cc +++ b/libsrc/spatialdata/spatialdb/f77spatialdb.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include "f77spatialdb.h" #include @@ -40,7 +41,4 @@ spatialdb_query_f(void* db, } // spatialdb_query_f -// version -// $Id$ - // End of file diff --git a/libsrc/spatialdata/spatialdb/f77spatialdb.h b/libsrc/spatialdata/spatialdb/f77spatialdb.h index 6d1c4586..f2efcac3 100644 --- a/libsrc/spatialdata/spatialdb/f77spatialdb.h +++ b/libsrc/spatialdata/spatialdb/f77spatialdb.h @@ -1,13 +1,13 @@ -/* - * ================================================================================================ - * This code is part of SpatialData, developed through the Computational Infrastructure - * for Geodynamics (https://github.com/geodynamics/spatialdata). - * - * Copyright (c) 2010-2026 All rights reserved. - * - * See https://mit-license.org/ and LICENSE.md and for license information. - * ================================================================================================= - */ +// -*- c++ -*- +// -*- coding: utf-8 -*- +// +// This code is part of SpatialData, developed through the Computational Infrastructure +// for Geodynamics (https://github.com/geodynamics/spatialdata). +// +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once // ---------------------------------------------------------------------- @@ -31,4 +31,5 @@ extern "C" void spatialdb_query_f(void* db, const void* cs, int* ok); + // End of file diff --git a/libsrc/spatialdata/spatialdb/spatialdbfwd.hh b/libsrc/spatialdata/spatialdb/spatialdbfwd.hh index 1d75277d..0cd976cb 100644 --- a/libsrc/spatialdata/spatialdb/spatialdbfwd.hh +++ b/libsrc/spatialdata/spatialdb/spatialdbfwd.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once namespace spatialdata { @@ -35,4 +37,5 @@ namespace spatialdata { } // namespace spatialdb } // namespace spatialdata + // End of file diff --git a/libsrc/spatialdata/units/Makefile.am b/libsrc/spatialdata/units/Makefile.am index 5aeecea7..edab7ef5 100644 --- a/libsrc/spatialdata/units/Makefile.am +++ b/libsrc/spatialdata/units/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + subpackage = units include $(top_srcdir)/subpackage.am diff --git a/libsrc/spatialdata/units/Parser.cc b/libsrc/spatialdata/units/Parser.cc index 3588504a..db500f7f 100644 --- a/libsrc/spatialdata/units/Parser.cc +++ b/libsrc/spatialdata/units/Parser.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/units/Parser.hh b/libsrc/spatialdata/units/Parser.hh index f202c5eb..1ba33931 100644 --- a/libsrc/spatialdata/units/Parser.hh +++ b/libsrc/spatialdata/units/Parser.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "unitsfwd.hh" @@ -45,4 +47,5 @@ class spatialdata::units::Parser { // class Parser }; // class Parser + // End of file diff --git a/libsrc/spatialdata/units/unitsfwd.hh b/libsrc/spatialdata/units/unitsfwd.hh index 644a3b92..3b00fc41 100644 --- a/libsrc/spatialdata/units/unitsfwd.hh +++ b/libsrc/spatialdata/units/unitsfwd.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once namespace spatialdata { @@ -14,4 +16,5 @@ namespace spatialdata { } // namespace units } // namespace spatialdata + // End of file diff --git a/libsrc/spatialdata/utils/LineParser.cc b/libsrc/spatialdata/utils/LineParser.cc index 573ce57c..10963880 100644 --- a/libsrc/spatialdata/utils/LineParser.cc +++ b/libsrc/spatialdata/utils/LineParser.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/utils/LineParser.hh b/libsrc/spatialdata/utils/LineParser.hh index 7ef3abb7..0cd7f3b2 100644 --- a/libsrc/spatialdata/utils/LineParser.hh +++ b/libsrc/spatialdata/utils/LineParser.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "utilsfwd.hh" @@ -70,4 +72,5 @@ class spatialdata::utils::LineParser { // LineParser }; // LineParser + // End of file diff --git a/libsrc/spatialdata/utils/Makefile.am b/libsrc/spatialdata/utils/Makefile.am index 20900184..80e0178e 100644 --- a/libsrc/spatialdata/utils/Makefile.am +++ b/libsrc/spatialdata/utils/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + subpackage = utils include $(top_srcdir)/subpackage.am diff --git a/libsrc/spatialdata/utils/PointsStream.cc b/libsrc/spatialdata/utils/PointsStream.cc index ab9ac417..cb872222 100644 --- a/libsrc/spatialdata/utils/PointsStream.cc +++ b/libsrc/spatialdata/utils/PointsStream.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include "PointsStream.hh" // Implementation of class methods diff --git a/libsrc/spatialdata/utils/PointsStream.hh b/libsrc/spatialdata/utils/PointsStream.hh index 4155d390..41886dc6 100644 --- a/libsrc/spatialdata/utils/PointsStream.hh +++ b/libsrc/spatialdata/utils/PointsStream.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "utilsfwd.hh" @@ -115,4 +117,5 @@ class spatialdata::utils::PointsStream { // class PointsStream #include "PointsStream.icc" // inline methods + // End of file diff --git a/libsrc/spatialdata/utils/PointsStream.icc b/libsrc/spatialdata/utils/PointsStream.icc index f5920b6b..fe18ffb6 100644 --- a/libsrc/spatialdata/utils/PointsStream.icc +++ b/libsrc/spatialdata/utils/PointsStream.icc @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once // Set name of file for input/output. diff --git a/libsrc/spatialdata/utils/SpatialdataVersion.cc b/libsrc/spatialdata/utils/SpatialdataVersion.cc index 2c9b1c8d..dd72c316 100644 --- a/libsrc/spatialdata/utils/SpatialdataVersion.cc +++ b/libsrc/spatialdata/utils/SpatialdataVersion.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/libsrc/spatialdata/utils/SpatialdataVersion.hh b/libsrc/spatialdata/utils/SpatialdataVersion.hh index 68300757..05c07b8a 100644 --- a/libsrc/spatialdata/utils/SpatialdataVersion.hh +++ b/libsrc/spatialdata/utils/SpatialdataVersion.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "utilsfwd.hh" // forward declarations @@ -82,4 +84,5 @@ class spatialdata::utils::SpatialdataVersion { // SpatialdataVersion }; // SpatialdataVersion + // End of file diff --git a/libsrc/spatialdata/utils/utilsfwd.hh b/libsrc/spatialdata/utils/utilsfwd.hh index 4926fe4b..26068d55 100644 --- a/libsrc/spatialdata/utils/utilsfwd.hh +++ b/libsrc/spatialdata/utils/utilsfwd.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once namespace spatialdata { @@ -17,4 +19,5 @@ namespace spatialdata { } // namespace utils } // namespace spatialdata + // End of file diff --git a/modulesrc/Makefile.am b/modulesrc/Makefile.am index 7a0963d7..1c8d11ee 100644 --- a/modulesrc/Makefile.am +++ b/modulesrc/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + SUBDIRS = \ include \ diff --git a/modulesrc/geocoords/CSCart.i b/modulesrc/geocoords/CSCart.i index 5d8e693c..161b8fd4 100644 --- a/modulesrc/geocoords/CSCart.i +++ b/modulesrc/geocoords/CSCart.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/geocoords/CSCart.i * @@ -59,4 +60,5 @@ namespace spatialdata { } // namespace geocoords } // namespace spatialdata + // End of file diff --git a/modulesrc/geocoords/CSGeo.i b/modulesrc/geocoords/CSGeo.i index 21ff13ed..57ef24de 100644 --- a/modulesrc/geocoords/CSGeo.i +++ b/modulesrc/geocoords/CSGeo.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/geocoords/CSGeo.i * @@ -105,4 +106,5 @@ namespace spatialdata { } // namespace geocoords } // namespace spatialdata + // End of file diff --git a/modulesrc/geocoords/CSGeoLocal.i b/modulesrc/geocoords/CSGeoLocal.i index 4a68d388..adb6cd9b 100644 --- a/modulesrc/geocoords/CSGeoLocal.i +++ b/modulesrc/geocoords/CSGeoLocal.i @@ -1,16 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT -/** @file modulesrc/geocoords/CSGeoLocal.i - * - * @brief SWIG interface to C++ CSGeoLocal object. - */ namespace spatialdata { namespace geocoords { @@ -48,16 +44,16 @@ namespace spatialdata { * @param[out] originY Y coordinate of local origin. * @param[out] yAzimuth Azimuth (degrees) of y axis. */ - % apply double* OUTPUT{double* originX}; - % apply double* OUTPUT{double* originY}; - % apply double* OUTPUT{double* yAzimuth}; + %apply double* OUTPUT{double* originX}; + %apply double* OUTPUT{double* originY}; + %apply double* OUTPUT{double* yAzimuth}; void getLocal(double* originX, double* originY, double* yAzimuth) const; - % clear double* originX; - % clear double* originY; - % clear double* yAzimuth; + %clear double* originX; + %clear double* originY; + %clear double* yAzimuth; /** Convert coordinates from local coordinate system to geographic coordinate system. * @@ -96,4 +92,5 @@ namespace spatialdata { } // namespace geocoords } // namespace spatialdata + // End of file diff --git a/modulesrc/geocoords/Converter.i b/modulesrc/geocoords/Converter.i index ec86dab6..fe4ee03a 100644 --- a/modulesrc/geocoords/Converter.i +++ b/modulesrc/geocoords/Converter.i @@ -1,16 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT -/** @file modulesrc/geocoords/Converter.i - * - * @brief SWIG interface to C++ Converter object. - */ namespace spatialdata { namespace geocoords { @@ -35,7 +31,7 @@ namespace spatialdata { * @param pCSDest Pointer to destination coordinate system * @param pCSSrc Pointer to source coordinate system */ - % apply(double* INPLACE_ARRAY2, + %apply(double* INPLACE_ARRAY2, int DIM1, int DIM2){(double* coords, const size_t numLocs, @@ -46,7 +42,7 @@ namespace spatialdata { const CoordSys* pCSDest, const CoordSys* pCSSrc); - % clear(double* coords, + %clear(double* coords, const size_t numLocs, const size_t numDims); @@ -55,4 +51,5 @@ namespace spatialdata { } // namespace geocoords } // namespace spatialdata + // End of file diff --git a/modulesrc/geocoords/CoordSys.i b/modulesrc/geocoords/CoordSys.i index c9246c78..d97ade08 100644 --- a/modulesrc/geocoords/CoordSys.i +++ b/modulesrc/geocoords/CoordSys.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/geocoords/CoordSys.i * @@ -72,4 +73,5 @@ namespace spatialdata { } // namespace geocoords } // namespace spatialdata + // End of file diff --git a/modulesrc/geocoords/Makefile.am b/modulesrc/geocoords/Makefile.am index 24be54ac..69169264 100644 --- a/modulesrc/geocoords/Makefile.am +++ b/modulesrc/geocoords/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + subpackage = geocoords include $(top_srcdir)/subpackage.am diff --git a/modulesrc/geocoords/geocoords.i b/modulesrc/geocoords/geocoords.i index a8d1f90f..d698f1c6 100644 --- a/modulesrc/geocoords/geocoords.i +++ b/modulesrc/geocoords/geocoords.i @@ -1,52 +1,54 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= -// SWIG interface -% - module geocoords - - // Header files for module C++ code - % - { +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + +%module geocoords + +// Header files for module C++ code +%{ #include #include // USES std::string // Headers for interfaces +#include "spatialdata/geocoords/CoordSys.hh" #include "spatialdata/geocoords/CSCart.hh" #include "spatialdata/geocoords/CSGeo.hh" #include "spatialdata/geocoords/CSGeoLocal.hh" #include "spatialdata/geocoords/Converter.hh" -#include "spatialdata/geocoords/CoordSys.hh" - % } - - % include "exception.i" % exception { - try { - $action - } catch (const std::exception& err) { - SWIG_exception(SWIG_RuntimeError, err.what()); - } // try/catch -} // exception - -% - include "typemaps.i" - - // Numpy interface stuff - % - { +%} + +%include "exception.i" +%exception { + try { + $action + } catch (const std::exception& err) { + SWIG_exception(SWIG_RuntimeError, err.what()); + } // try/catch + } // exception + +%include "typemaps.i" + +// Numpy interface stuff +%{ #define SWIG_FILE_WITH_INIT - % } % - include "../include/numpy.i" % init % { - import_array(); - % -} +%} +%include "../include/numpy.i" +%init %{ +import_array(); +%} // Interfaces -% include "CoordSys.i" % include "CSCart.i" % include "CSGeo.i" % include "CSGeoLocal.i" % - include "Converter.i" +%include "CoordSys.i" +%include "CSCart.i" +%include "CSGeo.i" +%include "CSGeoLocal.i" +%include "Converter.i" + - // End of file +// End of file diff --git a/modulesrc/include/Makefile.am b/modulesrc/include/Makefile.am index 9df888a0..02178d1f 100644 --- a/modulesrc/include/Makefile.am +++ b/modulesrc/include/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + subpackage = swig/include include $(top_srcdir)/subpackage.am diff --git a/modulesrc/include/chararray.i b/modulesrc/include/chararray.i index 22c54aaf..d0ef157e 100644 --- a/modulesrc/include/chararray.i +++ b/modulesrc/include/chararray.i @@ -1,68 +1,67 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + // Treat const char* const* as a special case. -% typemap(in)(const char* const* string_list) { - // Check to make sure input is a list. - if (PyList_Check($input)) { - const int size = PyList_Size($input); - $1 = (size > 0) ? new char*[size] : NULL; - for (int i = 0; i < size; i++) { - PyObject* s = PyList_GetItem($input, i); - if (PyUnicode_Check(s)) - $1[i] = (char*)PyUnicode_AsUTF8(PyList_GetItem($input, i)); - else { - PyErr_SetString(PyExc_TypeError, "List must contain strings."); - delete[] $1; - return NULL; - } // else - } // for - } else { - PyErr_SetString(PyExc_TypeError, "Expected list of strings."); - return NULL; - } // if/else +%typemap(in) (const char* const* string_list) { + // Check to make sure input is a list. + if (PyList_Check($input)) { + const int size = PyList_Size($input); + $1 = (size > 0) ? new char*[size] : NULL; + for (int i = 0; i < size; i++) { + PyObject *s = PyList_GetItem($input,i); + if (PyUnicode_Check(s)) + $1[i] = (char*)PyUnicode_AsUTF8(PyList_GetItem($input,i)); + else { + PyErr_SetString(PyExc_TypeError, "List must contain strings."); + delete[] $1; + return NULL; + } // else + } // for + } else { + PyErr_SetString(PyExc_TypeError, "Expected list of strings."); + return NULL; + } // if/else } // typemap(in) const char* const* // This cleans up the char** array we malloc'd before the function call -% typemap(freearg)(const char* const* string_list) { - delete[] $1; +%typemap(freearg) (const char* const* string_list) { + delete[] $1; } // Treat const char* const* as a special case. -% typemap(in)(const char* const* string_list, - const int list_len) { - // Check to make sure input is a list. - if (PyList_Check($input)) { - const int size = PyList_Size($input); - $2 = size; - $1 = (size > 0) ? new char*[size] : 0; - for (int i = 0; i < size; i++) { - PyObject* s = PyList_GetItem($input, i); - if (PyUnicode_Check(s)) - $1[i] = (char*)PyUnicode_AsUTF8(PyList_GetItem($input, i)); - else { - PyErr_SetString(PyExc_TypeError, "List must contain strings."); - delete[] $1; - return NULL; - } // else - } // for - } else { - PyErr_SetString(PyExc_TypeError, "Expected list of strings."); - return NULL; - } // if/else +%typemap(in) (const char* const* string_list, const int list_len) { + // Check to make sure input is a list. + if (PyList_Check($input)) { + const int size = PyList_Size($input); + $2 = size; + $1 = (size > 0) ? new char*[size] : 0; + for (int i = 0; i < size; i++) { + PyObject *s = PyList_GetItem($input,i); + if (PyUnicode_Check(s)) + $1[i] = (char*)PyUnicode_AsUTF8(PyList_GetItem($input,i)); + else { + PyErr_SetString(PyExc_TypeError, "List must contain strings."); + delete[] $1; + return NULL; + } // else + } // for + } else { + PyErr_SetString(PyExc_TypeError, "Expected list of strings."); + return NULL; + } // if/else } // typemap(in) const char* const* // This cleans up the char** array we malloc'd before the function call -% typemap(freearg)(const char* const* string_list, - const int list_len) { - delete[] $1; +%typemap(freearg) (const char* const* string_list, const int list_len) { + delete[] $1; } diff --git a/modulesrc/include/numpy.i b/modulesrc/include/numpy.i index a7392abb..1f03ef4e 100644 --- a/modulesrc/include/numpy.i +++ b/modulesrc/include/numpy.i @@ -1,4 +1,12 @@ -/* -*- C -*- (not really, but good for syntax highlighting) */ +// -*- c++ -*- +// -*- coding: utf-8 -*- +// +// This code is part of SpatialData, developed through the Computational Infrastructure +// for Geodynamics (https://github.com/geodynamics/spatialdata). +// +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /* * Copyright (c) 2005-2015, NumPy Developers. @@ -2969,3 +2977,6 @@ PyObject* cap = PyCapsule_New((void*)(*$5), SWIGPY_CAPSULE_NAME, free_cap); #endif #endif /* SWIGPYTHON */ + + +// End of file diff --git a/modulesrc/module.am b/modulesrc/module.am index 45098a50..1301c5ad 100644 --- a/modulesrc/module.am +++ b/modulesrc/module.am @@ -1,15 +1,17 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + AM_CPPFLAGS = \ -I$(top_srcdir)/libsrc \ -I$(NUMPY_INCDIR) \ -I$(PYTHON_INCDIR) + # End of file diff --git a/modulesrc/spatialdb/AnalyticDB.i b/modulesrc/spatialdb/AnalyticDB.i index 7005b7f4..94a9efa7 100644 --- a/modulesrc/spatialdb/AnalyticDB.i +++ b/modulesrc/spatialdb/AnalyticDB.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/spatialdb/AnalyticDB.i * @@ -37,9 +38,9 @@ namespace spatialdata { * @param expressions Array of expressions in database. * @param numValues Number of values in database. */ - % apply(const char* const* string_list){(const char* const* names)}; - % apply(const char* const* string_list){(const char* const* units)}; - % apply(const char* const* string_list, + %apply(const char* const* string_list){(const char* const* names)}; + %apply(const char* const* string_list){(const char* const* units)}; + %apply(const char* const* string_list, const int list_len){(const char* const* expressions, const size_t numValues)}; void setData(const char* const* names, @@ -47,9 +48,9 @@ namespace spatialdata { const char* const* expressions, const size_t numValues); - % clear(const char* const* names); - % clear(const char* const* units); - % clear(const char* const* expressions, + %clear(const char* const* names); + %clear(const char* const* units); + %clear(const char* const* expressions, const size_t numValues); /** Set coordinate system associated with user functions. @@ -71,13 +72,13 @@ namespace spatialdata { * @param names Names of values to be returned in queries * @param numValues Number of values to be returned in queries */ - % apply(const char* const* string_list, + %apply(const char* const* string_list, const int list_len){(const char* const* names, const size_t numValues)}; void setQueryValues(const char* const* names, const size_t numValues); - % clear(const char* const* names, + %clear(const char* const* names, const size_t numValues); /** Query the database. @@ -94,10 +95,10 @@ namespace spatialdata { * @returns 0 on success, 1 on failure (i.e., could not interpolate * so values set to 0) */ - % apply(double* INPLACE_ARRAY1, + %apply(double* INPLACE_ARRAY1, int DIM1){(double* values, const size_t numValues)}; - % apply(double* IN_ARRAY1, + %apply(double* IN_ARRAY1, int DIM1){(const double* coords, const size_t numDims)}; int query(double* values, @@ -106,9 +107,9 @@ namespace spatialdata { const size_t numDims, const spatialdata::geocoords::CoordSys* pCSQuery); - % clear(double* values, + %clear(double* values, const size_t numValues); - % clear(const double* coords, + %clear(const double* coords, const size_t numDims); }; // class AnalyticDB @@ -116,4 +117,5 @@ namespace spatialdata { } // namespace spatialdb } // namespace spatialdata + // End of file diff --git a/modulesrc/spatialdb/CompositeDB.i b/modulesrc/spatialdb/CompositeDB.i index 85480772..b861b89b 100644 --- a/modulesrc/spatialdb/CompositeDB.i +++ b/modulesrc/spatialdb/CompositeDB.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/spatialdb/CompositeDB.i * @@ -38,13 +39,13 @@ namespace spatialdata { * @param names Array of names of values to use with database. * @param numNames Size of array of names. */ - % apply(const char* const* string_list, + %apply(const char* const* string_list, const int list_len){(const char* const* names, const size_t numNames)}; void setDBA(SpatialDB* db, const char* const* names, const size_t numNames); - % clear(const char* const* names, + %clear(const char* const* names, const size_t numNames); /** Set database B. @@ -53,13 +54,13 @@ namespace spatialdata { * @param names Array of names of values to use with database. * @param numNames Size of array of names. */ - % apply(const char* const* string_list, + %apply(const char* const* string_list, const int list_len){(const char* const* names, const size_t numNames)}; void setDBB(SpatialDB* db, const char* const* names, const size_t numNames); - % clear(const char* const* names, + %clear(const char* const* names, const size_t numNames); /// Open the database and prepare for querying. @@ -75,12 +76,12 @@ namespace spatialdata { * @param names Names of values to be returned in queries * @param numVals Number of values to be returned in queries */ - % apply(const char* const* string_list, + %apply(const char* const* string_list, const int list_len){(const char* const* names, const size_t numVals)}; void setQueryValues(const char* const* names, const size_t numVals); - % clear(const char* const* names, + %clear(const char* const* names, const size_t numVals); /** Query the database. @@ -97,10 +98,10 @@ namespace spatialdata { * @returns 0 on success, 1 on failure (i.e., could not interpolate * so values set to 0) */ - % apply(double* INPLACE_ARRAY1, + %apply(double* INPLACE_ARRAY1, int DIM1){(double* vals, const size_t numVals)}; - % apply(double* IN_ARRAY1, + %apply(double* IN_ARRAY1, int DIM1){(const double* coords, const size_t numDims)}; int query(double* vals, @@ -108,9 +109,9 @@ namespace spatialdata { const double* coords, const size_t numDims, const spatialdata::geocoords::CoordSys* pCSQuery); - % clear(double* vals, + %clear(double* vals, const size_t numVals); - % clear(const double* coords, + %clear(const double* coords, const size_t numDims); }; // class CompositeDB diff --git a/modulesrc/spatialdb/GravityField.i b/modulesrc/spatialdb/GravityField.i index fff0bb07..6b675420 100644 --- a/modulesrc/spatialdb/GravityField.i +++ b/modulesrc/spatialdb/GravityField.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/spatialdb/GravityField.i * @@ -62,12 +63,12 @@ namespace spatialdata { * @param names Names of values to be returned in queries * @param numVals Number of values to be returned in queries */ - % apply(const char* const* string_list, + %apply(const char* const* string_list, const int list_len){(const char* const* names, const size_t numVals)}; void setQueryValues(const char* const* names, const size_t numVals); - % clear(const char* const* names, + %clear(const char* const* names, const size_t numVals); /** Query the database. @@ -84,10 +85,10 @@ namespace spatialdata { * @returns 0 on success, 1 on failure (i.e., could not interpolate * so values set to 0) */ - % apply(double* INPLACE_ARRAY1, + %apply(double* INPLACE_ARRAY1, int DIM1){(double* vals, const size_t numVals)}; - % apply(double* IN_ARRAY1, + %apply(double* IN_ARRAY1, int DIM1){(const double* coords, const size_t numDims)}; int query(double* vals, @@ -95,9 +96,9 @@ namespace spatialdata { const double* coords, const size_t numDims, const spatialdata::geocoords::CoordSys* cs); - % clear(double* vals, + %clear(double* vals, const size_t numVals); - % clear(const double* coords, + %clear(const double* coords, const size_t numDims); }; // class GravityField diff --git a/modulesrc/spatialdb/Makefile.am b/modulesrc/spatialdb/Makefile.am index 0b305721..ed4bd0fd 100644 --- a/modulesrc/spatialdb/Makefile.am +++ b/modulesrc/spatialdb/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + subpackage = spatialdb include $(top_srcdir)/subpackage.am diff --git a/modulesrc/spatialdb/SCECCVMH.i b/modulesrc/spatialdb/SCECCVMH.i index 9208d917..3122cb14 100644 --- a/modulesrc/spatialdb/SCECCVMH.i +++ b/modulesrc/spatialdb/SCECCVMH.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/spatialdb/SCECCVMH.i * @@ -66,12 +67,12 @@ namespace spatialdata { * @param names Names of values to be returned in queries * @param numVals Number of values to be returned in queries */ - % apply(const char* const* string_list, + %apply(const char* const* string_list, const int list_len){(const char* const* names, const size_t numVals)}; void setQueryValues(const char* const* names, const size_t numVals); - % clear(const char* const* names, + %clear(const char* const* names, const size_t numVals); /** Query the database. @@ -89,10 +90,10 @@ namespace spatialdata { * * @returns 0 on success, 1 on failure (i.e., could not interpolate) */ - % apply(double* INPLACE_ARRAY1, + %apply(double* INPLACE_ARRAY1, int DIM1){(double* vals, const size_t numVals)}; - % apply(double* IN_ARRAY1, + %apply(double* IN_ARRAY1, int DIM1){(const double* coords, const size_t numDims)}; int query(double* vals, @@ -100,9 +101,9 @@ namespace spatialdata { const double* coords, const size_t numDims, const spatialdata::geocoords::CoordSys* pCSQuery); - % clear(double* vals, + %clear(double* vals, const size_t numVals); - % clear(const double* coords, + %clear(const double* coords, const size_t numDims); }; // SCECCVMH diff --git a/modulesrc/spatialdb/SimpleDB.i b/modulesrc/spatialdb/SimpleDB.i index 6355be3c..66339c8f 100644 --- a/modulesrc/spatialdb/SimpleDB.i +++ b/modulesrc/spatialdb/SimpleDB.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/spatialdb/SimpleDB.i * @@ -77,12 +78,12 @@ namespace spatialdata { * @param names Names of values to be returned in queries * @param numVals Number of values to be returned in queries */ - % apply(const char* const* string_list, + %apply(const char* const* string_list, const int list_len){(const char* const* names, const size_t numVals)}; void setQueryValues(const char* const* names, const size_t numVals); - % clear(const char* const* names, + %clear(const char* const* names, const size_t numVals); /** Query the database. @@ -99,10 +100,10 @@ namespace spatialdata { * @returns 0 on success, 1 on failure (i.e., could not interpolate * so values set to 0) */ - % apply(double* INPLACE_ARRAY1, + %apply(double* INPLACE_ARRAY1, int DIM1){(double* vals, const size_t numVals)}; - % apply(double* IN_ARRAY1, + %apply(double* IN_ARRAY1, int DIM1){(const double* coords, const size_t numDims)}; int query(double* vals, @@ -110,9 +111,9 @@ namespace spatialdata { const double* coords, const size_t numDims, const spatialdata::geocoords::CoordSys* pCSQuery); - % clear(double* vals, + %clear(double* vals, const size_t numVals); - % clear(const double* coords, + %clear(const double* coords, const size_t numDims); }; // class SimpleDB diff --git a/modulesrc/spatialdb/SimpleDBData.i b/modulesrc/spatialdb/SimpleDBData.i index 1cd0b7f6..b7a2c2ca 100644 --- a/modulesrc/spatialdb/SimpleDBData.i +++ b/modulesrc/spatialdb/SimpleDBData.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/spatialdb/SimpleDBData.i * @@ -46,7 +47,7 @@ namespace spatialdata { * @param numLocs Number of locations. * @param numValues Number of values. */ - % apply(double* IN_ARRAY2, + %apply(double* IN_ARRAY2, int DIM1, int DIM2){(const double* values, const size_t numLocs, @@ -54,7 +55,7 @@ namespace spatialdata { void setData(const double* values, const size_t numLocs, const size_t numValues); - % clear(const double* values, + %clear(const double* values, const size_t numLocs, const size_t numValues); @@ -66,7 +67,7 @@ namespace spatialdata { * @param numLocs Number of locations. * @param spaceDim Spatial dimension of coordinates. */ - % apply(double* IN_ARRAY2, + %apply(double* IN_ARRAY2, int DIM1, int DIM2){(const double* values, const size_t numLocs, @@ -74,7 +75,7 @@ namespace spatialdata { void setCoordinates(const double* values, const size_t numLocs, const size_t spaceDim); - % clear(const double* values, + %clear(const double* values, const size_t numLocs, const size_t numValues); @@ -85,12 +86,12 @@ namespace spatialdata { * @param values Array of names of values [numValues]. * @param numValues Number of values. */ - % apply(const char* const* string_list, + %apply(const char* const* string_list, const int list_len){(const char* const* values, const size_t numValues)}; void setNames(const char* const* values, const size_t numValues); - % clear(const char* const* values, + %clear(const char* const* values, const size_t numValues); /** Set units of values. @@ -100,12 +101,12 @@ namespace spatialdata { * @param values Array of units of values [numValues]. * @param numValues Number of values. */ - % apply(const char* const* string_list, + %apply(const char* const* string_list, const int list_len){(const char* const* values, const int numValues)}; void setUnits(const char* const* values, const int numValues); - % clear(const char* const* values, + %clear(const char* const* values, const int numValues); /** Get number of locations for data. diff --git a/modulesrc/spatialdb/SimpleGridAscii.i b/modulesrc/spatialdb/SimpleGridAscii.i index cdf16985..f8332f5a 100644 --- a/modulesrc/spatialdb/SimpleGridAscii.i +++ b/modulesrc/spatialdb/SimpleGridAscii.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/spatialdb/SimpleGridAscii.i * @@ -41,4 +42,5 @@ namespace spatialdata { } // namespace spatialdb } // namespace spatialdata + // End of file diff --git a/modulesrc/spatialdb/SimpleGridDB.i b/modulesrc/spatialdb/SimpleGridDB.i index 843ce7f6..f98e1390 100644 --- a/modulesrc/spatialdb/SimpleGridDB.i +++ b/modulesrc/spatialdb/SimpleGridDB.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/spatialdb/SimpleGridDB.i * @@ -63,12 +64,12 @@ namespace spatialdata { * @param names Names of values to be returned in queries * @param numVals Number of values to be returned in queries */ - % apply(const char* const* string_list, + %apply(const char* const* string_list, const int list_len){(const char* const* names, const size_t numVals)}; void setQueryValues(const char* const* names, const size_t numVals); - % clear(const char* const* names, + %clear(const char* const* names, const size_t numVals); /** Query the database. @@ -85,10 +86,10 @@ namespace spatialdata { * @returns 0 on success, 1 on failure (i.e., could not interpolate * so values set to 0) */ - % apply(double* INPLACE_ARRAY1, + %apply(double* INPLACE_ARRAY1, int DIM1){(double* vals, const size_t numVals)}; - % apply(double* IN_ARRAY1, + %apply(double* IN_ARRAY1, int DIM1){(const double* coords, const size_t numDims)}; int query(double* vals, @@ -96,9 +97,9 @@ namespace spatialdata { const double* coords, const size_t numDims, const spatialdata::geocoords::CoordSys* pCSQuery); - % clear(double* vals, + %clear(double* vals, const size_t numVals); - % clear(const double* coords, + %clear(const double* coords, const size_t numDims); /** Allocate room for data. @@ -122,12 +123,12 @@ namespace spatialdata { * @param values Values along x-axis. * @param size Number of values along x-axis. */ - % apply(double* IN_ARRAY1, + %apply(double* IN_ARRAY1, int DIM1){(const double* values, const size_t size)}; void setX(const double* values, const size_t size); - % clear(double* values, + %clear(double* values, const size_t size); /** Set coordinates along y-axis; @@ -135,12 +136,12 @@ namespace spatialdata { * @param values Values along y-axis. * @param size Number of values along y-axis. */ - % apply(double* IN_ARRAY1, + %apply(double* IN_ARRAY1, int DIM1){(const double* values, const size_t size)}; void setY(const double* values, const size_t size); - % clear(double* values, + %clear(double* values, const size_t size); /** Set coordinates along z-axis; @@ -148,12 +149,12 @@ namespace spatialdata { * @param values Values along z-axis. * @param size Number of values along z-axis. */ - % apply(double* IN_ARRAY1, + %apply(double* IN_ARRAY1, int DIM1){(const double* values, const size_t size)}; void setZ(const double* values, const size_t size); - % clear(double* values, + %clear(double* values, const size_t size); /** Set data values. @@ -165,12 +166,12 @@ namespace spatialdata { * @param numLocs2 Number of locations. * @param numValues Number of values per location. */ - % apply(double* IN_ARRAY2, + %apply(double* IN_ARRAY2, int DIM1, int DIM2){(const double* coords, const size_t numLocs, const size_t spaceDim)}; - % apply(double* IN_ARRAY2, + %apply(double* IN_ARRAY2, int DIM1, int DIM2){(const double* values, const size_t numLocs2, @@ -181,10 +182,10 @@ namespace spatialdata { const double* values, const size_t numLocs2, const size_t numValues); - % clear(double* coords, + %clear(double* coords, const size_t size, const size_t spaceDim); - % clear(double* values, + %clear(double* values, const size_t numLocs2, const size_t numValues); @@ -193,12 +194,12 @@ namespace spatialdata { * @param values Names of values. * @param numValues Number of values. */ - % apply(const char* const* string_list, + %apply(const char* const* string_list, const int list_len){(const char* const* values, const size_t numValues)}; void setNames(const char* const* values, const size_t numValues); - % clear(const char* const* values, + %clear(const char* const* values, const size_t numValues); /** Set units of data values. @@ -206,12 +207,12 @@ namespace spatialdata { * @param values Units of values. * @param numValues Number of values. */ - % apply(const char* const* string_list, + %apply(const char* const* string_list, const int list_len){(const char* const* values, const size_t numValues)}; void setUnits(const char* const* values, const size_t numValues); - % clear(const char* const* values, + %clear(const char* const* values, const size_t numValues); /** Set filename containing data. diff --git a/modulesrc/spatialdb/SimpleIO.i b/modulesrc/spatialdb/SimpleIO.i index 706e447c..a5756ef4 100644 --- a/modulesrc/spatialdb/SimpleIO.i +++ b/modulesrc/spatialdb/SimpleIO.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/spatialdb/SimpleIO.i * @@ -59,4 +60,5 @@ namespace spatialdata { } // namespace spatialdb } // namespace spatialdata + // End of file diff --git a/modulesrc/spatialdb/SimpleIOAscii.i b/modulesrc/spatialdb/SimpleIOAscii.i index a1431ff5..42dee3a0 100644 --- a/modulesrc/spatialdb/SimpleIOAscii.i +++ b/modulesrc/spatialdb/SimpleIOAscii.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/spatialdb/SimpleIOAscii.i * @@ -47,4 +48,5 @@ namespace spatialdata { } // namespace spatialdb } // namespace spatialdata + // End of file diff --git a/modulesrc/spatialdb/SpatialDBObj.i b/modulesrc/spatialdb/SpatialDBObj.i index 78d3ed67..4c4a0021 100644 --- a/modulesrc/spatialdb/SpatialDBObj.i +++ b/modulesrc/spatialdb/SpatialDBObj.i @@ -1,16 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT -/** @file modulesrc/spatialdb/SpatialDBObj.i - * - * @brief SWIG interface to C++ SpatialDB object. - */ namespace spatialdata { namespace geocoords { @@ -59,13 +55,13 @@ namespace spatialdata { * @param names Names of values to be returned in queries * @param numVals Number of values to be returned in queries */ - % apply(const char* const* string_list, + %apply(const char* const* string_list, const int list_len){(const char* const* names, const size_t numVals)}; virtual void setQueryValues(const char* const* names, const size_t numVals) = 0; - % clear(const char* const* names, + %clear(const char* const* names, const size_t numVals); /** Query the database. @@ -83,10 +79,10 @@ namespace spatialdata { * * @returns 0 on success, 1 on failure (i.e., could not interpolate) */ - % apply(double* INPLACE_ARRAY1, + %apply(double* INPLACE_ARRAY1, int DIM1){(double* vals, const size_t numVals)}; - % apply(double* IN_ARRAY1, + %apply(double* IN_ARRAY1, int DIM1){(const double* coords, const size_t numDims)}; virtual int query(double* vals, @@ -95,9 +91,9 @@ namespace spatialdata { const size_t numDims, const spatialdata::geocoords::CoordSys* csQuery) = 0; - % clear(double* vals, + %clear(double* vals, const size_t numVals); - % clear(const double* coords, + %clear(const double* coords, const size_t numDims); /** Perform multiple queries of the database. @@ -121,15 +117,15 @@ namespace spatialdata { * @param numDimsC Number of dimensions for coordinates. * @param csQuery Coordinate system of coordinates. */ - % apply(double* INPLACE_ARRAY2, + %apply(double* INPLACE_ARRAY2, int DIM1, int DIM2){(double* vals, const size_t numLocsV, const size_t numValsV)}; - % apply(int* INPLACE_ARRAY1, + %apply(int* INPLACE_ARRAY1, int DIM1){(int* err, const size_t numLocsE)}; - % apply(double* IN_ARRAY2, + %apply(double* IN_ARRAY2, int DIM1, int DIM2){(const double* coords, const size_t numLocsC, @@ -144,12 +140,12 @@ namespace spatialdata { const size_t numDimsC, const spatialdata::geocoords::CoordSys* csQuery); - % clear(double* vals, + %clear(double* vals, const size_t numLocsV, const size_t numValsV); - % clear(int* err, + %clear(int* err, const size_t numLocsE); - % clear(const double* coords, + %clear(const double* coords, const size_t numLocsC, const size_t numDimsC); @@ -158,4 +154,5 @@ namespace spatialdata { } // namespace spatialdb } // namespace spatialdata + // End of file diff --git a/modulesrc/spatialdb/TimeHistory.i b/modulesrc/spatialdb/TimeHistory.i index c93e5e07..5b1fb400 100644 --- a/modulesrc/spatialdb/TimeHistory.i +++ b/modulesrc/spatialdb/TimeHistory.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/spatialdb/TimeHistory.i * @@ -69,15 +70,16 @@ namespace spatialdata { * * @returns 0 on success, 1 on failure (i.e., could not interpolate) */ - % apply double* OUTPUT{double* value}; + %apply double* OUTPUT{double* value}; int query(double* value, const double t); - % clear(double* value); + %clear(double* value); }; // class TimeHistory } // namespace spatialdb } // namespace spatialdata + // End of file diff --git a/modulesrc/spatialdb/TimeHistoryIO.i b/modulesrc/spatialdb/TimeHistoryIO.i index a9fe9f83..413fd01c 100644 --- a/modulesrc/spatialdb/TimeHistoryIO.i +++ b/modulesrc/spatialdb/TimeHistoryIO.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/spatialdb/TimeHistory.i * @@ -30,10 +31,10 @@ namespace spatialdata { * @param timeUnits Units associated with time stamps. * @param filename Filename for time history. */ - % apply(double* IN_ARRAY1, + %apply(double* IN_ARRAY1, int DIM1){(const double* time, const size_t nptsT)}; - % apply(double* IN_ARRAY1, + %apply(double* IN_ARRAY1, int DIM1){(const double* amplitude, const size_t nptsA)}; static void write(const double* time, @@ -42,9 +43,9 @@ namespace spatialdata { const size_t nptsA, const char* timeUnits, const char* filename); - % clear(const double* time, + %clear(const double* time, const size_t nptsT); - % clear(const double* amplitude, + %clear(const double* amplitude, const size_t nptsA); }; // class TimeHistoryIO diff --git a/modulesrc/spatialdb/UniformDB.i b/modulesrc/spatialdb/UniformDB.i index df221b77..a3bc780e 100644 --- a/modulesrc/spatialdb/UniformDB.i +++ b/modulesrc/spatialdb/UniformDB.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/spatialdb/UniformDB.i * @@ -37,9 +38,9 @@ namespace spatialdata { * @param values Array of values in database. * @param numValues Number of values in database. */ - % apply(const char* const* string_list){(const char* const* names)}; - % apply(const char* const* string_list){(const char* const* units)}; - % apply(double* IN_ARRAY1, + %apply(const char* const* string_list){(const char* const* names)}; + %apply(const char* const* string_list){(const char* const* units)}; + %apply(double* IN_ARRAY1, int DIM1){(const double* values, const size_t numValues)}; void setData(const char* const* names, @@ -47,9 +48,9 @@ namespace spatialdata { const double* values, const size_t numValues); - % clear(const char* const* names); - % clear(const char* const* units); - % clear(const double* values, + %clear(const char* const* names); + %clear(const char* const* units); + %clear(const double* values, const size_t numValues); /// Open the database and prepare for querying. @@ -65,13 +66,13 @@ namespace spatialdata { * @param names Names of values to be returned in queries * @param numVals Number of values to be returned in queries */ - % apply(const char* const* string_list, + %apply(const char* const* string_list, const int list_len){(const char* const* names, const size_t numVals)}; void setQueryValues(const char* const* names, const size_t numVals); - % clear(const char* const* names, + %clear(const char* const* names, const size_t numVals); /** Query the database. @@ -88,10 +89,10 @@ namespace spatialdata { * @returns 0 on success, 1 on failure (i.e., could not interpolate * so values set to 0) */ - % apply(double* INPLACE_ARRAY1, + %apply(double* INPLACE_ARRAY1, int DIM1){(double* vals, const size_t numVals)}; - % apply(double* IN_ARRAY1, + %apply(double* IN_ARRAY1, int DIM1){(const double* coords, const size_t numDims)}; int query(double* vals, @@ -100,9 +101,9 @@ namespace spatialdata { const size_t numDims, const spatialdata::geocoords::CoordSys* pCSQuery); - % clear(double* vals, + %clear(double* vals, const size_t numVals); - % clear(const double* coords, + %clear(const double* coords, const size_t numDims); }; // class UniformDB @@ -110,4 +111,5 @@ namespace spatialdata { } // namespace spatialdb } // namespace spatialdata + // End of file diff --git a/modulesrc/spatialdb/UserFunctionDB.i b/modulesrc/spatialdb/UserFunctionDB.i index af728b4f..355f717e 100644 --- a/modulesrc/spatialdb/UserFunctionDB.i +++ b/modulesrc/spatialdb/UserFunctionDB.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** @file modulesrc/spatialdb/UserFunctionDB.i * @@ -98,12 +99,12 @@ namespace spatialdata { * @param names Names of values to be returned in queries * @param numVals Number of values to be returned in queries */ - % apply(const char* const* string_list, + %apply(const char* const* string_list, const int list_len){(const char* const* names, const size_t numVals)}; void setQueryValues(const char* const* names, const size_t numVals); - % clear(const char* const* names, + %clear(const char* const* names, const size_t numVals); /** Query the database. @@ -120,10 +121,10 @@ namespace spatialdata { * @returns 0 on success, 1 on failure (i.e., could not interpolate * so values set to 0) */ - % apply(double* INPLACE_ARRAY1, + %apply(double* INPLACE_ARRAY1, int DIM1){(double* vals, const size_t numVals)}; - % apply(double* IN_ARRAY1, + %apply(double* IN_ARRAY1, int DIM1){(const double* coords, const size_t numDims)}; int query(double* vals, @@ -131,9 +132,9 @@ namespace spatialdata { const double* coords, const size_t numDims, const spatialdata::geocoords::CoordSys* pCSQuery); - % clear(double* vals, + %clear(double* vals, const size_t numVals); - % clear(const double* coords, + %clear(const double* coords, const size_t numDims); /** Set coordinate system associated with user functions. diff --git a/modulesrc/spatialdb/spatialdb.i b/modulesrc/spatialdb/spatialdb.i index b5ff1ad8..ffe774e1 100644 --- a/modulesrc/spatialdb/spatialdb.i +++ b/modulesrc/spatialdb/spatialdb.i @@ -1,70 +1,79 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + // SWIG interface -% - module spatialdb +%module spatialdb - // Header files for module C++ code - % - { +// Header files for module C++ code +%{ #include #include // USES std::string #include "spatialdata/geocoords/CoordSys.hh" -#include "spatialdata/spatialdb/AnalyticDB.hh" -#include "spatialdata/spatialdb/CompositeDB.hh" -#include "spatialdata/spatialdb/GravityField.hh" -#include "spatialdata/spatialdb/SCECCVMH.hh" +#include "spatialdata/spatialdb/SpatialDB.hh" #include "spatialdata/spatialdb/SimpleDB.hh" #include "spatialdata/spatialdb/SimpleDBData.hh" -#include "spatialdata/spatialdb/SimpleGridAscii.hh" -#include "spatialdata/spatialdb/SimpleGridDB.hh" #include "spatialdata/spatialdb/SimpleIO.hh" #include "spatialdata/spatialdb/SimpleIOAscii.hh" -#include "spatialdata/spatialdb/SpatialDB.hh" -#include "spatialdata/spatialdb/TimeHistory.hh" -#include "spatialdata/spatialdb/TimeHistoryIO.hh" #include "spatialdata/spatialdb/UniformDB.hh" +#include "spatialdata/spatialdb/AnalyticDB.hh" +#include "spatialdata/spatialdb/SimpleGridDB.hh" +#include "spatialdata/spatialdb/SimpleGridAscii.hh" #include "spatialdata/spatialdb/UserFunctionDB.hh" +#include "spatialdata/spatialdb/CompositeDB.hh" +#include "spatialdata/spatialdb/SCECCVMH.hh" +#include "spatialdata/spatialdb/GravityField.hh" +#include "spatialdata/spatialdb/TimeHistory.hh" +#include "spatialdata/spatialdb/TimeHistoryIO.hh" - % } +%} - % include "exception.i" % exception { - try { - $action - } catch (const std::exception& err) { - SWIG_exception(SWIG_RuntimeError, err.what()); - } // try/catch -} // exception +%include "exception.i" +%exception { + try { + $action + } catch (const std::exception& err) { + SWIG_exception(SWIG_RuntimeError, err.what()); + } // try/catch + } // exception -% include "typemaps.i" % - include "../include/chararray.i" +%include "typemaps.i" +%include "../include/chararray.i" - // Numpy interface stuff - % - { +// Numpy interface stuff +%{ #define SWIG_FILE_WITH_INIT - % } % - include "../include/numpy.i" % init % { - import_array(); - % -} +%} +%include "../include/numpy.i" +%init %{ +import_array(); +%} // Interfaces -% include "SpatialDBObj.i" % include "SimpleDB.i" % include "SimpleDBData.i" % include "SimpleIO.i" % - include "SimpleIOAscii.i" % include "UniformDB.i" % include "AnalyticDB.i" % include "SimpleGridDB.i" % - include "SimpleGridAscii.i" % include "UserFunctionDB.i" % include "CompositeDB.i" % include "SCECCVMH.i" % - include "GravityField.i" % include "TimeHistory.i" % - include "TimeHistoryIO.i" +%include "SpatialDBObj.i" +%include "SimpleDB.i" +%include "SimpleDBData.i" +%include "SimpleIO.i" +%include "SimpleIOAscii.i" +%include "UniformDB.i" +%include "AnalyticDB.i" +%include "SimpleGridDB.i" +%include "SimpleGridAscii.i" +%include "UserFunctionDB.i" +%include "CompositeDB.i" +%include "SCECCVMH.i" +%include "GravityField.i" +%include "TimeHistory.i" +%include "TimeHistoryIO.i" - // End of file +// End of file diff --git a/modulesrc/utils/Makefile.am b/modulesrc/utils/Makefile.am index 45af90c4..41f7280a 100644 --- a/modulesrc/utils/Makefile.am +++ b/modulesrc/utils/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + subpackage = utils include $(top_srcdir)/subpackage.am diff --git a/modulesrc/utils/SpatialdataVersion.i b/modulesrc/utils/SpatialdataVersion.i index ec923832..9aa6bbc2 100644 --- a/modulesrc/utils/SpatialdataVersion.i +++ b/modulesrc/utils/SpatialdataVersion.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + /** * @file modulesrc/utils/SpatialdataVersion.i @@ -71,4 +72,5 @@ namespace spatialdata { } // namespace utils } // namespace spatialdata + // End of file diff --git a/modulesrc/utils/utils.i b/modulesrc/utils/utils.i index b88bfd55..ce745cb8 100644 --- a/modulesrc/utils/utils.i +++ b/modulesrc/utils/utils.i @@ -1,31 +1,32 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + // SWIG interface -% - module utils +%module utils - // Header files for module C++ code - % - { +// Header files for module C++ code +%{ #include "spatialdata/utils/SpatialdataVersion.hh" - % } +%} - % include "exception.i" % exception { - try { - $action - } catch (const std::exception& err) { - SWIG_exception(SWIG_RuntimeError, err.what()); - } // try/catch +%include "exception.i" +%exception { + try { + $action + } catch (const std::exception& err) { + SWIG_exception(SWIG_RuntimeError, err.what()); + } // try/catch } // exception // Interfaces -% include "SpatialdataVersion.i" +%include "SpatialdataVersion.i" - // End of file +// End of file diff --git a/setup.cfg b/setup.cfg index 7f5f87cd..b9acac28 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,13 @@ +# -*- config -*- +# -*- coding: utf-8 -*- +# +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + [egg_info] tag_build = tag_date = 0 @@ -35,3 +45,6 @@ exclude = modulesrc templates tests + + +# End of file diff --git a/setup.py b/setup.py index 259b086b..b11ef72d 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,14 @@ -# ================================================================================================= -# This code is part of PyLith, developed through the Computational Infrastructure -# for Geodynamics (https://github.com/geodynamics/pylith). +#!/usr/bin/env python3 +# -*- python -*- +# -*- coding: utf-8 -*- # -# Copyright (c) 2010-2026 All rights reserved. +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). # -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + # Setup configuration is in setup.cfg. import setuptools diff --git a/spatialdata/Makefile.am b/spatialdata/Makefile.am index a7d03f95..4c95ae91 100644 --- a/spatialdata/Makefile.am +++ b/spatialdata/Makefile.am @@ -1,12 +1,12 @@ -# -*- Makefile -*- -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + if PIP_BUILD_ISOLATION else diff --git a/spatialdata/__init__.py b/spatialdata/__init__.py index adaa0a65..0b7aebc4 100644 --- a/spatialdata/__init__.py +++ b/spatialdata/__init__.py @@ -1,14 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= -# @file spatialdata/__init__.py -# -# @brief Python top-level SpatialData module initialization +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + try: import importlib.metadata @@ -23,7 +21,6 @@ __all__ = [ "geocoords", "spatialdb", - "units", "utils", ] diff --git a/spatialdata/geocoords/CSCart.py b/spatialdata/geocoords/CSCart.py index c06871c6..179a4ddb 100644 --- a/spatialdata/geocoords/CSCart.py +++ b/spatialdata/geocoords/CSCart.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from .CoordSys import CoordSys from .geocoords import CSCart as ModuleCSCart diff --git a/spatialdata/geocoords/CSGeo.py b/spatialdata/geocoords/CSGeo.py index 4be3500c..23dee306 100644 --- a/spatialdata/geocoords/CSGeo.py +++ b/spatialdata/geocoords/CSGeo.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from .CoordSys import CoordSys from .geocoords import CSGeo as ModuleCSGeo diff --git a/spatialdata/geocoords/CSGeoLocal.py b/spatialdata/geocoords/CSGeoLocal.py index c271dd06..9c76561d 100644 --- a/spatialdata/geocoords/CSGeoLocal.py +++ b/spatialdata/geocoords/CSGeoLocal.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from .CSGeo import CSGeo from .geocoords import CSGeoLocal as ModuleCSGeoLocal diff --git a/spatialdata/geocoords/Converter.py b/spatialdata/geocoords/Converter.py index b280c071..65facbe3 100644 --- a/spatialdata/geocoords/Converter.py +++ b/spatialdata/geocoords/Converter.py @@ -1,11 +1,11 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT def convert(points, csDest, csSrc): diff --git a/spatialdata/geocoords/CoordSys.py b/spatialdata/geocoords/CoordSys.py index a72d54dc..436e2d16 100644 --- a/spatialdata/geocoords/CoordSys.py +++ b/spatialdata/geocoords/CoordSys.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from pythia.pyre.components.Component import Component diff --git a/spatialdata/geocoords/__init__.py b/spatialdata/geocoords/__init__.py index c19dbfe0..22b503de 100644 --- a/spatialdata/geocoords/__init__.py +++ b/spatialdata/geocoords/__init__.py @@ -1,16 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= -# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT -# @file spatialdata/geocoords/__init__.py -# -# @brief Python spatialdata geocoords module initialization. __all__ = [ "CoordSys", diff --git a/spatialdata/spatialdb/AnalyticDB.py b/spatialdata/spatialdb/AnalyticDB.py index 1883ef80..faef48ff 100644 --- a/spatialdata/spatialdb/AnalyticDB.py +++ b/spatialdata/spatialdb/AnalyticDB.py @@ -1,11 +1,11 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT from .SpatialDBObj import SpatialDBObj diff --git a/spatialdata/spatialdb/CompositeDB.py b/spatialdata/spatialdb/CompositeDB.py index f7e91e55..c50bef68 100644 --- a/spatialdata/spatialdb/CompositeDB.py +++ b/spatialdata/spatialdb/CompositeDB.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from .SpatialDBObj import SpatialDBObj from .spatialdb import CompositeDB as ModuleCompositeDB diff --git a/spatialdata/spatialdb/GravityField.py b/spatialdata/spatialdb/GravityField.py index f6377407..e3b5cd63 100644 --- a/spatialdata/spatialdb/GravityField.py +++ b/spatialdata/spatialdb/GravityField.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from .SpatialDBObj import SpatialDBObj from .spatialdb import GravityField as ModuleGravityField diff --git a/spatialdata/spatialdb/SCECCVMH.py b/spatialdata/spatialdb/SCECCVMH.py index 84180758..d382c134 100644 --- a/spatialdata/spatialdb/SCECCVMH.py +++ b/spatialdata/spatialdb/SCECCVMH.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from .SpatialDBObj import SpatialDBObj from .spatialdb import SCECCVMH as ModuleSCECCVMH diff --git a/spatialdata/spatialdb/SimpleDB.py b/spatialdata/spatialdb/SimpleDB.py index b831bd58..08d8d4b4 100644 --- a/spatialdata/spatialdb/SimpleDB.py +++ b/spatialdata/spatialdb/SimpleDB.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from .SpatialDBObj import SpatialDBObj from .spatialdb import SimpleDB as ModuleSimpleDB diff --git a/spatialdata/spatialdb/SimpleGridAscii.py b/spatialdata/spatialdb/SimpleGridAscii.py index 3d462d78..88a9dc64 100644 --- a/spatialdata/spatialdb/SimpleGridAscii.py +++ b/spatialdata/spatialdb/SimpleGridAscii.py @@ -1,11 +1,11 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT from pythia.pyre.components.Component import Component diff --git a/spatialdata/spatialdb/SimpleGridDB.py b/spatialdata/spatialdb/SimpleGridDB.py index 5d1f5873..fbab15e2 100644 --- a/spatialdata/spatialdb/SimpleGridDB.py +++ b/spatialdata/spatialdb/SimpleGridDB.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import pathlib diff --git a/spatialdata/spatialdb/SimpleIO.py b/spatialdata/spatialdb/SimpleIO.py index e8b303a4..e8aac0b6 100644 --- a/spatialdata/spatialdb/SimpleIO.py +++ b/spatialdata/spatialdb/SimpleIO.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import pathlib diff --git a/spatialdata/spatialdb/SimpleIOAscii.py b/spatialdata/spatialdb/SimpleIOAscii.py index 367d8799..30f7f27f 100644 --- a/spatialdata/spatialdb/SimpleIOAscii.py +++ b/spatialdata/spatialdb/SimpleIOAscii.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from .SimpleIO import SimpleIO from .spatialdb import SimpleIOAscii as ModuleSimpleIOAscii diff --git a/spatialdata/spatialdb/SpatialDBObj.py b/spatialdata/spatialdb/SpatialDBObj.py index 13a6b1ee..47621314 100644 --- a/spatialdata/spatialdb/SpatialDBObj.py +++ b/spatialdata/spatialdb/SpatialDBObj.py @@ -1,11 +1,11 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT from pythia.pyre.components.Component import Component diff --git a/spatialdata/spatialdb/TimeHistory.py b/spatialdata/spatialdb/TimeHistory.py index 55950e72..236354be 100644 --- a/spatialdata/spatialdb/TimeHistory.py +++ b/spatialdata/spatialdb/TimeHistory.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import pathlib diff --git a/spatialdata/spatialdb/TimeHistoryIO.py b/spatialdata/spatialdb/TimeHistoryIO.py index 9d350d2f..bd38f447 100644 --- a/spatialdata/spatialdb/TimeHistoryIO.py +++ b/spatialdata/spatialdb/TimeHistoryIO.py @@ -1,11 +1,11 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT def write(time, amplitude, units, filename): diff --git a/spatialdata/spatialdb/UniformDB.py b/spatialdata/spatialdb/UniformDB.py index f42bc647..43b43c8f 100644 --- a/spatialdata/spatialdb/UniformDB.py +++ b/spatialdata/spatialdb/UniformDB.py @@ -1,11 +1,11 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT from .SpatialDBObj import SpatialDBObj diff --git a/spatialdata/spatialdb/UserFunctionDB.py b/spatialdata/spatialdb/UserFunctionDB.py index bc20905b..6c304969 100644 --- a/spatialdata/spatialdb/UserFunctionDB.py +++ b/spatialdata/spatialdb/UserFunctionDB.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from .SpatialDBObj import SpatialDBObj from .spatialdb import UserFunctionDB as ModuleUserFunctionDB diff --git a/spatialdata/spatialdb/__init__.py b/spatialdata/spatialdb/__init__.py index 1ad61a57..6f9dde74 100644 --- a/spatialdata/spatialdb/__init__.py +++ b/spatialdata/spatialdb/__init__.py @@ -1,15 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= -# -# @file spatialdata/spatialdb/__init__.py -# -# @brief Python spatialdata spatialdb module initialization. +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + __all__ = [ "SCECCVMH", diff --git a/spatialdata/spatialdb/generator/GenSimpleDBApp.py b/spatialdata/spatialdb/generator/GenSimpleDBApp.py index b60b992c..c051d7bd 100644 --- a/spatialdata/spatialdb/generator/GenSimpleDBApp.py +++ b/spatialdata/spatialdb/generator/GenSimpleDBApp.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from pythia.pyre.applications.Script import Script from pythia.pyre.components.Component import Component diff --git a/spatialdata/spatialdb/generator/Geometry.py b/spatialdata/spatialdb/generator/Geometry.py index 6968f812..e6dceea6 100644 --- a/spatialdata/spatialdb/generator/Geometry.py +++ b/spatialdata/spatialdb/generator/Geometry.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from pythia.pyre.components.Component import Component diff --git a/spatialdata/spatialdb/generator/Shaper.py b/spatialdata/spatialdb/generator/Shaper.py index b68a2666..589b0b1c 100644 --- a/spatialdata/spatialdb/generator/Shaper.py +++ b/spatialdata/spatialdb/generator/Shaper.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from pythia.pyre.components.Component import Component diff --git a/spatialdata/spatialdb/generator/Value.py b/spatialdata/spatialdb/generator/Value.py index 9d1f280a..56849ca8 100644 --- a/spatialdata/spatialdb/generator/Value.py +++ b/spatialdata/spatialdb/generator/Value.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import numpy diff --git a/spatialdata/spatialdb/generator/__init__.py b/spatialdata/spatialdb/generator/__init__.py index 880c4fca..d08441f8 100644 --- a/spatialdata/spatialdb/generator/__init__.py +++ b/spatialdata/spatialdb/generator/__init__.py @@ -1,14 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= -# @file spatialdata/spatialdb/generator/__init__.py -# -# @brief Python spatialdata generator module initialization. +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + __all__ = [ "GenSimpleDBApp", diff --git a/spatialdata/testing/TestCases.py b/spatialdata/testing/TestCases.py index 55a11b55..537ad49c 100644 --- a/spatialdata/testing/TestCases.py +++ b/spatialdata/testing/TestCases.py @@ -1,11 +1,13 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + """PyLith module for unit test helper functions.""" import unittest diff --git a/spatialdata/testing/UnitTestApp.py b/spatialdata/testing/UnitTestApp.py index eb66a8e7..092da8e7 100644 --- a/spatialdata/testing/UnitTestApp.py +++ b/spatialdata/testing/UnitTestApp.py @@ -1,11 +1,13 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + """Application for running Python unit tests with code coverage. We place this script in tests/pytests so that we can import it into the individual scripts in the diff --git a/spatialdata/testing/__init__.py b/spatialdata/testing/__init__.py index 0411dc5b..770f76ce 100644 --- a/spatialdata/testing/__init__.py +++ b/spatialdata/testing/__init__.py @@ -1,11 +1,12 @@ -# ================================================================================================= -# This code is part of PyLith, developed through the Computational Infrastructure -# for Geodynamics (https://github.com/geodynamics/pylith). +#!/usr/bin/env python3 +# -*- python -*- +# -*- coding: utf-8 -*- # -# Copyright (c) 2010-2026 All rights reserved. +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). # -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT # End of file diff --git a/spatialdata/utils/PointsStream.py b/spatialdata/utils/PointsStream.py index 85e83278..dab5e14e 100644 --- a/spatialdata/utils/PointsStream.py +++ b/spatialdata/utils/PointsStream.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from pythia.pyre.components.Component import Component diff --git a/spatialdata/utils/__init__.py b/spatialdata/utils/__init__.py index 70b0f8ba..43034d4e 100644 --- a/spatialdata/utils/__init__.py +++ b/spatialdata/utils/__init__.py @@ -1,14 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT -# @file spatialdata/utils/__init__.py -# @brief Python spatialdata utils module initialization. __all__ = [ "PointsStream", diff --git a/subpackage.am b/subpackage.am index 1f00920f..cd5c51f0 100644 --- a/subpackage.am +++ b/subpackage.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + # define subpackage dirs subpkgsysconfdir = $(pkgsysconfdir)/$(subpackage) diff --git a/templates/Makefile.am b/templates/Makefile.am index d5960403..e435ae74 100644 --- a/templates/Makefile.am +++ b/templates/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + # Include files in templates in spatialdata source distribution. EXTRA_DIST = \ @@ -27,4 +28,5 @@ EXTRA_DIST = \ spatialdb/m4/cit_numpy.m4 \ spatialdb/m4/cit_python.m4 + # End of file diff --git a/templates/README b/templates/README deleted file mode 100644 index ee937bb4..00000000 --- a/templates/README +++ /dev/null @@ -1,4 +0,0 @@ -This directory contains templates for extending the functionality of -spatialdata. This includes adding interfaces to new types of spatial -databases, such as seismic velocity models (see the spatialdb -directory). diff --git a/templates/README.md b/templates/README.md new file mode 100644 index 00000000..ed0c28b1 --- /dev/null +++ b/templates/README.md @@ -0,0 +1,15 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + +# Templates + +This directory contains templates for extending the functionality of spatialdata. +This includes adding interfaces to new types of spatial databases, such as seismic velocity models(see the spatialdb directory). + +% End of file diff --git a/templates/spatialdb/Makefile.am b/templates/spatialdb/Makefile.am index 8516ebad..861b7b5a 100644 --- a/templates/spatialdb/Makefile.am +++ b/templates/spatialdb/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + # This files uses autoconf patterns in variables names so that the GNU # build system can automatically construct the dependencies and build diff --git a/templates/spatialdb/UniformVelModel.cc b/templates/spatialdb/UniformVelModel.cc index c7cd4cbf..51769865 100644 --- a/templates/spatialdb/UniformVelModel.cc +++ b/templates/spatialdb/UniformVelModel.cc @@ -1,14 +1,14 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + -// See UniformVelModel.hh for a description of each C++ function and -// its arguments. +// See UniformVelModel.hh for a description of each C++ function and its arguments. #include // machine specific info generated by configure diff --git a/templates/spatialdb/UniformVelModel.hh b/templates/spatialdb/UniformVelModel.hh index 06ae1b84..a284ed73 100644 --- a/templates/spatialdb/UniformVelModel.hh +++ b/templates/spatialdb/UniformVelModel.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "spatialdata/spatialdb/SpatialDB.hh" // ISA SpatialDB @@ -133,4 +135,5 @@ class contrib::spatialdb::UniformVelModel : public spatialdata::spatialdb::Spati }; // UniformVelModel + // End of file diff --git a/templates/spatialdb/UniformVelModel.i b/templates/spatialdb/UniformVelModel.i index 3d3c10aa..de5e5a8b 100644 --- a/templates/spatialdb/UniformVelModel.i +++ b/templates/spatialdb/UniformVelModel.i @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + // SWIG interface to C++ UniformVelModel object. @@ -102,4 +103,5 @@ namespace contrib { } // namespace spatialdb } // namespace contrib + // End of file diff --git a/templates/spatialdb/UniformVelModel.py b/templates/spatialdb/UniformVelModel.py index 57fc086e..11f3a6cc 100644 --- a/templates/spatialdb/UniformVelModel.py +++ b/templates/spatialdb/UniformVelModel.py @@ -1,18 +1,12 @@ -#!/usr/bin/env python +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT -# @brief Python object associated with the C++ UniformVelModel -# object. This objects provides a pythia.pyre interface to the C++ object. -## -# Factory: spatial_database from spatialdata.spatialdb.SpatialDBObj import SpatialDBObj from .spatialdbcontrib import UniformVelModel as ModuleUniformVelModel diff --git a/templates/spatialdb/__init__.py b/templates/spatialdb/__init__.py index 40f4849f..61dd7524 100644 --- a/templates/spatialdb/__init__.py +++ b/templates/spatialdb/__init__.py @@ -1,17 +1,12 @@ -#!/usr/bin/env python +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT -## @file __init__.py -## -## @brief Python module initialization __all__ = [ "UniformVelModel", diff --git a/templates/spatialdb/configure.ac b/templates/spatialdb/configure.ac index 77286f92..e42b6213 100644 --- a/templates/spatialdb/configure.ac +++ b/templates/spatialdb/configure.ac @@ -1,13 +1,12 @@ -# -*- autoconf -*- -# -# ================================================================================================= -# This code is part of SpatialData, developed through the Computational Infrastructure -# for Geodynamics (https://github.com/geodynamics/spatialdata). -# -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +dnl -*- autoconf -*- +dnl -*- coding: utf-8 -*- +dnl +dnl This code is part of SpatialData, developed through the Computational Infrastructure +dnl for Geodynamics (https://github.com/geodynamics/spatialdata). +dnl +dnl Copyright (c) 2010-2026 The SpatialData authors and contributors +dnl SPDX-License-Identifier: MIT + AC_PREREQ(2.59) AC_INIT([spatialdbcontrib], [0.0.1], [cig-short@geodynamics.org]) @@ -16,15 +15,15 @@ AC_CONFIG_AUX_DIR([./aux-config]) AC_CONFIG_MACRO_DIR([./m4]) AM_INIT_AUTOMAKE([foreign]) -# ---------------------------------------------------------------------- -# C/C++/libtool/install +dnl ---------------------------------------------------------------------- +dnl C/C++/libtool/install AC_PROG_CXX AC_PROG_CC AC_DISABLE_STATIC AC_PROG_LIBTOOL +dnl See issue119. if test "$allow_undefined_flag" = unsupported; then - # See issue119. AM_LDFLAGS="-no-undefined $AM_LDFLAGS" fi AM_CONDITIONAL([NO_UNDEFINED], [test "$allow_undefined_flag" = unsupported]) @@ -32,16 +31,16 @@ AC_SUBST(AM_LDFLAGS) AC_PROG_INSTALL -# PYTHON +dnl PYTHON AM_PATH_PYTHON([2.3]) CIT_PYTHON_SYSCONFIG -# SWIG +dnl SWIG CIT_NUMPY_PYTHON_MODULE CIT_NUMPY_INCDIR AC_PROG_SWIG(1.3.33) -# SPATIALDATA +dnl SPATIALDATA AC_LANG(C++) AC_CHECK_HEADER([spatialdata/spatialdb/SpatialDB.hh], [], [ AC_MSG_ERROR([SpatialDB header not found; try CPPFLAGS="-I"]) @@ -66,14 +65,14 @@ else fi -# ENDIANNESS +dnl ENDIANNESS AC_C_BIGENDIAN -# ---------------------------------------------------------------------- +dnl ---------------------------------------------------------------------- AC_CONFIG_FILES([Makefile tests/Makefile]) AC_OUTPUT -# End of file +dnl End of file diff --git a/templates/spatialdb/spatialdbcontrib.i b/templates/spatialdb/spatialdbcontrib.i index 28633fa3..c343c0b6 100644 --- a/templates/spatialdb/spatialdbcontrib.i +++ b/templates/spatialdb/spatialdbcontrib.i @@ -1,48 +1,51 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + // Define the spatialdatacontrib SWIG interface module. // Set module name -% - module spatialdbcontrib +%module spatialdbcontrib - // Header files for module C++ code. - % - { +// Header files for module C++ code. +%{ #include "UniformVelModel.hh" - % } + % +} - // Convert standard C++ exceptions to Python exceptions. - % include "exception.i" % exception { +// Convert standard C++ exceptions to Python exceptions. +%include "exception.i" +%exception { try { $ action } catch (const std::exception& err) { - SWIG_exception(SWIG_RuntimeError, err.what()); + SWIG_exception (SWIG_RuntimeError, err.what ()); } // try/catch } // exception -% include "typemaps.i" % - include "include/chararray.i" +%include "typemaps.i" +%include "include/chararray.i" - // Numpy interface stuff - % - { +// Numpy interface stuff +%{ #define SWIG_FILE_WITH_INIT - % } % - include "include/numpy.i" % init % { + % +} +%include "include/numpy.i" +%init %{ import_array(); % } // Interface files. -% include "spatialdb/SpatialDBObj.i" % - include "UniformVelModel.i" +%include "spatialdb/SpatialDBObj.i" +%include "UniformVelModel.i" + - // End of file +// End of file diff --git a/templates/spatialdb/tests/Makefile.am b/templates/spatialdb/tests/Makefile.am index bd90f525..c0b74d0f 100644 --- a/templates/spatialdb/tests/Makefile.am +++ b/templates/spatialdb/tests/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + TESTS = testcontrib.py dist_check_SCRIPTS = testcontrib.py diff --git a/templates/spatialdb/tests/TestUniformVelModel.py b/templates/spatialdb/tests/TestUniformVelModel.py index b036752e..08ef9d6a 100644 --- a/templates/spatialdb/tests/TestUniformVelModel.py +++ b/templates/spatialdb/tests/TestUniformVelModel.py @@ -1,13 +1,13 @@ #!/usr/bin/env python +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/templates/spatialdb/tests/testcontrib.py b/templates/spatialdb/tests/testcontrib.py index d9626987..89b247e1 100644 --- a/templates/spatialdb/tests/testcontrib.py +++ b/templates/spatialdb/tests/testcontrib.py @@ -1,13 +1,13 @@ #!/usr/bin/env python +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/Makefile.am b/tests/Makefile.am index a028173d..2f6f951b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + SUBDIRS = \ src \ diff --git a/tests/check.am b/tests/check.am index 3016b6e6..a03efe93 100644 --- a/tests/check.am +++ b/tests/check.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + AM_CPPFLAGS = -I$(top_srcdir)/libsrc -I$(PYTHON_INCDIR) diff --git a/tests/libtests/Makefile.am b/tests/libtests/Makefile.am index b3245bd5..c7d4a796 100644 --- a/tests/libtests/Makefile.am +++ b/tests/libtests/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + SUBDIRS = \ geocoords \ diff --git a/tests/libtests/geocoords/Makefile.am b/tests/libtests/geocoords/Makefile.am index 93d43e6c..d077baed 100644 --- a/tests/libtests/geocoords/Makefile.am +++ b/tests/libtests/geocoords/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + include $(top_srcdir)/tests/check.am diff --git a/tests/libtests/geocoords/TestCSCart.cc b/tests/libtests/geocoords/TestCSCart.cc index ce98251c..ee8d69da 100644 --- a/tests/libtests/geocoords/TestCSCart.cc +++ b/tests/libtests/geocoords/TestCSCart.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/geocoords/TestCSGeo.cc b/tests/libtests/geocoords/TestCSGeo.cc index 934b9b06..b88dd5da 100644 --- a/tests/libtests/geocoords/TestCSGeo.cc +++ b/tests/libtests/geocoords/TestCSGeo.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/geocoords/TestCSGeoLocal.cc b/tests/libtests/geocoords/TestCSGeoLocal.cc index e715527f..cd61b027 100644 --- a/tests/libtests/geocoords/TestCSGeoLocal.cc +++ b/tests/libtests/geocoords/TestCSGeoLocal.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/geocoords/TestCSPicklerAscii.cc b/tests/libtests/geocoords/TestCSPicklerAscii.cc index 432e0f83..db4245ac 100644 --- a/tests/libtests/geocoords/TestCSPicklerAscii.cc +++ b/tests/libtests/geocoords/TestCSPicklerAscii.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/geocoords/TestConverter.cc b/tests/libtests/geocoords/TestConverter.cc index 85470d31..833aa5c1 100644 --- a/tests/libtests/geocoords/TestConverter.cc +++ b/tests/libtests/geocoords/TestConverter.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/geocoords/TestConverter.hh b/tests/libtests/geocoords/TestConverter.hh index 50ae963b..1c2a4e98 100644 --- a/tests/libtests/geocoords/TestConverter.hh +++ b/tests/libtests/geocoords/TestConverter.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "spatialdata/geocoords/geocoordsfwd.hh" // HOLDSA CoordSys @@ -62,4 +64,5 @@ class spatialdata::geocoords::TestConverter_Data { }; // TestConverter_Data + // End of file diff --git a/tests/libtests/geocoords/TestConverter_Cases.cc b/tests/libtests/geocoords/TestConverter_Cases.cc index 66ebf030..cf2cc86d 100644 --- a/tests/libtests/geocoords/TestConverter_Cases.cc +++ b/tests/libtests/geocoords/TestConverter_Cases.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/geocoords/test_driver.cc b/tests/libtests/geocoords/test_driver.cc index 2fa649e6..c34723a3 100644 --- a/tests/libtests/geocoords/test_driver.cc +++ b/tests/libtests/geocoords/test_driver.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include "spatialdata/testing/TestDriver.hh" diff --git a/tests/libtests/spatialdb/Makefile.am b/tests/libtests/spatialdb/Makefile.am index de5d64e3..233d6234 100644 --- a/tests/libtests/spatialdb/Makefile.am +++ b/tests/libtests/spatialdb/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + include $(top_srcdir)/tests/check.am @@ -46,4 +47,5 @@ noinst_HEADERS = \ TestSimpleGridDB.hh \ TestUserFunctionDB.hh + # End of file diff --git a/tests/libtests/spatialdb/TestAnalyticDB.cc b/tests/libtests/spatialdb/TestAnalyticDB.cc index ad817ac0..11455e29 100644 --- a/tests/libtests/spatialdb/TestAnalyticDB.cc +++ b/tests/libtests/spatialdb/TestAnalyticDB.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestCompositeDB.cc b/tests/libtests/spatialdb/TestCompositeDB.cc index 18890e8f..fa4dead2 100644 --- a/tests/libtests/spatialdb/TestCompositeDB.cc +++ b/tests/libtests/spatialdb/TestCompositeDB.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestGravityField.cc b/tests/libtests/spatialdb/TestGravityField.cc index eb5c9745..8ff6fc8a 100644 --- a/tests/libtests/spatialdb/TestGravityField.cc +++ b/tests/libtests/spatialdb/TestGravityField.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestGravityField.hh b/tests/libtests/spatialdb/TestGravityField.hh index e97975d6..f53e281b 100644 --- a/tests/libtests/spatialdb/TestGravityField.hh +++ b/tests/libtests/spatialdb/TestGravityField.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "spatialdata/geocoords/geocoordsfwd.hh" // USES CoordSys @@ -75,4 +77,5 @@ class spatialdata::spatialdb::TestGravityField_Data { }; // TestGravityField_Data + // End of file diff --git a/tests/libtests/spatialdb/TestGravityField_Cases.cc b/tests/libtests/spatialdb/TestGravityField_Cases.cc index b36d16d4..dbc5a144 100644 --- a/tests/libtests/spatialdb/TestGravityField_Cases.cc +++ b/tests/libtests/spatialdb/TestGravityField_Cases.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestSCECCVMH.cc b/tests/libtests/spatialdb/TestSCECCVMH.cc index 5247c7c6..6bb4f745 100644 --- a/tests/libtests/spatialdb/TestSCECCVMH.cc +++ b/tests/libtests/spatialdb/TestSCECCVMH.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include @@ -758,4 +759,5 @@ spatialdata::spatialdb::TestSCECCVMH::testQuerySquashed(void) { #endif + // End of file diff --git a/tests/libtests/spatialdb/TestSimpleDB.cc b/tests/libtests/spatialdb/TestSimpleDB.cc index 264a517b..09328d74 100644 --- a/tests/libtests/spatialdb/TestSimpleDB.cc +++ b/tests/libtests/spatialdb/TestSimpleDB.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestSimpleDB.hh b/tests/libtests/spatialdb/TestSimpleDB.hh index 4c1f866d..1de9b7ba 100644 --- a/tests/libtests/spatialdb/TestSimpleDB.hh +++ b/tests/libtests/spatialdb/TestSimpleDB.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "spatialdata/spatialdb/spatialdbfwd.hh" @@ -96,4 +98,5 @@ class spatialdata::spatialdb::TestSimpleDB_Data { const int* errFlags; }; + // End of file diff --git a/tests/libtests/spatialdb/TestSimpleDBData.cc b/tests/libtests/spatialdb/TestSimpleDBData.cc index 696a5471..e0fa7d87 100644 --- a/tests/libtests/spatialdb/TestSimpleDBData.cc +++ b/tests/libtests/spatialdb/TestSimpleDBData.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestSimpleDBQuery.cc b/tests/libtests/spatialdb/TestSimpleDBQuery.cc index 5ab5eb01..838b61ff 100644 --- a/tests/libtests/spatialdb/TestSimpleDBQuery.cc +++ b/tests/libtests/spatialdb/TestSimpleDBQuery.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestSimpleDBQuery.hh b/tests/libtests/spatialdb/TestSimpleDBQuery.hh index a5d5df6d..d5ef96cf 100644 --- a/tests/libtests/spatialdb/TestSimpleDBQuery.hh +++ b/tests/libtests/spatialdb/TestSimpleDBQuery.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "spatialdata/spatialdb/spatialdbfwd.hh" // USES SimpleDB, SimpleDBQuery @@ -97,4 +99,5 @@ class spatialdata::spatialdb::TestSimpleDBQuery_Data { }; // TestSimpleDBQuery_Data + // End of file diff --git a/tests/libtests/spatialdb/TestSimpleDBQuery_Cases.cc b/tests/libtests/spatialdb/TestSimpleDBQuery_Cases.cc index c51fac3a..d619edc6 100644 --- a/tests/libtests/spatialdb/TestSimpleDBQuery_Cases.cc +++ b/tests/libtests/spatialdb/TestSimpleDBQuery_Cases.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestSimpleDB_Cases.cc b/tests/libtests/spatialdb/TestSimpleDB_Cases.cc index a60ca2fe..8f7abcbd 100644 --- a/tests/libtests/spatialdb/TestSimpleDB_Cases.cc +++ b/tests/libtests/spatialdb/TestSimpleDB_Cases.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestSimpleGridAscii.cc b/tests/libtests/spatialdb/TestSimpleGridAscii.cc index bb63c15c..56931814 100644 --- a/tests/libtests/spatialdb/TestSimpleGridAscii.cc +++ b/tests/libtests/spatialdb/TestSimpleGridAscii.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestSimpleGridDB.cc b/tests/libtests/spatialdb/TestSimpleGridDB.cc index e2e6d9f8..d5fb6ddc 100644 --- a/tests/libtests/spatialdb/TestSimpleGridDB.cc +++ b/tests/libtests/spatialdb/TestSimpleGridDB.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestSimpleGridDB.hh b/tests/libtests/spatialdb/TestSimpleGridDB.hh index 9972e690..8574909b 100644 --- a/tests/libtests/spatialdb/TestSimpleGridDB.hh +++ b/tests/libtests/spatialdb/TestSimpleGridDB.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "spatialdata/spatialdb/spatialdbfwd.hh" @@ -130,4 +132,5 @@ class spatialdata::spatialdb::TestSimpleGridDB_Data { //@} }; + // End of file diff --git a/tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc b/tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc index b0e6256c..9cfa5dac 100644 --- a/tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc +++ b/tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestSimpleIOAscii.cc b/tests/libtests/spatialdb/TestSimpleIOAscii.cc index 7b11e2fa..a709c083 100644 --- a/tests/libtests/spatialdb/TestSimpleIOAscii.cc +++ b/tests/libtests/spatialdb/TestSimpleIOAscii.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestSpatialDB.cc b/tests/libtests/spatialdb/TestSpatialDB.cc index da8a9067..c1a149be 100644 --- a/tests/libtests/spatialdb/TestSpatialDB.cc +++ b/tests/libtests/spatialdb/TestSpatialDB.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestTimeHistory.cc b/tests/libtests/spatialdb/TestTimeHistory.cc index 115919bb..e78d7dd0 100644 --- a/tests/libtests/spatialdb/TestTimeHistory.cc +++ b/tests/libtests/spatialdb/TestTimeHistory.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestTimeHistoryIO.cc b/tests/libtests/spatialdb/TestTimeHistoryIO.cc index f29f2d0e..012a1df2 100644 --- a/tests/libtests/spatialdb/TestTimeHistoryIO.cc +++ b/tests/libtests/spatialdb/TestTimeHistoryIO.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestUniformDB.cc b/tests/libtests/spatialdb/TestUniformDB.cc index f4ce96da..57acffbc 100644 --- a/tests/libtests/spatialdb/TestUniformDB.cc +++ b/tests/libtests/spatialdb/TestUniformDB.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestUserFunctionDB.cc b/tests/libtests/spatialdb/TestUserFunctionDB.cc index 13f19c82..3c643d8c 100644 --- a/tests/libtests/spatialdb/TestUserFunctionDB.cc +++ b/tests/libtests/spatialdb/TestUserFunctionDB.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/spatialdb/TestUserFunctionDB.hh b/tests/libtests/spatialdb/TestUserFunctionDB.hh index f3414742..d05a74e2 100644 --- a/tests/libtests/spatialdb/TestUserFunctionDB.hh +++ b/tests/libtests/spatialdb/TestUserFunctionDB.hh @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once #include "spatialdata/spatialdb/UserFunctionDB.hh" // Test subject @@ -92,4 +94,5 @@ class spatialdata::spatialdb::TestUserFunctionDB_Data { }; // TestUserFunctionDB_Data + // End of file diff --git a/tests/libtests/spatialdb/TestUserFunctionDB_Cases.cc b/tests/libtests/spatialdb/TestUserFunctionDB_Cases.cc index a42e121b..c04ff17f 100644 --- a/tests/libtests/spatialdb/TestUserFunctionDB_Cases.cc +++ b/tests/libtests/spatialdb/TestUserFunctionDB_Cases.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include @@ -450,4 +451,5 @@ TEST_CASE("TestUserFunctionDB::testQuery", .testQuery(); } + // End of file diff --git a/tests/libtests/spatialdb/data/Makefile.am b/tests/libtests/spatialdb/data/Makefile.am index 954eaec7..a22e2a44 100644 --- a/tests/libtests/spatialdb/data/Makefile.am +++ b/tests/libtests/spatialdb/data/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + dist_noinst_DATA = \ spatialdb.dat \ @@ -41,4 +42,5 @@ clean-local: clean-data datafiles: bash generate.sh all + # End of file diff --git a/tests/libtests/spatialdb/test_driver.cc b/tests/libtests/spatialdb/test_driver.cc index 2fa649e6..c34723a3 100644 --- a/tests/libtests/spatialdb/test_driver.cc +++ b/tests/libtests/spatialdb/test_driver.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include "spatialdata/testing/TestDriver.hh" diff --git a/tests/libtests/spatialdb/testf77query.h b/tests/libtests/spatialdb/testf77query.h index d20254de..5ba24fc6 100644 --- a/tests/libtests/spatialdb/testf77query.h +++ b/tests/libtests/spatialdb/testf77query.h @@ -1,17 +1,18 @@ -/* - * ================================================================================================ - * This code is part of SpatialData, developed through the Computational Infrastructure - * for Geodynamics (https://github.com/geodynamics/spatialdata). - * - * Copyright (c) 2010-2026 All rights reserved. - * - * See https://mit-license.org/ and LICENSE.md and for license information. - * ================================================================================================= - */ +// -*- c++ -*- +// -*- coding: utf-8 -*- +// +// This code is part of SpatialData, developed through the Computational Infrastructure +// for Geodynamics (https://github.com/geodynamics/spatialdata). +// +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #pragma once /** Fortran name mangling */ #define testf77query FC_FUNC_(testf77query, TESTF77QUERY) + /** Call spatialdb_query_f(). * * @param db Pointer to SpatialDB @@ -30,4 +31,5 @@ int testf77query(void* db, const int numDims, void* cs); -/* End of file */ + +// End of file diff --git a/tests/libtests/units/Makefile.am b/tests/libtests/units/Makefile.am index c1605260..e225322e 100644 --- a/tests/libtests/units/Makefile.am +++ b/tests/libtests/units/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + include $(top_srcdir)/tests/check.am diff --git a/tests/libtests/units/TestParser.cc b/tests/libtests/units/TestParser.cc index 1f62ebc6..b9e7c096 100644 --- a/tests/libtests/units/TestParser.cc +++ b/tests/libtests/units/TestParser.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/utils/Makefile.am b/tests/libtests/utils/Makefile.am index 3d1b4aec..8bcd08d9 100644 --- a/tests/libtests/utils/Makefile.am +++ b/tests/libtests/utils/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + include $(top_srcdir)/tests/check.am @@ -19,5 +20,4 @@ libtest_utils_SOURCES = \ $(top_srcdir)/tests/src/driver_catch2.cc - # End of file diff --git a/tests/libtests/utils/TestPointsStream.cc b/tests/libtests/utils/TestPointsStream.cc index 95ceac24..1e4cce6a 100644 --- a/tests/libtests/utils/TestPointsStream.cc +++ b/tests/libtests/utils/TestPointsStream.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/libtests/utils/TestSpatialdataVersion.cc b/tests/libtests/utils/TestSpatialdataVersion.cc index a1553381..94e5c2c1 100644 --- a/tests/libtests/utils/TestSpatialdataVersion.cc +++ b/tests/libtests/utils/TestSpatialdataVersion.cc @@ -1,11 +1,12 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + #include diff --git a/tests/pytests/Makefile.am b/tests/pytests/Makefile.am index 2a972e9c..7aaf9935 100644 --- a/tests/pytests/Makefile.am +++ b/tests/pytests/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + SUBDIRS = \ geocoords \ diff --git a/tests/pytests/geocoords/Makefile.am b/tests/pytests/geocoords/Makefile.am index c127d2e8..ba7eb8ea 100644 --- a/tests/pytests/geocoords/Makefile.am +++ b/tests/pytests/geocoords/Makefile.am @@ -1,12 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= -# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + include $(top_srcdir)/tests/check.am diff --git a/tests/pytests/geocoords/TestCSCart.py b/tests/pytests/geocoords/TestCSCart.py index ad1c54a2..2b97a7b1 100644 --- a/tests/pytests/geocoords/TestCSCart.py +++ b/tests/pytests/geocoords/TestCSCart.py @@ -1,13 +1,13 @@ #!/usr/bin/env nemesis +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/geocoords/TestCSGeo.py b/tests/pytests/geocoords/TestCSGeo.py index 22112cd3..5eecc4cf 100644 --- a/tests/pytests/geocoords/TestCSGeo.py +++ b/tests/pytests/geocoords/TestCSGeo.py @@ -1,13 +1,13 @@ #!/usr/bin/env nemesis +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/geocoords/TestCSGeoLocal.py b/tests/pytests/geocoords/TestCSGeoLocal.py index 0e156100..ca2f8472 100644 --- a/tests/pytests/geocoords/TestCSGeoLocal.py +++ b/tests/pytests/geocoords/TestCSGeoLocal.py @@ -1,13 +1,13 @@ #!/usr/bin/env nemesis +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/geocoords/TestConverter.py b/tests/pytests/geocoords/TestConverter.py index 6c9bab76..95f4139f 100644 --- a/tests/pytests/geocoords/TestConverter.py +++ b/tests/pytests/geocoords/TestConverter.py @@ -1,13 +1,13 @@ #!/usr/bin/env nemesis +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/geocoords/test_geocoords.py b/tests/pytests/geocoords/test_geocoords.py index 5cdba643..037e28a4 100755 --- a/tests/pytests/geocoords/test_geocoords.py +++ b/tests/pytests/geocoords/test_geocoords.py @@ -1,16 +1,13 @@ #!/usr/bin/env nemesis +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT -import pathlib -import sys from spatialdata.testing.UnitTestApp import UnitTestApp diff --git a/tests/pytests/spatialdb/Makefile.am b/tests/pytests/spatialdb/Makefile.am index 122a8735..806024ed 100644 --- a/tests/pytests/spatialdb/Makefile.am +++ b/tests/pytests/spatialdb/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + include $(top_srcdir)/tests/check.am @@ -60,4 +61,5 @@ clean-local: clean-data CLEANFILES = \ $(srcdir)/TestSCECCVMH.py + # End of file diff --git a/tests/pytests/spatialdb/TestAnalyticDB.py b/tests/pytests/spatialdb/TestAnalyticDB.py index 720067a1..d304f141 100644 --- a/tests/pytests/spatialdb/TestAnalyticDB.py +++ b/tests/pytests/spatialdb/TestAnalyticDB.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/spatialdb/TestCompositeDB.py b/tests/pytests/spatialdb/TestCompositeDB.py index fb3e0a53..985d4b1e 100644 --- a/tests/pytests/spatialdb/TestCompositeDB.py +++ b/tests/pytests/spatialdb/TestCompositeDB.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/spatialdb/TestGenSimpleDBApp.py b/tests/pytests/spatialdb/TestGenSimpleDBApp.py index f747ad44..d3837f22 100644 --- a/tests/pytests/spatialdb/TestGenSimpleDBApp.py +++ b/tests/pytests/spatialdb/TestGenSimpleDBApp.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/spatialdb/TestGravityField.py b/tests/pytests/spatialdb/TestGravityField.py index 40b91679..64f9a23f 100644 --- a/tests/pytests/spatialdb/TestGravityField.py +++ b/tests/pytests/spatialdb/TestGravityField.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/spatialdb/TestSCECCVMH.py.in b/tests/pytests/spatialdb/TestSCECCVMH.py.in index 3a96ff69..398c2e12 100644 --- a/tests/pytests/spatialdb/TestSCECCVMH.py.in +++ b/tests/pytests/spatialdb/TestSCECCVMH.py.in @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/spatialdb/TestSimpleDB.py b/tests/pytests/spatialdb/TestSimpleDB.py index 72441612..f3c3638c 100644 --- a/tests/pytests/spatialdb/TestSimpleDB.py +++ b/tests/pytests/spatialdb/TestSimpleDB.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/spatialdb/TestSimpleGridDB.py b/tests/pytests/spatialdb/TestSimpleGridDB.py index 3140b740..766b99a7 100644 --- a/tests/pytests/spatialdb/TestSimpleGridDB.py +++ b/tests/pytests/spatialdb/TestSimpleGridDB.py @@ -1,13 +1,13 @@ #!/usr/bin/env nemesis +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/spatialdb/TestSimpleIOAscii.py b/tests/pytests/spatialdb/TestSimpleIOAscii.py index 78d2cea6..53fcb340 100644 --- a/tests/pytests/spatialdb/TestSimpleIOAscii.py +++ b/tests/pytests/spatialdb/TestSimpleIOAscii.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/spatialdb/TestTimeHistory.py b/tests/pytests/spatialdb/TestTimeHistory.py index 341c6c89..505a9e4e 100644 --- a/tests/pytests/spatialdb/TestTimeHistory.py +++ b/tests/pytests/spatialdb/TestTimeHistory.py @@ -1,13 +1,13 @@ #!/usr/bin/env nemesis +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/spatialdb/TestTimeHistoryIO.py b/tests/pytests/spatialdb/TestTimeHistoryIO.py index 5b9047fc..a9a15f5b 100644 --- a/tests/pytests/spatialdb/TestTimeHistoryIO.py +++ b/tests/pytests/spatialdb/TestTimeHistoryIO.py @@ -1,13 +1,13 @@ #!/usr/bin/env nemesis +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/spatialdb/TestUniformDB.py b/tests/pytests/spatialdb/TestUniformDB.py index bae285bd..6fd0b01f 100644 --- a/tests/pytests/spatialdb/TestUniformDB.py +++ b/tests/pytests/spatialdb/TestUniformDB.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/spatialdb/TestUserFunctionDB.py b/tests/pytests/spatialdb/TestUserFunctionDB.py index 3e5fee99..ea638585 100644 --- a/tests/pytests/spatialdb/TestUserFunctionDB.py +++ b/tests/pytests/spatialdb/TestUserFunctionDB.py @@ -1,13 +1,13 @@ #!/usr/bin/env nemesis +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/spatialdb/data/Makefile.am b/tests/pytests/spatialdb/data/Makefile.am index 110ab9b3..230251f4 100644 --- a/tests/pytests/spatialdb/data/Makefile.am +++ b/tests/pytests/spatialdb/data/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + dist_noinst_DATA = \ simple.spatialdb \ diff --git a/tests/pytests/spatialdb/gensimpledb.cfg b/tests/pytests/spatialdb/gensimpledb.cfg index ce9a178f..9043e51f 100644 --- a/tests/pytests/spatialdb/gensimpledb.cfg +++ b/tests/pytests/spatialdb/gensimpledb.cfg @@ -1,3 +1,13 @@ +# -*- config -*- +# -*- coding: utf-8 -*- +# +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + [gensimpledb] # ---------------------------------------------------------------------- @@ -80,3 +90,6 @@ db.iohandler.filename = data/gen1Din2D_two_divide.spatialdb # ---------------------------------------------------------------------- [gensimpledb] filename = data/gen1Din2D.spatialdb + + +# End of file diff --git a/tests/pytests/spatialdb/test_sceccvmh.py b/tests/pytests/spatialdb/test_sceccvmh.py index 227cde3c..7f77a7df 100755 --- a/tests/pytests/spatialdb/test_sceccvmh.py +++ b/tests/pytests/spatialdb/test_sceccvmh.py @@ -1,13 +1,13 @@ #!/usr/bin/env nemesis +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from spatialdata.testing.UnitTestApp import UnitTestApp diff --git a/tests/pytests/spatialdb/test_spatialdb.py b/tests/pytests/spatialdb/test_spatialdb.py index bca04b2e..1d16dce6 100755 --- a/tests/pytests/spatialdb/test_spatialdb.py +++ b/tests/pytests/spatialdb/test_spatialdb.py @@ -1,13 +1,13 @@ #!/usr/bin/env nemesis +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from spatialdata.testing.UnitTestApp import UnitTestApp diff --git a/tests/pytests/spatialdb/testgen1din2d.odb b/tests/pytests/spatialdb/testgen1din2d.odb index 139432f9..6fcddf39 100644 --- a/tests/pytests/spatialdb/testgen1din2d.odb +++ b/tests/pytests/spatialdb/testgen1din2d.odb @@ -7,6 +7,7 @@ # See https://mit-license.org/ and LICENSE.md and for license information. # ================================================================================================= + from pythia.pyre.components.Component import Component import numpy diff --git a/tests/pytests/utils/Makefile.am b/tests/pytests/utils/Makefile.am index cec664d3..504df36e 100644 --- a/tests/pytests/utils/Makefile.am +++ b/tests/pytests/utils/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + include $(top_srcdir)/tests/check.am diff --git a/tests/pytests/utils/TestSpatialdataVersion.py b/tests/pytests/utils/TestSpatialdataVersion.py index 34427c1e..8bb8c067 100644 --- a/tests/pytests/utils/TestSpatialdataVersion.py +++ b/tests/pytests/utils/TestSpatialdataVersion.py @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- python -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + import unittest diff --git a/tests/pytests/utils/test_utils.py b/tests/pytests/utils/test_utils.py index 2f04c33a..9cc50eb4 100755 --- a/tests/pytests/utils/test_utils.py +++ b/tests/pytests/utils/test_utils.py @@ -1,13 +1,13 @@ #!/usr/bin/env nemesis +# -*- python -*- +# -*- coding: utf-8 -*- # -# ================================================================================================= # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + from spatialdata.testing.UnitTestApp import UnitTestApp diff --git a/tests/src/Makefile.am b/tests/src/Makefile.am index ba31f5da..929b1f41 100644 --- a/tests/src/Makefile.am +++ b/tests/src/Makefile.am @@ -1,11 +1,12 @@ -# ================================================================================================= +# -*- makefile -*- +# -*- coding: utf-8 -*- +# # This code is part of SpatialData, developed through the Computational Infrastructure # for Geodynamics (https://github.com/geodynamics/spatialdata). # -# Copyright (c) 2010-2026 All rights reserved. -# -# See https://mit-license.org/ and LICENSE.md and for license information. -# ================================================================================================= +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + dist_noinst_HEADERS = diff --git a/tests/src/driver_catch2.cc b/tests/src/driver_catch2.cc index 64b8d4ce..e58bf96b 100644 --- a/tests/src/driver_catch2.cc +++ b/tests/src/driver_catch2.cc @@ -1,11 +1,13 @@ -// ================================================================================================= +// -*- c++ -*- +// -*- coding: utf-8 -*- +// // This code is part of SpatialData, developed through the Computational Infrastructure // for Geodynamics (https://github.com/geodynamics/spatialdata). // -// Copyright (c) 2010-2026 All rights reserved. -// -// See https://mit-license.org/ and LICENSE.md and for license information. -// ================================================================================================= +// Copyright (c) 2010-2026 The SpatialData authors and contributors +// SPDX-License-Identifier: MIT + + #include #include "catch2/catch_session.hpp" From 56a9c031aad7ddd1db3d5d0255a5ae8692ecfbb2 Mon Sep 17 00:00:00 2001 From: Brad Aagaard Date: Thu, 19 Nov 2026 08:43:02 -0700 Subject: [PATCH 08/10] tidy: Convert setup.py to pyproject.toml. Fix 'make dist'. --- Makefile.am | 2 +- pyproject.toml | 51 +++++++++++++++++ setup.cfg | 50 ----------------- setup.py | 2 +- templates/Makefile.am | 4 +- templates/spatialdb/README | 101 ---------------------------------- templates/spatialdb/README.md | 88 +++++++++++++++++++++++++++++ 7 files changed, 143 insertions(+), 155 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.cfg delete mode 100644 templates/spatialdb/README create mode 100644 templates/spatialdb/README.md diff --git a/Makefile.am b/Makefile.am index 15adf638..a5e27470 100644 --- a/Makefile.am +++ b/Makefile.am @@ -31,7 +31,7 @@ EXTRA_DIST = \ README.md \ CHANGES.md \ setup.py \ - setup.cfg \ + pyproject.toml \ configure.ac \ applications/gensimpledb.py \ LICENSE.md \ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..03e0e075 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,51 @@ +# -*- config -*- +# -*- coding: utf-8 -*- +# +# This code is part of SpatialData, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/spatialdata). +# +# Copyright (c) 2010-2026 The SpatialData authors and contributors +# SPDX-License-Identifier: MIT + + +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "spatialdata" +version = "4.0.1" +description = "Library for specifying spatial variations in input parameters (used in PyLith)." +authors = [{ name = "Brad Aagaard", email = "baagaard@usgs.gov" }] +license = { text = "MIT" } +requires-python = ">=3.10" + +[project.urls] +Homepage = "https://geodynamics.org/resources/spatialdata" + +[tool.setuptools] +zip-safe = false +script-files = ["applications/gensimpledb.py"] + +[tool.setuptools.packages.find] +exclude = [ + "developer", + "docs", + "docker", + "examples", + "libsrc", + "m4", + "modulesrc", + "templates", + "tests", +] + +[tool.conventions] +exempt = [ + "libsrc/spatialdata/muparser/*", + "*.spatialdb", + "*.timedb", + ] + + +# End of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b9acac28..00000000 --- a/setup.cfg +++ /dev/null @@ -1,50 +0,0 @@ -# -*- config -*- -# -*- coding: utf-8 -*- -# -# This code is part of SpatialData, developed through the Computational Infrastructure -# for Geodynamics (https://github.com/geodynamics/spatialdata). -# -# Copyright (c) 2010-2026 The SpatialData authors and contributors -# SPDX-License-Identifier: MIT - - -[egg_info] -tag_build = -tag_date = 0 - -[metadata] -name = spatialdata -version = 4.0.1 -author = Brad Aagaard -author_email = baagaard@usgs.gov -description = Library for specifying spatial variations in input parameters (used in PyLith). -license = MIT -url = https://geodynamics.org/resources/spatialdata - -[options] -python_requires = >=3.8 - -packages = find: - -scripts = - applications/gensimpledb.py - -#include_package_data = True -zip_safe = False - -#[options.package_data] - -[options.packages.find] -exclude = - developer - docs - docker - examples - libsrc - m4 - modulesrc - templates - tests - - -# End of file diff --git a/setup.py b/setup.py index b11ef72d..9ce5e485 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ # SPDX-License-Identifier: MIT -# Setup configuration is in setup.cfg. +# Setup configuration is in pyproject.toml. import setuptools diff --git a/templates/Makefile.am b/templates/Makefile.am index e435ae74..b2c4e5c3 100644 --- a/templates/Makefile.am +++ b/templates/Makefile.am @@ -11,8 +11,8 @@ # Include files in templates in spatialdata source distribution. EXTRA_DIST = \ Makefile.am \ - README \ - spatialdb/README \ + README.md \ + spatialdb/README.md \ spatialdb/configure.ac \ spatialdb/Makefile.am \ spatialdb/UniformVelModel.hh \ diff --git a/templates/spatialdb/README b/templates/spatialdb/README deleted file mode 100644 index 9ba357cb..00000000 --- a/templates/spatialdb/README +++ /dev/null @@ -1,101 +0,0 @@ -Overview - - This directory contains source files for building a user defined - spatial database component consisting of C++ code, a Python module, - and Python code. The example implementation provides a uniform - seismic velocity model than can be used to provide elastic physical - properties in PyLith simulations using a georeferenced coordinate - system. - - The suggested path to customizing this component is to build and - install the provided UniformVelModel component and then rename/copy - the files and gradually adopt it to your specific needs. - -Requirements - - In order to build the component and interface it with PyLith, you will need - * C++ compiler - * SWIG (version 1.3.33 or later) - * Python with header files (version 2.3 or later) - * autoconf tools - - The C++ compiler must be compatible with the installed Python and - both must be compatible with the C++ compiler and Python used to - build PyLith. The safest way to insure compatibility is to use the - C++ compiler and Python provided with your operating system and - build PyLith from source. However, on many systems it should be - possible to build the component and have it work with PyLith - installed from a binary package. - -Files - - Makefile.am - automake parameters for constructing a Makefile - README - this file - UniformVelModel.cc - C++ source file implementing UniformVelModel object functions - UniformVelModel.hh - C++ header file with class definition for UniformVelModel - UniformVelModel.i - SWIG interface file for the C++ UniformVelModel object - __init__.py - Python source file for module initialization - configure.ac - autoconf parameters for construction a configure script - m4 - directory containing autoconf macros - spatialdbcontrib.i - SWIG interface file defining the spatialdbcontrib Python module - tests - directory containing tests of the UniformVelModel object - -How to build/install the UniformVelModel component - - 1. Run "autoreconf -if" in this directory (templates/spatialdb). - - 2. Run configure either from this directory or a scratch build - directory. Use the --prefix=DIRECTORY to indicate where the files - should be installed. We strongly recommend that you install the - component to the same location as where PyLith is installed. For - example, if PyLith is installed in $HOME/cig then use the - --prefix=$HOME/cig command line argument to configure. To build in a - separate directory simply invoke the configure script from the other - directory. For example, from $HOME/build/spatialdb-contrib run - $HOME/src/spatialdata/templates/spatialdb/configure --prefix=$HOME/cig. - - Configure will check for a number of files including the location of - spatialdata C++ header files, library, and SWIG interface files. You - may need to define some additional command line arguments to - configure and/or environment variables to help configure find the - required files. - - We run configure using on a MacBook Pro using MacPorts where we have - defined a number of environment variables in .bashrc for installed - tools. - - ${HOME}/src/cig/spatialdata/templates/spatialdb/configure --config-cache \ - --prefix=${HOME}/tools/cig/gcc-4.0 \ - CPPFLAGS="-I${PROJ4_INCDIR} -I${PORTS_INCDIR} -I${CIG_INCDIR}" \ - LDFLAGS="-L${PROJ4_LIBDIR} -L${PORTS_LIBDIR} -L${CIG_LIBDIR} -F${PORTS_DIR}/Library/Frameworks" \ - SPATIALDATA_SWIG_DIR="${CIG_DIR}/share/spatialdata/swig" CC=gcc CXX=g++ - - 3. Run "make", "make install", and "make check" from the top-level - build directory. This will first build the C++ library and module, - then install the files to the location specified by the --prefix - command line argument to configure, and finally run some Python - tests to verify that the UniformVelModel component was installed - correctly. - -Customization - - This is where the fun begins. Read over the Python and C++ source - code to become familiar with the features implemented with the - UniformVelModel component. The UniformVelModel Python object simply - acquires user input using Pyre properties (and could use facilities - as well) and in _configure() transfers that information to the - UniformVelModel C++ object via the SWIG module in. The - UniformVelModel C++ object does the grunt work of managing which - values will be returned in a query and performing the query - itself. In this case, the query is trivial (it simply returns the - same value independent of the location where the physical properties - are desired). In a real UniformVelModel component, the query - function can be quite complex and will usually involve interpolation - of values to the location specified in the arguments of the query() - function (the query location). - - We recommend that you start by changing the default values assigned - to the UniformVelModel, followed by changing the user controlled - parameters (Pyre properties). When you change the Pyre properties - (vp, vs, density) you should change the corresponding names of the - C++ accessor functions (vp, vs, density). diff --git a/templates/spatialdb/README.md b/templates/spatialdb/README.md new file mode 100644 index 00000000..9f286b5f --- /dev/null +++ b/templates/spatialdb/README.md @@ -0,0 +1,88 @@ +% -*- markdown -*- +% -*- coding: utf-8 -*- +% +% This code is part of SpatialData, developed through the Computational Infrastructure +% for Geodynamics (https://github.com/geodynamics/spatialdata). +% +% Copyright (c) 2010-2026 The SpatialData authors and contributors +% SPDX-License-Identifier: MIT + +# Uniform Velocity Model Spatial Database Template + +## Overview + +This directory contains source files for building a user defined spatial database component consisting of C++ code, a Python module, and Python code. +The example implementation provides a uniform seismic velocity model that can be used to provide elastic physical properties in PyLith simulations using a georeferenced coordinate system. + +The suggested path to customizing this component is to build and install the provided UniformVelModel component and then rename/copy the files and gradually adapt it to your specific needs. + +## Requirements + +In order to build the component and interface it with PyLith, you will need: + +* C++ compiler +* SWIG (version 1.3.33 or later) +* Python with header files (version 2.3 or later) +* autoconf tools + +The C++ compiler must be compatible with the installed Python, and both must be compatible with the C++ compiler and Python used to build PyLith. +The safest way to ensure compatibility is to use the C++ compiler and Python provided with your operating system and build PyLith from source. +However, on many systems it should be possible to build the component and have it work with PyLith installed from a binary package. + +## Files + +* `Makefile.am`: automake parameters for constructing a Makefile +* `README.md`: this file +* `UniformVelModel.cc`: C++ source file implementing UniformVelModel object functions +* `UniformVelModel.hh`: C++ header file with class definition for UniformVelModel +* `UniformVelModel.i`: SWIG interface file for the C++ UniformVelModel object +* `__init__.py`: Python source file for module initialization +* `configure.ac`: autoconf parameters for constructing a configure script +* `m4`: directory containing autoconf macros +* `spatialdbcontrib.i`: SWIG interface file defining the spatialdbcontrib Python module +* `tests`: directory containing tests of the UniformVelModel object + +## How to build/install the UniformVelModel component + +1. Run `autoreconf -if` in this directory (`templates/spatialdb`). + +2. Run configure either from this directory or a scratch build directory. + Use the `--prefix=DIRECTORY` argument to indicate where the files should be installed. + We strongly recommend that you install the component to the same location as where PyLith is installed. + For example, if PyLith is installed in `$HOME/cig`, then use the `--prefix=$HOME/cig` command line argument to configure. + To build in a separate directory, simply invoke the configure script from the other directory. + For example, from `$HOME/build/spatialdb-contrib` run `$HOME/src/spatialdata/templates/spatialdb/configure --prefix=$HOME/cig`. + + Configure will check for a number of files including the location of spatialdata C++ header files, library, and SWIG interface files. + You may need to define some additional command line arguments to configure and/or environment variables to help configure find the required files. + + We run configure on a MacBook Pro using MacPorts, where we have defined a number of environment variables in `.bashrc` for installed tools. + + ```bash + ${HOME}/src/cig/spatialdata/templates/spatialdb/configure --config-cache \ + --prefix=${HOME}/tools/cig/gcc-4.0 \ + CPPFLAGS="-I${PROJ4_INCDIR} -I${PORTS_INCDIR} -I${CIG_INCDIR}" \ + LDFLAGS="-L${PROJ4_LIBDIR} -L${PORTS_LIBDIR} -L${CIG_LIBDIR} -F${PORTS_DIR}/Library/Frameworks" \ + SPATIALDATA_SWIG_DIR="${CIG_DIR}/share/spatialdata/swig" CC=gcc CXX=g++ + ``` + +3. Run `make`, `make install`, and `make check` from the top-level build directory. + This will first build the C++ library and module. + It will then install the files to the location specified by the `--prefix` command line argument to configure. + Finally, it will run some Python tests to verify that the UniformVelModel component was installed correctly. + +## Customization + +This is where the fun begins. +Read over the Python and C++ source code to become familiar with the features implemented with the UniformVelModel component. +The UniformVelModel Python object simply acquires user input using Pyre properties (and could use facilities as well). +In `_configure()` it transfers that information to the UniformVelModel C++ object via the SWIG module. +The UniformVelModel C++ object does the grunt work of managing which values will be returned in a query and performing the query itself. +In this case, the query is trivial (it simply returns the same value independent of the location where the physical properties are desired). +In a real UniformVelModel component, the query function can be quite complex. +It will usually involve interpolation of values to the location specified in the arguments of the `query()` function (the query location). + +We recommend that you start by changing the default values assigned to the UniformVelModel, followed by changing the user controlled parameters (Pyre properties). +When you change the Pyre properties (`vp`, `vs`, `density`), you should change the corresponding names of the C++ accessor functions (`vp`, `vs`, `density`). + +# End of file From d72b255edb9be11f97b8cc6394aa4ca2064e45d3 Mon Sep 17 00:00:00 2001 From: Brad Aagaard Date: Thu, 19 Nov 2026 21:37:46 -0700 Subject: [PATCH 09/10] spelling: Fix typos. --- CHANGES.md | 2 +- ci-config/run_tests.sh | 2 +- .../spatialdb/generator/GenSimpleDBApp.md | 2 +- docs/user/spatialdb/compositedb.md | 2 +- docs/user/spatialdb/gravity-field.md | 2 +- etc/ci/conventions/codespell-lines.txt | 0 etc/ci/conventions/codespell-words.txt | 3 +++ etc/ci/conventions/selftest.py | 0 libsrc/spatialdata/geocoords/CSPicklerAscii.hh | 2 +- libsrc/spatialdata/spatialdb/AnalyticDB.hh | 2 +- libsrc/spatialdata/spatialdb/SimpleDBData.cc | 2 +- libsrc/spatialdata/spatialdb/SimpleDBData.hh | 2 +- libsrc/spatialdata/spatialdb/SimpleDBQuery.cc | 14 +++++++------- libsrc/spatialdata/spatialdb/SimpleDBQuery.hh | 10 +++++----- libsrc/spatialdata/spatialdb/SimpleIO.hh | 2 +- libsrc/spatialdata/spatialdb/UserFunctionDB.hh | 2 +- libsrc/spatialdata/utils/PointsStream.cc | 2 +- libsrc/spatialdata/utils/PointsStream.hh | 2 +- modulesrc/spatialdb/SimpleDBData.i | 2 +- pyproject.toml | 6 ++++++ spatialdata/spatialdb/generator/GenSimpleDBApp.py | 2 +- templates/spatialdb/UniformVelModel.cc | 2 +- templates/spatialdb/UniformVelModel.py | 2 +- tests/libtests/spatialdb/TestCompositeDB.cc | 2 +- tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc | 8 ++++---- 25 files changed, 43 insertions(+), 34 deletions(-) create mode 100644 etc/ci/conventions/codespell-lines.txt create mode 100644 etc/ci/conventions/codespell-words.txt mode change 100644 => 100755 etc/ci/conventions/selftest.py diff --git a/CHANGES.md b/CHANGES.md index 4e266db5..2b9fbb1d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -182,7 +182,7 @@ WKT. ## 2007/01/01 -* Changed interface so that it no longer uses pointers to pointers when passing arrays as arugments. You now pass just a pointer to where the values are to be stored. This makes the user interface cleaner. +* Changed interface so that it no longer uses pointers to pointers when passing arrays as arguments. You now pass just a pointer to where the values are to be stored. This makes the user interface cleaner. * Numpy version >= 1.0 is now required (previous changeset). ## 2007/01/07 diff --git a/ci-config/run_tests.sh b/ci-config/run_tests.sh index c4cd30fe..291d1dfc 100755 --- a/ci-config/run_tests.sh +++ b/ci-config/run_tests.sh @@ -9,7 +9,7 @@ # SPDX-License-Identifier: MIT -# WARNING: If test coverage is enabled, this script downlaods the +# WARNING: If test coverage is enabled, this script downloads the # CodeCov uploader for Linux. # # Run tests to generate coverage information. Upload test coverage data. diff --git a/docs/user/components/spatialdb/generator/GenSimpleDBApp.md b/docs/user/components/spatialdb/generator/GenSimpleDBApp.md index ea7433c0..1b111d71 100644 --- a/docs/user/components/spatialdb/generator/GenSimpleDBApp.md +++ b/docs/user/components/spatialdb/generator/GenSimpleDBApp.md @@ -48,7 +48,7 @@ Example of setting `GenSimpleDBApp` Pyre properties and facilities in a paramete # Vp is generated from a background value given in `vp_background.spatialdb` # plus a perturbation given in `vp_perturbation.spatialdb`. # -# Vs is generatef from a backgorund value given in `vs_background.spatialdb` +# Vs is generatef from a background value given in `vs_background.spatialdb` # multiplied by a value given in `vs_scaling.spatialdb`. [gensimpledb.geometry] reader = read_geometry diff --git a/docs/user/spatialdb/compositedb.md b/docs/user/spatialdb/compositedb.md index 24080fa3..4bb8158e 100644 --- a/docs/user/spatialdb/compositedb.md +++ b/docs/user/spatialdb/compositedb.md @@ -62,7 +62,7 @@ dbComposite.setDBB(&dbViscoelastic, namesViscoelastic, numViscoelastic); :::{tab-item} Python Python applications should use the Pyre framework for creating the `CompositeDB`. -We show how to do it programatically in Python for completeness. +We show how to do it programmatically in Python for completeness. ```{code-block} python --- diff --git a/docs/user/spatialdb/gravity-field.md b/docs/user/spatialdb/gravity-field.md index 430a42a6..2537676b 100644 --- a/docs/user/spatialdb/gravity-field.md +++ b/docs/user/spatialdb/gravity-field.md @@ -38,7 +38,7 @@ gravityField.setGravityDir(0.0, -1.0, 0.0); :::{tab-item} Python Python applications should use the Pyre framework for creating the `CompositeDB`. -We show how to do it programatically in Python for completeness. +We show how to do it programmatically in Python for completeness. ```{code-block} python --- diff --git a/etc/ci/conventions/codespell-lines.txt b/etc/ci/conventions/codespell-lines.txt new file mode 100644 index 00000000..e69de29b diff --git a/etc/ci/conventions/codespell-words.txt b/etc/ci/conventions/codespell-words.txt new file mode 100644 index 00000000..5a4d34c2 --- /dev/null +++ b/etc/ci/conventions/codespell-words.txt @@ -0,0 +1,3 @@ +inout +localY +tread \ No newline at end of file diff --git a/etc/ci/conventions/selftest.py b/etc/ci/conventions/selftest.py old mode 100644 new mode 100755 diff --git a/libsrc/spatialdata/geocoords/CSPicklerAscii.hh b/libsrc/spatialdata/geocoords/CSPicklerAscii.hh index 3a2a751e..b8482817 100644 --- a/libsrc/spatialdata/geocoords/CSPicklerAscii.hh +++ b/libsrc/spatialdata/geocoords/CSPicklerAscii.hh @@ -20,7 +20,7 @@ class spatialdata::geocoords::CSPicklerAscii { /** Pickle coordinate system. * - * @param s Ouput stream + * @param s Output stream * @param cs Pointer to coordinate system */ static void pickle(std::ostream& s, diff --git a/libsrc/spatialdata/spatialdb/AnalyticDB.hh b/libsrc/spatialdata/spatialdb/AnalyticDB.hh index bfbcd87d..f04dba84 100644 --- a/libsrc/spatialdata/spatialdb/AnalyticDB.hh +++ b/libsrc/spatialdata/spatialdb/AnalyticDB.hh @@ -117,7 +117,7 @@ class spatialdata::spatialdb::AnalyticDB : public SpatialDB { geocoords::CoordSys* _cs; ///< Coordinate system geocoords::Converter* _converter; /// Convert query points to local coordinate system. size_t* _queryValues; ///< Indices of values to be returned in queries. - size_t _numValues; ///< Number of valuess in database + size_t _numValues; ///< Number of values in database size_t _querySize; ///< Number of values requested to be returned in queries. }; // class AnalyticDB diff --git a/libsrc/spatialdata/spatialdb/SimpleDBData.cc b/libsrc/spatialdata/spatialdb/SimpleDBData.cc index 7dedca0e..0bd5c155 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBData.cc +++ b/libsrc/spatialdata/spatialdb/SimpleDBData.cc @@ -50,7 +50,7 @@ spatialdata::spatialdb::SimpleDBData::~SimpleDBData(void) { // ---------------------------------------------------------------------- -// Allocate data structues. +// Allocate data structures. void spatialdata::spatialdb::SimpleDBData::allocate(const size_t numLocs, const size_t numValues, diff --git a/libsrc/spatialdata/spatialdb/SimpleDBData.hh b/libsrc/spatialdata/spatialdb/SimpleDBData.hh index cdbe9731..e1e24d0d 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBData.hh +++ b/libsrc/spatialdata/spatialdb/SimpleDBData.hh @@ -26,7 +26,7 @@ class spatialdata::spatialdb::SimpleDBData { // SimpleDBData /// Default destructor ~SimpleDBData(void); - /** Allocate data structues. + /** Allocate data structures. * * @param numLocs Number of locations. * @param numValues Number of values. diff --git a/libsrc/spatialdata/spatialdb/SimpleDBQuery.cc b/libsrc/spatialdata/spatialdb/SimpleDBQuery.cc index 2ae88fb3..2d8ba8e0 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBQuery.cc +++ b/libsrc/spatialdata/spatialdb/SimpleDBQuery.cc @@ -524,20 +524,20 @@ spatialdata::spatialdb::SimpleDBQuery::_findVolumePt(std::vector* pWei double wtB = 0; double wtC = 0; double wtD = 0; - double ptD[3]; + double pointD[3]; // find nearest pt where we can interpolate const size_t nearSize = _nearest.size(); size_t nearIndexD = nearIndexC + 1; while (nearIndexD < nearSize) { const size_t locIndexD = _nearest[nearIndexD]; - _setPoint3(ptD, _db._data->getCoordinates(locIndexD), spaceDim); + _setPoint3(pointD, _db._data->getCoordinates(locIndexD), spaceDim); // make sure A,B,C,D are not coplanar by checking if volume of // tetrahedron ABCD is not a tiny fraction of the distance AB // volume abcd - const double abcd = _volume(ptA, ptB, ptC, ptD); + const double abcd = _volume(ptA, ptB, ptC, pointD); // ab = length(ab) const double ab3 = pow(pow(ptA[0] - ptB[0], 2) + pow(ptA[1] - ptB[1], 2) + pow(ptA[2] - ptB[2], 2), 3); @@ -545,17 +545,17 @@ spatialdata::spatialdb::SimpleDBQuery::_findVolumePt(std::vector* pWei const double tolerance = 1.0e-06; if (fabs(abcd) > tolerance * ab3) { // volume pbcd - const double pbcd = _volume(_q, ptB, ptC, ptD); + const double pbcd = _volume(_q, ptB, ptC, pointD); // wtA = vol(pbcd)/vol(abcd) wtA = pbcd / abcd; // volume apcd - const double apcd = _volume(ptA, _q, ptC, ptD); + const double apcd = _volume(ptA, _q, ptC, pointD); // wtB = vol(apcd)/vol(abcd) wtB = apcd / abcd; // volume abpd - const double abpd = _volume(ptA, ptB, _q, ptD); + const double abpd = _volume(ptA, ptB, _q, pointD); // wtC = vol(abpd)/vol(abcd) wtC = abpd / abcd; @@ -585,7 +585,7 @@ spatialdata::spatialdb::SimpleDBQuery::_findVolumePt(std::vector* pWei // ---------------------------------------------------------------------- -// Set coordiantes of point in 3-D space using coordinates in +// Set coordinates of point in 3-D space using coordinates in // current coordinate system. void spatialdata::spatialdb::SimpleDBQuery::_setPoint3(double pt3[3], diff --git a/libsrc/spatialdata/spatialdb/SimpleDBQuery.hh b/libsrc/spatialdata/spatialdb/SimpleDBQuery.hh index 5c7d8e4d..212bf595 100644 --- a/libsrc/spatialdata/spatialdb/SimpleDBQuery.hh +++ b/libsrc/spatialdata/spatialdb/SimpleDBQuery.hh @@ -33,7 +33,7 @@ class spatialdata::spatialdb::SimpleDBQuery { // class SimpleDBQuery /// Default destructor. ~SimpleDBQuery(void); - /// Dellocate data structures. + /// Deallocate data structures. void deallocate(void); /** Set query type. @@ -134,11 +134,11 @@ class spatialdata::spatialdb::SimpleDBQuery { // class SimpleDBQuery */ void _findVolumePt(std::vector* pWeights); - /** Set coordiantes of point in 3-D space using coordinates in + /** Set coordinates of point in 3-D space using coordinates in * current coordinate system. * * @param pt3 Coordinates of point in 3-D space [output]. - * @param pt Cooridinates of point in current coordinate sytem. + * @param pt Coordinates of point in current coordinate system. * @param spaceDim Spatial dimension of current coordinate system. */ static void _setPoint3(double* const pt3, @@ -185,10 +185,10 @@ class spatialdata::spatialdb::SimpleDBQuery { // class SimpleDBQuery SimpleDB::QueryEnum _queryType; ///< Query type. std::vector _nearest; ///< Index of nearest points in database to location. const SimpleDB& _db; ///< Reference to simple database. - spatialdata::geocoords::Converter* _converter; ///< Covert query points to local coordinate system. + spatialdata::geocoords::Converter* _converter; ///< Convert query points to local coordinate system. size_t* _queryValues; ///< Indices of values to be returned in queries. - size_t _querySize; ///< Nmber of values to be returned in queries. + size_t _querySize; ///< Number of values to be returned in queries. }; // class SimpleDBQuery diff --git a/libsrc/spatialdata/spatialdb/SimpleIO.hh b/libsrc/spatialdata/spatialdb/SimpleIO.hh index b5f4a5d5..929367a9 100644 --- a/libsrc/spatialdata/spatialdb/SimpleIO.hh +++ b/libsrc/spatialdata/spatialdb/SimpleIO.hh @@ -67,7 +67,7 @@ class spatialdata::spatialdb::SimpleIO { // class SimpleIO /** Check compatibility of topology and spatial distribution. * - * Currently, this compatiblity check only involves making sure + * Currently, this compatibility check only involves making sure * there are enough number of points to perform the interpolation * corresponding to the topology of the spatial distribution. It * does not check the actual topology of the distribution. diff --git a/libsrc/spatialdata/spatialdb/UserFunctionDB.hh b/libsrc/spatialdata/spatialdb/UserFunctionDB.hh index 81761b97..948534e0 100644 --- a/libsrc/spatialdata/spatialdb/UserFunctionDB.hh +++ b/libsrc/spatialdata/spatialdb/UserFunctionDB.hh @@ -155,7 +155,7 @@ class spatialdata::spatialdb::UserFunctionDB : public SpatialDB { private: /** Check suitability of arguments for adding user function. * - * @parma[in] name Name of value. + * @param[in] name Name of value. * @param[in] fn User-defined function for value. * @param[in] units Units of value. */ diff --git a/libsrc/spatialdata/utils/PointsStream.cc b/libsrc/spatialdata/utils/PointsStream.cc index cb872222..039c9f50 100644 --- a/libsrc/spatialdata/utils/PointsStream.cc +++ b/libsrc/spatialdata/utils/PointsStream.cc @@ -45,7 +45,7 @@ spatialdata::utils::PointsStream::read(double** ppPoints, if (!sin || !sin->good()) { const std::string name = !_filename.length() ? _filename : "std::cin"; std::ostringstream msg; - msg << "Could not open intput stream '" << name << "' for reading points."; + msg << "Could not open input stream '" << name << "' for reading points."; throw std::runtime_error(msg.str()); } // if diff --git a/libsrc/spatialdata/utils/PointsStream.hh b/libsrc/spatialdata/utils/PointsStream.hh index 41886dc6..54386a19 100644 --- a/libsrc/spatialdata/utils/PointsStream.hh +++ b/libsrc/spatialdata/utils/PointsStream.hh @@ -71,7 +71,7 @@ class spatialdata::utils::PointsStream { // class PointsStream */ void setFilename(const char* filename); - /** Get name of fle. + /** Get name of file. * * If no filename is supplied, stdin/stdout is used. * diff --git a/modulesrc/spatialdb/SimpleDBData.i b/modulesrc/spatialdb/SimpleDBData.i index b7a2c2ca..0692bfbf 100644 --- a/modulesrc/spatialdb/SimpleDBData.i +++ b/modulesrc/spatialdb/SimpleDBData.i @@ -27,7 +27,7 @@ namespace spatialdata { /// Default destructor ~SimpleDBData(void); - /** Allocate data structues. + /** Allocate data structures. * * @param numLocs Number of locations. * @param numValues Number of values. diff --git a/pyproject.toml b/pyproject.toml index 03e0e075..7df5b309 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,4 +48,10 @@ exempt = [ ] +[tool.codespell] +exclude-file = "etc/ci/conventions/codespell-lines.txt" +ignore-words = "etc/ci/conventions/codespell-words.txt" +skip = "numpy.i,*.pdf,libsrc/spatialdata/muparser/*" + + # End of file diff --git a/spatialdata/spatialdb/generator/GenSimpleDBApp.py b/spatialdata/spatialdb/generator/GenSimpleDBApp.py index c051d7bd..6b6eb769 100644 --- a/spatialdata/spatialdb/generator/GenSimpleDBApp.py +++ b/spatialdata/spatialdb/generator/GenSimpleDBApp.py @@ -60,7 +60,7 @@ class GenSimpleDBApp(Script): # Vp is generated from a background value given in `vp_background.spatialdb` # plus a perturbation given in `vp_perturbation.spatialdb`. # - # Vs is generatef from a backgorund value given in `vs_background.spatialdb` + # Vs is generatef from a background value given in `vs_background.spatialdb` # multiplied by a value given in `vs_scaling.spatialdb`. [gensimpledb.geometry] reader = read_geometry diff --git a/templates/spatialdb/UniformVelModel.cc b/templates/spatialdb/UniformVelModel.cc index 51769865..7898d8ad 100644 --- a/templates/spatialdb/UniformVelModel.cc +++ b/templates/spatialdb/UniformVelModel.cc @@ -101,7 +101,7 @@ contrib::spatialdb::UniformVelModel::close(void) { // close // Deallocate all data allocated in open() and query(). // Deallocate coordinate system object and set to null so that - // subsequent calls to delete won't try to dellocate memory that has + // subsequent calls to delete won't try to deallocate memory that has // already been deallocated. delete _cs; _cs = 0; diff --git a/templates/spatialdb/UniformVelModel.py b/templates/spatialdb/UniformVelModel.py index 11f3a6cc..690cd9d5 100644 --- a/templates/spatialdb/UniformVelModel.py +++ b/templates/spatialdb/UniformVelModel.py @@ -64,7 +64,7 @@ class Inventory(SpatialDBObj.Inventory): # units and convert the value to SI units. # # The help string will be printed when the user uses the command - # line arugments --FULL_COMPONENT_NAME.help-properties or + # line arguments --FULL_COMPONENT_NAME.help-properties or # --FULL_COMPONENT.help-components. See the PyLith manual chapter # "Running PyLith" for more information regarding getting help # using command line arguments. diff --git a/tests/libtests/spatialdb/TestCompositeDB.cc b/tests/libtests/spatialdb/TestCompositeDB.cc index fa4dead2..0ca420a4 100644 --- a/tests/libtests/spatialdb/TestCompositeDB.cc +++ b/tests/libtests/spatialdb/TestCompositeDB.cc @@ -62,7 +62,7 @@ class spatialdata::spatialdb::TestCompositeDB { private: UniformDB _dbA; ///< Spatial database A. - UniformDB _dbB; ///< Spatial databsae B. + UniformDB _dbB; ///< Spatial database B. }; // class TestCompositeDB // ------------------------------------------------------------------------------------------------ diff --git a/tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc b/tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc index 9cfa5dac..995b21da 100644 --- a/tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc +++ b/tests/libtests/spatialdb/TestSimpleGridDB_Cases.cc @@ -252,7 +252,7 @@ spatialdata::spatialdb::TestSimpleGridDB_Cases::Line1D(void) { 0.0, // not found 3.0, 0.0, - 0.0, // not fount + 0.0, // not found }; data->queryLinear = queryLinear; @@ -341,7 +341,7 @@ spatialdata::spatialdb::TestSimpleGridDB_Cases::Line2D(void) { 3.5, 3.0, 0.0, - 0.0, // not fount + 0.0, // not found }; data->queryLinear = queryLinear; @@ -441,7 +441,7 @@ spatialdata::spatialdb::TestSimpleGridDB_Cases::Line3D(void) { 7.5, 3.0, 0.0, - 0.0, // not fount + 0.0, // not found }; data->queryLinear = queryLinear; @@ -537,7 +537,7 @@ spatialdata::spatialdb::TestSimpleGridDB_Cases::Area2D(void) { 3.0, 2.0, 0.0, - 0.0, // not fount + 0.0, // not found }; data->queryLinear = queryLinear; From 9544de44f2d1f0152f50094a9a301b2610eb270c Mon Sep 17 00:00:00 2001 From: Brad Aagaard Date: Thu, 19 Nov 2026 21:50:42 -0700 Subject: [PATCH 10/10] ci: Allow commit messages that are more than one line. --- etc/ci/conventions/check.py | 4 ---- etc/ci/conventions/selftest.py | 2 -- 2 files changed, 6 deletions(-) diff --git a/etc/ci/conventions/check.py b/etc/ci/conventions/check.py index c4ee61a1..563c6648 100755 --- a/etc/ci/conventions/check.py +++ b/etc/ci/conventions/check.py @@ -684,10 +684,6 @@ def commits(*, root: str, base: str | None) -> list: if not SUBJECT.match(subject): # or else it does not read like the rest of the history problems.append(f"{sha}: '{subject}' is not of the form 'area: what the commit does'") - # and the subject is all there is - if body.strip(): - # the narrative belongs in the pull request, not the commit - problems.append(f"{sha}: has a body; the subject line is the whole message") # hand off the complaints return problems diff --git a/etc/ci/conventions/selftest.py b/etc/ci/conventions/selftest.py index e6998cb8..f0eb56d3 100755 --- a/etc/ci/conventions/selftest.py +++ b/etc/ci/conventions/selftest.py @@ -234,8 +234,6 @@ def violations() -> None: expect(report=report, check="preambles", needle="good.cc: touched") # the subject that names no area expect(report=report, check="commits", needle="is not of the form") - # and the body - expect(report=report, check="commits", needle="has a body") # all done return