├── .gitattributes ├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── SourceMonitorOS.smproj ├── documentation ├── architecture │ ├── architecture.drawio │ ├── architecture.svg │ └── readme.md ├── history.md ├── readme.md └── smcore │ ├── About SourceMonitor.png │ ├── about.md │ ├── license.md │ ├── options.md │ ├── project.md │ ├── readme.md │ ├── smstring.md │ └── version.md ├── playground ├── logging │ ├── CMakeLists.txt │ ├── Logging_en_150.ts │ ├── logging.cpp │ ├── logging.h │ └── main.cpp ├── readme.md └── resource │ ├── CMakeLists.txt │ ├── SourceMonitorOS.ico │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ ├── mainwindow.ui │ └── smcore.qrc ├── readme.md ├── smcli ├── CMakeLists.txt ├── main.cpp ├── readme.md └── smcli_en_150.ts ├── smcore ├── CMakeLists.txt ├── about.cpp ├── about.h ├── archivereader.cpp ├── archivereader.h ├── checkpoint.cpp ├── checkpoint.h ├── classinfo.h ├── error.cpp ├── error.h ├── factory.cpp ├── factory.h ├── language.cpp ├── language.h ├── languagebase.cpp ├── languagebase.h ├── languages.cpp ├── languages.h ├── license.cpp ├── license.h ├── optionflags.h ├── options.cpp ├── options.h ├── printvector.h ├── project.cpp ├── project.h ├── readme.md ├── smcheckpointsreader.cpp ├── smcheckpointsreader.h ├── smlanguagereader.cpp ├── smlanguagereader.h ├── smpreader.cpp ├── smpreader.h ├── smstring.cpp ├── smstring.h ├── subdirectorymode.h ├── version.cpp └── version.h ├── smgui ├── CMakeLists.txt ├── main.cpp ├── readme.md ├── sggui.cpp ├── sggui.h ├── sggui.ui ├── sggui_en_150.ts ├── sgoptions.cpp ├── sgoptions.h └── sgoptions.ui └── smtest ├── CMakeLists.txt ├── main.cpp ├── readme.md ├── test_about.cpp ├── test_about.h ├── test_checkpoint.cpp ├── test_checkpoint.h ├── test_license.cpp ├── test_license.h ├── test_options.cpp ├── test_options.h ├── test_project.cpp ├── test_project.h ├── test_smpreader.cpp ├── test_smpreader.h ├── test_version.cpp ├── test_version.h ├── testfiles └── osm.smp └── testrunner.h /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | ### Added by ThirtySomething 75 | CMakeLists.txt.user 76 | build* 77 | .vscode 78 | /.vscode 79 | *.bak 80 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ******************************************************************************* 2 | # Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the "Software"), 6 | # to deal in the Software without restriction, including without limitation 7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | # and/or sell copies of the Software, and to permit persons to whom the 9 | # Software is furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | # DEALINGS IN THE SOFTWARE. 21 | # ******************************************************************************* 22 | 23 | cmake_minimum_required(VERSION 3.5) 24 | 25 | project(SourceMonitorOS LANGUAGES CXX VERSION 0.0.1 DESCRIPTION "SourceMonitor OpenSource") 26 | 27 | # ******************************************************************************* 28 | # Settings for smcore 29 | # ******************************************************************************* 30 | add_subdirectory(smcore) 31 | 32 | # ******************************************************************************* 33 | # Settings for smcli 34 | # ******************************************************************************* 35 | add_subdirectory(smcli) 36 | target_include_directories(smcli PRIVATE smcore) 37 | 38 | # ******************************************************************************* 39 | # Settings for smgui 40 | # ******************************************************************************* 41 | add_subdirectory(smgui) 42 | target_include_directories(smgui PRIVATE smcore) 43 | 44 | # ******************************************************************************* 45 | # Settings for smtest 46 | # ******************************************************************************* 47 | add_subdirectory(smtest) 48 | target_include_directories(smtest PRIVATE smcore) 49 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (C) 1999 by Jim Wanner and the SourceMonitor team 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a 6 | copy of this software and associated documentation files (the "Software"), 7 | to deal in the Software without restriction, including without limitation 8 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | and/or sell copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included 13 | in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 16 | KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 21 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /SourceMonitorOS.smproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SourceMonitor/SourceMonitorOS/1586c61f730459ab47d7f08f2c29e90ed415ca04/SourceMonitorOS.smproj -------------------------------------------------------------------------------- /documentation/architecture/architecture.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /documentation/architecture/readme.md: -------------------------------------------------------------------------------- 1 | # Architecture 2 | 3 | This is the technical documentation about the systems architecture. 4 | 5 | ## Graphical overview 6 | 7 | ![Graphical overview][img_architecture] 8 | 9 | [img_architecture]: ./architecture.svg 10 | -------------------------------------------------------------------------------- /documentation/history.md: -------------------------------------------------------------------------------- 1 | # History of SourceMonitorOS 2 | 3 | ## 2022-12-12 4 | 5 | - Fixed naming issues 6 | - Settigs are named options in the original 7 | - Because of redundancies 8 | - Core classes named as usual 9 | - CLI classes are prefixed with `sc` 10 | - UI classes are prefixed with `sm` 11 | - SMMainWindow is named SMGUI 12 | - Introduced factory class 13 | - Draft options dialog 14 | - Options perform a load on object creation to initialize the member variables 15 | 16 | ## 2022-12-04 17 | 18 | - Extended the readme with a hint about compilation 19 | - Updated the readme with informations about the used technologies 20 | 21 | ## 2022-12-02 22 | 23 | - Updated readme files 24 | - Added SourceMonitor project file 25 | 26 | ## 2022-11-29 27 | 28 | - Added dialog box for "View License 29 | - Added "About" class 30 | - Added dialog box for "About SourceMonitorOS" 31 | - Added documentation for "About" 32 | - Removed ".vscode" folder 33 | 34 | ## 2022-11-27 35 | 36 | - Added/reworked tests for license and settings. 37 | - Updated documentation. 38 | 39 | ## 2022-11-23 40 | 41 | - Added documentation for settings. 42 | - Added missing translation feature to smcore. 43 | - Added subproject for tests, smtest. 44 | - Improved CMakeLists.txt with details for translation. 45 | - Enable all compile warnings in CMakeLists.txt files. 46 | - Uniform header for CMakeLists.txt and source files. 47 | 48 | ## 2022-11-20 49 | 50 | - Added basic settings object. 51 | 52 | ## 2022-11-12 53 | 54 | - Start SourceMonitorOS from scratch, initial setup with smgui, smcore and smcli. 55 | -------------------------------------------------------------------------------- /documentation/readme.md: -------------------------------------------------------------------------------- 1 | # Documentation 2 | 3 | In this directory the documentation of SourceMonitorOS is located. At the moment this is a loose collection of [markdown][markdown_github] files. For later there is a need to use [QT help system][qt_help]. 4 | 5 | ## History 6 | 7 | To get an information about the history of SourceMonitorOS, please see [here][file_history]. 8 | 9 | ## Available descriptions 10 | 11 | - [Architecture][doc_architecture] - The systems architecture 12 | - [SMCORE][doc_smcore] - The core functionality 13 | 14 | [doc_architecture]: ./architecture/readme.md 15 | [doc_smcore]: ./smcore/readme.md 16 | [file_history]: ./history.md 17 | [markdown_github]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax 18 | [qt_help]: https://doc.qt.io/qt-6.2/qthelp-framework.html 19 | -------------------------------------------------------------------------------- /documentation/smcore/About SourceMonitor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SourceMonitor/SourceMonitorOS/1586c61f730459ab47d7f08f2c29e90ed415ca04/documentation/smcore/About SourceMonitor.png -------------------------------------------------------------------------------- /documentation/smcore/about.md: -------------------------------------------------------------------------------- 1 | # The about dialog 2 | 3 | The help menu offers an entry named "About SourceMonitorOS". This will fire up a dialog with rough information about the Software. In the original software the dialog looks like this: 4 | 5 | ![SourceMonitor About Dialog][smabout] 6 | 7 | ## Implementation 8 | 9 | This is a functionality of `smcore` and located in `smcore/about.*`. 10 | 11 | ### Public API 12 | 13 | ```c++ 14 | namespace smos 15 | { 16 | namespace smcore 17 | { 18 | class About 19 | { 20 | public: 21 | /** 22 | * @brief Get the about text 23 | * 24 | * @return QString 25 | */ 26 | static smos::smcore::SMSring getAbout(void); 27 | }; 28 | } 29 | } 30 | ``` 31 | 32 | ### Usage 33 | 34 | ```c++ 35 | #include "about.h" 36 | 37 | smos::smcore::SMSring about = smos::smcore::About::getAbout(); 38 | ``` 39 | 40 | [smabout]: ./About%20SourceMonitor.png 41 | -------------------------------------------------------------------------------- /documentation/smcore/license.md: -------------------------------------------------------------------------------- 1 | # The used license 2 | 3 | This is a static function to get the license text to display. Actually this is a hardcoded MIT license. There was the idea about reading the text from a file. But what to display in case the file does not exist? 4 | 5 | ## Implementation 6 | 7 | This is a functionality of `smcore` and located in `smcore/license.*`. 8 | 9 | ### Public API 10 | 11 | ```c++ 12 | namespace smos 13 | { 14 | namespace smcore 15 | { 16 | class License 17 | { 18 | public: 19 | /** 20 | * @brief Get the license text 21 | * 22 | * @return smos::smcore::SMSring 23 | */ 24 | static smos::smcore::SMSring getLicense(void); 25 | }; 26 | } 27 | } 28 | 29 | ``` 30 | 31 | ### Usage 32 | 33 | ```c++ 34 | #include "license.h" 35 | 36 | smos::smcore::SMSring license = smos::smcore::License::getLicense(); 37 | ``` 38 | 39 | ## Possible issues 40 | 41 | At the moment the project uses the [MIT][license_mit]. Unfortunately QT proposes other [licenses][license_qt], e. g. the [LGPL][license_lgpl]. This needs further investigation. 42 | 43 | => According to [this][license_ok] article there is no problem with this combination. 44 | 45 | [license_lgpl]: https://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License 46 | [license_mit]: https://en.wikipedia.org/wiki/MIT_License 47 | [license_ok]: https://softwareengineering.stackexchange.com/questions/267582/is-it-ok-to-use-the-mit-license-for-a-project-that-uses-qt 48 | [license_qt]: https://www.qt.io/download-open-source#consider 49 | -------------------------------------------------------------------------------- /documentation/smcore/options.md: -------------------------------------------------------------------------------- 1 | # The options object 2 | 3 | There is a need to have persistent options somewhere. For this is this object. Because of the plattform independency the options are stored in an [INI file][wiki_ini_file]. This kind of format is supported by [Qts settings object][qt_qsettings]. 4 | 5 | ## Implementation 6 | 7 | This is a functionality of `smcore` and located in `smcore/options.*`. 8 | 9 | ## Internals 10 | 11 | - Section names will be always in uppercase letters. 12 | - Key names will be always in lowercase letters. 13 | - For both the class will take care about. 14 | - On creation of the object a load is performed to initialize the member variables. 15 | 16 | ### Public API 17 | 18 | ```c++ 19 | namespace smos 20 | { 21 | namespace smcore 22 | { 23 | class Options 24 | { 25 | public: 26 | /** 27 | * @brief Default constructor 28 | * 29 | * @param optionsfile Name of options file 30 | */ 31 | Options(smos::smcore::SMSring optionsfile); 32 | 33 | /** 34 | * @brief Default destructor 35 | * 36 | */ 37 | ~Options(void); 38 | 39 | /** 40 | * @brief Get the editor call with filename templated 41 | * 42 | * @return smos::smcore::SMSring 43 | */ 44 | smos::smcore::SMSring codeEditorGet(void); 45 | 46 | /** 47 | * @brief Get the editor call with filename templated 48 | * 49 | * @param codeeditor smos::smcore::SMSring 50 | */ 51 | void codeEditorSet(smos::smcore::SMSring codeeditor); 52 | 53 | /** 54 | * @brief Get the absolute path to the logfile 55 | * 56 | * @return smos::smcore::SMSring The absolute path to the logfile 57 | */ 58 | smos::smcore::SMSring logfileNameGet(void); 59 | 60 | /** 61 | * @brief Set the name (and path) of the logfile 62 | * 63 | * @param logfileName Name (and path) of the logfile to use 64 | */ 65 | void logfileNameSet(smos::smcore::SMSring logfileName); 66 | }; 67 | } 68 | } 69 | ``` 70 | 71 | ### Usage 72 | 73 | ```c++ 74 | #include "settings.h" 75 | 76 | smos::smcore::SMSettings settings = smos::smcore::SMSettings("smos_core.ini"); 77 | 78 | smos::smcore::SMSring logfileOld = settings.logfileNameGet(); 79 | settings.logfileNameSet("logfilenew.log"); 80 | ``` 81 | 82 | ## Possible issues 83 | 84 | This object could be a [singleton][wiki_singleton]. But the intention is to create an instance at the top most level and then [inject][wiki_dependency_injection] it into the core. 85 | 86 | [qt_qsettings]: https://doc.qt.io/qt-6.2/qsettings.html 87 | [wiki_dependency_injection]: https://en.wikipedia.org/wiki/Dependency_injection 88 | [wiki_ini_file]: https://en.wikipedia.org/wiki/INI_file 89 | [wiki_singleton]: https://en.wikipedia.org/wiki/Singleton_pattern 90 | -------------------------------------------------------------------------------- /documentation/smcore/project.md: -------------------------------------------------------------------------------- 1 | # The project object 2 | 3 | This object contains the project data. This means the project name, the checkpoints, the metrics and much more. 4 | 5 | ## Implementation 6 | 7 | This is a functionality of `smcore` and located in `smcore/project.*`. 8 | 9 | ## Internals 10 | 11 | - The `loadProject` and `saveProject` methods are static. 12 | 13 | ### Public API 14 | 15 | ```c++ 16 | namespace smos 17 | { 18 | namespace smcore 19 | { 20 | class Project 21 | { 22 | public: 23 | /** 24 | * @brief Construct a new Project object 25 | */ 26 | Project(void); 27 | 28 | /** 29 | * @brief Destroy the Project object 30 | */ 31 | ~Project(void); 32 | 33 | /** 34 | * @brief Load project data 35 | * 36 | * @param filename Name of project file 37 | * @param project Pointer to project object 38 | * 39 | * @return smos::smcore::Error::ErrorCode 40 | */ 41 | static smos::smcore::Error::ErrorCode loadProject(const smos::smcore::SMString &filename, Project &project); 42 | 43 | /** 44 | * @brief Save project data 45 | * 46 | * @param filename Name of project file 47 | * @param project Pointer to project object 48 | * @param force Force saving in case project file already exist 49 | * 50 | * @return smos::smcore::Error::ErrorCode 51 | */ 52 | static smos::smcore::Error::ErrorCode saveProject(const smos::smcore::SMString &filename, Project &project, bool force = false); 53 | 54 | /** 55 | * @brief Get the Project Name 56 | * 57 | * @return smos::smcore::SMString 58 | */ 59 | smos::smcore::SMString getProjectName(void) const; 60 | 61 | /** 62 | * @brief Set the Project Name 63 | * 64 | * @param projectName 65 | */ 66 | void setProjectName(smos::smcore::SMString projectName); 67 | 68 | /** 69 | * @brief Enable writing to stream 70 | * 71 | * @param os Outputstream to write to 72 | * @param obj Project object to write to stream 73 | * 74 | * @return std::ostream& 75 | */ 76 | friend std::ostream &operator<<(std::ostream &os, const Project &obj); 77 | 78 | /** 79 | * @brief Enable reading from stream 80 | * 81 | * @param is Inputstream to read from 82 | * @param obj Project object to read from stream 83 | * 84 | * @return std::istream& 85 | */ 86 | friend std::istream &operator>>(std::istream &is, Project &obj); 87 | }; 88 | } 89 | } 90 | ``` 91 | 92 | ### Usage 93 | 94 | ```c++ 95 | #include "project.h" 96 | 97 | // Creation of project 98 | smos::smcore::SMString projectNameSet = smos::smcore::SMString("ProjectName"); 99 | smos::smcore::Project objProject; 100 | 101 | // Change project name 102 | objProject.setProjectName(projectNameSet); 103 | smos::smcore::SMString projectNameGet = objProject.getProjectName(); 104 | 105 | // Save and load project 106 | smos::smcore::SMString filename = smos::smcore::SMString("project.dat"); 107 | smos::smcore::Error::ErrorCode result = smos::smcore::Project::saveProject(filename, objProject); 108 | result = smos::smcore::Project::loadProject(filename, objProject); 109 | ``` 110 | 111 | ## Possible issues 112 | -------------------------------------------------------------------------------- /documentation/smcore/readme.md: -------------------------------------------------------------------------------- 1 | # Documentation of SMCORE 2 | 3 | - [About][doc_about] 4 | - [License][doc_license] 5 | - [Options][doc_options] 6 | - [Project][doc_project] 7 | - [SMString][doc_smstring] 8 | - [Version][doc_version] 9 | 10 | [doc_about]: ./about.md 11 | [doc_license]: ./license.md 12 | [doc_options]: ./options.md 13 | [doc_project]: ./project.md 14 | [doc_smstring]: ./smstring.md 15 | [doc_version]: ./version.md 16 | -------------------------------------------------------------------------------- /documentation/smcore/smstring.md: -------------------------------------------------------------------------------- 1 | # The smstring object 2 | 3 | WTF?! There are so much possibilities for using strings in C++ - don't know how to do a wise decision for stalbe use. There are a few possibilities 4 | 5 | - std::string 6 | - std::wstring 7 | - [ICU][lib_icu] 8 | 9 | We have to keep always in mind that the source code could contain comments or variables in local languages. Imagine source code in Arabic (from right to left, from top to bottom), Chinese (from left to right, from top to bottom), Hebrew (from right to left, from top to bottom), Japanese (from right to left, from top to bottom) or Thai (from left to right, from top to bottom) - it will not be easy to deal with such source code. 10 | 11 | ## Implementation 12 | 13 | This is a functionality of `smcore` and located in `smcore/smstring.*`. 14 | 15 | The decision of which kind of string handling is moved to the future. To enable the project for working a simple `typedef` on `std::string` is used as placeholder for the future implementation. Of course this is not safe for the future but better than nothing. 16 | 17 | ### Public API 18 | 19 | ```c++ 20 | namespace smos 21 | { 22 | namespace smcore 23 | { 24 | typedef std::string SMSring; 25 | } 26 | } 27 | ``` 28 | 29 | ### Usage 30 | 31 | ```c++ 32 | #include "smstring.h" 33 | 34 | smos::smcore::SMString message = "Hello world"; 35 | ``` 36 | 37 | [lib_icu]: https://icu.unicode.org/design/cpp 38 | -------------------------------------------------------------------------------- /documentation/smcore/version.md: -------------------------------------------------------------------------------- 1 | # The project object 2 | 3 | This object contains the program version information. 4 | 5 | ## Implementation 6 | 7 | This is a functionality of `smcore` and located in `smcore/version.*`. 8 | 9 | ## Internals 10 | 11 | ### Public API 12 | 13 | ```c++ 14 | namespace smos 15 | { 16 | namespace smcore 17 | { 18 | class Version 19 | { 20 | public: 21 | /** 22 | * @brief Default constructor 23 | */ 24 | Version(void); 25 | 26 | /** 27 | * @brief Default destructor 28 | */ 29 | ~Version(void); 30 | 31 | /** 32 | * @brief Copy constructor 33 | * 34 | * @param versionObject Version to copy data from 35 | */ 36 | Version(const Version &versionObject); 37 | 38 | /** 39 | * @brief Assignment operator 40 | * 41 | * @param versionObject 42 | * @return Version& reference to current object 43 | */ 44 | Version &operator=(const Version &versionObject); 45 | 46 | /** 47 | * @brief Equal operator 48 | * 49 | * @param versionObject Version to compare with 50 | * @return bool True on equal, otherwise false 51 | */ 52 | bool operator==(const Version &versionObject) const; 53 | 54 | /** 55 | * @brief Non equal operator 56 | * 57 | * @param versionObject Version to compare with 58 | * @return bool True on non equal, otherwise false 59 | */ 60 | bool operator!=(const Version &versionObject) const; 61 | 62 | /** 63 | * @brief Get version information as string 64 | * 65 | * @return smos::smcore::SMString 66 | */ 67 | smos::smcore::SMString AsString(void) const; 68 | 69 | /** 70 | * @brief Set the Version object 71 | * 72 | * @param major Major version information 73 | * @param minor Minor version information 74 | * @param revision Revision version informationi 75 | */ 76 | void SetVersion(const short &major, const short &minor, const short &revision); 77 | }; 78 | } 79 | } 80 | 81 | ``` 82 | 83 | ### Usage 84 | 85 | ```c++ 86 | smos::smcore::Version verObjectSrc; 87 | smos::smcore::Version verObjectDst(verObjectSrc); 88 | smos::smcore::SMString versionSrc = verObjectSrc.AsString(); 89 | 90 | verObjectSrc.SetVersion(1, 2, 3); 91 | verObjectDst = verObjectSrc; 92 | ``` 93 | 94 | ## Possible issues 95 | -------------------------------------------------------------------------------- /playground/logging/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | project(logging LANGUAGES CXX) 4 | 5 | set(CMAKE_AUTOUIC ON) 6 | set(CMAKE_AUTOMOC ON) 7 | set(CMAKE_AUTORCC ON) 8 | 9 | set(CMAKE_CXX_STANDARD 17) 10 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 11 | 12 | find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core LinguistTools) 13 | find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core LinguistTools) 14 | 15 | set(TS_FILES logging_en_150.ts) 16 | 17 | add_executable(logging 18 | main.cpp 19 | logging.h 20 | logging.cpp 21 | ${TS_FILES} 22 | ) 23 | target_link_libraries(logging Qt${QT_VERSION_MAJOR}::Core) 24 | 25 | if(COMMAND qt_create_translation) 26 | qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) 27 | else() 28 | qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) 29 | endif() 30 | 31 | install(TARGETS logging 32 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) 33 | -------------------------------------------------------------------------------- /playground/logging/Logging_en_150.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /playground/logging/logging.cpp: -------------------------------------------------------------------------------- 1 | #include "logging.h" 2 | -------------------------------------------------------------------------------- /playground/logging/logging.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include -------------------------------------------------------------------------------- /playground/logging/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // #include "logging.h" 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | QCoreApplication a(argc, argv); 10 | 11 | QTranslator translator; 12 | const QStringList uiLanguages = QLocale::system().uiLanguages(); 13 | for (const QString &locale : uiLanguages) 14 | { 15 | const QString baseName = "logging_" + QLocale(locale).name(); 16 | if (translator.load(":/i18n/" + baseName)) 17 | { 18 | a.installTranslator(&translator); 19 | break; 20 | } 21 | } 22 | 23 | qDebug("Test!"); 24 | 25 | return a.exec(); 26 | } 27 | -------------------------------------------------------------------------------- /playground/readme.md: -------------------------------------------------------------------------------- 1 | # Playground 2 | 3 | In this directory you can find some simple projects (also to be opened in QT creator) for testing some features of QT. 4 | 5 | - To test/setup logging (logging) 6 | - To test/setup usage of resources (resource) 7 | -------------------------------------------------------------------------------- /playground/resource/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(resource VERSION 0.1 LANGUAGES CXX) 4 | 5 | set(CMAKE_AUTOUIC ON) 6 | set(CMAKE_AUTOMOC ON) 7 | set(CMAKE_AUTORCC ON) 8 | 9 | set(CMAKE_CXX_STANDARD 17) 10 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 11 | 12 | find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) 13 | find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) 14 | 15 | set(PROJECT_SOURCES 16 | main.cpp 17 | mainwindow.cpp 18 | mainwindow.h 19 | mainwindow.ui 20 | smcore.qrc 21 | ) 22 | 23 | qt_add_resources(${PROJECT_NAME} 24 | smcore.qrc 25 | ) 26 | 27 | if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) 28 | qt_add_executable(resource 29 | MANUAL_FINALIZATION 30 | ${PROJECT_SOURCES} 31 | ) 32 | 33 | # Define target properties for Android with Qt 6 as: 34 | # set_property(TARGET resource APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR 35 | # ${CMAKE_CURRENT_SOURCE_DIR}/android) 36 | # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation 37 | else() 38 | if(ANDROID) 39 | add_library(resource SHARED 40 | ${PROJECT_SOURCES} 41 | ) 42 | 43 | # Define properties for Android with Qt 5 after find_package() calls as: 44 | # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") 45 | else() 46 | add_executable(resource 47 | ${PROJECT_SOURCES} 48 | ) 49 | endif() 50 | endif() 51 | 52 | target_link_libraries(resource PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) 53 | 54 | set_target_properties(resource PROPERTIES 55 | MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com 56 | MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} 57 | MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} 58 | MACOSX_BUNDLE TRUE 59 | WIN32_EXECUTABLE TRUE 60 | ) 61 | 62 | install(TARGETS resource 63 | BUNDLE DESTINATION . 64 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) 65 | 66 | if(QT_VERSION_MAJOR EQUAL 6) 67 | qt_finalize_executable(resource) 68 | endif() 69 | -------------------------------------------------------------------------------- /playground/resource/SourceMonitorOS.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SourceMonitor/SourceMonitorOS/1586c61f730459ab47d7f08f2c29e90ed415ca04/playground/resource/SourceMonitorOS.ico -------------------------------------------------------------------------------- /playground/resource/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | MainWindow w; 9 | w.show(); 10 | w.setWindowIcon(QIcon(":/SourceMonitorOS.ico")); 11 | return a.exec(); 12 | } 13 | -------------------------------------------------------------------------------- /playground/resource/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "./ui_mainwindow.h" 3 | 4 | MainWindow::MainWindow(QWidget *parent) 5 | : QMainWindow(parent) 6 | , ui(new Ui::MainWindow) 7 | { 8 | ui->setupUi(this); 9 | } 10 | 11 | MainWindow::~MainWindow() 12 | { 13 | delete ui; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /playground/resource/mainwindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | QT_BEGIN_NAMESPACE 6 | namespace Ui { class MainWindow; } 7 | QT_END_NAMESPACE 8 | 9 | class MainWindow : public QMainWindow 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | MainWindow(QWidget *parent = nullptr); 15 | ~MainWindow(); 16 | 17 | private: 18 | Ui::MainWindow *ui; 19 | }; 20 | -------------------------------------------------------------------------------- /playground/resource/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /playground/resource/smcore.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | ./SourceMonitorOS.ico 4 | 5 | 6 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # SourceMonitorOS 2 | 3 | [Jim Wanner][wannerjim] retired from software development. This project aims to get the original SourceMonitor code of [Campwood Software LTD][campwoodsw] to become open source. 4 | 5 | ## Motivation 6 | 7 | Because of some licensed code and other issues a refactoring of the existing code base will be not done. Instead of this a re-write from scratch is aimed according to the functionality known from the original. 8 | 9 | _Getting there is half the fun. - Konfuzius_ 10 | 11 | _A journey of a thousand miles begins with a single step. - Laotse_ 12 | 13 | ## Definitions for environment 14 | 15 | - Programming language: [C++17][cpp17] 16 | - Build system: [CMake][cmake], minimum version 3.5 17 | - License: [MIT][licensemit] 18 | - Framework: [QT][qt] in version 6.2 LTS 19 | 20 | ### Compiling 21 | 22 | To compile the project the following prerequisites must be installed: 23 | 24 | - [CMake][cmake], minimum version 3.5 25 | - [QT][qt] in version 6.2 LTS 26 | 27 | A compiler should be installed during the installation of [QT][qt]. If you wish to use another compiler, you have to take care about this by yourself. 28 | 29 | Once the prerequisites are installed, you have to open the [CMakeLists.txt project][project_file] file of the root folder in [QT Creator][tool_qt_creator], select the kit of your choice and then press `Configure Project`. Then you can compile the code. 30 | 31 | ## Contribution 32 | 33 | This project is open source. Every kind of contribution is welcome. Usually by a fork and a pull request. The team will be happy about any kind of support. See here an incomplete list of possible areas you're able to support: 34 | 35 | - [![CPP](https://skillicons.dev/icons?i=cpp)](https://skillicons.dev) - [C++][cpp17], the basic programming language 36 | - [![CMake](https://skillicons.dev/icons?i=cmake)](https://skillicons.dev) - [CMake][cmake], the build system used 37 | - [![git](https://skillicons.dev/icons?i=git)](https://skillicons.dev) - [git][gitscm], the used code versioning system 38 | - [![GitHub](https://skillicons.dev/icons?i=github)](https://skillicons.dev) - [GitHub][github], the hoster of the project code 39 | - [![GitHubActions](https://skillicons.dev/icons?i=githubactions)](https://skillicons.dev) - [GitHubActions][githubactions], used for CI/CD processes and other automations 40 | - [![Markdown](https://skillicons.dev/icons?i=md)](https://skillicons.dev) - [Markdown][markdown], used for documentation, in [GitHub flavor][githubmarkdown] 41 | - [![QT](https://skillicons.dev/icons?i=qt)](https://skillicons.dev) - [QT][qt], the used framework 42 | 43 | ## Project folder organization 44 | 45 | Allthough there are CMake files existing up to know you need to run them using QT Creator. 46 | 47 | - In the folder [documentation][folder_documentation] you can find the documentation of SourceMonitorOS 48 | - In the folder [playground][folder_playground] you can find small programs for several tests 49 | - In the folder [smcli][folder_smcli] you can find the command line client of SourceMonitorOS 50 | - In the folder [smcore][folder_smcore] you can find the core functionality of SourceMonitorOS 51 | - In the folder [smgui][folder_smgui] you can find the UI of SourceMonitorOS 52 | - In the folder [smtest][folder_smtest] you can find the tests of at least the [smcore][folder_smcore]. 53 | 54 | [campwoodsw]: https://www.campwoodsw.com/sourcemonitor.html 55 | [cmake]: https://www.cmake.org 56 | [cpp17]: https://en.wikipedia.org/wiki/C%2B%2B17 57 | [folder_documentation]: ./documentation/readme.md 58 | [folder_playground]: ./playground/readme.md 59 | [folder_smcli]: ./smcli/readme.md 60 | [folder_smcore]: ./smcore/readme.md 61 | [folder_smgui]: ./smgui/readme.md 62 | [folder_smtest]: ./smtest/readme.md 63 | [github]: https://www.github.com 64 | [githubactions]: https://github.com/features/actions 65 | [githubmarkdown]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax 66 | [gitscm]: https://git-scm.com/ 67 | [licensemit]: https://opensource.org/licenses/MIT 68 | [markdown]: https://daringfireball.net/projects/markdown/ 69 | [project_file]: ./CMakeLists.txt 70 | [qt]: https://www.qt.io/ 71 | [tool_qt_creator]: https://www.qt.io/product/development-tools 72 | [wannerjim]: https://campwoodsw.com/emcomp/about-us/ 73 | -------------------------------------------------------------------------------- /smcli/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ******************************************************************************* 2 | # Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the "Software"), 6 | # to deal in the Software without restriction, including without limitation 7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | # and/or sell copies of the Software, and to permit persons to whom the 9 | # Software is furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | # DEALINGS IN THE SOFTWARE. 21 | # ******************************************************************************* 22 | 23 | cmake_minimum_required(VERSION 3.5) 24 | 25 | project(smcli LANGUAGES CXX VERSION 0.0.1 DESCRIPTION "SourceMonitor CLI") 26 | 27 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 28 | 29 | set(CMAKE_AUTOUIC ON) 30 | set(CMAKE_AUTOMOC ON) 31 | set(CMAKE_AUTORCC ON) 32 | 33 | set(CMAKE_CXX_STANDARD 17) 34 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 35 | 36 | find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core LinguistTools) 37 | find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core LinguistTools) 38 | 39 | set(SMCLI_TS_FILES 40 | smcli_en_150.ts 41 | ) 42 | 43 | add_executable(smcli 44 | main.cpp 45 | ${SMCLI_TS_FILES} 46 | ${SMCORE_INCLUDE} 47 | ) 48 | 49 | # Copy required files 50 | configure_file(./../LICENSE LICENSE COPYONLY) 51 | configure_file(./../smtest/testfiles/osm.smp osm.smp COPYONLY) 52 | 53 | target_compile_options(smcli PRIVATE 54 | $<$:/W4 /WX> 55 | $<$>:-Wall -Wextra -Wpedantic -Werror> 56 | ) 57 | 58 | target_link_libraries(smcli Qt${QT_VERSION_MAJOR}::Core smcore) 59 | 60 | if(COMMAND qt_create_translation) 61 | qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${SMCLI_TS_FILES}) 62 | endif() 63 | 64 | install(TARGETS smcli LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) 65 | 66 | qt_finalize_executable(smcli) 67 | -------------------------------------------------------------------------------- /smcli/main.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include "smpreader.h" 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | int main(int argc, char *argv[]) 35 | { 36 | QCoreApplication a(argc, argv); 37 | 38 | QTranslator translator; 39 | const QStringList uiLanguages = QLocale::system().uiLanguages(); 40 | for (const QString &locale : uiLanguages) 41 | { 42 | const QString baseName = "smcli_" + QLocale(locale).name(); 43 | if (translator.load(":/i18n/" + baseName)) 44 | { 45 | a.installTranslator(&translator); 46 | break; 47 | } 48 | } 49 | // smos::smcore::SMPReader smpReader; 50 | // if (!smpReader.Open("d:\\SourceMonitor\\SourceMonitorOS\\test2.smp")) 51 | // return 1; 52 | 53 | std::string workingdir_raw = std::filesystem::u8path(argv[0]).remove_filename().string(); 54 | QString workingdir = QString::fromStdString(workingdir_raw); 55 | 56 | // QStringList strList(); 57 | QDirIterator it(workingdir, QStringList() << "*.smp", QDir::Files, QDirIterator::Subdirectories); 58 | while (it.hasNext()) 59 | { 60 | QString filePath(it.next()); 61 | qDebug() << filePath; 62 | smos::smcore::SMPReader smpReader; 63 | if (!smpReader.Open(filePath.toStdString())) 64 | return 1; 65 | smos::smcore::Project project; 66 | if (!smpReader.Read(project)) 67 | return 1; 68 | } 69 | 70 | // smos::smcore::Project project; 71 | // if (!smpReader.Read(project)) 72 | // return 1; 73 | return 0; // a.exec(); 74 | } 75 | -------------------------------------------------------------------------------- /smcli/readme.md: -------------------------------------------------------------------------------- 1 | # smcli 2 | 3 | In this directory the command line client of SourceMonitorOS is located. 4 | 5 | - Influence the software via XML files 6 | - Settings 7 | - Options 8 | - Language 9 | - Logging 10 | - Project handling 11 | - Read project file 12 | - Write project file 13 | - Create checkpoints 14 | 15 | The functionality called is located in [smcore][smcore]. 16 | 17 | ## Technical information 18 | 19 | - The classes of `smcli` are prefixed with `sc` to avoid complications with the classes of `smcore` 20 | 21 | [smcore]: ./../smcore/readme.md 22 | -------------------------------------------------------------------------------- /smcli/smcli_en_150.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /smcore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ******************************************************************************* 2 | # Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the "Software"), 6 | # to deal in the Software without restriction, including without limitation 7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | # and/or sell copies of the Software, and to permit persons to whom the 9 | # Software is furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | # DEALINGS IN THE SOFTWARE. 21 | # ******************************************************************************* 22 | 23 | cmake_minimum_required(VERSION 3.5) 24 | 25 | project(smcore LANGUAGES CXX VERSION 0.0.1 DESCRIPTION "SourceMonitor Core Functionality") 26 | 27 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 28 | set(CMAKE_CXX_STANDARD 17) 29 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 30 | 31 | set(SMCORE_INCLUDE 32 | about.h 33 | archivereader.h 34 | checkpoint.h 35 | classinfo.h 36 | error.h 37 | factory.h 38 | language.h 39 | languages.h 40 | languagebase.h 41 | license.h 42 | optionflags.h 43 | options.h 44 | printvector.h 45 | project.h 46 | smcheckpointsreader.h 47 | smlanguagereader.h 48 | smpreader.h 49 | smstring.h 50 | subdirectorymode.h 51 | version.h 52 | ) 53 | 54 | set(SMCORE_BODY 55 | about.cpp 56 | archivereader.cpp 57 | checkpoint.cpp 58 | error.cpp 59 | factory.cpp 60 | language.cpp 61 | languages.cpp 62 | languagebase.cpp 63 | license.cpp 64 | options.cpp 65 | project.cpp 66 | smcheckpointsreader.cpp 67 | smlanguagereader.cpp 68 | smpreader.cpp 69 | smstring.cpp 70 | version.cpp 71 | ) 72 | 73 | add_library(smcore STATIC 74 | ${SMCORE_INCLUDE} 75 | ${SMCORE_BODY} 76 | ) 77 | 78 | target_compile_options(smcore PRIVATE 79 | $<$:/W4 /WX> 80 | $<$>:-Wall -Wextra -Wpedantic -Werror> 81 | ) 82 | 83 | target_link_libraries(smcore) 84 | 85 | target_compile_definitions(smcore PRIVATE SMCORE_LIBRARY) 86 | 87 | if(MSVC OR MINGW) 88 | target_compile_definitions(smcore PRIVATE _CRT_SECURE_NO_WARNINGS) 89 | endif() 90 | -------------------------------------------------------------------------------- /smcore/about.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "about.h" 24 | 25 | namespace smos 26 | { 27 | namespace smcore 28 | { 29 | //****************************************************************************** 30 | smos::smcore::SMString About::getAbout(void) 31 | { 32 | smos::smcore::SMString aboutText = R"~~~~(SourceMonitor Tracks Source Code Quality and Quantity 33 | Version [InsertBuildInformationHere] 34 | 35 | SourceMonitor Team 36 | http://www.github.com/SourceMonitor 37 | © SourceMonitor Team)~~~~"; 38 | return aboutText; 39 | } 40 | //****************************************************************************** 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /smcore/about.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include "smstring.h" 26 | 27 | namespace smos 28 | { 29 | namespace smcore 30 | { 31 | class About 32 | { 33 | public: 34 | /** 35 | * @brief Get the about text 36 | * 37 | * @return QString 38 | */ 39 | static smos::smcore::SMString getAbout(void); 40 | 41 | private: 42 | /** 43 | * @brief Hide constructor to avoid instances 44 | * 45 | */ 46 | About(void); 47 | 48 | /** 49 | * @brief Hide destructor to avoid instances 50 | * 51 | */ 52 | ~About(void); 53 | }; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /smcore/archivereader.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "archivereader.h" 24 | 25 | namespace smos 26 | { 27 | namespace smcore 28 | { 29 | //****************************************************************************** 30 | unsigned int ArchiveReader::ReadCount() 31 | { 32 | // reads the size of the container stored in the file 33 | std::uint16_t nCount = Read(); 34 | if (nCount != UINT16_MAX) 35 | return nCount; 36 | 37 | // stored size is 32 bits and we need to read it again 38 | std::uint32_t dwCount = Read(); 39 | return dwCount; 40 | } 41 | //****************************************************************************** 42 | unsigned int ArchiveReader::ReadStringLength() 43 | { 44 | // the logic of this function is copied from the CArchive class 45 | unsigned char byteLength = Read(); 46 | if (byteLength < 0xff) 47 | return byteLength; 48 | 49 | unsigned short shortLength = Read(); 50 | if (shortLength == 0xfffe) 51 | { 52 | // UNICODE string prefix (length will follow) 53 | return (unsigned int)-1; 54 | } 55 | else if (shortLength == UINT16_MAX) 56 | { 57 | // read DWORD of length 58 | unsigned long longLength = Read(); 59 | return (unsigned int)longLength; 60 | } 61 | else 62 | return shortLength; 63 | } 64 | //****************************************************************************** 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /smcore/checkpoint.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include "checkpoint.h" 26 | 27 | namespace smos 28 | { 29 | namespace smcore 30 | { 31 | //****************************************************************************** 32 | Checkpoint::Checkpoint(void) : m_version(), m_name("") 33 | { 34 | } 35 | //****************************************************************************** 36 | Checkpoint::~Checkpoint(void) 37 | { 38 | } 39 | //****************************************************************************** 40 | smos::smcore::Version Checkpoint::versionGet(void) 41 | { 42 | return this->m_version; 43 | } 44 | //****************************************************************************** 45 | void Checkpoint::versionSet(const smos::smcore::Version &version) 46 | { 47 | this->m_version = version; 48 | } 49 | //****************************************************************************** 50 | smos::smcore::SMString Checkpoint::checkpointNameGet(void) 51 | { 52 | return this->m_name; 53 | } 54 | //****************************************************************************** 55 | void Checkpoint::checkpointNameSet(const smos::smcore::SMString &checkpointName) 56 | { 57 | this->m_name = checkpointName; 58 | } 59 | //****************************************************************************** 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /smcore/checkpoint.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include "archivereader.h" 26 | #include "smstring.h" 27 | #include "version.h" 28 | 29 | namespace smos 30 | { 31 | namespace smcore 32 | { 33 | class Checkpoint 34 | { 35 | public: 36 | /** 37 | * @brief Default constructor 38 | * 39 | */ 40 | Checkpoint(void); 41 | 42 | /** 43 | * @brief Default destructor 44 | * 45 | */ 46 | ~Checkpoint(void); 47 | 48 | /** 49 | * @brief Get version information object 50 | * 51 | * @return smos::smcore::Version 52 | */ 53 | smos::smcore::Version versionGet(void); 54 | 55 | /** 56 | * @brief Set version information object 57 | * 58 | * @param version Version information object 59 | */ 60 | void versionSet(const smos::smcore::Version &version); 61 | 62 | /** 63 | * @brief Get name of checkpoint 64 | * 65 | * @return smos::smcore::SMString 66 | */ 67 | smos::smcore::SMString checkpointNameGet(void); 68 | 69 | /** 70 | * @brief Set name of checkpoint 71 | * 72 | * @param checkpointName 73 | */ 74 | void checkpointNameSet(const smos::smcore::SMString &checkpointName); 75 | 76 | protected: 77 | /** 78 | * @brief Version information of checkpoint 79 | * 80 | */ 81 | smos::smcore::Version m_version; 82 | 83 | /** 84 | * @brief Name of checkpoins 85 | */ 86 | smos::smcore::SMString m_name; 87 | }; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /smcore/classinfo.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | namespace smos 28 | { 29 | namespace smcore 30 | { 31 | struct ClassInfo 32 | { 33 | std::string m_name; 34 | }; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /smcore/error.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "error.h" 24 | 25 | namespace smos 26 | { 27 | namespace smcore 28 | { 29 | //****************************************************************************** 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /smcore/error.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include "smstring.h" 26 | 27 | // See error class in C++ with enum 28 | // https://stackoverflow.com/questions/21295935/can-a-c-enum-class-have-methods 29 | // And how to convert enum to string 30 | // https://stackoverflow.com/questions/28828957/enum-to-string-in-modern-c11-c14-c17-and-future-c20 31 | 32 | namespace smos 33 | { 34 | namespace smcore 35 | { 36 | class Error 37 | { 38 | public: 39 | enum ErrorCode 40 | { 41 | ERR_NONE = 0, 42 | ERR_PROJECT_ALREADY_EXIST, 43 | ERR_PROJECT_DOES_NOT_EXIST, 44 | ERR_PROJECT_INVALID, 45 | }; 46 | }; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /smcore/factory.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "factory.h" 24 | 25 | #include 26 | #include 27 | 28 | namespace smos 29 | { 30 | namespace smcore 31 | { 32 | //****************************************************************************** 33 | Options *Factory::getOptions(smos::smcore::SMString optionsfile) 34 | { 35 | static std::unordered_map programOptions; 36 | if (programOptions.find(optionsfile) == programOptions.end()) 37 | { 38 | programOptions.insert(std::make_pair(optionsfile, new Options(optionsfile))); 39 | } 40 | return programOptions[optionsfile]; 41 | } 42 | //****************************************************************************** 43 | Version *Factory::getVersion(void) 44 | { 45 | static Version smVersion; 46 | return &smVersion; 47 | } 48 | //****************************************************************************** 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /smcore/factory.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | #include "options.h" 28 | #include "smstring.h" 29 | #include "version.h" 30 | 31 | namespace smos 32 | { 33 | namespace smcore 34 | { 35 | /** 36 | * @brief Factory class to retrieve specific objects from 37 | */ 38 | class Factory 39 | { 40 | public: 41 | /** 42 | * @brief Get the options object 43 | * 44 | * @param optionsfile Name of options file 45 | * 46 | * @return Options* Pointer to options object 47 | */ 48 | static Options *getOptions(smos::smcore::SMString optionsfile); 49 | 50 | /** 51 | * @brief Get the version object 52 | * 53 | * @return Version* Pointer to version object 54 | */ 55 | static Version *getVersion(void); 56 | }; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /smcore/language.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include "language.h" 26 | 27 | namespace smos 28 | { 29 | namespace smcore 30 | { 31 | //****************************************************************************** 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /smcore/language.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | namespace smos 26 | { 27 | namespace smcore 28 | { 29 | class Language 30 | { 31 | public: 32 | virtual Language *MakeNew() const { return 0; } // no constructor - create w/ factory 33 | virtual ~Language() { ; } 34 | }; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /smcore/languagebase.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include "languagebase.h" 26 | 27 | namespace smos 28 | { 29 | namespace smcore 30 | { 31 | //****************************************************************************** 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /smcore/languagebase.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include "languages.h" 26 | 27 | namespace smos 28 | { 29 | namespace smcore 30 | { 31 | class LanguageBase 32 | { 33 | }; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /smcore/languages.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include "languages.h" 26 | 27 | namespace smos 28 | { 29 | namespace smcore 30 | { 31 | //****************************************************************************** 32 | const char *Languages::languageStrings[] = { 33 | "SMC", 34 | "SMCpp", 35 | "SMCs", 36 | "SMDELPHI", 37 | "SMHTML", 38 | "SMJava", 39 | "SMVBNET", 40 | "SMVISUALBASIC"}; 41 | //****************************************************************************** 42 | const char *Languages::getLanguageString(smos::smcore::Languages::Type lang) 43 | { 44 | return smos::smcore::Languages::languageStrings[static_cast(lang)]; 45 | } 46 | //****************************************************************************** 47 | bool Languages::caseInsCharCompareN(char a, char b) 48 | { 49 | char x = a; 50 | char y = b; 51 | return (toupper(x) == toupper(y)); 52 | } 53 | //****************************************************************************** 54 | bool Languages::isClassOfType(smos::smcore::SMString classString, smos::smcore::Languages::Type classType) 55 | { 56 | smos::smcore::SMString workClass = classString; 57 | smos::smcore::SMString workType = smos::smcore::Languages::getLanguageString(classType); 58 | 59 | bool result = ((workClass.size() == workType.size()) && 60 | equal(workClass.begin(), workClass.end(), workType.begin(), Languages::caseInsCharCompareN)); 61 | return result; 62 | } 63 | //****************************************************************************** 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /smcore/languages.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | #include "smstring.h" 27 | 28 | namespace smos 29 | { 30 | namespace smcore 31 | { 32 | class Languages 33 | { 34 | public: 35 | /** 36 | * @brief Definition of enums according to the strings in the body 37 | * 38 | */ 39 | enum class Type 40 | { 41 | SMC = 0, 42 | SMCPP = 1, 43 | SMCS = 2, 44 | SMDELPHI = 3, 45 | SMHTML = 4, 46 | SMJAVA = 5, 47 | SMVBNET = 6, 48 | SMVISUALBASIC = 7 49 | }; 50 | 51 | /** 52 | * @brief Convert the enum to a char* as in the array languageStrings 53 | * @see languageStrings 54 | * 55 | * @param smos::smcore::Languages::Type Kind of language to get string for 56 | * @return const char* Language enum as string 57 | */ 58 | static const char *getLanguageString(smos::smcore::Languages::Type lang); 59 | 60 | /** 61 | * @brief Validate the given string if it matches the given class type (enum) 62 | * @see https://www.oreilly.com/library/view/c-cookbook/0596007612/ch04s14.html 63 | * @param classString Class as string like SMCpp 64 | * @param classType Class as enum type 65 | * @return bool Result of case insensitive comparison 66 | */ 67 | static bool isClassOfType(smos::smcore::SMString classString, smos::smcore::Languages::Type classType); 68 | 69 | /** 70 | * @brief Array of language strings, order equal to the enum here 71 | */ 72 | static const char *languageStrings[]; 73 | 74 | protected: 75 | /** 76 | * @brief Function to compare two characters case insensitive 77 | * @see https://www.oreilly.com/library/view/c-cookbook/0596007612/ch04s14.html 78 | * @param a Left character 79 | * @param b Right character 80 | * @return bool Result of case insensitive comparison 81 | */ 82 | static bool Languages::caseInsCharCompareN(char a, char b); 83 | }; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /smcore/license.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "license.h" 24 | 25 | namespace smos 26 | { 27 | namespace smcore 28 | { 29 | //****************************************************************************** 30 | smos::smcore::SMString License::getLicense(void) 31 | { 32 | smos::smcore::SMString licenseText = R"~~~~(MIT License 33 | 34 | Copyright (C) 1999 by Jim Wanner and the SourceMonitor team 35 | 36 | Permission is hereby granted, free of charge, to any person obtaining a 37 | copy of this software and associated documentation files (the "Software"), 38 | to deal in the Software without restriction, including without limitation 39 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 40 | and/or sell copies of the Software, and to permit persons to whom the 41 | Software is furnished to do so, subject to the following conditions: 42 | 43 | The above copyright notice and this permission notice shall be included 44 | in all copies or substantial portions of the Software. 45 | 46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 47 | KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 48 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 49 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 50 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 51 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 52 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 53 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 54 | DEALINGS IN THE SOFTWARE. 55 | )~~~~"; 56 | return licenseText; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /smcore/license.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include "smstring.h" 26 | 27 | namespace smos 28 | { 29 | namespace smcore 30 | { 31 | class License 32 | { 33 | public: 34 | /** 35 | * @brief Get the license text 36 | * 37 | * @return smos::smcore::SMSring 38 | */ 39 | static smos::smcore::SMString getLicense(void); 40 | 41 | private: 42 | /** 43 | * @brief Hide constructor to avoid instances 44 | * 45 | */ 46 | License(void){}; 47 | 48 | /** 49 | * @brief Hide destructor to avoid instances 50 | * 51 | */ 52 | ~License(void){}; 53 | }; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /smcore/optionflags.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | namespace smos 26 | { 27 | namespace smcore 28 | { 29 | enum class OptionFlags 30 | { 31 | None = 0, 32 | IgnoreCommentsOnly = 1, 33 | IgnoreDOCCommentsOnly = 2, 34 | IgnoreAllComments = 3, 35 | ModifiedComplexity = 4, 36 | IncludeSubdirectoriesFlag = 8, 37 | FilesFromXmlFile = 16, // when set, m_sDirectory contains file path DIRECTORY_SEPARATOR XPath spec 38 | IgnoreBlankLines = 32, 39 | }; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /smcore/options.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "options.h" 24 | 25 | namespace smos 26 | { 27 | namespace smcore 28 | { 29 | //****************************************************************************** 30 | Options::Options(smos::smcore::SMString optionsfile) : m_optionsFile(optionsfile) 31 | { 32 | } 33 | //****************************************************************************** 34 | Options::~Options(void) 35 | { 36 | } 37 | //****************************************************************************** 38 | smos::smcore::SMString Options::codeEditorGet(void) 39 | { 40 | return this->m_general_CodeEditor; 41 | } 42 | //****************************************************************************** 43 | void Options::codeEditorSet(smos::smcore::SMString codeeditor) 44 | { 45 | this->m_general_CodeEditor = codeeditor; 46 | } 47 | //****************************************************************************** 48 | smos::smcore::SMString Options::logfileNameGet(void) 49 | { 50 | return this->m_logfileName; 51 | } 52 | //****************************************************************************** 53 | void Options::logfileNameSet(smos::smcore::SMString logfileName) 54 | { 55 | this->m_logfileName = logfileName; 56 | } 57 | //****************************************************************************** 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /smcore/options.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | // Think about this: 24 | // http://katecpp.github.io/qsettings/ 25 | 26 | #pragma once 27 | 28 | #include 29 | 30 | #include "smstring.h" 31 | 32 | namespace smos 33 | { 34 | namespace smcore 35 | { 36 | class Options 37 | { 38 | public: 39 | /** 40 | * @brief Default constructor 41 | * 42 | * @param optionsfile Name of options file 43 | */ 44 | Options(smos::smcore::SMString optionsfile); 45 | 46 | /** 47 | * @brief Default destructor 48 | * 49 | */ 50 | ~Options(void); 51 | 52 | /** 53 | * @brief Get the editor call with filename templated 54 | * 55 | * @return smos::smcore::SMSring 56 | */ 57 | smos::smcore::SMString codeEditorGet(void); 58 | 59 | /** 60 | * @brief Get the editor call with filename templated 61 | * 62 | * @param codeeditor smos::smcore::SMSring 63 | */ 64 | void codeEditorSet(smos::smcore::SMString codeeditor); 65 | 66 | /** 67 | * @brief Get the absolute path to the logfile 68 | * 69 | * @return smos::smcore::SMSring The absolute path to the logfile 70 | */ 71 | smos::smcore::SMString logfileNameGet(void); 72 | 73 | /** 74 | * @brief Set the name (and path) of the logfile 75 | * 76 | * @param logfileName Name (and path) of the logfile to use 77 | */ 78 | void logfileNameSet(smos::smcore::SMString logfileName); 79 | 80 | protected: 81 | /** 82 | * @brief Absolute path to editor for code files 83 | */ 84 | smos::smcore::SMString m_general_CodeEditor = "${filename}"; 85 | 86 | /** 87 | * @brief Name of used ini file 88 | */ 89 | smos::smcore::SMString m_logfileName; 90 | 91 | /** 92 | * @brief Name of options file 93 | */ 94 | smos::smcore::SMString m_optionsFile; 95 | }; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /smcore/printvector.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace smos 30 | { 31 | namespace smcore 32 | { 33 | template 34 | void printVector(const std::vector &vec, std::string sep = " ") 35 | { 36 | for (auto elem : vec) 37 | { 38 | std::cout << elem << sep; 39 | } 40 | std::cout << std::endl; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /smcore/readme.md: -------------------------------------------------------------------------------- 1 | # smcore 2 | 3 | In this directory the core functionality of SourceMonitorOS is located. 4 | 5 | - Influence the software 6 | - Settings 7 | - Options 8 | - Language 9 | - Logging 10 | - Project handling 11 | - Read project file 12 | - Write project file 13 | - Create checkpoints 14 | - Plugin system 15 | - Each language should be a dynamic library. Just drop the file to the SourceMonitor directory and it should work. 16 | - Each dynamic library must satisfy an interface for data exchange. 17 | 18 | See how this is used in [smgui][smgui] and [smcli][smcli]. The corresponding tests are located in [smtest][smtest]. 19 | 20 | ## Technical information 21 | 22 | - `smcore` is a designed as a library which is statically linked to [smgui][smgui], [smcli][smcli] and [smtest][smtest]. 23 | - Each class is named without any prefix. 24 | - `Project` class will be serialized, see [here][serialization] for details 25 | 26 | [smcli]: ./../smcli/readme.md 27 | [smgui]: ./../smgui/readme.md 28 | [smtest]: ./../smtest/readme.md 29 | [serialization]: https://stackoverflow.com/questions/37038909/c-read-write-class-from-to-binary-file 30 | -------------------------------------------------------------------------------- /smcore/smcheckpointsreader.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include "smcheckpointsreader.h" 26 | 27 | #include 28 | 29 | #include "checkpoint.h" 30 | #include "smlanguagereader.h" 31 | #include "version.h" 32 | 33 | namespace smos 34 | { 35 | namespace smcore 36 | { 37 | //****************************************************************************** 38 | void SMCheckpointsReader::Read() 39 | { 40 | unsigned int sizeCheckpoints = m_archiveReader.ReadCount(); 41 | std::cout << "sizeCheckpoints: " << sizeCheckpoints << std::endl; 42 | for (unsigned int i = 0; i < sizeCheckpoints; i++) 43 | { 44 | smos::smcore::Checkpoint curCheckpoint = smos::smcore::Checkpoint(); 45 | Version versionCheckpoint = m_archiveReader.Read(); 46 | std::cout << "Checkpoint version: " << versionCheckpoint.AsString() << std::endl; 47 | curCheckpoint.versionSet(versionCheckpoint); 48 | 49 | // ar >> m_sName >> m_oDate >> m_fUseModifiedComplexity >> m_poLanguage; 50 | std::string nameSMCheckpoint = m_archiveReader.Read(); 51 | std::cout << "nameSMCheckpoint: " << nameSMCheckpoint << std::endl; 52 | curCheckpoint.checkpointNameSet(nameSMCheckpoint); 53 | 54 | std::time_t t64_checkpointSMCheckpoint = m_archiveReader.Read(); 55 | std::cout << "Checkpoint time: " << t64_checkpointSMCheckpoint << std::endl; 56 | 57 | std::int32_t m_fUseModifiedComplexity = m_archiveReader.Read(); 58 | std::cout << "m_fUseModifiedComplexity: " << m_fUseModifiedComplexity << std::endl; 59 | 60 | std::cout << "read SMLanguage" << std::endl; 61 | SMLanguageReader languageReader(m_archiveReader); 62 | languageReader.Read(); 63 | 64 | if (versionCheckpoint >= Version(3, 1)) 65 | { 66 | std::string m_sBaseDirectory = m_archiveReader.Read(); 67 | std::cout << "m_sBaseDirectory: " << m_sBaseDirectory << std::endl; 68 | } 69 | 70 | // if (!m_oVersion.IsOKVersion(2, 0)) 71 | if (!(versionCheckpoint >= Version(2, 0))) 72 | { 73 | // m_poLanguage->Serialize(ar); // include redundant copy for older versions only 74 | languageReader.Read(); 75 | } 76 | 77 | unsigned int m_iFileCount = m_archiveReader.ReadCount(); 78 | std::cout << "m_iFileCount: " << m_iFileCount << std::endl; 79 | // m_oFiles.Serialize(ar); 80 | 81 | for (unsigned int f = 0; f < m_iFileCount; f++) 82 | { 83 | // void SMFile::Serialize(CArchive &ar) 84 | std::string m_sPathname = m_archiveReader.Read(); 85 | std::cout << "m_sPathname: " << m_sPathname << std::endl; 86 | std::cout << "read SMLanguage" << std::endl; 87 | SMLanguageReader languageReaderFile(m_archiveReader); 88 | languageReaderFile.Read(); 89 | } 90 | } 91 | } 92 | //****************************************************************************** 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /smcore/smcheckpointsreader.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include "archivereader.h" 26 | 27 | namespace smos 28 | { 29 | namespace smcore 30 | { 31 | class SMCheckpointsReader 32 | { 33 | public: 34 | SMCheckpointsReader(ArchiveReader &archiveReader) : m_archiveReader(archiveReader){}; 35 | void Read(); 36 | 37 | private: 38 | ArchiveReader &m_archiveReader; 39 | }; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /smcore/smlanguagereader.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include "smlanguagereader.h" 26 | #include "languages.h" 27 | 28 | #include 29 | #include 30 | 31 | #include "classinfo.h" 32 | #include "printvector.h" 33 | 34 | namespace smos 35 | { 36 | namespace smcore 37 | { 38 | //****************************************************************************** 39 | void SMLanguageReader::Read() 40 | { 41 | ClassInfo classInfo = m_archiveReader.Read(); 42 | std::cout << "class name: " << classInfo.m_name << std::endl; 43 | if (classInfo.m_name.empty()) 44 | return; 45 | 46 | if (Languages::isClassOfType(classInfo.m_name, smos::smcore::Languages::Type::SMCPP) || 47 | Languages::isClassOfType(classInfo.m_name, smos::smcore::Languages::Type::SMCS) || 48 | Languages::isClassOfType(classInfo.m_name, smos::smcore::Languages::Type::SMJAVA) || 49 | Languages::isClassOfType(classInfo.m_name, smos::smcore::Languages::Type::SMVBNET)) 50 | { 51 | std::vector m_saComplexMetrics = m_archiveReader.Read>(); 52 | std::cout << "m_saComplexMetrics: size = " << m_saComplexMetrics.size() << " skip" << std::endl; 53 | 54 | std::vector m_iCounts = m_archiveReader.Read>(); 55 | std::cout << "m_iCounts: size = " << m_iCounts.size() << " elements: " << std::endl; 56 | printVector(m_iCounts); 57 | 58 | std::map m_oClassList = m_archiveReader.Read>(); 59 | std::cout << "m_oClassList: size = " << m_oClassList.size() << " elements: " << std::endl; 60 | } 61 | else if (Languages::isClassOfType(classInfo.m_name, smos::smcore::Languages::Type::SMC)) 62 | { 63 | std::vector m_saComplexMetrics = m_archiveReader.Read>(); 64 | std::cout << "m_saComplexMetrics: size = " << m_saComplexMetrics.size() << " skip" << std::endl; 65 | 66 | std::vector m_iCounts = m_archiveReader.Read>(); 67 | std::cout << "m_iCounts: size = " << m_iCounts.size() << " elements: " << std::endl; 68 | printVector(m_iCounts); 69 | 70 | // m_oFunctionList.Serialize(ar); 71 | std::map m_oFunctionList = m_archiveReader.Read>(); 72 | std::cout << "m_oFunctionList: size = " << m_oFunctionList.size() << " elements: " << std::endl; 73 | } 74 | else if (Languages::isClassOfType(classInfo.m_name, smos::smcore::Languages::Type::SMDELPHI)) 75 | { 76 | std::string m_sSubroutineName = m_archiveReader.Read(); 77 | std::cout << "m_sSubroutineName: " << m_sSubroutineName << std::endl; 78 | 79 | std::vector m_saComplexMetrics = m_archiveReader.Read>(); 80 | std::cout << "m_saComplexMetrics: size = " << m_saComplexMetrics.size() << " skip" << std::endl; 81 | 82 | std::vector m_iCounts = m_archiveReader.Read>(); 83 | std::cout << "m_iCounts: size = " << m_iCounts.size() << " elements: " << std::endl; 84 | printVector(m_iCounts); 85 | 86 | std::map m_oClassList = m_archiveReader.Read>(); 87 | std::cout << "m_oClassList: size = " << m_oClassList.size() << " elements: " << std::endl; 88 | } 89 | else if (Languages::isClassOfType(classInfo.m_name, smos::smcore::Languages::Type::SMHTML)) 90 | { 91 | std::vector m_saComplexMetrics = m_archiveReader.Read>(); 92 | std::cout << "m_saComplexMetrics: size = " << m_saComplexMetrics.size() << " skip" << std::endl; 93 | 94 | std::vector m_iCounts = m_archiveReader.Read>(); 95 | std::cout << "m_iCounts: size = " << m_iCounts.size() << " elements: " << std::endl; 96 | printVector(m_iCounts); 97 | } 98 | else if (Languages::isClassOfType(classInfo.m_name, smos::smcore::Languages::Type::SMVISUALBASIC)) 99 | { 100 | std::string m_sSubroutineName = m_archiveReader.Read(); 101 | std::cout << "m_sSubroutineName: " << m_sSubroutineName << std::endl; 102 | 103 | std::int32_t m_iSubroutineStatements = m_archiveReader.Read(); 104 | std::cout << "m_iSubroutineStatements: " << m_iSubroutineStatements << std::endl; 105 | 106 | std::vector m_saComplexMetrics = m_archiveReader.Read>(); 107 | std::cout << "m_saComplexMetrics: size = " << m_saComplexMetrics.size() << " skip" << std::endl; 108 | 109 | std::vector m_iCounts = m_archiveReader.Read>(); 110 | std::cout << "m_iCounts: size = " << m_iCounts.size() << " elements: " << std::endl; 111 | printVector(m_iCounts); 112 | } 113 | } 114 | //****************************************************************************** 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /smcore/smlanguagereader.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include "archivereader.h" 26 | #include "languages.h" 27 | 28 | namespace smos 29 | { 30 | namespace smcore 31 | { 32 | class SMLanguageReader 33 | { 34 | public: 35 | SMLanguageReader(ArchiveReader &archiveReader) : m_archiveReader(archiveReader) {} 36 | void Read(); 37 | 38 | private: 39 | ArchiveReader &m_archiveReader; 40 | }; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /smcore/smpreader.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "smpreader.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "archivereader.h" 31 | #include "classinfo.h" 32 | #include "smcheckpointsreader.h" 33 | #include "smlanguagereader.h" 34 | #include "version.h" 35 | 36 | namespace smos 37 | { 38 | namespace smcore 39 | { 40 | //****************************************************************************** 41 | SMPReader::~SMPReader() 42 | { 43 | if (m_stream.is_open()) 44 | m_stream.close(); 45 | } 46 | //****************************************************************************** 47 | bool SMPReader::Open(std::filesystem::path path) 48 | { 49 | m_stream.exceptions(std::ifstream::failbit); 50 | m_stream.open(path, std::ios_base::in | std::ios_base::binary); 51 | return m_stream.is_open(); 52 | } 53 | //****************************************************************************** 54 | bool SMPReader::Read(Project &project) 55 | { 56 | try 57 | { 58 | ArchiveReader archiveReader(m_stream); 59 | 60 | Version versionProject = archiveReader.Read(); 61 | std::cout << "Version: " << versionProject.AsString() << std::endl; 62 | 63 | std::string name = archiveReader.Read(); 64 | std::cout << "m_sName: " << name << std::endl; 65 | project.setProjectName(name); 66 | 67 | std::int32_t includeSubdirectories = archiveReader.Read(); 68 | std::cout << "m_fIncludeSubdirectories: " << includeSubdirectories << std::endl; 69 | project.setIncludeSubdirectories(static_cast(includeSubdirectories)); 70 | 71 | std::cout << "read SMLanguage" << std::endl; 72 | SMLanguageReader languageReader(archiveReader); 73 | languageReader.Read(); 74 | 75 | if (versionProject >= Version(1, 2)) 76 | { 77 | std::string m_sDirectory = archiveReader.Read(); 78 | std::cout << "m_sDirectory: " << m_sDirectory << std::endl; 79 | project.setSourcePath(m_sDirectory); 80 | } 81 | 82 | if (versionProject >= Version(2, 0)) 83 | { 84 | std::int32_t m_eOptionFlags = archiveReader.Read(); 85 | std::cout << "m_eOptionFlags: " << m_eOptionFlags << std::endl; 86 | project.SetOptionFlags(m_eOptionFlags); 87 | } 88 | 89 | if (!(versionProject >= Version(2, 0))) 90 | { 91 | languageReader.Read(); 92 | } 93 | 94 | SMCheckpointsReader checkpointsReader(archiveReader); 95 | checkpointsReader.Read(); 96 | 97 | m_stream.exceptions(std::ifstream::goodbit); 98 | char c; 99 | while (m_stream.get(c)) // checking if we missed any data, only for debug 100 | { 101 | // assert(0); 102 | std::cout << c; 103 | } 104 | } 105 | catch (const std::ios_base::failure &fail) 106 | { 107 | std::cout << fail.what() << std::endl; 108 | return false; 109 | } 110 | catch (...) 111 | { 112 | return false; 113 | } 114 | return true; 115 | } 116 | //****************************************************************************** 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /smcore/smpreader.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | #include 27 | 28 | #include "project.h" 29 | 30 | namespace smos 31 | { 32 | namespace smcore 33 | { 34 | class SMPReader 35 | { 36 | public: 37 | SMPReader() = default; 38 | ~SMPReader(); 39 | bool Open(std::filesystem::path path); 40 | bool Read(Project &project); 41 | 42 | protected: 43 | std::ifstream m_stream; 44 | }; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /smcore/smstring.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "smstring.h" 24 | 25 | namespace smos 26 | { 27 | namespace smcore 28 | { 29 | //****************************************************************************** 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /smcore/smstring.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | namespace smos 28 | { 29 | namespace smcore 30 | { 31 | //****************************************************************************** 32 | /** 33 | * @brief Convenience typedef 34 | * 35 | * @attention std::string is used because of ANTLR will use std::string 36 | */ 37 | typedef std::string SMString; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /smcore/subdirectorymode.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | namespace smos 28 | { 29 | namespace smcore 30 | { 31 | enum class SubdirectoryMode 32 | { 33 | AllSubs = 0, 34 | SelectedSubs = 1, 35 | NoSubs = 2 36 | }; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /smcore/version.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "version.h" 24 | 25 | #include 26 | 27 | namespace smos 28 | { 29 | namespace smcore 30 | { 31 | //****************************************************************************** 32 | Version::Version(void) : Version(0, 0, 0, 0) 33 | { 34 | } 35 | //****************************************************************************** 36 | Version::~Version(void) 37 | { 38 | } 39 | //****************************************************************************** 40 | Version::Version(short major, short minor, short revision, std::time_t time) 41 | : m_major(major), m_minor(minor), m_revision(revision), m_time(time) 42 | { 43 | } 44 | //****************************************************************************** 45 | Version::Version(const Version &versionObject) 46 | { 47 | this->m_major = versionObject.m_major; 48 | this->m_minor = versionObject.m_minor; 49 | this->m_revision = versionObject.m_revision; 50 | } 51 | //****************************************************************************** 52 | smos::smcore::SMString Version::AsString(void) const 53 | { 54 | std::stringstream os; 55 | os << this->m_major << "." << this->m_minor << "." << this->m_revision; 56 | 57 | smos::smcore::SMString result = os.str(); 58 | return result; 59 | } 60 | //****************************************************************************** 61 | bool Version::operator!=(const Version &versionObject) const 62 | { 63 | bool result = !(*this == versionObject); 64 | return result; 65 | } 66 | //****************************************************************************** 67 | std::ostream &operator<<(std::ostream &os, const Version &obj) 68 | { 69 | os << obj.m_major; 70 | os << obj.m_minor; 71 | os << obj.m_revision; 72 | return os; 73 | } 74 | //****************************************************************************** 75 | Version &Version::operator=(const Version &versionObject) 76 | { 77 | if (&versionObject != this) 78 | { 79 | this->m_major = versionObject.m_major; 80 | this->m_minor = versionObject.m_minor; 81 | this->m_revision = versionObject.m_revision; 82 | } 83 | return *this; 84 | } 85 | //****************************************************************************** 86 | bool Version::operator==(const Version &versionObject) const 87 | { 88 | if (&versionObject == this) 89 | { 90 | return true; 91 | } 92 | bool result = (this->m_major == versionObject.m_major) && (this->m_minor == versionObject.m_minor) && (this->m_revision == versionObject.m_revision); 93 | return result; 94 | } 95 | //****************************************************************************** 96 | bool Version::operator>=(const Version &otherVersion) const 97 | { 98 | bool result = (m_major > otherVersion.m_major) || (m_major == otherVersion.m_major && m_minor > otherVersion.m_minor) || (m_major == otherVersion.m_major && m_minor == otherVersion.m_minor && m_revision > otherVersion.m_revision) || (m_major == otherVersion.m_major && m_minor == otherVersion.m_minor && m_revision == otherVersion.m_revision); 99 | return result; 100 | } 101 | //****************************************************************************** 102 | std::istream &operator>>(std::istream &is, Version &obj) 103 | { 104 | is >> obj.m_major; 105 | is >> obj.m_minor; 106 | is >> obj.m_revision; 107 | return is; 108 | } 109 | //****************************************************************************** 110 | void Version::SetVersion(const uint16_t major, const uint16_t minor, const uint16_t revision) 111 | { 112 | this->m_major = major; 113 | this->m_minor = minor; 114 | this->m_revision = revision; 115 | } 116 | //****************************************************************************** 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /smcore/version.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "smstring.h" 31 | 32 | namespace smos 33 | { 34 | namespace smcore 35 | { 36 | class Version 37 | { 38 | public: 39 | /** 40 | * @brief Default constructor 41 | */ 42 | Version(void); 43 | 44 | /** 45 | * @brief Default destructor 46 | */ 47 | ~Version(void); 48 | 49 | /** 50 | * @brief Constructor 51 | */ 52 | Version(short major, short minor, short revision = 0, std::time_t time = 0); 53 | 54 | /** 55 | * @brief Copy constructor 56 | * 57 | * @param versionObject Version to copy data from 58 | */ 59 | Version(const Version &versionObject); 60 | 61 | /** 62 | * @brief Get version information as string 63 | * 64 | * @return smos::smcore::SMString 65 | */ 66 | smos::smcore::SMString AsString(void) const; 67 | 68 | /** 69 | * @brief Non equal operator 70 | * 71 | * @param versionObject Version to compare with 72 | * @return bool True on non equal, otherwise false 73 | */ 74 | bool operator!=(const Version &versionObject) const; 75 | 76 | /** 77 | * @brief Assignment operator 78 | * 79 | * @param versionObject 80 | * @return Version& reference to current object 81 | */ 82 | Version &operator=(const Version &versionObject); 83 | 84 | /** 85 | * @brief Equal operator 86 | * 87 | * @param versionObject Version to compare with 88 | * @return bool True on equal, otherwise false 89 | */ 90 | bool operator==(const Version &versionObject) const; 91 | 92 | /** 93 | * @brief Object comparison greater than 94 | * 95 | * @param otherVersion Version to compare with 96 | * @return bool True on equal, otherwise false 97 | */ 98 | bool operator>=(const Version &otherVersion) const; 99 | 100 | /** 101 | * @brief Set the Version object 102 | * 103 | * @param major Major version information 104 | * @param minor Minor version information 105 | * @param revision Revision version informationi 106 | */ 107 | void SetVersion(const uint16_t major, const uint16_t minor, const uint16_t revision); 108 | 109 | /** 110 | * @brief Enable writing to stream 111 | * 112 | * @param os Outputstream to write to 113 | * @param obj Version object to write to stream 114 | * 115 | * @return std::ostream& 116 | */ 117 | friend std::ostream &operator<<(std::ostream &os, const Version &obj); 118 | 119 | /** 120 | * @brief Enable reading from stream 121 | * 122 | * @param is Inputstream to read from 123 | * @param obj Version object to read from stream 124 | * 125 | * @return std::istream& 126 | */ 127 | friend std::istream &operator>>(std::istream &is, Version &obj); 128 | 129 | private: 130 | /** 131 | * @brief Major version number 132 | */ 133 | uint16_t m_major; 134 | /** 135 | * @brief Minor version number 136 | */ 137 | uint16_t m_minor; 138 | /** 139 | * @brief Revision version number 140 | */ 141 | uint16_t m_revision; 142 | /** 143 | * @brief Timestamp 144 | */ 145 | std::time_t m_time; 146 | }; 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /smgui/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ******************************************************************************* 2 | # Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the "Software"), 6 | # to deal in the Software without restriction, including without limitation 7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | # and/or sell copies of the Software, and to permit persons to whom the 9 | # Software is furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | # DEALINGS IN THE SOFTWARE. 21 | # ******************************************************************************* 22 | 23 | cmake_minimum_required(VERSION 3.5) 24 | 25 | project(smgui LANGUAGES CXX VERSION 0.0.1 DESCRIPTION "SourceMonitor UI") 26 | 27 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 28 | 29 | set(CMAKE_AUTOUIC ON) 30 | set(CMAKE_AUTOMOC ON) 31 | set(CMAKE_AUTORCC ON) 32 | 33 | set(CMAKE_CXX_STANDARD 17) 34 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 35 | 36 | find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools) 37 | find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools) 38 | 39 | set(SMGUI_TS_FILES 40 | sggui_en_150.ts 41 | ) 42 | 43 | set(SMGUI_UI_DEFINITIONS 44 | sggui.ui 45 | sgoptions.ui 46 | ) 47 | 48 | set(SMGUI_INCLUDE 49 | sggui.h 50 | sgoptions.h 51 | ) 52 | 53 | set(PROJECT_SOURCES 54 | main.cpp 55 | sggui.cpp 56 | sgoptions.cpp 57 | ${SMGUI_UI_DEFINITIONS} 58 | ${SMGUI_TS_FILES} 59 | ${SMGUI_INCLUDE} 60 | ${SMCORE_INCLUDE} 61 | ) 62 | 63 | qt_add_executable(smgui 64 | MANUAL_FINALIZATION 65 | ${PROJECT_SOURCES} 66 | ) 67 | 68 | target_compile_options(smgui PRIVATE 69 | $<$:/W4 /WX> 70 | $<$>:-Wall -Wextra -Wpedantic -Werror> 71 | ) 72 | 73 | qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${SMCORE_TS_FILES}) 74 | 75 | target_link_libraries(smgui PRIVATE Qt${QT_VERSION_MAJOR}::Widgets smcore) 76 | 77 | set_target_properties(smgui PROPERTIES 78 | MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com 79 | MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} 80 | MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} 81 | MACOSX_BUNDLE TRUE 82 | WIN32_EXECUTABLE TRUE 83 | ) 84 | 85 | install(TARGETS smgui 86 | BUNDLE DESTINATION . 87 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) 88 | 89 | qt_finalize_executable(smgui) 90 | -------------------------------------------------------------------------------- /smgui/main.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "sggui.h" 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | int main(int argc, char *argv[]) 30 | { 31 | QApplication a(argc, argv); 32 | 33 | QTranslator translator; 34 | const QStringList uiLanguages = QLocale::system().uiLanguages(); 35 | for (const QString &locale : uiLanguages) 36 | { 37 | const QString baseName = "smgui_" + QLocale(locale).name(); 38 | if (translator.load(":/i18n/" + baseName)) 39 | { 40 | a.installTranslator(&translator); 41 | break; 42 | } 43 | } 44 | smos::smgui::SGGUI w; 45 | w.initUI(); 46 | w.show(); 47 | return a.exec(); 48 | } 49 | -------------------------------------------------------------------------------- /smgui/readme.md: -------------------------------------------------------------------------------- 1 | # smgui 2 | 3 | In this directory the UI of SourceMonitorOS is located. 4 | 5 | - User interaction for 6 | - Settings 7 | - Options 8 | - Language 9 | - Logging 10 | - Project handling 11 | - Read project file 12 | - Write project file 13 | - Create checkpoints 14 | - Displaying the grids for 15 | - Checkpoints (all files) 16 | - Functions/methods (specific file) 17 | - Displaying the graphics 18 | - Checkpoints (all files) 19 | - Functions/methods (specific file) 20 | 21 | The functionality called is located in [smcore][smcore]. 22 | 23 | ## Technical information 24 | 25 | - The classes of `smgui` are prefixed with `sg` to avoid complications with the classes of `smcore` 26 | 27 | [smcore]: ./../smcore/readme.md 28 | -------------------------------------------------------------------------------- /smgui/sggui.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "sggui.h" 24 | #include "ui_sggui.h" 25 | 26 | #include 27 | #include 28 | 29 | #include "about.h" 30 | #include "factory.h" 31 | #include "license.h" 32 | #include "options.h" 33 | #include "sgoptions.h" 34 | 35 | namespace smos 36 | { 37 | namespace smgui 38 | { 39 | //****************************************************************************** 40 | SGGUI::SGGUI(QWidget *parent) 41 | : QMainWindow(parent), ui(new Ui::SGGUI) 42 | { 43 | ui->setupUi(this); 44 | } 45 | //****************************************************************************** 46 | SGGUI::~SGGUI(void) 47 | { 48 | delete ui; 49 | } 50 | //****************************************************************************** 51 | bool SGGUI::initUI(void) 52 | { 53 | QString optionfileName = QDir::cleanPath(QDir::currentPath() + QDir::separator() + "smos.ini"); 54 | // std::shared_ptr smOptions = smos::smcore::SMFactory::getOptions(optionfileName); 55 | this->options = smos::smcore::Factory::getOptions(optionfileName.toStdString()); 56 | return true; 57 | } 58 | //****************************************************************************** 59 | void SGGUI::notImplemented(QString featurename) 60 | { 61 | QMessageBox::about(this, featurename, "Currently not implemented!"); 62 | } 63 | //****************************************************************************** 64 | // Menu File 65 | //****************************************************************************** 66 | void SGGUI::on_actionNew_Project_triggered() 67 | { 68 | this->notImplemented("New project"); 69 | } 70 | //****************************************************************************** 71 | void SGGUI::on_actionOpen_Project_triggered() 72 | { 73 | this->notImplemented("Open project"); 74 | } 75 | //****************************************************************************** 76 | void SGGUI::on_actionOptions_triggered(void) 77 | { 78 | smos::smgui::SGOptions optionsDialog(this, this->options); 79 | 80 | optionsDialog.setModal(true); 81 | optionsDialog.exec(); 82 | } 83 | //****************************************************************************** 84 | void SGGUI::on_actionPrint_Setup_triggered() 85 | { 86 | this->notImplemented("Print setup"); 87 | } 88 | //****************************************************************************** 89 | void SGGUI::on_actionExit_triggered(void) 90 | { 91 | QCoreApplication::quit(); 92 | } 93 | //****************************************************************************** 94 | // Menu View 95 | //****************************************************************************** 96 | void SGGUI::on_actionToolbar_triggered() 97 | { 98 | this->notImplemented("Toolbar"); 99 | } 100 | //****************************************************************************** 101 | void SGGUI::on_actionStatus_triggered() 102 | { 103 | this->notImplemented("Status"); 104 | } 105 | //****************************************************************************** 106 | void SGGUI::on_actionView_log_file_triggered() 107 | { 108 | this->notImplemented("View log file"); 109 | } 110 | //****************************************************************************** 111 | // Menu Help 112 | //****************************************************************************** 113 | void SGGUI::on_actionHelp_Topics_triggered() 114 | { 115 | this->notImplemented("Help Topics"); 116 | } 117 | //****************************************************************************** 118 | void SGGUI::on_actionContext_Help_triggered() 119 | { 120 | this->notImplemented("Context Help"); 121 | } 122 | //****************************************************************************** 123 | void SGGUI::on_actionCheck_SourceMonitor_Update_triggered() 124 | { 125 | this->notImplemented("Check SourceMonitorOS Update"); 126 | } 127 | //****************************************************************************** 128 | void SGGUI::on_actionView_License_triggered(void) 129 | { 130 | QMessageBox::about(this, "SourceMonitorOS License", QString::fromUtf8(smos::smcore::License::getLicense().c_str())); 131 | } 132 | //****************************************************************************** 133 | void SGGUI::on_actionAbout_SourceMonitor_triggered(void) 134 | { 135 | QString str = QString::fromUtf8(smos::smcore::About::getAbout().c_str()); 136 | QMessageBox::about(this, "About SourceMonitorOS", str); 137 | } 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /smgui/sggui.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | #include "options.h" 28 | 29 | QT_BEGIN_NAMESPACE 30 | namespace Ui 31 | { 32 | class SGGUI; 33 | } 34 | QT_END_NAMESPACE 35 | 36 | namespace smos 37 | { 38 | namespace smgui 39 | { 40 | class SGGUI : public QMainWindow 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | /** 46 | * @brief Default constructor 47 | * 48 | * @param parent 49 | */ 50 | SGGUI(QWidget *parent = nullptr); 51 | /** 52 | * @brief Default desctructor 53 | * 54 | */ 55 | ~SGGUI(void); 56 | /** 57 | * @brief Initialize UI 58 | * 59 | * @return true On succes 60 | * @return false On failure 61 | */ 62 | bool initUI(void); 63 | 64 | private slots: 65 | //****************************************************************************** 66 | // Menu File 67 | //****************************************************************************** 68 | /** 69 | * @brief Called when menu entry 'File - New project' is triggered 70 | * 71 | */ 72 | void on_actionNew_Project_triggered(); 73 | 74 | /** 75 | * @brief Called when menu entry 'File - Open project' is triggered 76 | * 77 | */ 78 | void on_actionOpen_Project_triggered(); 79 | 80 | /** 81 | * @brief Called when menu entry 'File - Options' is triggered 82 | * 83 | */ 84 | void on_actionOptions_triggered(void); 85 | 86 | /** 87 | * @brief Called when menu entry 'File - Print setup' is triggered 88 | * 89 | */ 90 | void on_actionPrint_Setup_triggered(); 91 | 92 | /** 93 | * @brief Called when menu entry 'File - Exit' is triggered 94 | * 95 | */ 96 | void on_actionExit_triggered(void); 97 | 98 | //****************************************************************************** 99 | // Menu View 100 | //****************************************************************************** 101 | /** 102 | * @brief Called when menu entry 'View - Toolbar' is triggered 103 | * 104 | */ 105 | void on_actionToolbar_triggered(); 106 | 107 | /** 108 | * @brief Called when menu entry 'View - Status' is triggered 109 | * 110 | */ 111 | void on_actionStatus_triggered(); 112 | 113 | /** 114 | * @brief Called when menu entry 'View - View log File' is triggered 115 | * 116 | */ 117 | void on_actionView_log_file_triggered(); 118 | 119 | //****************************************************************************** 120 | // Menu Help 121 | //****************************************************************************** 122 | /** 123 | * @brief Called when menu entry 'Help - Help Topics' is triggered 124 | * 125 | */ 126 | void on_actionHelp_Topics_triggered(); 127 | 128 | /** 129 | * @brief Called when menu entry 'Help - Context Help' is triggered 130 | * 131 | */ 132 | void on_actionContext_Help_triggered(); 133 | 134 | /** 135 | * @brief Called when menu entry 'Help - Check for SourceMonitorOS Update' is triggered 136 | * 137 | */ 138 | void on_actionCheck_SourceMonitor_Update_triggered(); 139 | 140 | /** 141 | * @brief Called when menu entry 'Help - View License' is triggered 142 | * 143 | */ 144 | void on_actionView_License_triggered(void); 145 | 146 | /** 147 | * @brief Called when menu entry 'Help - About SourceMonitor' is triggered 148 | * 149 | */ 150 | void on_actionAbout_SourceMonitor_triggered(void); 151 | 152 | private: 153 | /** 154 | * @brief Instance of UI 155 | * 156 | */ 157 | Ui::SGGUI *ui; 158 | /** 159 | * @brief Pointer to program options 160 | * 161 | */ 162 | // std::shared_ptr smOptions = nullptr; 163 | smos::smcore::Options *options = nullptr; 164 | /** 165 | * @brief Dialog to show "Currently not implemented!" message 166 | * 167 | */ 168 | void notImplemented(QString featurename); 169 | }; 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /smgui/sggui.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | SGGUI 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1024 10 | 768 11 | 12 | 13 | 14 | 15 | 1024 16 | 768 17 | 18 | 19 | 20 | SourceMonitorOS 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 0 30 | 0 31 | 1024 32 | 22 33 | 34 | 35 | 36 | 37 | File 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | View 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | Help 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | New Project 77 | 78 | 79 | Ctrl+N 80 | 81 | 82 | 83 | 84 | Open Project 85 | 86 | 87 | Ctrl+O 88 | 89 | 90 | 91 | 92 | Options 93 | 94 | 95 | 96 | 97 | Print Setup 98 | 99 | 100 | 101 | 102 | Exit 103 | 104 | 105 | 106 | 107 | true 108 | 109 | 110 | Toolbar 111 | 112 | 113 | 114 | 115 | true 116 | 117 | 118 | Status 119 | 120 | 121 | 122 | 123 | View log file 124 | 125 | 126 | 127 | 128 | Help Topics 129 | 130 | 131 | 132 | 133 | Context Help 134 | 135 | 136 | 137 | 138 | Check for SourceMonitorOS Update 139 | 140 | 141 | 142 | 143 | View License 144 | 145 | 146 | 147 | 148 | About SourceMonitor 149 | 150 | 151 | 152 | 153 | 154 | 155 | -------------------------------------------------------------------------------- /smgui/sggui_en_150.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /smgui/sgoptions.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "sgoptions.h" 24 | 25 | #include 26 | 27 | #include "ui_sgoptions.h" 28 | 29 | namespace smos 30 | { 31 | namespace smgui 32 | { 33 | //****************************************************************************** 34 | SGOptions::SGOptions(QWidget *parent, smos::smcore::Options *options) : QDialog(parent), ui(new Ui::SGOptions), m_options(options) 35 | { 36 | ui->setupUi(this); 37 | this->dialogInit(); 38 | } 39 | //****************************************************************************** 40 | SGOptions::~SGOptions(void) 41 | { 42 | delete ui; 43 | } 44 | //****************************************************************************** 45 | void SGOptions::dialogInit(void) 46 | { 47 | QString editorOld = QString::fromUtf8(this->m_options->codeEditorGet().c_str()); 48 | ui->lineEditEditor->setText(editorOld); 49 | } 50 | //****************************************************************************** 51 | void SGOptions::on_btnEditor_clicked(void) 52 | { 53 | QString fileName = QFileDialog::getOpenFileName(this, "Select editor", "", "Executable Files (*.exe);;All files (*.*)"); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /smgui/sgoptions.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | #include "options.h" 27 | 28 | namespace Ui 29 | { 30 | class SGOptions; 31 | } 32 | 33 | namespace smos 34 | { 35 | namespace smgui 36 | { 37 | class SGOptions : public QDialog 38 | { 39 | Q_OBJECT 40 | 41 | public: 42 | /** 43 | * @brief Default constructor 44 | * 45 | * @param parent 46 | */ 47 | explicit SGOptions(QWidget *parent, smos::smcore::Options *options); 48 | /** 49 | * @brief Default desctructor 50 | * 51 | */ 52 | ~SGOptions(void); 53 | 54 | private slots: 55 | /** 56 | * @brief Called when button 'General - ...' is triggered 57 | * 58 | */ 59 | void on_btnEditor_clicked(void); 60 | 61 | private: 62 | Ui::SGOptions *ui; 63 | 64 | /** 65 | * @brief Temporary options object 66 | * 67 | */ 68 | smos::smcore::Options *m_options = nullptr; 69 | 70 | /** 71 | * @brief Called for initialization 72 | * 73 | */ 74 | void dialogInit(void); 75 | }; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /smtest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ******************************************************************************* 2 | # Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the "Software"), 6 | # to deal in the Software without restriction, including without limitation 7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | # and/or sell copies of the Software, and to permit persons to whom the 9 | # Software is furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | # DEALINGS IN THE SOFTWARE. 21 | # ******************************************************************************* 22 | 23 | cmake_minimum_required(VERSION 3.5) 24 | 25 | project(smtest LANGUAGES CXX VERSION 0.0.1 DESCRIPTION "SourceMonitor tests") 26 | 27 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 28 | 29 | set(CMAKE_AUTOUIC ON) 30 | set(CMAKE_AUTOMOC ON) 31 | set(CMAKE_AUTORCC ON) 32 | 33 | set(CMAKE_CXX_STANDARD 17) 34 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 35 | 36 | find_package(Qt6 REQUIRED COMPONENTS Core Gui Test Widgets) 37 | 38 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 39 | 40 | # ******************************************************************************* 41 | enable_testing(true) 42 | 43 | set(SMTEST_INCLUDE 44 | test_about.h 45 | test_checkpoint.h 46 | test_license.h 47 | test_options.h 48 | test_project.h 49 | test_version.h 50 | test_smpreader.h 51 | ) 52 | 53 | set(PROJECT_SOURCES 54 | main.cpp 55 | test_about.cpp 56 | test_checkpoint.cpp 57 | test_license.cpp 58 | test_options.cpp 59 | test_project.cpp 60 | test_version.cpp 61 | test_smpreader.cpp 62 | ${SMTEST_INCLUDE} 63 | ${SMCORE_INCLUDE} 64 | ) 65 | 66 | add_executable( 67 | smtest 68 | ${PROJECT_SOURCES} 69 | ) 70 | 71 | # Copy license file required in test_license 72 | configure_file(./../LICENSE LICENSE COPYONLY) 73 | configure_file(./testfiles/osm.smp osm.smp COPYONLY) 74 | 75 | target_compile_options(smtest PRIVATE 76 | $<$:/W4 /WX> 77 | $<$>:-Wall -Wextra -Wpedantic -Werror> 78 | ) 79 | 80 | add_test( 81 | NAME smtest 82 | COMMAND 83 | TestLicense 84 | ) 85 | 86 | target_link_libraries(smtest PRIVATE Qt::Test smcore) 87 | -------------------------------------------------------------------------------- /smtest/main.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "testrunner.h" 24 | 25 | #include "test_about.h" 26 | #include "test_checkpoint.h" 27 | #include "test_license.h" 28 | #include "test_options.h" 29 | #include "test_project.h" 30 | #include "test_version.h" 31 | #include "test_smpreader.h" 32 | 33 | // QTEST_MAIN(smos::smtest::TestLicense) 34 | 35 | int main(int argc, char *argv[]) 36 | { 37 | 38 | int status = 0; 39 | 40 | RUN_TESTS(smos::smtest::TestAbout, argc, argv, &status); 41 | RUN_TESTS(smos::smtest::TestCheckpoint, argc, argv, &status); 42 | RUN_TESTS(smos::smtest::TestLicense, argc, argv, &status); 43 | RUN_TESTS(smos::smtest::TestOptions, argc, argv, &status); 44 | RUN_TESTS(smos::smtest::TestProject, argc, argv, &status); 45 | RUN_TESTS(smos::smtest::TestVersion, argc, argv, &status); 46 | RUN_TESTS(smos::smtest::TestSMPReader, argc, argv, &status); 47 | 48 | return status; 49 | } 50 | -------------------------------------------------------------------------------- /smtest/readme.md: -------------------------------------------------------------------------------- 1 | # smgui 2 | 3 | In this directory the tests of [smcore][folder_smcore] is located. 4 | 5 | [folder_smcore]: ./../smcore/readme.md 6 | -------------------------------------------------------------------------------- /smtest/test_about.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "test_about.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include "about.h" 29 | 30 | namespace smos 31 | { 32 | namespace smtest 33 | { 34 | //****************************************************************************** 35 | QString TestAbout::buildAboutString(void) 36 | { 37 | return "SourceMonitor Tracks Source Code Quality and Quantity\nVersion [InsertBuildInformationHere]\n\nSourceMonitor Team\nhttp://www.github.com/SourceMonitor\n© SourceMonitor Team"; 38 | } 39 | //****************************************************************************** 40 | void TestAbout::initTestCase(void) 41 | { 42 | } 43 | //****************************************************************************** 44 | void TestAbout::TestGetAbout(void) 45 | { 46 | // Build about string 47 | QString aboutData = this->buildAboutString(); 48 | // Get about string from application 49 | QString aboutApplication = QString::fromUtf8(smos::smcore::About::getAbout().c_str()); 50 | // They must be equal 51 | QCOMPARE(aboutData, aboutApplication); 52 | } 53 | //****************************************************************************** 54 | void TestAbout::cleanupTestCase(void) 55 | { 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /smtest/test_about.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | namespace smos 28 | { 29 | namespace smtest 30 | { 31 | class TestAbout : public QObject 32 | { 33 | Q_OBJECT 34 | 35 | private: 36 | QString buildAboutString(void); 37 | 38 | private slots: 39 | void initTestCase(void); 40 | void TestGetAbout(void); 41 | void cleanupTestCase(void); 42 | }; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /smtest/test_checkpoint.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "test_checkpoint.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include "checkpoint.h" 29 | 30 | namespace smos 31 | { 32 | namespace smtest 33 | { 34 | //****************************************************************************** 35 | void TestCheckpoint::initTestCase(void) 36 | { 37 | } 38 | //****************************************************************************** 39 | void TestCheckpoint::TestConstructor(void) 40 | { 41 | smos::smcore::Checkpoint checkpoint = smos::smcore::Checkpoint(); 42 | smos::smcore::Version version = smos::smcore::Version(); 43 | 44 | QCOMPARE(checkpoint.versionGet(), version); 45 | 46 | QString nameObject = QString::fromUtf8(checkpoint.checkpointNameGet().c_str()); 47 | smos::smcore::SMString nameExpectedRaw = ""; 48 | QString nameExpected = QString::fromUtf8(nameExpectedRaw.c_str()); 49 | 50 | QCOMPARE(nameObject, nameExpected); 51 | } 52 | //****************************************************************************** 53 | void TestCheckpoint::TestVersion(void) 54 | { 55 | smos::smcore::Checkpoint checkpoint = smos::smcore::Checkpoint(); 56 | smos::smcore::Version version = smos::smcore::Version(); 57 | 58 | QCOMPARE(checkpoint.versionGet(), version); 59 | 60 | smos::smcore::Version versionNew = smos::smcore::Version(2, 2, 2); 61 | checkpoint.versionSet(versionNew); 62 | QCOMPARE(checkpoint.versionGet(), versionNew); 63 | } 64 | //****************************************************************************** 65 | void TestCheckpoint::TestName(void) 66 | { 67 | smos::smcore::Checkpoint checkpoint = smos::smcore::Checkpoint(); 68 | QString nameObject = QString::fromUtf8(checkpoint.checkpointNameGet().c_str()); 69 | smos::smcore::SMString nameExpectedRaw = ""; 70 | QString nameExpected = QString::fromUtf8(nameExpectedRaw.c_str()); 71 | 72 | nameExpectedRaw = "Hello world!"; 73 | checkpoint.checkpointNameSet(nameExpectedRaw); 74 | nameObject = QString::fromUtf8(checkpoint.checkpointNameGet().c_str()); 75 | nameExpected = QString::fromUtf8(nameExpectedRaw.c_str()); 76 | QCOMPARE(nameObject, nameExpected); 77 | } 78 | //****************************************************************************** 79 | void TestCheckpoint::cleanupTestCase(void) 80 | { 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /smtest/test_checkpoint.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | namespace smos 28 | { 29 | namespace smtest 30 | { 31 | class TestCheckpoint : public QObject 32 | { 33 | Q_OBJECT 34 | 35 | private slots: 36 | void initTestCase(void); 37 | void TestConstructor(void); 38 | void TestVersion(void); 39 | void TestName(void); 40 | void cleanupTestCase(void); 41 | }; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /smtest/test_license.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "test_license.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include "license.h" 29 | 30 | namespace smos 31 | { 32 | namespace smtest 33 | { 34 | //****************************************************************************** 35 | QString TestLicense::readLicenseFromFile(void) 36 | { 37 | QString licenseText = ""; 38 | QString filename = "LICENSE"; 39 | QFile licenseFile(filename); 40 | if (!licenseFile.open(QFile::ReadOnly | QFile::Text)) 41 | { 42 | // Cannot open or read file containing license text, abort 43 | return licenseText; 44 | } 45 | // Read license from file 46 | QTextStream licenseFileStream(&licenseFile); 47 | licenseText = licenseFileStream.readAll(); 48 | licenseFile.close(); 49 | return licenseText; 50 | } 51 | //****************************************************************************** 52 | void TestLicense::initTestCase(void) 53 | { 54 | } 55 | //****************************************************************************** 56 | void TestLicense::TestGetLicense(void) 57 | { 58 | // Read license from given license file (part of project) 59 | QString licenseFile = this->readLicenseFromFile(); 60 | // Get license text from application 61 | QString licenseApplication = QString::fromUtf8(smos::smcore::License::getLicense().c_str()); 62 | // They must be equal 63 | QCOMPARE(licenseFile, licenseApplication); 64 | } 65 | //****************************************************************************** 66 | void TestLicense::cleanupTestCase(void) 67 | { 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /smtest/test_license.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | namespace smos 28 | { 29 | namespace smtest 30 | { 31 | class TestLicense : public QObject 32 | { 33 | Q_OBJECT 34 | 35 | private: 36 | QString readLicenseFromFile(void); 37 | 38 | private slots: 39 | void initTestCase(void); 40 | void TestGetLicense(void); 41 | void cleanupTestCase(void); 42 | }; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /smtest/test_options.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "test_options.h" 24 | #include "options.h" 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | namespace smos 31 | { 32 | namespace smtest 33 | { 34 | //****************************************************************************** 35 | void TestOptions::initTestCase(void) 36 | { 37 | QString optionsfileName = QDir::cleanPath(QDir::currentPath() + QDir::separator() + "smos.ini"); 38 | if (QFile::exists(optionsfileName)) 39 | { 40 | QFile configfile(optionsfileName); 41 | configfile.remove(); 42 | } 43 | } 44 | //****************************************************************************** 45 | void TestOptions::TestCodeEditorGetSet(void) 46 | { 47 | QString optionsfileName = QDir::cleanPath(QDir::currentPath() + QDir::separator() + "smos.ini"); 48 | QString codeEditorExpected = "${filename}"; 49 | 50 | smos::smcore::Options options(optionsfileName.toStdString()); 51 | 52 | QString value = QString::fromUtf8(options.codeEditorGet().c_str()); 53 | QCOMPARE(codeEditorExpected, value); 54 | 55 | codeEditorExpected = "something else"; 56 | options.codeEditorSet(codeEditorExpected.toStdString()); 57 | value = QString::fromUtf8(options.codeEditorGet().c_str()); 58 | QCOMPARE(codeEditorExpected, value); 59 | } 60 | //****************************************************************************** 61 | void TestOptions::TestLogfileNameGetSet(void) 62 | { 63 | QString optionsfileName = QDir::cleanPath(QDir::currentPath() + QDir::separator() + "smos.ini"); 64 | QString logfileNameExpected = QDir::cleanPath(QDir::currentPath() + QDir::separator() + "smos.log"); 65 | 66 | smos::smcore::Options options(optionsfileName.toStdString()); 67 | options.logfileNameSet(logfileNameExpected.toStdString()); 68 | 69 | QString logfileName = QString::fromUtf8(options.logfileNameGet().c_str()); 70 | QCOMPARE(logfileNameExpected, logfileName); 71 | } 72 | //****************************************************************************** 73 | void TestOptions::cleanupTestCase(void) 74 | { 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /smtest/test_options.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | namespace smos 28 | { 29 | namespace smtest 30 | { 31 | class TestOptions : public QObject 32 | { 33 | Q_OBJECT 34 | 35 | private slots: 36 | void initTestCase(void); 37 | void TestCodeEditorGetSet(void); 38 | void TestLogfileNameGetSet(void); 39 | void cleanupTestCase(void); 40 | }; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /smtest/test_project.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "test_project.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "project.h" 30 | #include "optionflags.h" 31 | #include "smstring.h" 32 | 33 | namespace smos 34 | { 35 | namespace smtest 36 | { 37 | //****************************************************************************** 38 | void TestProject::cleanupTestCase(void) 39 | { 40 | smos::smcore::SMString filename = smos::smcore::SMString("testfile.dat"); 41 | std::filesystem::remove(filename); 42 | } 43 | //****************************************************************************** 44 | void TestProject::initTestCase(void) 45 | { 46 | smos::smcore::SMString filename = smos::smcore::SMString("testfile.dat"); 47 | std::filesystem::remove(filename); 48 | } 49 | //****************************************************************************** 50 | void TestProject::TestIncludeSubdirectories(void) 51 | { 52 | smos::smcore::Project objProject; 53 | smos::smcore::SubdirectoryMode flag = smos::smcore::SubdirectoryMode::NoSubs; 54 | QCOMPARE(flag, objProject.getIncludeSubdirectories()); 55 | flag = smos::smcore::SubdirectoryMode::SelectedSubs; 56 | objProject.setIncludeSubdirectories(flag); 57 | QCOMPARE(flag, objProject.getIncludeSubdirectories()); 58 | flag = smos::smcore::SubdirectoryMode::AllSubs; 59 | objProject.setIncludeSubdirectories(flag); 60 | QCOMPARE(flag, objProject.getIncludeSubdirectories()); 61 | } 62 | //****************************************************************************** 63 | void TestProject::TestOptions(void) 64 | { 65 | bool flag; 66 | smos::smcore::Project objProject; 67 | 68 | int optionCurrent = objProject.GetOptionFlags(); 69 | QCOMPARE((int)smos::smcore::OptionFlags::None, optionCurrent); 70 | 71 | flag = true; 72 | objProject.UseModifiedComplexity(flag); 73 | optionCurrent = objProject.GetOptionFlags(); 74 | QCOMPARE((int)smos::smcore::OptionFlags::ModifiedComplexity, optionCurrent); 75 | QCOMPARE(flag, objProject.UseModifiedComplexity()); 76 | flag = false; 77 | objProject.UseModifiedComplexity(flag); 78 | optionCurrent = objProject.GetOptionFlags(); 79 | QCOMPARE((int)smos::smcore::OptionFlags::None, optionCurrent); 80 | QCOMPARE(flag, objProject.UseModifiedComplexity()); 81 | 82 | flag = true; 83 | objProject.UseIgnoreBlankLines(flag); 84 | optionCurrent = objProject.GetOptionFlags(); 85 | QCOMPARE((int)smos::smcore::OptionFlags::IgnoreBlankLines, optionCurrent); 86 | QCOMPARE(flag, objProject.UseIgnoreBlankLines()); 87 | flag = false; 88 | objProject.UseIgnoreBlankLines(flag); 89 | optionCurrent = objProject.GetOptionFlags(); 90 | QCOMPARE((int)smos::smcore::OptionFlags::None, optionCurrent); 91 | QCOMPARE(flag, objProject.UseIgnoreBlankLines()); 92 | 93 | flag = true; 94 | objProject.SetFileListFromXmlFile(flag); 95 | optionCurrent = objProject.GetOptionFlags(); 96 | QCOMPARE((int)smos::smcore::OptionFlags::FilesFromXmlFile, optionCurrent); 97 | QCOMPARE(flag, objProject.IsFileListFromXmlFile()); 98 | flag = false; 99 | objProject.SetFileListFromXmlFile(flag); 100 | optionCurrent = objProject.GetOptionFlags(); 101 | QCOMPARE((int)smos::smcore::OptionFlags::None, optionCurrent); 102 | QCOMPARE(flag, objProject.IsFileListFromXmlFile()); 103 | 104 | flag = true; 105 | objProject.IgnoreHeaderFooter(flag); 106 | optionCurrent = objProject.GetOptionFlags(); 107 | QCOMPARE((int)smos::smcore::OptionFlags::IgnoreCommentsOnly, optionCurrent); 108 | QCOMPARE(flag, objProject.IgnoreHeaderFooter()); 109 | flag = false; 110 | objProject.IgnoreHeaderFooter(flag); 111 | optionCurrent = objProject.GetOptionFlags(); 112 | QCOMPARE((int)smos::smcore::OptionFlags::None, optionCurrent); 113 | QCOMPARE(flag, objProject.IgnoreHeaderFooter()); 114 | } 115 | //****************************************************************************** 116 | void TestProject::TestPersistence(void) 117 | { 118 | smos::smcore::SMString filename = smos::smcore::SMString("testfile.dat"); 119 | smos::smcore::SMString projectNameSet = smos::smcore::SMString("ProjectName"); 120 | smos::smcore::Project objProjectSave; 121 | objProjectSave.setProjectName(projectNameSet); 122 | QCOMPARE(false, std::filesystem::exists(filename)); 123 | smos::smcore::Error::ErrorCode result = smos::smcore::Project::saveProject(filename, objProjectSave); 124 | QCOMPARE(smos::smcore::Error::ErrorCode::ERR_NONE, result); 125 | QCOMPARE(true, std::filesystem::exists(filename)); 126 | smos::smcore::Project objProjectLoad; 127 | result = smos::smcore::Project::loadProject(filename, objProjectLoad); 128 | QCOMPARE(smos::smcore::Error::ErrorCode::ERR_NONE, result); 129 | QCOMPARE(objProjectLoad.getProjectName(), objProjectSave.getProjectName()); 130 | } 131 | //****************************************************************************** 132 | void TestProject::TestProjectName(void) 133 | { 134 | smos::smcore::SMString projectNameSet = smos::smcore::SMString("ProjectName"); 135 | smos::smcore::Project objProject; 136 | objProject.setProjectName(projectNameSet); 137 | smos::smcore::SMString projectNameGet = objProject.getProjectName(); 138 | QCOMPARE(projectNameSet, projectNameGet); 139 | } 140 | //****************************************************************************** 141 | void TestProject::TestSourcePath(void) 142 | { 143 | smos::smcore::SMString sourcePathSet = smos::smcore::SMString("C:\\develop\\source"); 144 | smos::smcore::Project objProject; 145 | objProject.setSourcePath(sourcePathSet); 146 | smos::smcore::SMString sourcePathGet = objProject.getSourcePath(); 147 | QCOMPARE(sourcePathSet, sourcePathGet); 148 | } 149 | //****************************************************************************** 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /smtest/test_project.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | namespace smos 28 | { 29 | namespace smtest 30 | { 31 | class TestProject : public QObject 32 | { 33 | Q_OBJECT 34 | 35 | private slots: 36 | void cleanupTestCase(void); 37 | void initTestCase(void); 38 | void TestIncludeSubdirectories(void); 39 | void TestOptions(void); 40 | void TestPersistence(void); 41 | void TestProjectName(void); 42 | void TestSourcePath(void); 43 | }; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /smtest/test_smpreader.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "test_smpreader.h" 24 | 25 | #include 26 | #include "smpreader.h" 27 | 28 | namespace smos 29 | { 30 | namespace smtest 31 | { 32 | //****************************************************************************** 33 | void TestSMPReader::initTestCase(void) 34 | { 35 | } 36 | //****************************************************************************** 37 | void TestSMPReader::TestReadCppSMPoject(void) 38 | { 39 | smos::smcore::SMPReader smpReader; 40 | QCOMPARE(smpReader.Open("osm.smp"), true); 41 | smos::smcore::Project project; 42 | QCOMPARE(smpReader.Read(project), true); 43 | 44 | QCOMPARE(project.getProjectName(), "osm"); 45 | } 46 | //****************************************************************************** 47 | void TestSMPReader::cleanupTestCase(void) 48 | { 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /smtest/test_smpreader.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | namespace smos 28 | { 29 | namespace smtest 30 | { 31 | class TestSMPReader : public QObject 32 | { 33 | Q_OBJECT 34 | 35 | private slots: 36 | void initTestCase(void); 37 | void TestReadCppSMPoject(void); 38 | void cleanupTestCase(void); 39 | }; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /smtest/test_version.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #include "test_version.h" 24 | 25 | #include 26 | #include "version.h" 27 | #include 28 | #include 29 | 30 | namespace smos 31 | { 32 | namespace smtest 33 | { 34 | //****************************************************************************** 35 | void TestVersion::initTestCase(void) 36 | { 37 | } 38 | //****************************************************************************** 39 | void TestVersion::TestVersionConstructor(void) 40 | { 41 | smos::smcore::Version verObject = {1, 2, 3}; 42 | smos::smcore::SMString versionString = verObject.AsString(); 43 | QCOMPARE(versionString, "1.2.3"); 44 | } 45 | //****************************************************************************** 46 | void TestVersion::TestVersionCopyConstructor(void) 47 | { 48 | smos::smcore::Version verObjectSrc; 49 | smos::smcore::Version verObjectDst(verObjectSrc); 50 | QCOMPARE(verObjectSrc, verObjectDst); 51 | } 52 | //****************************************************************************** 53 | void TestVersion::TestVersionAssignmentOperator(void) 54 | { 55 | smos::smcore::Version verObjectSrc; 56 | smos::smcore::Version verObjectDst(verObjectSrc); 57 | QCOMPARE(true, (verObjectSrc == verObjectDst)); 58 | 59 | verObjectSrc.SetVersion(1, 2, 3); 60 | QCOMPARE(false, (verObjectSrc == verObjectDst)); 61 | 62 | verObjectDst = verObjectSrc; 63 | QCOMPARE(true, (verObjectSrc == verObjectDst)); 64 | } 65 | //****************************************************************************** 66 | void TestVersion::TestVersionEqualOperator(void) 67 | { 68 | smos::smcore::Version verObjectSrc; 69 | smos::smcore::Version verObjectDst(verObjectSrc); 70 | QCOMPARE(true, (verObjectSrc == verObjectDst)); 71 | 72 | verObjectSrc.SetVersion(1, 2, 3); 73 | QCOMPARE(false, (verObjectSrc == verObjectDst)); 74 | 75 | verObjectDst.SetVersion(1, 2, 3); 76 | QCOMPARE(true, (verObjectSrc == verObjectDst)); 77 | } 78 | //****************************************************************************** 79 | void TestVersion::TestVersionNonEqualOperator(void) 80 | { 81 | smos::smcore::Version verObjectSrc; 82 | smos::smcore::Version verObjectDst(verObjectSrc); 83 | QCOMPARE(false, (verObjectSrc != verObjectDst)); 84 | 85 | verObjectSrc.SetVersion(1, 2, 3); 86 | QCOMPARE(true, (verObjectSrc != verObjectDst)); 87 | 88 | verObjectDst.SetVersion(1, 2, 3); 89 | QCOMPARE(false, (verObjectSrc != verObjectDst)); 90 | } 91 | //****************************************************************************** 92 | void TestVersion::TestVersionGreaterEqualOperator(void) 93 | { 94 | QCOMPARE(true, (smos::smcore::Version(0, 0, 0) >= smos::smcore::Version(0, 0, 0))); 95 | QCOMPARE(true, (smos::smcore::Version(1, 0, 0) >= smos::smcore::Version(0, 0, 0))); 96 | QCOMPARE(true, (smos::smcore::Version(1, 1, 0) >= smos::smcore::Version(1, 0, 0))); 97 | QCOMPARE(true, (smos::smcore::Version(1, 1, 1) >= smos::smcore::Version(1, 1, 0))); 98 | QCOMPARE(false, (smos::smcore::Version(0, 0, 0) >= smos::smcore::Version(1, 0, 0))); 99 | QCOMPARE(false, (smos::smcore::Version(0, 0, 0) >= smos::smcore::Version(0, 1, 0))); 100 | QCOMPARE(false, (smos::smcore::Version(0, 0, 0) >= smos::smcore::Version(0, 0, 1))); 101 | } 102 | //****************************************************************************** 103 | void TestVersion::TestVersionString(void) 104 | { 105 | smos::smcore::Version verObjectSrc; 106 | smos::smcore::Version verObjectDst(verObjectSrc); 107 | smos::smcore::SMString versionSrc = verObjectSrc.AsString(); 108 | smos::smcore::SMString versionDst = verObjectDst.AsString(); 109 | QCOMPARE(true, (verObjectSrc == verObjectDst)); 110 | 111 | verObjectSrc.SetVersion(1, 2, 3); 112 | versionSrc = verObjectSrc.AsString(); 113 | QCOMPARE(false, (verObjectSrc == verObjectDst)); 114 | 115 | verObjectDst.SetVersion(1, 2, 3); 116 | versionDst = verObjectDst.AsString(); 117 | QCOMPARE(true, (verObjectSrc == verObjectDst)); 118 | } 119 | //****************************************************************************** 120 | void TestVersion::cleanupTestCase(void) 121 | { 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /smtest/test_version.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | namespace smos 28 | { 29 | namespace smtest 30 | { 31 | class TestVersion : public QObject 32 | { 33 | Q_OBJECT 34 | 35 | private slots: 36 | void initTestCase(void); 37 | void TestVersionConstructor(void); 38 | void TestVersionCopyConstructor(void); 39 | void TestVersionAssignmentOperator(void); 40 | void TestVersionEqualOperator(void); 41 | void TestVersionNonEqualOperator(void); 42 | void TestVersionGreaterEqualOperator(void); 43 | void TestVersionString(void); 44 | void cleanupTestCase(void); 45 | }; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /smtest/testfiles/osm.smp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SourceMonitor/SourceMonitorOS/1586c61f730459ab47d7f08f2c29e90ed415ca04/smtest/testfiles/osm.smp -------------------------------------------------------------------------------- /smtest/testrunner.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // Copyright (C) 1999 Jim Wanner and the SourceMonitor team. 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | //****************************************************************************** 22 | 23 | // This testrunner is inspired by the information found in the internet: 24 | // http://www.robert-puskas.info/2019/10/lod-running-multiple-qtest-classes.html 25 | // https://stackoverflow.com/questions/46367557/using-qexec-to-create-qt-test-suite 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | #define RUN_TESTS(test_class, argc, argv, status) \ 32 | { \ 33 | test_class instance; \ 34 | *status |= QTest::qExec(&instance, argc, argv); \ 35 | } 36 | --------------------------------------------------------------------------------