├── example ├── SourcesList.cmake └── CMakeLists.txt ├── test ├── test-files │ ├── encoding-chinese-gbk.sgf │ ├── encoding-korean-macos.sgf │ ├── encoding-utf16-nobom.sgf │ ├── encoding-chinese-gb18030.sgf │ ├── encoding-japanese-macos.sgf │ ├── encoding-utf16-withbom.sgf │ ├── encoding-cyrillic-windows.sgf │ ├── encoding-japanese-shiftjis.sgf │ ├── encoding-western-isolatin1.sgf │ ├── encoding-western-isolatin9.sgf │ ├── encoding-western-macosroman.sgf │ ├── encoding-western-windowslatin1.sgf │ ├── encoding-simplifiedchinese-gb2312.sgf │ ├── encoding-simplifiedchinese-macos.sgf │ ├── encoding-traditionalchinese-big5.sgf │ ├── encoding-traditionalchinese-macos.sgf │ ├── encoding-japanese-iso2022jp.sgf │ ├── compressed-point-list.sgf │ ├── escaping.sgf │ ├── encoding-utf8-nobom.sgf │ ├── encoding-utf8-withbom.sgf │ └── gameinfo.sgf ├── SourcesList.cmake ├── AssertHelperFunctions.h ├── game │ └── go │ │ └── SgfcGoStoneTest.cpp └── sgfc │ └── save │ └── SgfcSgfContentTest.cpp ├── src ├── Config.cmake.in ├── MasterHeaderFile.h.in ├── interface │ ├── public │ │ ├── ISgfcGame.cpp │ │ ├── ISgfcNode.cpp │ │ ├── ISgfcGoMove.cpp │ │ ├── ISgfcGoPoint.cpp │ │ ├── ISgfcGoStone.cpp │ │ ├── ISgfcMessage.cpp │ │ ├── ISgfcArgument.cpp │ │ ├── ISgfcDocument.cpp │ │ ├── ISgfcGameInfo.cpp │ │ ├── ISgfcProperty.cpp │ │ ├── ISgfcArguments.cpp │ │ ├── ISgfcGoGameInfo.cpp │ │ ├── ISgfcCommandLine.cpp │ │ ├── ISgfcTreeBuilder.cpp │ │ ├── ISgfcDocumentReader.cpp │ │ ├── ISgfcDocumentWriter.cpp │ │ ├── ISgfcPropertyFactory.cpp │ │ ├── ISgfcGameTypeProperty.cpp │ │ ├── ISgfcBoardSizeProperty.cpp │ │ ├── ISgfcMovePropertyValue.cpp │ │ ├── ISgfcRealPropertyValue.cpp │ │ ├── ISgfcTextPropertyValue.cpp │ │ ├── ISgfcColorPropertyValue.cpp │ │ ├── ISgfcDocumentReadResult.cpp │ │ ├── ISgfcPointPropertyValue.cpp │ │ ├── ISgfcStonePropertyValue.cpp │ │ ├── ISgfcDocumentWriteResult.cpp │ │ ├── ISgfcDoublePropertyValue.cpp │ │ ├── ISgfcGoMovePropertyValue.cpp │ │ ├── ISgfcNumberPropertyValue.cpp │ │ ├── ISgfcSinglePropertyValue.cpp │ │ ├── ISgfcGoPointPropertyValue.cpp │ │ ├── ISgfcGoStonePropertyValue.cpp │ │ ├── ISgfcPropertyValueFactory.cpp │ │ ├── ISgfcComposedPropertyValue.cpp │ │ ├── ISgfcSimpleTextPropertyValue.cpp │ │ └── ISgfcPropertyValue.cpp │ └── internal │ │ ├── SgfcPropertyValueTypeDescriptorType.h │ │ └── ISgfcPropertyValueTypeDescriptor.cpp ├── sgfc │ ├── backend │ │ ├── SgfcBackendSaveResult.cpp │ │ ├── SgfcDataLocation.h │ │ ├── SgfcBackendLoadResult.cpp │ │ ├── SgfcBackendDataState.h │ │ ├── SgfcBackendSaveResult.h │ │ └── SgfcBackendLoadResult.h │ ├── save │ │ ├── SgfcSgfContent.cpp │ │ └── SgfcSgfContent.h │ ├── frontend │ │ ├── SgfcDocumentReader.h │ │ └── SgfcDocumentWriter.h │ └── message │ │ └── SgfcMessageStream.h ├── document │ ├── typedpropertyvalue │ │ ├── SgfcRealPropertyValue.cpp │ │ ├── SgfcTextPropertyValue.cpp │ │ ├── SgfcColorPropertyValue.cpp │ │ ├── SgfcDoublePropertyValue.cpp │ │ ├── SgfcNumberPropertyValue.cpp │ │ ├── SgfcSimpleTextPropertyValue.cpp │ │ ├── SgfcMovePropertyValue.cpp │ │ ├── SgfcPointPropertyValue.cpp │ │ ├── SgfcStonePropertyValue.cpp │ │ ├── go │ │ │ ├── SgfcGoPointPropertyValue.cpp │ │ │ ├── SgfcGoStonePropertyValue.cpp │ │ │ ├── SgfcGoMovePropertyValue.cpp │ │ │ ├── SgfcGoPointPropertyValue.h │ │ │ └── SgfcGoStonePropertyValue.h │ │ ├── SgfcRealPropertyValue.h │ │ ├── SgfcTextPropertyValue.h │ │ ├── SgfcColorPropertyValue.h │ │ ├── SgfcDoublePropertyValue.h │ │ ├── SgfcNumberPropertyValue.h │ │ ├── SgfcMovePropertyValue.h │ │ ├── SgfcPointPropertyValue.h │ │ ├── SgfcStonePropertyValue.h │ │ └── SgfcSimpleTextPropertyValue.h │ ├── SgfcComposedPropertyValue.cpp │ ├── typedproperty │ │ ├── SgfcGameTypeProperty.h │ │ └── SgfcGameTypeProperty.cpp │ └── SgfcComposedPropertyValue.h ├── game │ ├── go │ │ ├── SgfcGoStone.cpp │ │ ├── SgfcGoStone.h │ │ ├── SgfcGoMove.cpp │ │ └── SgfcGoMove.h │ └── SgfcBoardSize.cpp └── parsing │ ├── SgfcSinglePropertyValueContext.h │ └── propertyvaluetypedescriptor │ ├── SgfcPropertyBasicValueTypeDescriptor.cpp │ └── SgfcPropertyElistValueTypeDescriptor.cpp ├── .gitignore ├── doc ├── SourcesList.cmake └── ChangeLog.md ├── .gitmodules ├── NOTICE ├── include ├── SgfcColor.h ├── SgfcGoPlayerRatingType.h ├── SgfcCoordinateSystem.h ├── SgfcMessageType.h ├── SgfcGoRulesetType.h ├── SgfcGameResultType.h ├── SgfcDouble.h ├── ISgfcGoMovePropertyValue.h ├── ISgfcRealPropertyValue.h ├── ISgfcTextPropertyValue.h ├── ISgfcGoStonePropertyValue.h ├── ISgfcColorPropertyValue.h ├── SgfcWinType.h ├── ISgfcDoublePropertyValue.h ├── ISgfcNumberPropertyValue.h ├── SgfcGoPlayerRankType.h ├── ISgfcGoStone.h ├── ISgfcGoPointPropertyValue.h ├── ISgfcSimpleTextPropertyValue.h ├── SgfcExitCode.h ├── SgfcGameType.h ├── ISgfcComposedPropertyValue.h ├── ISgfcMovePropertyValue.h ├── ISgfcPointPropertyValue.h └── ISgfcStonePropertyValue.h └── script └── build.sh /example/SourcesList.cmake: -------------------------------------------------------------------------------- 1 | set ( 2 | SOURCES 3 | main.cpp 4 | ${SOURCES_LIST_FILE_NAME} 5 | ) 6 | -------------------------------------------------------------------------------- /test/test-files/encoding-chinese-gbk.sgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herzbube/libsgfcplusplus/HEAD/test/test-files/encoding-chinese-gbk.sgf -------------------------------------------------------------------------------- /test/test-files/encoding-korean-macos.sgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herzbube/libsgfcplusplus/HEAD/test/test-files/encoding-korean-macos.sgf -------------------------------------------------------------------------------- /test/test-files/encoding-utf16-nobom.sgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herzbube/libsgfcplusplus/HEAD/test/test-files/encoding-utf16-nobom.sgf -------------------------------------------------------------------------------- /test/test-files/encoding-chinese-gb18030.sgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herzbube/libsgfcplusplus/HEAD/test/test-files/encoding-chinese-gb18030.sgf -------------------------------------------------------------------------------- /test/test-files/encoding-japanese-macos.sgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herzbube/libsgfcplusplus/HEAD/test/test-files/encoding-japanese-macos.sgf -------------------------------------------------------------------------------- /test/test-files/encoding-utf16-withbom.sgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herzbube/libsgfcplusplus/HEAD/test/test-files/encoding-utf16-withbom.sgf -------------------------------------------------------------------------------- /test/test-files/encoding-cyrillic-windows.sgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herzbube/libsgfcplusplus/HEAD/test/test-files/encoding-cyrillic-windows.sgf -------------------------------------------------------------------------------- /test/test-files/encoding-japanese-shiftjis.sgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herzbube/libsgfcplusplus/HEAD/test/test-files/encoding-japanese-shiftjis.sgf -------------------------------------------------------------------------------- /test/test-files/encoding-western-isolatin1.sgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herzbube/libsgfcplusplus/HEAD/test/test-files/encoding-western-isolatin1.sgf -------------------------------------------------------------------------------- /test/test-files/encoding-western-isolatin9.sgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herzbube/libsgfcplusplus/HEAD/test/test-files/encoding-western-isolatin9.sgf -------------------------------------------------------------------------------- /src/Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/libsgfcplusplus.cmake") 4 | 5 | check_required_components(libsgfcplusplus) 6 | -------------------------------------------------------------------------------- /test/test-files/encoding-western-macosroman.sgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herzbube/libsgfcplusplus/HEAD/test/test-files/encoding-western-macosroman.sgf -------------------------------------------------------------------------------- /test/test-files/encoding-western-windowslatin1.sgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herzbube/libsgfcplusplus/HEAD/test/test-files/encoding-western-windowslatin1.sgf -------------------------------------------------------------------------------- /test/test-files/encoding-simplifiedchinese-gb2312.sgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herzbube/libsgfcplusplus/HEAD/test/test-files/encoding-simplifiedchinese-gb2312.sgf -------------------------------------------------------------------------------- /test/test-files/encoding-simplifiedchinese-macos.sgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herzbube/libsgfcplusplus/HEAD/test/test-files/encoding-simplifiedchinese-macos.sgf -------------------------------------------------------------------------------- /test/test-files/encoding-traditionalchinese-big5.sgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herzbube/libsgfcplusplus/HEAD/test/test-files/encoding-traditionalchinese-big5.sgf -------------------------------------------------------------------------------- /test/test-files/encoding-traditionalchinese-macos.sgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herzbube/libsgfcplusplus/HEAD/test/test-files/encoding-traditionalchinese-macos.sgf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build products 2 | build/ 3 | 4 | # Visual Studio 5 | # These folders are created when the project folder is opened 6 | # in Visual Studio, as recommended on the Microsoft docs page 7 | # for CMake projects. 8 | .vs/ 9 | out/ 10 | 11 | # Other files 12 | .DS_Store 13 | -------------------------------------------------------------------------------- /doc/SourcesList.cmake: -------------------------------------------------------------------------------- 1 | set ( 2 | SOURCES 3 | ../include 4 | ../src 5 | ../doc 6 | ../README.md 7 | ) 8 | 9 | set ( 10 | OUTPUT_DIRECTORIES 11 | ${CMAKE_CURRENT_BINARY_DIR}/html 12 | # Add more directories here if you have configured Doxygen to generate more 13 | # output. 14 | ) 15 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "sgfc"] 2 | path = sgfc 3 | url = https://bitbucket.org/arnoh/sgfc.git 4 | [submodule "test/Catch2"] 5 | path = test/Catch2 6 | url = https://github.com/catchorg/Catch2.git 7 | [submodule "win-iconv"] 8 | path = win-iconv 9 | url = https://github.com/win-iconv/win-iconv.git 10 | -------------------------------------------------------------------------------- /test/test-files/encoding-japanese-iso2022jp.sgf: -------------------------------------------------------------------------------- 1 | (;FF[4]CA[ISO-2022-JP]GM[1] 2 | ;C[BBEdit calls the encoding of this file "Japanese (ISO 2022-JP)". It is most likely ISO-2022-JP.] 3 | ;C[The comment in the following node is in Japanese.] 4 | ;C[Go$B$O8EBe$N%2!<%`$G$"$j!"Cf9q$G$N5/8;$rK:$l$F$+$i!":G=i$KEl%"%8%"$NB>$NCO0h$K9-$,$j!"> saveResult) 24 | : saveResult(saveResult) 25 | { 26 | } 27 | 28 | SgfcBackendSaveResult::~SgfcBackendSaveResult() 29 | { 30 | } 31 | 32 | std::vector> SgfcBackendSaveResult::GetSaveResult() const 33 | { 34 | return this->saveResult; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/interface/public/ISgfcPropertyValue.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "../../../include/ISgfcPropertyValue.h" 19 | 20 | namespace LibSgfcPlusPlus 21 | { 22 | ISgfcPropertyValue::ISgfcPropertyValue() 23 | { 24 | } 25 | 26 | ISgfcPropertyValue::~ISgfcPropertyValue() 27 | { 28 | } 29 | 30 | const ISgfcSinglePropertyValue* ISgfcPropertyValue::ToSingleValue() const 31 | { 32 | return nullptr; 33 | } 34 | 35 | const ISgfcComposedPropertyValue* ISgfcPropertyValue::ToComposedValue() const 36 | { 37 | return nullptr; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/sgfc/backend/SgfcDataLocation.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | namespace LibSgfcPlusPlus 20 | { 21 | /// @brief SgfcDataLocation enumerates the locations where SGF data can be 22 | /// read from or written to. 23 | /// 24 | /// @ingroup internals 25 | enum class SgfcDataLocation 26 | { 27 | /// @brief The SGF data is read from or written to a file in the filesystem. 28 | Filesystem, 29 | 30 | /// @brief The SGF data is read from or written to an in-memory buffer, 31 | /// typically an std::string. 32 | InMemoryBuffer, 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /test/test-files/escaping.sgf: -------------------------------------------------------------------------------- 1 | This SGF file demonstrates various things related to escaping. 2 | - The game type is not 1, i.e. not Go, so that SGFC does not attempt to 3 | interpret move/point/stone values. 4 | ( 5 | ;FF[4]GM[19] 6 | AP[First \: SimpleText \: value \: in \: composed \: value \: with \: [neces\\sary\] \: escape \: characters:Second \: SimpleText \: value \: in \: composed \: value \: with \: \u\n\n\e\c\c\e\s\s\a\r\y \: escape \: characters] 7 | ;C[Text \: value \: with \: \u\n\n\e\c\c\e\s\s\a\r\y \: escape \: characters] 8 | ;C[Text \: value \: with \: [neces\\sary\] \: escape \: characters] 9 | ;N[SimpleText \: value \: with \: \u\n\n\e\c\c\e\s\s\a\r\y \: escape \: characters] 10 | ;N[SimpleText \: value \: with \: [neces\\sary\] \: escape \: characters] 11 | ;B[Move \: value \: with \: \u\n\n\e\c\c\e\s\s\a\r\y \: escape \: characters] 12 | ;B[Move \: value \: with \: [neces\\sary\] \: escape \: characters] 13 | ;CR[Point \: value \: with \: \u\n\n\e\c\c\e\s\s\a\r\y \: escape \: characters] 14 | ;CR[Point \: value \: with \: [neces\\sary\] \: escape \: characters] 15 | ;AB[Stone \: value \: with \: \u\n\n\e\c\c\e\s\s\a\r\y \: escape \: characters] 16 | ;AW[Stone \: value \: with \: [neces\\sary\] \: escape \: characters] 17 | ;AR[First \: Point \: value \: in \: composed \: value \: with \: [neces\\sary\] \: escape \: characters:Second \: Point \: value \: in \: composed \: value \: with \: \u\n\n\e\c\c\e\s\s\a\r\y \: escape \: characters] 18 | ) 19 | -------------------------------------------------------------------------------- /src/sgfc/save/SgfcSgfContent.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcSgfContent.h" 19 | 20 | namespace LibSgfcPlusPlus 21 | { 22 | SgfcSgfContent::SgfcSgfContent() 23 | { 24 | } 25 | 26 | SgfcSgfContent::SgfcSgfContent( 27 | const std::string& sgfContent, 28 | const std::string& filePath) 29 | : sgfContent(sgfContent) 30 | , filePath(filePath) 31 | { 32 | } 33 | 34 | SgfcSgfContent::~SgfcSgfContent() 35 | { 36 | } 37 | 38 | std::string SgfcSgfContent::GetSgfContent() const 39 | { 40 | return this->sgfContent; 41 | } 42 | 43 | std::string SgfcSgfContent::GetFilePath() const 44 | { 45 | return this->filePath; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /include/SgfcColor.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes (generated) 20 | #include "SgfcPlusPlusExport.h" 21 | 22 | namespace LibSgfcPlusPlus 23 | { 24 | /// @brief SgfcColor enumerates the values that a property value of type 25 | /// SgfcPropertyValueType::Color can have. 26 | /// 27 | /// @ingroup public-api 28 | enum class SGFCPLUSPLUS_EXPORT SgfcColor 29 | { 30 | /// @brief The property value signifies the abstract color "Black". 31 | /// 32 | /// The raw property string value is "B". 33 | Black, 34 | /// @brief The property value signifies the abstract color "White". 35 | /// 36 | /// The raw property string value is "W". 37 | White, 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcRealPropertyValue.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcRealPropertyValue.h" 19 | 20 | namespace LibSgfcPlusPlus 21 | { 22 | SgfcRealPropertyValue::SgfcRealPropertyValue(const std::string& rawValue, SgfcReal realValue) 23 | : SgfcSinglePropertyValue(rawValue, SgfcPropertyValueType::Real) 24 | , realValue(realValue) 25 | { 26 | } 27 | 28 | SgfcRealPropertyValue::~SgfcRealPropertyValue() 29 | { 30 | } 31 | 32 | SgfcReal SgfcRealPropertyValue::GetRealValue() const 33 | { 34 | return this->realValue; 35 | } 36 | 37 | const ISgfcRealPropertyValue* SgfcRealPropertyValue::ToRealValue() const 38 | { 39 | return this; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcTextPropertyValue.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcTextPropertyValue.h" 19 | 20 | namespace LibSgfcPlusPlus 21 | { 22 | SgfcTextPropertyValue::SgfcTextPropertyValue(const std::string& rawValue, const SgfcText& textValue) 23 | : SgfcSinglePropertyValue(rawValue, SgfcPropertyValueType::Text) 24 | , textValue(textValue) 25 | { 26 | } 27 | 28 | SgfcTextPropertyValue::~SgfcTextPropertyValue() 29 | { 30 | } 31 | 32 | SgfcText SgfcTextPropertyValue::GetTextValue() const 33 | { 34 | return this->textValue; 35 | } 36 | 37 | const ISgfcTextPropertyValue* SgfcTextPropertyValue::ToTextValue() const 38 | { 39 | return this; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcColorPropertyValue.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcColorPropertyValue.h" 19 | 20 | namespace LibSgfcPlusPlus 21 | { 22 | SgfcColorPropertyValue::SgfcColorPropertyValue(const std::string& rawValue, SgfcColor colorValue) 23 | : SgfcSinglePropertyValue(rawValue, SgfcPropertyValueType::Color) 24 | , colorValue(colorValue) 25 | { 26 | } 27 | 28 | SgfcColorPropertyValue::~SgfcColorPropertyValue() 29 | { 30 | } 31 | 32 | SgfcColor SgfcColorPropertyValue::GetColorValue() const 33 | { 34 | return this->colorValue; 35 | } 36 | 37 | const ISgfcColorPropertyValue* SgfcColorPropertyValue::ToColorValue() const 38 | { 39 | return this; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcDoublePropertyValue.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcDoublePropertyValue.h" 19 | 20 | namespace LibSgfcPlusPlus 21 | { 22 | SgfcDoublePropertyValue::SgfcDoublePropertyValue(const std::string& rawValue, SgfcDouble doubleValue) 23 | : SgfcSinglePropertyValue(rawValue, SgfcPropertyValueType::Double) 24 | , doubleValue(doubleValue) 25 | { 26 | } 27 | 28 | SgfcDoublePropertyValue::~SgfcDoublePropertyValue() 29 | { 30 | } 31 | 32 | SgfcDouble SgfcDoublePropertyValue::GetDoubleValue() const 33 | { 34 | return this->doubleValue; 35 | } 36 | 37 | const ISgfcDoublePropertyValue* SgfcDoublePropertyValue::ToDoubleValue() const 38 | { 39 | return this; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcNumberPropertyValue.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcNumberPropertyValue.h" 19 | 20 | namespace LibSgfcPlusPlus 21 | { 22 | SgfcNumberPropertyValue::SgfcNumberPropertyValue(const std::string& rawValue, SgfcNumber numberValue) 23 | : SgfcSinglePropertyValue(rawValue, SgfcPropertyValueType::Number) 24 | , numberValue(numberValue) 25 | { 26 | } 27 | 28 | SgfcNumberPropertyValue::~SgfcNumberPropertyValue() 29 | { 30 | } 31 | 32 | SgfcNumber SgfcNumberPropertyValue::GetNumberValue() const 33 | { 34 | return this->numberValue; 35 | } 36 | 37 | const ISgfcNumberPropertyValue* SgfcNumberPropertyValue::ToNumberValue() const 38 | { 39 | return this; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/game/go/SgfcGoStone.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcGoStone.h" 19 | 20 | // C++ Standard Library includes 21 | #include 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | SgfcGoStone::SgfcGoStone(SgfcColor color, std::shared_ptr location) 26 | : color(color) 27 | , location(location) 28 | { 29 | if (this->location == nullptr) 30 | throw std::invalid_argument("SgfcGoStone constructor failed: location object is nullptr"); 31 | } 32 | 33 | SgfcGoStone::~SgfcGoStone() 34 | { 35 | } 36 | 37 | SgfcColor SgfcGoStone::GetColor() const 38 | { 39 | return this->color; 40 | } 41 | 42 | std::shared_ptr SgfcGoStone::GetLocation() const 43 | { 44 | return this->location; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/sgfc/backend/SgfcBackendLoadResult.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcBackendLoadResult.h" 19 | 20 | namespace LibSgfcPlusPlus 21 | { 22 | SgfcBackendLoadResult::SgfcBackendLoadResult( 23 | std::vector> parseResult, 24 | std::shared_ptr sgfDataWrapper) 25 | : parseResult(parseResult) 26 | , sgfDataWrapper(sgfDataWrapper) 27 | { 28 | } 29 | 30 | SgfcBackendLoadResult::~SgfcBackendLoadResult() 31 | { 32 | } 33 | 34 | std::vector> SgfcBackendLoadResult::GetParseResult() const 35 | { 36 | return this->parseResult; 37 | } 38 | 39 | std::shared_ptr SgfcBackendLoadResult::GetSgfDataWrapper() const 40 | { 41 | return this->sgfDataWrapper; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcSimpleTextPropertyValue.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcSimpleTextPropertyValue.h" 19 | 20 | namespace LibSgfcPlusPlus 21 | { 22 | SgfcSimpleTextPropertyValue::SgfcSimpleTextPropertyValue(const std::string& rawValue, const SgfcSimpleText& simpleTextValue) 23 | : SgfcSinglePropertyValue(rawValue, SgfcPropertyValueType::SimpleText) 24 | , simpleTextValue(simpleTextValue) 25 | { 26 | } 27 | 28 | SgfcSimpleTextPropertyValue::~SgfcSimpleTextPropertyValue() 29 | { 30 | } 31 | 32 | SgfcSimpleText SgfcSimpleTextPropertyValue::GetSimpleTextValue() const 33 | { 34 | return this->simpleTextValue; 35 | } 36 | 37 | const ISgfcSimpleTextPropertyValue* SgfcSimpleTextPropertyValue::ToSimpleTextValue() const 38 | { 39 | return this; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcMovePropertyValue.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcMovePropertyValue.h" 19 | 20 | namespace LibSgfcPlusPlus 21 | { 22 | SgfcMovePropertyValue::SgfcMovePropertyValue(const std::string& rawValue, const SgfcMove& moveValue) 23 | : SgfcSinglePropertyValue(rawValue, SgfcPropertyValueType::Move) 24 | , moveValue(moveValue) 25 | { 26 | } 27 | 28 | SgfcMovePropertyValue::~SgfcMovePropertyValue() 29 | { 30 | } 31 | 32 | std::string SgfcMovePropertyValue::GetMoveValue() const 33 | { 34 | return this->moveValue; 35 | } 36 | 37 | const ISgfcMovePropertyValue* SgfcMovePropertyValue::ToMoveValue() const 38 | { 39 | return this; 40 | } 41 | 42 | const ISgfcGoMovePropertyValue* SgfcMovePropertyValue::ToGoMoveValue() const 43 | { 44 | return nullptr; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcPointPropertyValue.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcPointPropertyValue.h" 19 | 20 | namespace LibSgfcPlusPlus 21 | { 22 | SgfcPointPropertyValue::SgfcPointPropertyValue(const std::string& rawValue, const SgfcPoint& pointValue) 23 | : SgfcSinglePropertyValue(rawValue, SgfcPropertyValueType::Point) 24 | , pointValue(pointValue) 25 | { 26 | } 27 | 28 | SgfcPointPropertyValue::~SgfcPointPropertyValue() 29 | { 30 | } 31 | 32 | std::string SgfcPointPropertyValue::GetPointValue() const 33 | { 34 | return this->pointValue; 35 | } 36 | 37 | const ISgfcPointPropertyValue* SgfcPointPropertyValue::ToPointValue() const 38 | { 39 | return this; 40 | } 41 | 42 | const ISgfcGoPointPropertyValue* SgfcPointPropertyValue::ToGoPointValue() const 43 | { 44 | return nullptr; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcStonePropertyValue.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcStonePropertyValue.h" 19 | 20 | namespace LibSgfcPlusPlus 21 | { 22 | SgfcStonePropertyValue::SgfcStonePropertyValue(const std::string& rawValue, const SgfcStone& stoneValue) 23 | : SgfcSinglePropertyValue(rawValue, SgfcPropertyValueType::Stone) 24 | , stoneValue(stoneValue) 25 | { 26 | } 27 | 28 | SgfcStonePropertyValue::~SgfcStonePropertyValue() 29 | { 30 | } 31 | 32 | std::string SgfcStonePropertyValue::GetStoneValue() const 33 | { 34 | return this->stoneValue; 35 | } 36 | 37 | const ISgfcStonePropertyValue* SgfcStonePropertyValue::ToStoneValue() const 38 | { 39 | return this; 40 | } 41 | 42 | const ISgfcGoStonePropertyValue* SgfcStonePropertyValue::ToGoStoneValue() const 43 | { 44 | return nullptr; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /include/SgfcGoPlayerRatingType.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes (generated) 20 | #include "SgfcPlusPlusExport.h" 21 | 22 | namespace LibSgfcPlusPlus 23 | { 24 | /// @brief SgfcGoPlayerRatingType enumerates the rating types that can apply 25 | /// to a Go player's rank. 26 | /// 27 | /// @ingroup public-api 28 | /// @ingroup game 29 | /// @ingroup go 30 | /// 31 | /// @see ISgfcGameInfo 32 | enum class SGFCPLUSPLUS_EXPORT SgfcGoPlayerRatingType 33 | { 34 | /// @brief The rank of the Go player is uncertain. 35 | Uncertain, 36 | 37 | /// @brief The rank of the Go player is established. 38 | Established, 39 | 40 | /// @brief The rating type that applies to the Go player's rank is 41 | /// not specified, i.e. it is not known whether the rank is uncertain 42 | /// or established. 43 | Unspecified, 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /src/parsing/SgfcSinglePropertyValueContext.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | namespace LibSgfcPlusPlus 20 | { 21 | /// @brief SgfcSinglePropertyValueContext enumerates in which context a 22 | /// ISgfcSinglePropertyValue object can appear. 23 | /// 24 | /// @ingroup internals 25 | /// @ingroup parsing 26 | enum class SgfcSinglePropertyValueContext 27 | { 28 | /// @brief The ISgfcSinglePropertyValue object is the first value of an 29 | /// ISgfcComposedPropertyValue object. 30 | FirstValueOfComposedValue, 31 | 32 | /// @brief The ISgfcSinglePropertyValue object is the second value of an 33 | /// ISgfcComposedPropertyValue object. 34 | SecondValueOfComposedValue, 35 | 36 | /// @brief The ISgfcSinglePropertyValue object is a standalone value, i.e. 37 | /// it is not part of an ISgfcComposedPropertyValue object. 38 | Standalone, 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /include/SgfcCoordinateSystem.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes (generated) 20 | #include "SgfcPlusPlusExport.h" 21 | 22 | namespace LibSgfcPlusPlus 23 | { 24 | /// @brief SgfcCoordinateSystem enumerates the coordinate systems supported 25 | /// by game-specific representations of Point values. 26 | /// 27 | /// @ingroup public-api 28 | enum class SGFCPLUSPLUS_EXPORT SgfcCoordinateSystem 29 | { 30 | /// @brief The coordinate system's origin is in the upper-left corner. 31 | /// 32 | /// For instance, this coordinate system is used by SgfcGoPointNotation::Sgf 33 | /// and SgfcGoPointNotation::Figure. 34 | UpperLeftOrigin, 35 | 36 | /// @brief The coordinate system's origin is in the lower-left corner. 37 | /// 38 | /// For instance, this coordinate system is used by 39 | /// SgfcGoPointNotation::Hybrid. 40 | LowerLeftOrigin, 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /include/SgfcMessageType.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes (generated) 20 | #include "SgfcPlusPlusExport.h" 21 | 22 | namespace LibSgfcPlusPlus 23 | { 24 | /// @brief SgfcMessageType enumerates all message types generated by SGFC. 25 | /// 26 | /// @ingroup public-api 27 | enum class SGFCPLUSPLUS_EXPORT SgfcMessageType 28 | { 29 | /// @brief The message describes something that is likely a minor problem 30 | /// in the SGF data parsed by SGFC. The message may also document a 31 | /// corrective action taken by SGFC. 32 | Warning, 33 | 34 | /// @brief The message describes an error in the SGF data parsed by SGFC. 35 | Error, 36 | 37 | /// @brief The message describes a fatal error in the SGF data parsed by 38 | /// SGFC, or it describes a fatal error that occurred during the SGFC 39 | /// operation (e.g. a file handling error). 40 | FatalError, 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /test/test-files/encoding-utf8-nobom.sgf: -------------------------------------------------------------------------------- 1 | (;FF[4]CA[UTF-8]GM[1] 2 | ;C[BBEdit calls the encoding of this file "Unicode (UTF-8)". It is UTF-8 without BOM.] 3 | ;C[The comment in the following node is in English.] 4 | ;C[Go is an ancient game which, from its forgotten origins in China, spread first to the rest of East Asia, and then to the entire world.] 5 | ;C[The comment in the following node is in Cyrillic.] 6 | ;C[Го - древняя игра, которая со времен ее забытого происхождения в Китае распространилась сначала на остальную часть Восточной Азии, а затем и на весь мир.] 7 | ;C[The comment in the following node is in Greek.] 8 | ;C[Το Go είναι ένα αρχαίο παιχνίδι που, από την ξεχασμένη καταγωγή του στην Κίνα, εξαπλώθηκε πρώτα στην υπόλοιπη Ανατολική Ασία και μετά σε ολόκληρο τον κόσμο.] 9 | ;C[The comment in the following node is in Japanese.] 10 | ;C[Goは古代のゲームであり、中国での起源を忘れてから、最初に東アジアの他の地域に広がり、次に全世界に広がりました。] 11 | ;C[The comment in the following node is in Simplified Chinese.] 12 | ;C[围棋是一种古老的游戏,从被遗忘的中国起源先传到东亚其他地区,然后传到整个世界。] 13 | ;C[The comment in the following node is in Traditional Chinese.] 14 | ;C[圍棋是一種古老的遊戲,從其被遺忘的中國起源開始,首先傳播到東亞其他地區,然後傳播到整個世界。] 15 | ;C[The comment in the following node is in Korean.] 16 | ;C[바둑은 중국에서 잊혀진 기원에서 처음에는 동아시아의 나머지 지역으로 퍼진 후 전 세계로 퍼진 고대 게임입니다.] 17 | ;C[The comment in the following node is in Arabic.] 18 | ;C[Go هي لعبة قديمة ، من أصولها المنسية في الصين ، انتشرت أولاً إلى بقية شرق آسيا ، ثم إلى العالم بأسره.] 19 | ;C[The comment in the following node is in Hebrew.] 20 | ;C[גו הוא משחק עתיק אשר ממקורותיו הנשכחים בסין התפשט תחילה לשאר מזרח אסיה, ואחר כך לכל העולם.] 21 | ;C[The comment in the following node is in Hindi.] 22 | ;C[गो एक प्राचीन खेल है, जो चीन में अपने भूले हुए उद्गम से, पहले पूर्वी एशिया के बाकी हिस्सों में और फिर पूरी दुनिया में फैल गया।] 23 | ) 24 | -------------------------------------------------------------------------------- /test/test-files/encoding-utf8-withbom.sgf: -------------------------------------------------------------------------------- 1 | (;FF[4]CA[UTF-8]GM[1] 2 | ;C[BBEdit calls the encoding of this file "Unicode (UTF-8)". It is UTF-8 with BOM.] 3 | ;C[The comment in the following node is in English.] 4 | ;C[Go is an ancient game which, from its forgotten origins in China, spread first to the rest of East Asia, and then to the entire world.] 5 | ;C[The comment in the following node is in Cyrillic.] 6 | ;C[Го - древняя игра, которая со времен ее забытого происхождения в Китае распространилась сначала на остальную часть Восточной Азии, а затем и на весь мир.] 7 | ;C[The comment in the following node is in Greek.] 8 | ;C[Το Go είναι ένα αρχαίο παιχνίδι που, από την ξεχασμένη καταγωγή του στην Κίνα, εξαπλώθηκε πρώτα στην υπόλοιπη Ανατολική Ασία και μετά σε ολόκληρο τον κόσμο.] 9 | ;C[The comment in the following node is in Japanese.] 10 | ;C[Goは古代のゲームであり、中国での起源を忘れてから、最初に東アジアの他の地域に広がり、次に全世界に広がりました。] 11 | ;C[The comment in the following node is in Simplified Chinese.] 12 | ;C[围棋是一种古老的游戏,从被遗忘的中国起源先传到东亚其他地区,然后传到整个世界。] 13 | ;C[The comment in the following node is in Traditional Chinese.] 14 | ;C[圍棋是一種古老的遊戲,從其被遺忘的中國起源開始,首先傳播到東亞其他地區,然後傳播到整個世界。] 15 | ;C[The comment in the following node is in Korean.] 16 | ;C[바둑은 중국에서 잊혀진 기원에서 처음에는 동아시아의 나머지 지역으로 퍼진 후 전 세계로 퍼진 고대 게임입니다.] 17 | ;C[The comment in the following node is in Arabic.] 18 | ;C[Go هي لعبة قديمة ، من أصولها المنسية في الصين ، انتشرت أولاً إلى بقية شرق آسيا ، ثم إلى العالم بأسره.] 19 | ;C[The comment in the following node is in Hebrew.] 20 | ;C[גו הוא משחק עתיק אשר ממקורותיו הנשכחים בסין התפשט תחילה לשאר מזרח אסיה, ואחר כך לכל העולם.] 21 | ;C[The comment in the following node is in Hindi.] 22 | ;C[गो एक प्राचीन खेल है, जो चीन में अपने भूले हुए उद्गम से, पहले पूर्वी एशिया के बाकी हिस्सों में और फिर पूरी दुनिया में फैल गया।] 23 | ) 24 | -------------------------------------------------------------------------------- /src/parsing/propertyvaluetypedescriptor/SgfcPropertyBasicValueTypeDescriptor.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcPropertyBasicValueTypeDescriptor.h" 19 | 20 | namespace LibSgfcPlusPlus 21 | { 22 | SgfcPropertyBasicValueTypeDescriptor::SgfcPropertyBasicValueTypeDescriptor( 23 | SgfcPropertyValueType valueType) 24 | : valueType(valueType) 25 | { 26 | } 27 | 28 | SgfcPropertyBasicValueTypeDescriptor::~SgfcPropertyBasicValueTypeDescriptor() 29 | { 30 | } 31 | 32 | SgfcPropertyValueTypeDescriptorType SgfcPropertyBasicValueTypeDescriptor::GetDescriptorType() const 33 | { 34 | return SgfcPropertyValueTypeDescriptorType::BasicValueType; 35 | } 36 | 37 | const SgfcPropertyBasicValueTypeDescriptor* SgfcPropertyBasicValueTypeDescriptor::ToBasicValueTypeDescriptor() const 38 | { 39 | return this; 40 | } 41 | 42 | SgfcPropertyValueType SgfcPropertyBasicValueTypeDescriptor::GetValueType() const 43 | { 44 | return this->valueType; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /test/test-files/gameinfo.sgf: -------------------------------------------------------------------------------- 1 | (;FF[4]CA[UTF-8]GM[1]SZ[9]AP[SGFC:1.18] 2 | (;C[This game tree contains each game info property once, with very values to test the behaviour of SGF viewers] 3 | US[A very long recorder name (US property)] 4 | SO[A very long source name (SO property)] 5 | AN[A very long annotation author name (AN property)] 6 | CP[A very long copyright information text (CP property)] 7 | GN[A very long game name (GN property)] 8 | GC[A very long game information text (GC property)] 9 | DT[2019-02-28,2020-02-29,2021-01-10,11,12,02-03] 10 | RU[AGA] 11 | RE[W+17.5] 12 | TM[142.7] 13 | OT[A very long overtime information text (OT property)] 14 | ON[A very long opening information text (OT property)] 15 | PB[A very long black player name (PB property)] 16 | BR[25k?] 17 | BT[A very long black player team name (BT property)] 18 | PW[A very long white player name (PW property)] 19 | WR[7d*] 20 | WT[A very long white player team name (WT property)] 21 | PC[A very long game location name (PC property)] 22 | EV[A very long event name (EV property)] 23 | RO[A very long round information (RO property)] 24 | HA[2] 25 | KM[0.5] 26 | AB[aa][bb] 27 | ;B[ec];W[ef]) 28 | (;C[This game tree contains an alternative game result and a non-standard black player ranking for professional ranks] 29 | RE[W+R] 30 | BR[4p]) 31 | (;C[This game tree contains an alternative game result] 32 | RE[W+T]) 33 | (;C[This game tree contains an alternative game result] 34 | RE[W+F]) 35 | (;C[This game tree contains an alternative game result] 36 | RE[Draw]) 37 | (;C[This game tree contains an alternative game result] 38 | RE[Void]) 39 | (;C[This game tree contains an alternative game result] 40 | RE[?]) 41 | ) 42 | -------------------------------------------------------------------------------- /include/SgfcGoRulesetType.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes (generated) 20 | #include "SgfcPlusPlusExport.h" 21 | 22 | namespace LibSgfcPlusPlus 23 | { 24 | /// @brief SgfcGoRulesetType enumerates the ruleset types that are 25 | /// recognized by libsgfc++. 26 | /// 27 | /// @ingroup public-api 28 | /// @ingroup game 29 | /// @ingroup go 30 | /// 31 | /// @see ISgfcGameInfo 32 | enum class SGFCPLUSPLUS_EXPORT SgfcGoRulesetType 33 | { 34 | /// @brief The rules of the American Go Association (AGA). 35 | AGA, 36 | 37 | /// @brief The Ing rules. 38 | /// 39 | /// The SGF standard uses the description "The Ing rules of Goe". The word 40 | /// "Goe" is an alternative spelling of Go proposed by Ing Chang-Ki, the 41 | /// author of the ruleset, to differentiate it from the English verb 42 | /// "to go". 43 | Ing, 44 | 45 | /// @brief The Nihon-Kiin rule set. 46 | Japanese, 47 | 48 | /// @brief The New Zealand rules. 49 | NZ, 50 | }; 51 | } 52 | -------------------------------------------------------------------------------- /example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include( ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCES_LIST_FILE_NAME} ) 2 | if ( NOT DEFINED SOURCES ) 3 | message ( FATAL_ERROR "List of source files not defined by ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCES_LIST_FILE_NAME}" ) 4 | endif() 5 | 6 | # Here we define the example executable target. 7 | add_executable ( 8 | ${EXAMPLE_EXECUTABLE_TARGET_NAME} 9 | ${SOURCES} 10 | ) 11 | 12 | # The folder where the generated export header file is located must also be in 13 | # our list of include directories. We don't need to specify that folder here, 14 | # though, because we "inherit" it by linking against a libsgfc++ library target 15 | # below. Reason: The target_link_libraries statement is also a dependency 16 | # declaration that causes CMake to add all PUBLIC include directories of the 17 | # dependency target to our own target. 18 | target_include_directories ( 19 | ${EXAMPLE_EXECUTABLE_TARGET_NAME} 20 | # The examples treat libsgfc++ itself as a third-party library, so the next 21 | # include directory is required to find the public interface headers. 22 | PRIVATE ../include 23 | ) 24 | 25 | # Examples use only public symbols, so we don't care which library we link 26 | # against. 27 | target_link_libraries ( 28 | ${EXAMPLE_EXECUTABLE_TARGET_NAME} 29 | ${LINK_LIBRARY_TARGET_NAME} 30 | ) 31 | 32 | # Define additional compile options. 33 | # - EXPORT_HEADER_STATIC_DEFINE_MACRO_NAME macro: The example executable target 34 | # must define this macro to be able to link against the static library or 35 | # static library framework 36 | # - COMPILE_OPTION_C_FUNCTIONS_MAY_THROW_EXCEPTIONS: Tell the compiler that 37 | # C functions may throw exceptions. See main CMake config file for details. 38 | target_compile_options ( 39 | ${EXAMPLE_EXECUTABLE_TARGET_NAME} 40 | PUBLIC 41 | -D${EXPORT_HEADER_STATIC_DEFINE_MACRO_NAME} 42 | ${COMPILE_OPTION_C_FUNCTIONS_MAY_THROW_EXCEPTIONS} 43 | ) 44 | -------------------------------------------------------------------------------- /src/parsing/propertyvaluetypedescriptor/SgfcPropertyElistValueTypeDescriptor.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcPropertyElistValueTypeDescriptor.h" 19 | 20 | namespace LibSgfcPlusPlus 21 | { 22 | SgfcPropertyElistValueTypeDescriptor::SgfcPropertyElistValueTypeDescriptor( 23 | std::shared_ptr descriptorListValueType) 24 | : descriptorListValueType(descriptorListValueType) 25 | { 26 | } 27 | 28 | SgfcPropertyElistValueTypeDescriptor::~SgfcPropertyElistValueTypeDescriptor() 29 | { 30 | } 31 | 32 | SgfcPropertyValueTypeDescriptorType SgfcPropertyElistValueTypeDescriptor::GetDescriptorType() const 33 | { 34 | return SgfcPropertyValueTypeDescriptorType::ElistValueType; 35 | } 36 | 37 | const SgfcPropertyElistValueTypeDescriptor* SgfcPropertyElistValueTypeDescriptor::ToElistValueTypeDescriptor() const 38 | { 39 | return this; 40 | } 41 | 42 | std::shared_ptr SgfcPropertyElistValueTypeDescriptor::GetDescriptorListValueType() const 43 | { 44 | return this->descriptorListValueType; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /include/SgfcGameResultType.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes (generated) 20 | #include "SgfcPlusPlusExport.h" 21 | 22 | namespace LibSgfcPlusPlus 23 | { 24 | /// @brief SgfcGameResultType enumerates the main result types with which 25 | /// a game can end. Depending on the enumerator additional values are needed 26 | /// to determine the exact nature of the game result. 27 | /// 28 | /// @ingroup public-api 29 | /// @ingroup game 30 | /// 31 | /// @see ISgfcGameInfo 32 | enum class SGFCPLUSPLUS_EXPORT SgfcGameResultType 33 | { 34 | /// @brief The black player wins the game. The nature of the win is detailed 35 | /// by an accompanying SgfcWinType value. 36 | BlackWin, 37 | 38 | /// @brief The white player wins. The nature of the win is detailed 39 | /// by an accompanying SgfcWinType value. 40 | WhiteWin, 41 | 42 | /// @brief The game ends with a draw (jigo). 43 | Draw, 44 | 45 | /// @brief The game ends with no result, or with suspended play. 46 | NoResult, 47 | 48 | /// @brief The game ends with an unknown result. 49 | UnknownResult, 50 | }; 51 | } 52 | -------------------------------------------------------------------------------- /src/game/go/SgfcGoStone.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../../include/ISgfcGoStone.h" 21 | 22 | namespace LibSgfcPlusPlus 23 | { 24 | /// @brief The SgfcGoStone class provides an implementation of the 25 | /// ISgfcGoStone interface. See the interface header file for 26 | /// documentation. 27 | /// 28 | /// @ingroup internals 29 | /// @ingroup go 30 | class SgfcGoStone : public ISgfcGoStone 31 | { 32 | public: 33 | /// @brief Initializes a newly constructed SgfcGoStone object. @a color and 34 | /// @a location indicate the color and location of the stone. 35 | /// 36 | /// @exception std::invalid_argument Is thrown if @a location is nullptr. 37 | SgfcGoStone(SgfcColor color, std::shared_ptr location); 38 | 39 | /// @brief Destroys and cleans up the SgfcGoStone object. 40 | virtual ~SgfcGoStone(); 41 | 42 | virtual SgfcColor GetColor() const override; 43 | virtual std::shared_ptr GetLocation() const override; 44 | 45 | private: 46 | SgfcColor color; 47 | std::shared_ptr location; 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /test/AssertHelperFunctions.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | // C++ Standard Library includes 26 | #include 27 | #include 28 | 29 | namespace LibSgfcPlusPlus 30 | { 31 | // Forward declarations 32 | class ISgfcGameInfo; 33 | class ISgfcProperty; 34 | 35 | // Function prototypes 36 | void AssertGameInfoHasDefaultValues(std::shared_ptr gameInfo); 37 | void AssertGoGameInfoHasDefaultValues(std::shared_ptr gameInfo); 38 | void AssertGameInfoHasRootPropertyValues(std::shared_ptr gameInfo, SgfcGameType gameType, SgfcNumber gameTypeAsNumber, SgfcBoardSize boardSize); 39 | void AssertPropertiesContainRootPropertyValues(std::vector>& properties, SgfcNumber gameTypeAsNumber, SgfcBoardSize boardSize); 40 | void AssertPropertiesContainsGameInfoPropertyValue(std::vector>& properties, SgfcPropertyType propertyType, const SgfcSimpleText& propertyValue); 41 | } 42 | -------------------------------------------------------------------------------- /include/SgfcDouble.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes (generated) 20 | #include "SgfcPlusPlusExport.h" 21 | 22 | namespace LibSgfcPlusPlus 23 | { 24 | /// @brief SgfcDouble enumerates the values that a property value of type 25 | /// SgfcPropertyValueType::Double can have. 26 | /// 27 | /// @ingroup public-api 28 | /// 29 | /// @attention Do not rely on the numeric value underlying each enumeration 30 | /// member. Specifically, do not attempt to map the numeric value to the 31 | /// Double representation in the SGF content. 32 | enum class SGFCPLUSPLUS_EXPORT SgfcDouble 33 | { 34 | /// @brief The property value signifies "normal" importance. Example: If the 35 | /// property SgfcPropertyType::GB has this value, then it means 36 | /// "good for black". 37 | /// 38 | /// The raw property string value is "1". 39 | Normal, 40 | /// @brief The property value signifies "emphasized" importance. Example: If 41 | /// the property SgfcPropertyType::GB has this value, then it means 42 | /// "very good for black". 43 | /// 44 | /// The raw property string value is "2". 45 | Emphasized, 46 | }; 47 | } 48 | -------------------------------------------------------------------------------- /include/ISgfcGoMovePropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "ISgfcGoMove.h" 21 | #include "ISgfcMovePropertyValue.h" 22 | 23 | // Project includes (generated) 24 | #include "SgfcPlusPlusExport.h" 25 | 26 | // C++ Standard Library includes 27 | #include 28 | 29 | namespace LibSgfcPlusPlus 30 | { 31 | /// @brief The ISgfcGoMovePropertyValue interface makes the property value 32 | /// data of a property of type SgfcPropertyValueType::Move available as 33 | /// an ISgfcGoMove object. 34 | /// 35 | /// @ingroup public-api 36 | /// @ingroup property-value 37 | /// @ingroup go 38 | class SGFCPLUSPLUS_EXPORT ISgfcGoMovePropertyValue : virtual public ISgfcMovePropertyValue 39 | { 40 | public: 41 | /// @brief Initializes a newly constructed ISgfcGoMovePropertyValue object. 42 | ISgfcGoMovePropertyValue(); 43 | 44 | /// @brief Destroys and cleans up the ISgfcGoMovePropertyValue object. 45 | virtual ~ISgfcGoMovePropertyValue(); 46 | 47 | /// @brief Returns an ISgfcGoMove object that contains the property value 48 | /// data. 49 | virtual std::shared_ptr GetGoMove() const = 0; 50 | }; 51 | } 52 | -------------------------------------------------------------------------------- /src/sgfc/backend/SgfcBackendDataState.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | namespace LibSgfcPlusPlus 20 | { 21 | /// @brief SgfcBackendDataState enumerates the states that the SGFInfo data 22 | /// structure encapsulated by SgfcBackendDataWrapper can have. 23 | /// 24 | /// @ingroup internals 25 | enum class SgfcBackendDataState 26 | { 27 | /// @brief The SGFInfo data structure is allocated and empty. It contains 28 | /// neither a raw file buffer with SGF content, nor any child data 29 | /// structures. 30 | NotLoaded, 31 | 32 | /// @brief The SGFInfo data structure is allocated and contains a raw file 33 | /// buffer with SGF content, but no child data structures. The SGF content 34 | /// in the file buffer was either loaded from an actual file in the file 35 | /// system, generated from the content of an ISgfcDocument, or passed to 36 | /// the library by the library client. 37 | PartiallyLoaded, 38 | 39 | /// @brief The SGFInfo data structure is allocated and contains a raw file 40 | /// buffer with SGF content plus a full set of child data structures 41 | /// generated by parsing the SGF content. 42 | FullyLoaded, 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /include/ISgfcRealPropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "ISgfcSinglePropertyValue.h" 21 | #include "SgfcTypedefs.h" 22 | 23 | // Project includes (generated) 24 | #include "SgfcPlusPlusExport.h" 25 | 26 | namespace LibSgfcPlusPlus 27 | { 28 | /// @brief The ISgfcRealPropertyValue interface provides access to one of 29 | /// the values of a property of an SGF node. The value type is 30 | /// SgfcPropertyValueType::Real. 31 | /// 32 | /// @ingroup public-api 33 | /// @ingroup property-value 34 | /// 35 | /// ISgfcRealPropertyValue is immutable, i.e. once the 36 | /// ISgfcRealPropertyValue object is constructed it cannot be changed. 37 | class SGFCPLUSPLUS_EXPORT ISgfcRealPropertyValue : virtual public ISgfcSinglePropertyValue 38 | { 39 | public: 40 | /// @brief Initializes a newly constructed ISgfcRealPropertyValue object. 41 | ISgfcRealPropertyValue(); 42 | 43 | /// @brief Destroys and cleans up the ISgfcRealPropertyValue object. 44 | virtual ~ISgfcRealPropertyValue(); 45 | 46 | /// @brief Returns the property value interpreted as an SgfcReal value. 47 | virtual SgfcReal GetRealValue() const = 0; 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /include/ISgfcTextPropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "ISgfcSinglePropertyValue.h" 21 | #include "SgfcTypedefs.h" 22 | 23 | // Project includes (generated) 24 | #include "SgfcPlusPlusExport.h" 25 | 26 | namespace LibSgfcPlusPlus 27 | { 28 | /// @brief The ISgfcTextPropertyValue interface provides access to one of 29 | /// the values of a property of an SGF node. The value type is 30 | /// SgfcPropertyValueType::Text. 31 | /// 32 | /// @ingroup public-api 33 | /// @ingroup property-value 34 | /// 35 | /// ISgfcTextPropertyValue is immutable, i.e. once the 36 | /// ISgfcTextPropertyValue object is constructed it cannot be changed. 37 | class SGFCPLUSPLUS_EXPORT ISgfcTextPropertyValue : virtual public ISgfcSinglePropertyValue 38 | { 39 | public: 40 | /// @brief Initializes a newly constructed ISgfcTextPropertyValue object. 41 | ISgfcTextPropertyValue(); 42 | 43 | /// @brief Destroys and cleans up the ISgfcTextPropertyValue object. 44 | virtual ~ISgfcTextPropertyValue(); 45 | 46 | /// @brief Returns the property value interpreted as an SgfcText value. 47 | virtual SgfcText GetTextValue() const = 0; 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /include/ISgfcGoStonePropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "ISgfcGoStone.h" 21 | #include "ISgfcStonePropertyValue.h" 22 | 23 | // Project includes (generated) 24 | #include "SgfcPlusPlusExport.h" 25 | 26 | // C++ Standard Library includes 27 | #include 28 | 29 | namespace LibSgfcPlusPlus 30 | { 31 | /// @brief The ISgfcGoStonePropertyValue interface makes the property value 32 | /// data of a property of type SgfcPropertyValueType::Stone available as 33 | /// an ISgfcGoStone object. 34 | /// 35 | /// @ingroup public-api 36 | /// @ingroup property-value 37 | /// @ingroup go 38 | class SGFCPLUSPLUS_EXPORT ISgfcGoStonePropertyValue : virtual public ISgfcStonePropertyValue 39 | { 40 | public: 41 | /// @brief Initializes a newly constructed ISgfcGoStonePropertyValue object. 42 | ISgfcGoStonePropertyValue(); 43 | 44 | /// @brief Destroys and cleans up the ISgfcGoStonePropertyValue object. 45 | virtual ~ISgfcGoStonePropertyValue(); 46 | 47 | /// @brief Returns an ISgfcGoStone object that contains the property value 48 | /// data. 49 | virtual std::shared_ptr GetGoStone() const = 0; 50 | }; 51 | } 52 | -------------------------------------------------------------------------------- /include/ISgfcColorPropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "ISgfcSinglePropertyValue.h" 21 | #include "SgfcColor.h" 22 | 23 | // Project includes (generated) 24 | #include "SgfcPlusPlusExport.h" 25 | 26 | namespace LibSgfcPlusPlus 27 | { 28 | /// @brief The ISgfcColorPropertyValue interface provides access to one of 29 | /// the values of a property of an SGF node. The value type is 30 | /// SgfcPropertyValueType::Color. 31 | /// 32 | /// @ingroup public-api 33 | /// @ingroup property-value 34 | /// 35 | /// ISgfcColorPropertyValue is immutable, i.e. once the 36 | /// ISgfcColorPropertyValue object is constructed it cannot be changed. 37 | class SGFCPLUSPLUS_EXPORT ISgfcColorPropertyValue : virtual public ISgfcSinglePropertyValue 38 | { 39 | public: 40 | /// @brief Initializes a newly constructed ISgfcColorPropertyValue object. 41 | ISgfcColorPropertyValue(); 42 | 43 | /// @brief Destroys and cleans up the ISgfcColorPropertyValue object. 44 | virtual ~ISgfcColorPropertyValue(); 45 | 46 | /// @brief Returns the property value interpreted as an SgfcColor value. 47 | virtual SgfcColor GetColorValue() const = 0; 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /src/interface/internal/ISgfcPropertyValueTypeDescriptor.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "ISgfcPropertyValueTypeDescriptor.h" 19 | 20 | namespace LibSgfcPlusPlus 21 | { 22 | ISgfcPropertyValueTypeDescriptor::ISgfcPropertyValueTypeDescriptor() 23 | { 24 | } 25 | 26 | ISgfcPropertyValueTypeDescriptor::~ISgfcPropertyValueTypeDescriptor() 27 | { 28 | } 29 | 30 | const SgfcPropertyDualValueTypeDescriptor* ISgfcPropertyValueTypeDescriptor::ToDualValueTypeDescriptor() const 31 | { 32 | return nullptr; 33 | } 34 | 35 | const SgfcPropertyElistValueTypeDescriptor* ISgfcPropertyValueTypeDescriptor::ToElistValueTypeDescriptor() const 36 | { 37 | return nullptr; 38 | } 39 | 40 | const SgfcPropertyListValueTypeDescriptor* ISgfcPropertyValueTypeDescriptor::ToListValueTypeDescriptor() const 41 | { 42 | return nullptr; 43 | } 44 | 45 | const SgfcPropertyComposedValueTypeDescriptor* ISgfcPropertyValueTypeDescriptor::ToComposedValueTypeDescriptor() const 46 | { 47 | return nullptr; 48 | } 49 | 50 | const SgfcPropertyBasicValueTypeDescriptor* ISgfcPropertyValueTypeDescriptor::ToBasicValueTypeDescriptor() const 51 | { 52 | return nullptr; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/go/SgfcGoPointPropertyValue.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcGoPointPropertyValue.h" 19 | #include "../../../game/go/SgfcGoPoint.h" 20 | 21 | // C++ Standard Library includes 22 | #include 23 | 24 | namespace LibSgfcPlusPlus 25 | { 26 | SgfcGoPointPropertyValue::SgfcGoPointPropertyValue(std::shared_ptr goPoint) 27 | : SgfcPointPropertyValue(GetRawValueOrThrow(goPoint), GetRawValueOrThrow(goPoint)) 28 | , goPoint(goPoint) 29 | { 30 | } 31 | 32 | SgfcGoPointPropertyValue::~SgfcGoPointPropertyValue() 33 | { 34 | } 35 | 36 | const ISgfcGoPointPropertyValue* SgfcGoPointPropertyValue::ToGoPointValue() const 37 | { 38 | return this; 39 | } 40 | 41 | std::shared_ptr SgfcGoPointPropertyValue::GetGoPoint() const 42 | { 43 | return this->goPoint; 44 | } 45 | 46 | std::string SgfcGoPointPropertyValue::GetRawValueOrThrow(std::shared_ptr goPoint) 47 | { 48 | if (goPoint == nullptr) 49 | throw std::invalid_argument("SgfcGoPointPropertyValue constructor failed: go point object is nullptr"); 50 | 51 | return goPoint->GetPosition(SgfcGoPointNotation::Sgf); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /include/SgfcWinType.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes (generated) 20 | #include "SgfcPlusPlusExport.h" 21 | 22 | namespace LibSgfcPlusPlus 23 | { 24 | /// @brief SgfcWinType enumerates how a player can win a game. An SgfcWinType 25 | /// value is used to accompany a game result type value of either 26 | /// SgfcGameResultType::BlackWin or SgfcGameResultType::WhiteWin. 27 | /// 28 | /// @ingroup public-api 29 | /// @ingroup game 30 | /// 31 | /// @see ISgfcGameInfo 32 | enum class SGFCPLUSPLUS_EXPORT SgfcWinType 33 | { 34 | /// @brief The player wins the game by normal play which results in a 35 | /// score. The actual score is detailed by an accompanying SgfcReal value. 36 | WinWithScore, 37 | 38 | /// @brief The player wins the game by normal play which results in no 39 | /// score, or an unknown score. Some game types, such as chess, don't have 40 | /// a score. 41 | WinWithoutScore, 42 | 43 | /// @brief The player wins the game by resignation. 44 | WinByResignation, 45 | 46 | /// @brief The player wins the game on time. 47 | WinOnTime, 48 | 49 | /// @brief The player wins the game by forfeit. 50 | WinByForfeit, 51 | }; 52 | } 53 | -------------------------------------------------------------------------------- /include/ISgfcDoublePropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "ISgfcSinglePropertyValue.h" 21 | #include "SgfcDouble.h" 22 | 23 | // Project includes (generated) 24 | #include "SgfcPlusPlusExport.h" 25 | 26 | namespace LibSgfcPlusPlus 27 | { 28 | /// @brief The ISgfcDoublePropertyValue interface provides access to one of 29 | /// the values of a property of an SGF node. The value type is 30 | /// SgfcPropertyValueType::Double. 31 | /// 32 | /// @ingroup public-api 33 | /// @ingroup property-value 34 | /// 35 | /// ISgfcDoublePropertyValue is immutable, i.e. once the 36 | /// ISgfcDoublePropertyValue object is constructed it cannot be changed. 37 | class SGFCPLUSPLUS_EXPORT ISgfcDoublePropertyValue : virtual public ISgfcSinglePropertyValue 38 | { 39 | public: 40 | /// @brief Initializes a newly constructed ISgfcDoublePropertyValue object. 41 | ISgfcDoublePropertyValue(); 42 | 43 | /// @brief Destroys and cleans up the ISgfcDoublePropertyValue object. 44 | virtual ~ISgfcDoublePropertyValue(); 45 | 46 | /// @brief Returns the property value interpreted as an SgfcDouble value. 47 | virtual SgfcDouble GetDoubleValue() const = 0; 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /include/ISgfcNumberPropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "ISgfcSinglePropertyValue.h" 21 | #include "SgfcTypedefs.h" 22 | 23 | // Project includes (generated) 24 | #include "SgfcPlusPlusExport.h" 25 | 26 | namespace LibSgfcPlusPlus 27 | { 28 | /// @brief The ISgfcNumberPropertyValue interface provides access to one of 29 | /// the values of a property of an SGF node. The value type is 30 | /// SgfcPropertyValueType::Number. 31 | /// 32 | /// @ingroup public-api 33 | /// @ingroup property-value 34 | /// 35 | /// ISgfcNumberPropertyValue is immutable, i.e. once the 36 | /// ISgfcNumberPropertyValue object is constructed it cannot be changed. 37 | class SGFCPLUSPLUS_EXPORT ISgfcNumberPropertyValue : virtual public ISgfcSinglePropertyValue 38 | { 39 | public: 40 | /// @brief Initializes a newly constructed ISgfcNumberPropertyValue object. 41 | ISgfcNumberPropertyValue(); 42 | 43 | /// @brief Destroys and cleans up the ISgfcNumberPropertyValue object. 44 | virtual ~ISgfcNumberPropertyValue(); 45 | 46 | /// @brief Returns the property value interpreted as an SgfcNumber value. 47 | virtual SgfcNumber GetNumberValue() const = 0; 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /include/SgfcGoPlayerRankType.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes (generated) 20 | #include "SgfcPlusPlusExport.h" 21 | 22 | namespace LibSgfcPlusPlus 23 | { 24 | /// @brief SgfcGoPlayerRankType enumerates the rank types in the traditional 25 | /// Go ranking system. 26 | /// 27 | /// @ingroup public-api 28 | /// @ingroup game 29 | /// @ingroup go 30 | /// 31 | /// @see ISgfcGameInfo 32 | enum class SGFCPLUSPLUS_EXPORT SgfcGoPlayerRankType 33 | { 34 | /// @brief The rank type is Kyu. A Kyu rank is a student rank. The generally 35 | /// accepted Kyu ranks range from 30 (lowest) to 1 (highest). The notation 36 | /// is "30k", "29k", etc.. 37 | Kyu, 38 | 39 | /// @brief The rank type is amateur Dan. An amateur Dan rank is a master 40 | /// rank. The generally accepted amateur Dan ranks range from 1 (lowest) to 41 | /// 7 (highest). The notation is "1d", "2d", etc.. 42 | AmateurDan, 43 | 44 | /// @brief The rank type is professional Dan. A professional Dan rank is a 45 | /// master rank. The generally accepted professional Dan ranks range from 46 | /// 1 (lowest) to 9 (highest). The notation is "1p", "2p", etc.. 47 | ProfessionalDan, 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /include/ISgfcGoStone.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "SgfcColor.h" 21 | 22 | // Project includes (generated) 23 | #include "SgfcPlusPlusExport.h" 24 | 25 | // C++ Standard Library includes 26 | #include 27 | 28 | namespace LibSgfcPlusPlus 29 | { 30 | class ISgfcGoPoint; 31 | 32 | /// @brief The ISgfcGoStone interface represents a Go stone. 33 | /// 34 | /// @ingroup public-api 35 | /// @ingroup go 36 | /// 37 | /// A Go stone on a Go board is defined by its color and by its location on 38 | /// the Go board. ISgfcGoStone stores an SgfcColor value and a reference to an 39 | /// ISgfcGoPoint object to record these two pieces of information. 40 | class SGFCPLUSPLUS_EXPORT ISgfcGoStone 41 | { 42 | public: 43 | /// @brief Initializes a newly constructed ISgfcGoStone object. 44 | ISgfcGoStone(); 45 | 46 | /// @brief Destroys and cleans up the ISgfcGoStone object. 47 | virtual ~ISgfcGoStone(); 48 | 49 | /// @brief Returns the color of the stone. 50 | virtual SgfcColor GetColor() const = 0; 51 | 52 | /// @brief Returns the location of the stone on the Go board. 53 | virtual std::shared_ptr GetLocation() const = 0; 54 | }; 55 | } 56 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcRealPropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../../include/ISgfcRealPropertyValue.h" 21 | #include "../SgfcSinglePropertyValue.h" 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | /// @brief The SgfcRealPropertyValue class provides an implementation of 26 | /// the ISgfcRealPropertyValue interface. See the interface header file 27 | /// for documentation. 28 | /// 29 | /// @ingroup internals 30 | /// @ingroup property-value 31 | class SgfcRealPropertyValue : public SgfcSinglePropertyValue, public ISgfcRealPropertyValue 32 | { 33 | public: 34 | /// @brief Initializes a newly constructed SgfcRealPropertyValue object. 35 | /// The object holds the Real value @a realValue and 36 | /// the corresponding raw string value @a rawValue. 37 | SgfcRealPropertyValue(const std::string& rawValue, SgfcReal realValue); 38 | 39 | /// @brief Destroys and cleans up the SgfcRealPropertyValue object. 40 | virtual ~SgfcRealPropertyValue(); 41 | 42 | virtual SgfcReal GetRealValue() const override; 43 | virtual const ISgfcRealPropertyValue* ToRealValue() const override; 44 | 45 | private: 46 | SgfcReal realValue; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcTextPropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../../include/ISgfcTextPropertyValue.h" 21 | #include "../SgfcSinglePropertyValue.h" 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | /// @brief The SgfcTextPropertyValue class provides an implementation of 26 | /// the ISgfcTextPropertyValue interface. See the interface header file 27 | /// for documentation. 28 | /// 29 | /// @ingroup internals 30 | /// @ingroup property-value 31 | class SgfcTextPropertyValue : public SgfcSinglePropertyValue, public ISgfcTextPropertyValue 32 | { 33 | public: 34 | /// @brief Initializes a newly constructed SgfcTextPropertyValue 35 | /// object. The object holds the SgfcText value @a textValue and 36 | /// the corresponding raw string value @a rawValue. 37 | SgfcTextPropertyValue(const std::string& rawValue, const SgfcText& textValue); 38 | 39 | /// @brief Destroys and cleans up the SgfcTextPropertyValue object. 40 | virtual ~SgfcTextPropertyValue(); 41 | 42 | virtual SgfcText GetTextValue() const override; 43 | virtual const ISgfcTextPropertyValue* ToTextValue() const override; 44 | 45 | private: 46 | SgfcText textValue; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /include/ISgfcGoPointPropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "ISgfcGoPoint.h" 21 | #include "ISgfcPointPropertyValue.h" 22 | 23 | // Project includes (generated) 24 | #include "SgfcPlusPlusExport.h" 25 | 26 | // C++ Standard Library includes 27 | #include 28 | 29 | namespace LibSgfcPlusPlus 30 | { 31 | /// @brief The ISgfcGoPointPropertyValue interface makes the property value 32 | /// data of a property of type SgfcPropertyValueType::Point available as 33 | /// an ISgfcGoPoint object. 34 | /// 35 | /// @ingroup public-api 36 | /// @ingroup property-value 37 | /// @ingroup go 38 | class SGFCPLUSPLUS_EXPORT ISgfcGoPointPropertyValue : virtual public ISgfcPointPropertyValue 39 | { 40 | public: 41 | /// @brief Initializes a newly constructed ISgfcGoPointPropertyValue object. 42 | ISgfcGoPointPropertyValue(); 43 | 44 | /// @brief Destroys and cleans up the ISgfcGoPointPropertyValue object. 45 | virtual ~ISgfcGoPointPropertyValue(); 46 | 47 | /// @brief Returns an ISgfcGoPoint object that contains the property value 48 | /// data and makes it available in various forms and notations. 49 | virtual std::shared_ptr GetGoPoint() const = 0; 50 | }; 51 | } 52 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcColorPropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../../include/ISgfcColorPropertyValue.h" 21 | #include "../SgfcSinglePropertyValue.h" 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | /// @brief The SgfcColorPropertyValue class provides an implementation of 26 | /// the ISgfcColorPropertyValue interface. See the interface header file 27 | /// for documentation. 28 | /// 29 | /// @ingroup internals 30 | /// @ingroup property-value 31 | class SgfcColorPropertyValue : public SgfcSinglePropertyValue, public ISgfcColorPropertyValue 32 | { 33 | public: 34 | /// @brief Initializes a newly constructed SgfcColorPropertyValue object. 35 | /// The object holds the Color value @a colorValue and 36 | /// the corresponding raw string value @a rawValue. 37 | SgfcColorPropertyValue(const std::string& rawValue, SgfcColor colorValue); 38 | 39 | /// @brief Destroys and cleans up the SgfcColorPropertyValue object. 40 | virtual ~SgfcColorPropertyValue(); 41 | 42 | virtual SgfcColor GetColorValue() const override; 43 | virtual const ISgfcColorPropertyValue* ToColorValue() const override; 44 | 45 | private: 46 | SgfcColor colorValue; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcDoublePropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../../include/ISgfcDoublePropertyValue.h" 21 | #include "../SgfcSinglePropertyValue.h" 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | /// @brief The SgfcDoublePropertyValue class provides an implementation of 26 | /// the ISgfcDoublePropertyValue interface. See the interface header file 27 | /// for documentation. 28 | /// 29 | /// @ingroup internals 30 | /// @ingroup property-value 31 | class SgfcDoublePropertyValue : public SgfcSinglePropertyValue, public ISgfcDoublePropertyValue 32 | { 33 | public: 34 | /// @brief Initializes a newly constructed SgfcDoublePropertyValue object. 35 | /// The object holds the Double value @a doubleValue and 36 | /// the corresponding raw string value @a rawValue. 37 | SgfcDoublePropertyValue(const std::string& rawValue, SgfcDouble doubleValue); 38 | 39 | /// @brief Destroys and cleans up the SgfcDoublePropertyValue object. 40 | virtual ~SgfcDoublePropertyValue(); 41 | 42 | virtual SgfcDouble GetDoubleValue() const override; 43 | virtual const ISgfcDoublePropertyValue* ToDoubleValue() const override; 44 | 45 | private: 46 | SgfcDouble doubleValue; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcNumberPropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../../include/ISgfcNumberPropertyValue.h" 21 | #include "../SgfcSinglePropertyValue.h" 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | /// @brief The SgfcNumberPropertyValue class provides an implementation of 26 | /// the ISgfcNumberPropertyValue interface. See the interface header file 27 | /// for documentation. 28 | /// 29 | /// @ingroup internals 30 | /// @ingroup property-value 31 | class SgfcNumberPropertyValue : public SgfcSinglePropertyValue, public ISgfcNumberPropertyValue 32 | { 33 | public: 34 | /// @brief Initializes a newly constructed SgfcNumberPropertyValue object. 35 | /// The object holds the Number value @a numberValue and 36 | /// the corresponding raw string value @a rawValue. 37 | SgfcNumberPropertyValue(const std::string& rawValue, SgfcNumber numberValue); 38 | 39 | /// @brief Destroys and cleans up the SgfcNumberPropertyValue object. 40 | virtual ~SgfcNumberPropertyValue(); 41 | 42 | virtual SgfcNumber GetNumberValue() const override; 43 | virtual const ISgfcNumberPropertyValue* ToNumberValue() const override; 44 | 45 | private: 46 | SgfcNumber numberValue; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/go/SgfcGoStonePropertyValue.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcGoStonePropertyValue.h" 19 | #include "../../../game/go/SgfcGoPoint.h" 20 | #include "../../../game/go/SgfcGoStone.h" 21 | 22 | // C++ Standard Library includes 23 | #include 24 | 25 | namespace LibSgfcPlusPlus 26 | { 27 | SgfcGoStonePropertyValue::SgfcGoStonePropertyValue(std::shared_ptr goStone) 28 | : SgfcStonePropertyValue(GetRawValueOrThrow(goStone), GetRawValueOrThrow(goStone)) 29 | , goStone(goStone) 30 | { 31 | } 32 | 33 | SgfcGoStonePropertyValue::~SgfcGoStonePropertyValue() 34 | { 35 | } 36 | 37 | const ISgfcGoStonePropertyValue* SgfcGoStonePropertyValue::ToGoStoneValue() const 38 | { 39 | return this; 40 | } 41 | 42 | std::shared_ptr SgfcGoStonePropertyValue::GetGoStone() const 43 | { 44 | return this->goStone; 45 | } 46 | 47 | std::string SgfcGoStonePropertyValue::GetRawValueOrThrow(std::shared_ptr goStone) 48 | { 49 | if (goStone == nullptr) 50 | throw std::invalid_argument("SgfcGoStonePropertyValue constructor failed: go stone object is nullptr"); 51 | 52 | return goStone->GetLocation()->GetPosition(SgfcGoPointNotation::Sgf); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/sgfc/backend/SgfcBackendSaveResult.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../../include/ISgfcMessage.h" 21 | 22 | // C++ Standard Library includes 23 | #include 24 | #include 25 | 26 | namespace LibSgfcPlusPlus 27 | { 28 | /// @brief The SgfcBackendSaveResult class provides access to the result of 29 | /// a save operation performed by SgfcBackendController. 30 | /// 31 | /// @ingroup internals 32 | /// @ingroup sgfc-backend 33 | class SgfcBackendSaveResult 34 | { 35 | public: 36 | /// @brief Initializes a newly constructed SgfcBackendSaveResult object 37 | /// with the specified results. 38 | SgfcBackendSaveResult( 39 | std::vector> saveResult); 40 | 41 | /// @brief Destroys and cleans up the SgfcBackendSaveResult object. 42 | virtual ~SgfcBackendSaveResult(); 43 | 44 | /// @brief Returns a collection of ISgfcMessage objects which together form 45 | /// the result of the save operation. The messages appear in the order in 46 | /// which they were generated by SGFC. 47 | std::vector> GetSaveResult() const; 48 | 49 | private: 50 | std::vector> saveResult; 51 | }; 52 | } 53 | -------------------------------------------------------------------------------- /include/ISgfcSimpleTextPropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "ISgfcSinglePropertyValue.h" 21 | #include "SgfcTypedefs.h" 22 | 23 | // Project includes (generated) 24 | #include "SgfcPlusPlusExport.h" 25 | 26 | namespace LibSgfcPlusPlus 27 | { 28 | /// @brief The ISgfcSimpleTextPropertyValue interface provides access to one 29 | /// of the values of a property of an SGF node. The value type is 30 | /// SgfcPropertyValueType::SimpleText. 31 | /// 32 | /// @ingroup public-api 33 | /// @ingroup property-value 34 | /// 35 | /// ISgfcSimpleTextPropertyValue is immutable, i.e. once the 36 | /// ISgfcSimpleTextPropertyValue object is constructed it cannot be changed. 37 | class SGFCPLUSPLUS_EXPORT ISgfcSimpleTextPropertyValue : virtual public ISgfcSinglePropertyValue 38 | { 39 | public: 40 | /// @brief Initializes a newly constructed ISgfcSimpleTextPropertyValue 41 | /// object. 42 | ISgfcSimpleTextPropertyValue(); 43 | 44 | /// @brief Destroys and cleans up the ISgfcSimpleTextPropertyValue object. 45 | virtual ~ISgfcSimpleTextPropertyValue(); 46 | 47 | /// @brief Returns the property value interpreted as an SgfcSimpleText 48 | /// value. 49 | virtual SgfcSimpleText GetSimpleTextValue() const = 0; 50 | }; 51 | } 52 | -------------------------------------------------------------------------------- /src/game/go/SgfcGoMove.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "../../../include/ISgfcGoStone.h" 19 | #include "SgfcGoMove.h" 20 | 21 | // C++ Standard Library includes 22 | #include 23 | 24 | namespace LibSgfcPlusPlus 25 | { 26 | SgfcGoMove::SgfcGoMove(std::shared_ptr stone) 27 | : playerColor(SgfcColor::Black) 28 | , stone(stone) 29 | { 30 | if (this->stone == nullptr) 31 | throw std::invalid_argument("SgfcGoMove constructor failed: stone object is nullptr"); 32 | 33 | this->playerColor = this->stone->GetColor(); 34 | } 35 | 36 | SgfcGoMove::SgfcGoMove(SgfcColor playerColor) 37 | : playerColor(playerColor) 38 | , stone(nullptr) 39 | { 40 | } 41 | 42 | SgfcGoMove::~SgfcGoMove() 43 | { 44 | } 45 | 46 | bool SgfcGoMove::IsPassMove() const 47 | { 48 | return (this->stone == nullptr); 49 | } 50 | 51 | std::shared_ptr SgfcGoMove::GetStone() const 52 | { 53 | return this->stone; 54 | } 55 | 56 | SgfcColor SgfcGoMove::GetPlayerColor() const 57 | { 58 | return this->playerColor; 59 | } 60 | 61 | std::shared_ptr SgfcGoMove::GetStoneLocation() const 62 | { 63 | if (IsPassMove()) 64 | return nullptr; 65 | else 66 | return this->stone->GetLocation(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /include/SgfcExitCode.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes (generated) 20 | #include "SgfcPlusPlusExport.h" 21 | 22 | namespace LibSgfcPlusPlus 23 | { 24 | /// @brief SgfcExitCode enumerates all SGFC exit codes supported by the 25 | /// library. 26 | /// 27 | /// @ingroup public-api 28 | enum class SGFCPLUSPLUS_EXPORT SgfcExitCode 29 | { 30 | /// @brief The SGFC operation did not generate any warning or error 31 | /// messages. If the SgfcArgumentType::DisableMessageID argument was 32 | /// passed to SGFC some messages may have been ignored. 33 | Ok = 0, 34 | 35 | /// @brief The SGFC operation generated one or more warning messages, but 36 | /// no fatal error messages and no non-fatal error messages. 37 | Warning = 5, 38 | 39 | /// @brief The SGFC operation generated one or more error messages, but 40 | /// no fatal error messages. It may have generated 0-n warning messages. 41 | Error = 10, 42 | 43 | /// @brief The SGFC operation generated a fatal error message. It may have 44 | /// generated 0-n warning or error messages. Note that because the SGFC 45 | /// operation aborts immediately when a fatal error occurs, there is 46 | /// guaranteed to be exactly one fatal error message (i.e. not more than 1). 47 | FatalError = 20, 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcMovePropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../../include/ISgfcMovePropertyValue.h" 21 | #include "../SgfcSinglePropertyValue.h" 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | /// @brief The SgfcMovePropertyValue class provides an implementation of 26 | /// the ISgfcMovePropertyValue interface. See the interface header file 27 | /// for documentation. 28 | /// 29 | /// @ingroup internals 30 | /// @ingroup property-value 31 | class SgfcMovePropertyValue : public SgfcSinglePropertyValue, virtual public ISgfcMovePropertyValue 32 | { 33 | public: 34 | /// @brief Initializes a newly constructed SgfcMovePropertyValue 35 | /// object. The object holds the Move value @a moveValue and 36 | /// the corresponding raw string value @a rawValue. 37 | SgfcMovePropertyValue(const std::string& rawValue, const SgfcMove& moveValue); 38 | 39 | /// @brief Destroys and cleans up the SgfcMovePropertyValue object. 40 | virtual ~SgfcMovePropertyValue(); 41 | 42 | virtual SgfcMove GetMoveValue() const override; 43 | virtual const ISgfcMovePropertyValue* ToMoveValue() const override; 44 | virtual const ISgfcGoMovePropertyValue* ToGoMoveValue() const override; 45 | 46 | private: 47 | SgfcMove moveValue; 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcPointPropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../../include/ISgfcPointPropertyValue.h" 21 | #include "../SgfcSinglePropertyValue.h" 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | /// @brief The SgfcPointPropertyValue class provides an implementation of 26 | /// the ISgfcPointPropertyValue interface. See the interface header file 27 | /// for documentation. 28 | /// 29 | /// @ingroup internals 30 | /// @ingroup property-value 31 | class SgfcPointPropertyValue : public SgfcSinglePropertyValue, virtual public ISgfcPointPropertyValue 32 | { 33 | public: 34 | /// @brief Initializes a newly constructed SgfcPointPropertyValue 35 | /// object. The object holds the Point value @a pointValue and 36 | /// the corresponding raw string value @a rawValue. 37 | SgfcPointPropertyValue(const std::string& rawValue, const SgfcPoint& pointValue); 38 | 39 | /// @brief Destroys and cleans up the SgfcPointPropertyValue object. 40 | virtual ~SgfcPointPropertyValue(); 41 | 42 | virtual SgfcPoint GetPointValue() const override; 43 | virtual const ISgfcPointPropertyValue* ToPointValue() const override; 44 | virtual const ISgfcGoPointPropertyValue* ToGoPointValue() const override; 45 | 46 | private: 47 | SgfcPoint pointValue; 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcStonePropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../../include/ISgfcStonePropertyValue.h" 21 | #include "../SgfcSinglePropertyValue.h" 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | /// @brief The SgfcStonePropertyValue class provides an implementation of 26 | /// the ISgfcStonePropertyValue interface. See the interface header file 27 | /// for documentation. 28 | /// 29 | /// @ingroup internals 30 | /// @ingroup property-value 31 | class SgfcStonePropertyValue : public SgfcSinglePropertyValue, virtual public ISgfcStonePropertyValue 32 | { 33 | public: 34 | /// @brief Initializes a newly constructed SgfcStonePropertyValue 35 | /// object. The object holds the Stone value @a stoneValue and 36 | /// the corresponding raw string value @a rawValue. 37 | SgfcStonePropertyValue(const std::string& rawValue, const SgfcStone& stoneValue); 38 | 39 | /// @brief Destroys and cleans up the SgfcStonePropertyValue object. 40 | virtual ~SgfcStonePropertyValue(); 41 | 42 | virtual SgfcStone GetStoneValue() const override; 43 | virtual const ISgfcStonePropertyValue* ToStoneValue() const override; 44 | virtual const ISgfcGoStonePropertyValue* ToGoStoneValue() const override; 45 | 46 | private: 47 | SgfcStone stoneValue; 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/SgfcSimpleTextPropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../../include/ISgfcSimpleTextPropertyValue.h" 21 | #include "../SgfcSinglePropertyValue.h" 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | /// @brief The SgfcSimpleTextPropertyValue class provides an implementation of 26 | /// the ISgfcSimpleTextPropertyValue interface. See the interface header file 27 | /// for documentation. 28 | /// 29 | /// @ingroup internals 30 | /// @ingroup property-value 31 | class SgfcSimpleTextPropertyValue : public SgfcSinglePropertyValue, public ISgfcSimpleTextPropertyValue 32 | { 33 | public: 34 | /// @brief Initializes a newly constructed SgfcSimpleTextPropertyValue 35 | /// object. The object holds the SgfcSimpleText value @a simpleTextValue and 36 | /// the corresponding raw string value @a rawValue. 37 | SgfcSimpleTextPropertyValue(const std::string& rawValue, const SgfcSimpleText& simpleTextValue); 38 | 39 | /// @brief Destroys and cleans up the SgfcSimpleTextPropertyValue object. 40 | virtual ~SgfcSimpleTextPropertyValue(); 41 | 42 | virtual SgfcSimpleText GetSimpleTextValue() const override; 43 | virtual const ISgfcSimpleTextPropertyValue* ToSimpleTextValue() const override; 44 | 45 | private: 46 | SgfcSimpleText simpleTextValue; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /src/document/SgfcComposedPropertyValue.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "SgfcComposedPropertyValue.h" 19 | 20 | // C++ Standard Library includes 21 | #include 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | SgfcComposedPropertyValue::SgfcComposedPropertyValue( 26 | std::shared_ptr value1, 27 | std::shared_ptr value2) 28 | : value1(value1) 29 | , value2(value2) 30 | { 31 | if (value1 == nullptr) 32 | throw std::invalid_argument("SgfcComposedPropertyValue constructor failed: Property value1 is nullptr"); 33 | if (value2 == nullptr) 34 | throw std::invalid_argument("SgfcComposedPropertyValue constructor failed: Property value2 is nullptr"); 35 | } 36 | 37 | SgfcComposedPropertyValue::~SgfcComposedPropertyValue() 38 | { 39 | } 40 | 41 | bool SgfcComposedPropertyValue::IsComposedValue() const 42 | { 43 | return true; 44 | } 45 | 46 | const ISgfcComposedPropertyValue* SgfcComposedPropertyValue::ToComposedValue() const 47 | { 48 | return this; 49 | } 50 | 51 | std::shared_ptr SgfcComposedPropertyValue::GetValue1() const 52 | { 53 | return this->value1; 54 | } 55 | 56 | std::shared_ptr SgfcComposedPropertyValue::GetValue2() const 57 | { 58 | return this->value2; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /include/SgfcGameType.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes (generated) 20 | #include "SgfcPlusPlusExport.h" 21 | 22 | namespace LibSgfcPlusPlus 23 | { 24 | /// @brief SgfcGameType enumerates all game types defined by the SGF standard. 25 | /// The enum value SgfcGameType::Unknown is used for all non-standard game 26 | /// game types. 27 | /// 28 | /// @ingroup public-api 29 | /// 30 | /// @attention Do not rely on the numeric value underlying each enumeration 31 | /// member. Specifically, do not attempt to map the numeric value to the game 32 | /// type's representation in the SGF content. 33 | enum class SGFCPLUSPLUS_EXPORT SgfcGameType 34 | { 35 | Go, 36 | Othello, 37 | Chess, 38 | GomokuAndRenju, 39 | NineMensMorris, 40 | Backgammon, 41 | ChineseChess, 42 | Shogi, 43 | LinesOfAction, 44 | Ataxx, 45 | Hex, 46 | Jungle, 47 | Neutron, 48 | PhilosophersFootball, 49 | Quadrature, 50 | Trax, 51 | Tantrix, 52 | Amazons, 53 | Octi, 54 | Gess, 55 | Twixt, 56 | Zertz, 57 | Plateau, 58 | Yinsh, 59 | Punct, 60 | Gobblet, 61 | Hive, 62 | Exxit, 63 | Hnefatal, 64 | Kuba, 65 | Tripples, 66 | Chase, 67 | TumblingDown, 68 | Sahara, 69 | Byte, 70 | Focus, 71 | Dvonn, 72 | Tamsk, 73 | Gipf, 74 | Kropki, 75 | Unknown, 76 | }; 77 | } 78 | -------------------------------------------------------------------------------- /script/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_NAME="$(basename "$0")" 4 | SCRIPT_FOLDER="$(dirname "$0")" 5 | case "$SCRIPT_FOLDER" in 6 | /*) BASE_FOLDER="$SCRIPT_FOLDER/.." ;; 7 | *) BASE_FOLDER="$(pwd)/$SCRIPT_FOLDER/.." ;; 8 | esac 9 | SGFC_FOLDER="$BASE_FOLDER/sgfc" 10 | BUILD_FOLDER="$BASE_FOLDER/build" 11 | 12 | echo "" 13 | echo "------------------------------------------------------------" 14 | echo "Running CMake to create build system" 15 | echo "------------------------------------------------------------" 16 | if test ! -d "$BUILD_FOLDER"; then 17 | echo "Creating build folder ..." 18 | mkdir "$BUILD_FOLDER" 19 | if test $? -ne 0; then 20 | echo "Failed to create build folder $BUILD_FOLDER" 21 | exit 1 22 | fi 23 | echo "Build folder created successfully." 24 | fi 25 | cd "$BUILD_FOLDER" 26 | 27 | echo "Creating build system ..." 28 | cmake -DCMAKE_BUILD_TYPE=Release .. 29 | if test $? -ne 0; then 30 | echo "Failed to create build system" 31 | exit 1 32 | fi 33 | echo "Build system created successfully." 34 | cd "$BASE_FOLDER" 35 | 36 | echo "" 37 | echo "------------------------------------------------------------" 38 | echo "Running CMake to build the project" 39 | echo "------------------------------------------------------------" 40 | cd "$BUILD_FOLDER" 41 | cmake --build . 42 | if test $? -ne 0; then 43 | echo "Failed to build the project" 44 | exit 1 45 | fi 46 | echo "Project build successful." 47 | cd "$BASE_FOLDER" 48 | 49 | echo "" 50 | echo "------------------------------------------------------------" 51 | echo "Executing unit tests" 52 | echo "------------------------------------------------------------" 53 | cd "$BUILD_FOLDER" 54 | ./test/libsgfcplusplus-test 55 | if test $? -ne 0; then 56 | echo "Some unit tests failed" 57 | exit 1 58 | fi 59 | echo "Unit tests ran successfully." 60 | cd "$BASE_FOLDER" 61 | 62 | echo "" 63 | echo ------------------------------------------------------------ 64 | echo "You are now ready to install the build results with something like" 65 | echo " cmake --install . --prefix install" 66 | echo "You may also want to have a look at the sample code in the \"example\" folder." 67 | echo ------------------------------------------------------------ 68 | -------------------------------------------------------------------------------- /src/sgfc/save/SgfcSgfContent.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // C++ Standard Library includes 20 | #include 21 | 22 | namespace LibSgfcPlusPlus 23 | { 24 | /// @brief The SgfcSgfContent class represents a distinct piece of SGF 25 | /// content that is generated by SGFC when it performs a save operation. 26 | /// SgfcSgfContent objects are immutable. 27 | /// 28 | /// @ingroup internals 29 | /// @ingroup sgfc-backend 30 | class SgfcSgfContent 31 | { 32 | public: 33 | /// @brief Initializes a newly constructed SgfcSgfContent object. The object 34 | /// has no SGF content. 35 | SgfcSgfContent(); 36 | 37 | /// @brief Initializes a newly constructed SgfcSgfContent object. The object 38 | /// has the SGF content @a sgfContent, SGFC would have used @a filePath to 39 | /// save the SGF content to the filesystem. 40 | SgfcSgfContent( 41 | const std::string& sgfContent, 42 | const std::string& filePath); 43 | 44 | /// @brief Destroys and cleans up the SgfcSgfContent object. 45 | virtual ~SgfcSgfContent(); 46 | 47 | /// @brief Returns the SGF content. 48 | std::string GetSgfContent() const; 49 | 50 | /// @brief Returns the file path that SGFC would have used to save the SGF 51 | /// content to the filesystem. 52 | std::string GetFilePath() const; 53 | 54 | private: 55 | std::string sgfContent; 56 | std::string filePath; 57 | }; 58 | } 59 | -------------------------------------------------------------------------------- /test/game/go/SgfcGoStoneTest.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2024 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Library includes 18 | #include 19 | #include 20 | #include 21 | 22 | // Unit test library includes 23 | #include 24 | #include 25 | 26 | using namespace LibSgfcPlusPlus; 27 | 28 | SCENARIO( "SgfcGoStone is constructed", "[go]" ) 29 | { 30 | GIVEN( "The SgfcGoStone constructor is used" ) 31 | { 32 | WHEN( "SgfcGoStone is constructed with valid data" ) 33 | { 34 | SgfcColor color = GENERATE( SgfcColor::Black, SgfcColor::White ); 35 | std::shared_ptr goPoint = std::shared_ptr( 36 | new SgfcGoPoint("A1", SgfcConstants::BoardSizeDefaultGo)); 37 | 38 | SgfcGoStone goStone(color, goPoint); 39 | 40 | THEN( "SgfcGoStone is constructed successfully" ) 41 | { 42 | REQUIRE( goStone.GetColor() == color ); 43 | REQUIRE( goStone.GetLocation() == goPoint ); 44 | } 45 | } 46 | 47 | WHEN( "SgfcGoPoint is constructed with invalid data" ) 48 | { 49 | SgfcColor color = GENERATE( SgfcColor::Black, SgfcColor::White ); 50 | 51 | THEN( "The SgfcGoPoint contructor throws an exception" ) 52 | { 53 | REQUIRE_THROWS_AS( 54 | SgfcGoStone(color, nullptr), 55 | std::invalid_argument); 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/sgfc/frontend/SgfcDocumentReader.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../backend/SgfcDataLocation.h" 21 | #include "../../../include/ISgfcDocumentReader.h" 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | // Forward declarations 26 | class ISgfcDocument; 27 | 28 | /// @brief The SgfcDocumentReader class provides an implementation of the 29 | /// ISgfcDocumentReader interface. See the interface header file for 30 | /// documentation. 31 | /// 32 | /// @ingroup internals 33 | /// @ingroup sgfc-frontend 34 | /// @ingroup document 35 | class SgfcDocumentReader : public ISgfcDocumentReader 36 | { 37 | public: 38 | SgfcDocumentReader(); 39 | virtual ~SgfcDocumentReader(); 40 | 41 | virtual std::shared_ptr GetArguments() const override; 42 | virtual std::shared_ptr ReadSgfFile(const std::string& sgfFilePath) const override; 43 | virtual std::shared_ptr ReadSgfContent(const std::string& sgfContent) const override; 44 | 45 | private: 46 | std::shared_ptr arguments; 47 | 48 | std::shared_ptr ReadSgfContentFromFilesystemOrInMemoryBuffer( 49 | const std::string& sgfFilePath, 50 | const std::string& sgfContent, 51 | SgfcDataLocation dataLocation) const; 52 | 53 | void PostProcessDocument(std::shared_ptr document) const; 54 | }; 55 | } 56 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/go/SgfcGoMovePropertyValue.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "../../../../include/SgfcConstants.h" 19 | #include "../../../game/go/SgfcGoMove.h" 20 | #include "../../../game/go/SgfcGoPoint.h" 21 | #include "../../../game/go/SgfcGoStone.h" 22 | #include "SgfcGoMovePropertyValue.h" 23 | 24 | // C++ Standard Library includes 25 | #include 26 | 27 | namespace LibSgfcPlusPlus 28 | { 29 | SgfcGoMovePropertyValue::SgfcGoMovePropertyValue(std::shared_ptr goMove) 30 | : SgfcMovePropertyValue(GetRawValueOrThrow(goMove), GetRawValueOrThrow(goMove)) 31 | , goMove(goMove) 32 | { 33 | } 34 | 35 | SgfcGoMovePropertyValue::~SgfcGoMovePropertyValue() 36 | { 37 | } 38 | 39 | const ISgfcGoMovePropertyValue* SgfcGoMovePropertyValue::ToGoMoveValue() const 40 | { 41 | return this; 42 | } 43 | 44 | std::shared_ptr SgfcGoMovePropertyValue::GetGoMove() const 45 | { 46 | return this->goMove; 47 | } 48 | 49 | std::string SgfcGoMovePropertyValue::GetRawValueOrThrow(std::shared_ptr goMove) 50 | { 51 | if (goMove == nullptr) 52 | throw std::invalid_argument("SgfcGoMovePropertyValue constructor failed: go move object is nullptr"); 53 | 54 | if (goMove->IsPassMove()) 55 | return SgfcConstants::GoMovePassString; 56 | else 57 | return goMove->GetStone()->GetLocation()->GetPosition(SgfcGoPointNotation::Sgf); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/game/go/SgfcGoMove.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../../include/ISgfcGoMove.h" 21 | 22 | namespace LibSgfcPlusPlus 23 | { 24 | /// @brief The SgfcGoMove class provides an implementation of the 25 | /// ISgfcGoMove interface. See the interface header file for 26 | /// documentation. 27 | /// 28 | /// @ingroup internals 29 | /// @ingroup go 30 | class SgfcGoMove : public ISgfcGoMove 31 | { 32 | public: 33 | /// @brief Initializes a newly constructed SgfcGoMove object. The move is 34 | /// not a pass move. @a stone indicates the color and location of the stone 35 | /// that was placed by the move on the board. 36 | /// 37 | /// @exception std::invalid_argument Is thrown if @a stone is nullptr. 38 | SgfcGoMove(std::shared_ptr stone); 39 | 40 | /// @brief Initializes a newly constructed SgfcGoMove object. The move is 41 | /// a pass move. @a playerColor indicates the color of the player who made 42 | /// the move. 43 | SgfcGoMove(SgfcColor playerColor); 44 | 45 | /// @brief Destroys and cleans up the SgfcGoMove object. 46 | virtual ~SgfcGoMove(); 47 | 48 | virtual bool IsPassMove() const override; 49 | virtual std::shared_ptr GetStone() const override; 50 | virtual SgfcColor GetPlayerColor() const override; 51 | virtual std::shared_ptr GetStoneLocation() const override; 52 | 53 | private: 54 | SgfcColor playerColor; 55 | std::shared_ptr stone; 56 | }; 57 | } 58 | -------------------------------------------------------------------------------- /src/document/typedproperty/SgfcGameTypeProperty.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../../include/ISgfcGameTypeProperty.h" 21 | #include "../SgfcProperty.h" 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | // Forward declarations 26 | class ISgfcNumberPropertyValue; 27 | 28 | /// @brief The SgfcGameTypeProperty class provides an implementation of 29 | /// the ISgfcGameTypeProperty interface. See the interface header file 30 | /// for documentation. 31 | /// 32 | /// @ingroup internals 33 | /// @ingroup property 34 | class SgfcGameTypeProperty : public SgfcProperty, public ISgfcGameTypeProperty 35 | { 36 | public: 37 | /// @brief Initializes a newly constructed SgfcGameTypeProperty object. The 38 | /// property has no value. 39 | SgfcGameTypeProperty(); 40 | 41 | /// @brief Initializes a newly constructed SgfcGameTypeProperty object. The 42 | /// property has the specified property value @a propertyValue. 43 | /// 44 | /// @exception std::invalid_argument Is thrown if @a propertyValue is 45 | /// @e nullptr. 46 | SgfcGameTypeProperty( 47 | std::shared_ptr propertyValue); 48 | 49 | /// @brief Destroys and cleans up the SgfcGameTypeProperty object. 50 | virtual ~SgfcGameTypeProperty(); 51 | 52 | virtual const ISgfcGameTypeProperty* ToGameTypeProperty() const override; 53 | 54 | virtual SgfcGameType GetGameType() const override; 55 | virtual SgfcNumber GetGameTypeAsNumber() const override; 56 | }; 57 | } 58 | -------------------------------------------------------------------------------- /test/sgfc/save/SgfcSgfContentTest.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2024 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Library includes 18 | #include 19 | 20 | // Unit test library includes 21 | #include 22 | #include 23 | 24 | using namespace LibSgfcPlusPlus; 25 | 26 | SCENARIO( "SgfcSgfContent is constructed", "[public-api]" ) 27 | { 28 | GIVEN( "The default constructor is used" ) 29 | { 30 | WHEN( "SgfcSgfContent is constructed" ) 31 | { 32 | SgfcSgfContent sgfContent; 33 | 34 | THEN( "SgfcSgfContent has no content" ) 35 | { 36 | REQUIRE( std::string() == sgfContent.GetSgfContent() ); 37 | REQUIRE( std::string() == sgfContent.GetFilePath() ); 38 | } 39 | } 40 | } 41 | 42 | GIVEN( "The constructor that takes content and filename arguments is used" ) 43 | { 44 | struct TestData 45 | { 46 | std::string Content; 47 | std::string FileName; 48 | }; 49 | auto testData = GENERATE( 50 | TestData { "", "" }, 51 | TestData { "foo", "" }, 52 | TestData { "", "bar" }, 53 | TestData { "foo", "bar" } 54 | ); 55 | 56 | WHEN( "SgfcSgfContent is constructed" ) 57 | { 58 | SgfcSgfContent sgfContent(testData.Content, testData.FileName); 59 | 60 | THEN( "SgfcSgfContent has the expected content and file name" ) 61 | { 62 | REQUIRE( testData.Content == sgfContent.GetSgfContent() ); 63 | REQUIRE( testData.FileName == sgfContent.GetFilePath() ); 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/go/SgfcGoPointPropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../../../include/ISgfcGoPointPropertyValue.h" 21 | #include "../SgfcPointPropertyValue.h" 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | /// @brief The SgfcGoPointPropertyValue class provides an implementation of 26 | /// the ISgfcGoPointPropertyValue interface. See the interface header file 27 | /// for documentation. 28 | /// 29 | /// @ingroup internals 30 | /// @ingroup property-value 31 | /// @ingroup go 32 | class SgfcGoPointPropertyValue : public SgfcPointPropertyValue, public ISgfcGoPointPropertyValue 33 | { 34 | public: 35 | /// @brief Initializes a newly constructed SgfcGoPointPropertyValue object. 36 | /// The object holds a Point value represented by @a goPoint. 37 | /// 38 | /// SgfcGoPointPropertyValue uses the SGF notation of @a goPoint as the 39 | /// raw property value. 40 | /// 41 | /// @exception std::invalid_argument Is thrown if @a goPoint is nullptr. 42 | SgfcGoPointPropertyValue(std::shared_ptr goPoint); 43 | 44 | /// @brief Destroys and cleans up the SgfcGoPointPropertyValue object. 45 | virtual ~SgfcGoPointPropertyValue(); 46 | 47 | virtual const ISgfcGoPointPropertyValue* ToGoPointValue() const override; 48 | virtual std::shared_ptr GetGoPoint() const override; 49 | 50 | private: 51 | std::shared_ptr goPoint; 52 | 53 | std::string GetRawValueOrThrow(std::shared_ptr goPoint); 54 | }; 55 | } 56 | -------------------------------------------------------------------------------- /include/ISgfcComposedPropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "ISgfcPropertyValue.h" 21 | #include "ISgfcSinglePropertyValue.h" 22 | 23 | // Project includes (generated) 24 | #include "SgfcPlusPlusExport.h" 25 | 26 | // C++ Standard Library includes 27 | #include 28 | 29 | namespace LibSgfcPlusPlus 30 | { 31 | /// @brief The ISgfcComposedPropertyValue interface provides access to one of 32 | /// the values of a property of an SGF node. The value is a composite of two 33 | /// ISgfcSinglePropertyValue objects. 34 | /// 35 | /// @ingroup public-api 36 | /// @ingroup property-value 37 | /// 38 | /// The class name uses the term "composed" because that is how it appears in 39 | /// the SGF standard. 40 | /// 41 | /// ISgfcComposedPropertyValue is immutable, i.e. once the 42 | /// ISgfcComposedPropertyValue object is constructed it cannot be changed. 43 | class SGFCPLUSPLUS_EXPORT ISgfcComposedPropertyValue : public ISgfcPropertyValue 44 | { 45 | public: 46 | /// @brief Initializes a newly constructed ISgfcComposedPropertyValue 47 | /// object. 48 | ISgfcComposedPropertyValue(); 49 | 50 | /// @brief Destroys and cleans up the ISgfcComposedPropertyValue object. 51 | virtual ~ISgfcComposedPropertyValue(); 52 | 53 | /// @brief Returns the first property value. 54 | virtual std::shared_ptr GetValue1() const = 0; 55 | 56 | /// @brief Returns the second property value. 57 | virtual std::shared_ptr GetValue2() const = 0; 58 | }; 59 | } 60 | -------------------------------------------------------------------------------- /src/document/SgfcComposedPropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../include/ISgfcComposedPropertyValue.h" 21 | 22 | namespace LibSgfcPlusPlus 23 | { 24 | /// @brief The SgfcComposedPropertyValue class provides an implementation of 25 | /// the ISgfcComposedPropertyValue interface. See the interface header file 26 | /// for documentation. 27 | /// 28 | /// @ingroup internals 29 | /// @ingroup property-value 30 | class SgfcComposedPropertyValue : public ISgfcComposedPropertyValue 31 | { 32 | public: 33 | /// @brief Initializes a newly constructed SgfcComposedPropertyValue object 34 | /// that consists of the two values @a value1 and @a value2. 35 | /// 36 | /// @exception std::invalid_argument Is thrown if @a value1 is @e nullptr 37 | /// or if @a value2 is @e nullptr. 38 | SgfcComposedPropertyValue( 39 | std::shared_ptr value1, 40 | std::shared_ptr value2); 41 | 42 | /// @brief Destroys and cleans up the SgfcSinglePropertyValue object. 43 | virtual ~SgfcComposedPropertyValue(); 44 | 45 | virtual bool IsComposedValue() const override; 46 | virtual const ISgfcComposedPropertyValue* ToComposedValue() const override; 47 | 48 | virtual std::shared_ptr GetValue1() const override; 49 | virtual std::shared_ptr GetValue2() const override; 50 | 51 | private: 52 | std::shared_ptr value1; 53 | std::shared_ptr value2; 54 | }; 55 | } 56 | -------------------------------------------------------------------------------- /include/ISgfcMovePropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "ISgfcSinglePropertyValue.h" 21 | #include "SgfcTypedefs.h" 22 | 23 | // Project includes (generated) 24 | #include "SgfcPlusPlusExport.h" 25 | 26 | namespace LibSgfcPlusPlus 27 | { 28 | // Forward declarations 29 | class ISgfcGoMovePropertyValue; 30 | 31 | /// @brief The ISgfcMovePropertyValue interface provides access to one of 32 | /// the values of a property of an SGF node. The value type is 33 | /// SgfcPropertyValueType::Move. 34 | /// 35 | /// @ingroup public-api 36 | /// @ingroup property-value 37 | /// 38 | /// ISgfcMovePropertyValue is immutable, i.e. once the 39 | /// ISgfcMovePropertyValue object is constructed it cannot be changed. 40 | class SGFCPLUSPLUS_EXPORT ISgfcMovePropertyValue : virtual public ISgfcSinglePropertyValue 41 | { 42 | public: 43 | /// @brief Initializes a newly constructed ISgfcMovePropertyValue object. 44 | ISgfcMovePropertyValue(); 45 | 46 | /// @brief Destroys and cleans up the ISgfcMovePropertyValue object. 47 | virtual ~ISgfcMovePropertyValue(); 48 | 49 | /// @brief Returns the property value interpreted as an SgfcMove value. 50 | virtual SgfcMove GetMoveValue() const = 0; 51 | 52 | /// @brief Returns an ISgfcGoMovePropertyValue object if the property 53 | /// value object was created specifically for SgfcGameType::Go. Returns 54 | /// @e nullptr otherwise. The caller is not the owner of the returned 55 | /// object. 56 | virtual const ISgfcGoMovePropertyValue* ToGoMoveValue() const = 0; 57 | }; 58 | } 59 | -------------------------------------------------------------------------------- /src/sgfc/backend/SgfcBackendLoadResult.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../../include/ISgfcMessage.h" 21 | #include "SgfcBackendDataWrapper.h" 22 | 23 | // C++ Standard Library includes 24 | #include 25 | #include 26 | 27 | namespace LibSgfcPlusPlus 28 | { 29 | /// @brief The SgfcBackendLoadResult class provides access to the result of 30 | /// a load operation performed by SgfcBackendController. 31 | /// 32 | /// @ingroup internals 33 | /// @ingroup sgfc-backend 34 | class SgfcBackendLoadResult 35 | { 36 | public: 37 | /// @brief Initializes a newly constructed SgfcBackendLoadResult object 38 | /// with the specified results. 39 | SgfcBackendLoadResult( 40 | std::vector> parseResult, 41 | std::shared_ptr sgfDataWrapper); 42 | 43 | /// @brief Destroys and cleans up the SgfcBackendLoadResult object. 44 | virtual ~SgfcBackendLoadResult(); 45 | 46 | /// @brief Returns a collection of ISgfcMessage objects which together form 47 | /// the parse result of the load operation. The messages appear in the order 48 | /// in which they were generated by SGFC. 49 | std::vector> GetParseResult() const; 50 | 51 | /// @brief Returns a pointer to the SGF data that was generated by SGFC. 52 | std::shared_ptr GetSgfDataWrapper() const; 53 | 54 | private: 55 | std::vector> parseResult; 56 | std::shared_ptr sgfDataWrapper; 57 | }; 58 | } 59 | -------------------------------------------------------------------------------- /include/ISgfcPointPropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "ISgfcSinglePropertyValue.h" 21 | #include "SgfcTypedefs.h" 22 | 23 | // Project includes (generated) 24 | #include "SgfcPlusPlusExport.h" 25 | 26 | namespace LibSgfcPlusPlus 27 | { 28 | // Forward declarations 29 | class ISgfcGoPointPropertyValue; 30 | 31 | /// @brief The ISgfcPointPropertyValue interface provides access to one of 32 | /// the values of a property of an SGF node. The value type is 33 | /// SgfcPropertyValueType::Point. 34 | /// 35 | /// @ingroup public-api 36 | /// @ingroup property-value 37 | /// 38 | /// ISgfcPointPropertyValue is immutable, i.e. once the 39 | /// ISgfcPointPropertyValue object is constructed it cannot be changed. 40 | class SGFCPLUSPLUS_EXPORT ISgfcPointPropertyValue : virtual public ISgfcSinglePropertyValue 41 | { 42 | public: 43 | /// @brief Initializes a newly constructed ISgfcPointPropertyValue object. 44 | ISgfcPointPropertyValue(); 45 | 46 | /// @brief Destroys and cleans up the ISgfcPointPropertyValue object. 47 | virtual ~ISgfcPointPropertyValue(); 48 | 49 | /// @brief Returns the property value interpreted as an SgfcPoint value. 50 | virtual SgfcPoint GetPointValue() const = 0; 51 | 52 | /// @brief Returns an ISgfcGoPointPropertyValue object if the property 53 | /// value object was created specifically for SgfcGameType::Go. Returns 54 | /// @e nullptr otherwise. The caller is not the owner of the returned 55 | /// object. 56 | virtual const ISgfcGoPointPropertyValue* ToGoPointValue() const = 0; 57 | }; 58 | } 59 | -------------------------------------------------------------------------------- /include/ISgfcStonePropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "ISgfcSinglePropertyValue.h" 21 | #include "SgfcTypedefs.h" 22 | 23 | // Project includes (generated) 24 | #include "SgfcPlusPlusExport.h" 25 | 26 | namespace LibSgfcPlusPlus 27 | { 28 | // Forward declarations 29 | class ISgfcGoStonePropertyValue; 30 | 31 | /// @brief The ISgfcStonePropertyValue interface provides access to one of 32 | /// the values of a property of an SGF node. The value type is 33 | /// SgfcPropertyValueType::Stone. 34 | /// 35 | /// @ingroup public-api 36 | /// @ingroup property-value 37 | /// 38 | /// ISgfcStonePropertyValue is immutable, i.e. once the 39 | /// ISgfcStonePropertyValue object is constructed it cannot be changed. 40 | class SGFCPLUSPLUS_EXPORT ISgfcStonePropertyValue : virtual public ISgfcSinglePropertyValue 41 | { 42 | public: 43 | /// @brief Initializes a newly constructed ISgfcStonePropertyValue object. 44 | ISgfcStonePropertyValue(); 45 | 46 | /// @brief Destroys and cleans up the ISgfcStonePropertyValue object. 47 | virtual ~ISgfcStonePropertyValue(); 48 | 49 | /// @brief Returns the property value interpreted as an SgfcStone value. 50 | virtual SgfcStone GetStoneValue() const = 0; 51 | 52 | /// @brief Returns an ISgfcGoStonePropertyValue object if the property 53 | /// value object was created specifically for SgfcGameType::Go. Returns 54 | /// @e nullptr otherwise. The caller is not the owner of the returned 55 | /// object. 56 | virtual const ISgfcGoStonePropertyValue* ToGoStoneValue() const = 0; 57 | }; 58 | } 59 | -------------------------------------------------------------------------------- /src/document/typedproperty/SgfcGameTypeProperty.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "../../../include/ISgfcNumberPropertyValue.h" 19 | #include "../../../include/SgfcConstants.h" 20 | #include "../../game/SgfcGameUtility.h" 21 | #include "../../SgfcUtility.h" 22 | #include "SgfcGameTypeProperty.h" 23 | 24 | // C++ Standard Library includes 25 | #include 26 | 27 | namespace LibSgfcPlusPlus 28 | { 29 | SgfcGameTypeProperty::SgfcGameTypeProperty() 30 | : SgfcProperty(SgfcPropertyType::GM, 31 | SgfcUtility::MapPropertyTypeToPropertyName(SgfcPropertyType::GM)) 32 | { 33 | } 34 | 35 | SgfcGameTypeProperty::SgfcGameTypeProperty( 36 | std::shared_ptr propertyValue) 37 | : SgfcProperty(SgfcPropertyType::GM, 38 | SgfcUtility::MapPropertyTypeToPropertyName(SgfcPropertyType::GM), 39 | std::vector>{propertyValue}) 40 | { 41 | if (propertyValue == nullptr) 42 | throw std::invalid_argument("SgfcGameTypeProperty constructor failed: Property value is nullptr"); 43 | } 44 | 45 | SgfcGameTypeProperty::~SgfcGameTypeProperty() 46 | { 47 | } 48 | 49 | const ISgfcGameTypeProperty* SgfcGameTypeProperty::ToGameTypeProperty() const 50 | { 51 | return this; 52 | } 53 | 54 | SgfcGameType SgfcGameTypeProperty::GetGameType() const 55 | { 56 | return SgfcGameUtility::GetGameType(GetPropertyValues()); 57 | } 58 | 59 | SgfcNumber SgfcGameTypeProperty::GetGameTypeAsNumber() const 60 | { 61 | return SgfcGameUtility::GetGameTypeAsNumber(GetPropertyValues()); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/document/typedpropertyvalue/go/SgfcGoStonePropertyValue.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../../../../include/ISgfcGoStonePropertyValue.h" 21 | #include "../SgfcStonePropertyValue.h" 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | /// @brief The SgfcGoStonePropertyValue class provides an implementation of 26 | /// the ISgfcGoStonePropertyValue interface. See the interface header file 27 | /// for documentation. 28 | /// 29 | /// @ingroup internals 30 | /// @ingroup property-value 31 | /// @ingroup go 32 | class SgfcGoStonePropertyValue : public SgfcStonePropertyValue, public ISgfcGoStonePropertyValue 33 | { 34 | public: 35 | /// @brief Initializes a newly constructed SgfcGoStonePropertyValue object. 36 | /// The object holds a Point value represented by @a goStone. 37 | /// 38 | /// SgfcGoStonePropertyValue uses the SGF notation of the ISgfcGoPoint 39 | /// object referenced by @a goStone as the raw property value. This refers 40 | /// to the location of the stone on the board. 41 | /// 42 | /// @exception std::invalid_argument Is thrown if @a goStone is nullptr. 43 | SgfcGoStonePropertyValue(std::shared_ptr goStone); 44 | 45 | /// @brief Destroys and cleans up the SgfcGoStonePropertyValue object. 46 | virtual ~SgfcGoStonePropertyValue(); 47 | 48 | virtual const ISgfcGoStonePropertyValue* ToGoStoneValue() const override; 49 | virtual std::shared_ptr GetGoStone() const override; 50 | 51 | private: 52 | std::shared_ptr goStone; 53 | 54 | std::string GetRawValueOrThrow(std::shared_ptr goStone); 55 | }; 56 | } 57 | -------------------------------------------------------------------------------- /src/game/SgfcBoardSize.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Project includes 18 | #include "../../include/SgfcBoardSize.h" 19 | #include "../../include/SgfcConstants.h" 20 | 21 | namespace LibSgfcPlusPlus 22 | { 23 | bool SgfcBoardSize::IsSquare() const 24 | { 25 | return (this->Columns == this->Rows); 26 | } 27 | 28 | bool SgfcBoardSize::IsValid(SgfcGameType gameType) const 29 | { 30 | if (this->Columns < SgfcConstants::BoardSizeMinimum.Columns || 31 | this->Rows < SgfcConstants::BoardSizeMinimum.Rows) 32 | { 33 | return false; 34 | } 35 | 36 | if (gameType == SgfcGameType::Go) 37 | { 38 | if (this->Columns > SgfcConstants::BoardSizeMaximumGo.Columns || 39 | this->Rows > SgfcConstants::BoardSizeMaximumGo.Rows) 40 | { 41 | return false; 42 | } 43 | } 44 | 45 | return true; 46 | } 47 | 48 | SgfcBoardSize SgfcBoardSize::GetDefaultBoardSize(SgfcGameType gameType) 49 | { 50 | switch (gameType) 51 | { 52 | case SgfcGameType::Go: 53 | return SgfcConstants::BoardSizeDefaultGo; 54 | case SgfcGameType::Chess: 55 | return SgfcConstants::BoardSizeDefaultChess; 56 | default: 57 | return SgfcConstants::BoardSizeNone; 58 | } 59 | } 60 | 61 | bool SgfcBoardSize::operator==(const SgfcBoardSize& other) const 62 | { 63 | if (this == &other) 64 | return true; 65 | else if (this->Columns != other.Columns) 66 | return false; 67 | else if (this->Rows != other.Rows) 68 | return false; 69 | else 70 | return true; 71 | } 72 | 73 | bool SgfcBoardSize::operator!=(const SgfcBoardSize& other) const 74 | { 75 | return ! (*this == other); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/sgfc/frontend/SgfcDocumentWriter.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // Project includes 20 | #include "../backend/SgfcDataLocation.h" 21 | #include "../../../include/ISgfcDocumentWriter.h" 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | /// @brief The SgfcDocumentWriter class provides an implementation of the 26 | /// ISgfcDocumentWriter interface. See the interface header file for 27 | /// documentation. 28 | /// 29 | /// @ingroup internals 30 | /// @ingroup sgfc-frontend 31 | /// @ingroup document 32 | class SgfcDocumentWriter : public ISgfcDocumentWriter 33 | { 34 | public: 35 | SgfcDocumentWriter(); 36 | virtual ~SgfcDocumentWriter(); 37 | 38 | virtual std::shared_ptr GetArguments() const override; 39 | virtual std::shared_ptr WriteSgfFile( 40 | std::shared_ptr document, 41 | const std::string& sgfFilePath) const override; 42 | virtual std::shared_ptr WriteSgfContent( 43 | std::shared_ptr document, 44 | std::string& sgfContent) const override; 45 | virtual std::shared_ptr ValidateDocument( 46 | std::shared_ptr document) const override; 47 | virtual void DebugPrintToConsole( 48 | std::shared_ptr document) const override; 49 | 50 | private: 51 | std::shared_ptr arguments; 52 | 53 | std::shared_ptr WriteSgfContentToFilesystemOrInMemoryBuffer( 54 | std::shared_ptr document, 55 | const std::string& sgfFilePath, 56 | std::string& sgfContent, 57 | SgfcDataLocation dataLocation) const; 58 | }; 59 | } 60 | -------------------------------------------------------------------------------- /src/sgfc/message/SgfcMessageStream.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ----------------------------------------------------------------------------- 16 | 17 | #pragma once 18 | 19 | // C++ Standard Library includes 20 | #include 21 | #include 22 | 23 | namespace LibSgfcPlusPlus 24 | { 25 | // Forward declarations 26 | class ISgfcMessage; 27 | 28 | /// @brief The SgfcMessageStream class captures the stream of messages that 29 | /// is generated by SGFC. 30 | /// 31 | /// @ingroup internals 32 | /// @ingroup sgfc-message 33 | /// 34 | /// SgfcMessageStream starts to capture the stream of SGFC messages 35 | /// immediately upon construction. Capturing stops only when the 36 | /// SgfcMessageStream object is destroyed. A client can access the messages 37 | /// captured so far during the lifetime of the SgfcMessageStream object by 38 | /// invoking its GetMessages() method. 39 | /// 40 | /// Only one SgfcMessageStream can be active at any given time. 41 | class SgfcMessageStream 42 | { 43 | public: 44 | /// @brief Initializes a newly constructed SgfcMessageStream object. 45 | /// The object immediately starts capturing the SGFC message stream. 46 | /// 47 | /// @exception std::logic_error Is thrown if another SgfcMessageStream 48 | /// object already exists. 49 | SgfcMessageStream(); 50 | 51 | /// @brief Destroys and cleans up the SgfcMessageStream object. 52 | virtual ~SgfcMessageStream(); 53 | 54 | /// @brief Returns a collection of messages captured so far by the 55 | /// SgfcMessageStream object. The messages appear in the collection in the 56 | /// order in which they are generated by SGFC. The collection is empty 57 | /// if SGFC has not generated any messages. 58 | std::vector> GetMessagees() const; 59 | }; 60 | } 61 | -------------------------------------------------------------------------------- /doc/ChangeLog.md: -------------------------------------------------------------------------------- 1 | # ChangeLog 2 | 3 | ## Version 2.0.1 (January 5 2024) 4 | 5 | This release contains no changes to the libsgfc++ source code at all. The release is made only to fix the SGFC git submodule reference in branch `master`: The git submodule now correctly points to the `V2_0` tag in the SGFC repository. 6 | 7 | Also in this release are fixes for a number of errors in the libsgfc++ Doxygen documentation. 8 | 9 | ## Version 2.0.0 (January 3 2024) 10 | 11 | Note: The Git tag `2.0.0` in branch `master` points to the wrong commit in the SGFC git submodule. 12 | 13 | ### Features 14 | 15 | - None 16 | 17 | ### Bugfixes 18 | 19 | - Fixed numeric value of `SgfcMessageID::IllegalVariationStartCorrected` (#39). The enum value had the same numeric value as `SgfcMessageID::IllegalVariationStartIgnored`. 20 | - Changed the value type for referencing line and column numbers in messages to `unsigned long`, to match the error reporting interface of SGFC (#40). The old type `int` was insufficient to hold all possible `unsigned long` values, also the there was a signed/unsigned mismatch. The change affects the `ISgfcMessage` getters `GetLineNumber()` and `GetColumnNumber()`, as well as the constants `SgfcConstants::InvalidLineNumber` and `SgfcConstants::InvalidColumnNumber`. The constants also changed their value (previously -1, now 0). 21 | 22 | ### Regressions 23 | 24 | - None 25 | 26 | ### Technical changes 27 | 28 | - Replaced internal custom code to determine the path to a temporary folder with `std::filesystem::temp_directory_path()` (#18). 29 | - Updated unit test library Catch2 from v2.13.4 to v3.5.0. 30 | - Updated the [Cross-compiling for iOS](Build.md#cross-compiling-for-ios) documentation for modern CMake/Xcode versions. 31 | - Updated the GitHub build pipelines. 32 | 33 | ### GitHub issue list 34 | 35 | A list of all issues closed for this release is available [on GitHub](https://github.com/herzbube/libsgfcplusplus/milestone/4?closed=1) 36 | 37 | 38 | ## Version 1.0 (February 23 2021) 39 | 40 | Initial 1.0 release that includes SGFC v2.0. 41 | 42 | Note: The Git tag `1.0` in branch `master` points to the wrong commit in the SGFC git submodule. 43 | 44 | ## Version 0.2 (beta) (January 12 2021) 45 | 46 | Release of version 0.2 (beta). 47 | 48 | ## Version 0.1 (alpha) (October 11 2020) 49 | 50 | Release of version 0.1 (alpha). 51 | 52 | ## September 20 2020 53 | 54 | Unit tests largely completed. 55 | 56 | ## May 23 2020 57 | 58 | Unit tests (work in progress), CMake build system, Travis CI, cross-platform build. 59 | 60 | ## April 09 2020 61 | 62 | SGFC patching complete. 63 | 64 | ## February 5 2020 65 | 66 | Created project 67 | --------------------------------------------------------------------------------