diff --git a/CMakeLists.txt b/CMakeLists.txt index c90f9b5..804b399 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,13 @@ -INCLUDE (CheckIncludeFiles) +include(CheckIncludeFiles) +include(GNUInstallDirs) # define project cmake_minimum_required (VERSION 3.5) project (jstrings VERSION 1.1 LANGUAGES CXX) +set(PROJECT_CONTACT "Damian R (damian@sudden-desu.net)") +set(PROJECT_WEBSITE "https://github.com/drojaazu") + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/project.hpp.cfg" "${CMAKE_CURRENT_SOURCE_DIR}/src/project.hpp") set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_COMPILER_NAMES clang++ g++ icpc c++ cxx) @@ -16,12 +21,12 @@ if (NOT EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt) endif() # define target -aux_source_directory(${PROJECT_SOURCE_DIR}/src CPPFILES) -add_executable(jstrings ${CPPFILES}) +aux_source_directory("${CMAKE_CURRENT_SOURCE_DIR}/src" SRCFILES) +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/inc") + +add_executable(${PROJECT_NAME} ${SRCFILES}) -target_include_directories(jstrings PUBLIC "${PROJECT_SOURCE_DIR}/inc") -target_compile_features(jstrings PUBLIC cxx_std_11) -target_link_libraries(jstrings png) +target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11) install(TARGETS jstrings RUNTIME DESTINATION bin) diff --git a/inc/enc_cp932.h b/inc/enc_cp932.h index c6ae1ec..21c2de2 100644 --- a/inc/enc_cp932.h +++ b/inc/enc_cp932.h @@ -17,6 +17,7 @@ class cp932 : public shift_jis { public: u8 is_valid(u8 const *data); + ~cp932(){}; }; } // namespace encodings diff --git a/inc/enc_eucjp.h b/inc/enc_eucjp.h index c03a05c..5575647 100644 --- a/inc/enc_eucjp.h +++ b/inc/enc_eucjp.h @@ -16,6 +16,7 @@ class euc : public encoding public: euc() : encoding(3){}; u8 is_valid(u8 const *data); + ~euc(){}; }; } // namespace encodings diff --git a/inc/enc_shiftjis.h b/inc/enc_shiftjis.h index d38d172..a4bc5f8 100644 --- a/inc/enc_shiftjis.h +++ b/inc/enc_shiftjis.h @@ -17,6 +17,7 @@ class shift_jis : public encoding public: shift_jis() : encoding(2){}; u8 is_valid(u8 const *data); + ~shift_jis(){}; }; } // namespace encodings diff --git a/inc/encoding.h b/inc/encoding.h index 1d15f44..1d2241b 100644 --- a/inc/encoding.h +++ b/inc/encoding.h @@ -16,6 +16,8 @@ class encoding { public: encoding(u8 max_seq_len) { this->max_seq_len = max_seq_len; } + encoding() = delete; + virtual ~encoding(){}; /*! * \brief Determines if the given bytes are a valid byte sequence for the diff --git a/inc/types.h b/inc/types.h index ca27fd1..5577c8a 100644 --- a/inc/types.h +++ b/inc/types.h @@ -12,6 +12,7 @@ #include #include #include +#include typedef uint8_t u8; typedef uint16_t u16; diff --git a/src/main.cpp b/src/main.cpp index 11a425b..854b528 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,5 @@ #include "main.h" +#include "project.hpp" #ifdef DEBUG #include @@ -6,8 +7,6 @@ using namespace std; -static const string version = string("1.0"); - // 512k of buffer static u32 const DATABUFF_SIZE = 524288; static u8 const DEFAULT_MATCH_LEN = 10; @@ -79,7 +78,7 @@ int main(int argc, char **argv) // --- if yes, add string to list // -- clear temp string // start over - vector found_strings(); + vector found_strings; u8 databuff[DATABUFF_SIZE]; streamsize bytecount; u32 work_iter; @@ -271,7 +270,7 @@ void process_args(int argc, char **argv) void print_help() { - cerr << "jstrings version " << version << endl << endl; + cerr << PROJECT::PROJECT_NAME << " - ver. " << PROJECT::VERSION << endl << endl; cerr << "Valid options:" << endl; cerr << " --encoding, -e Specify encoding to use" << endl; cerr << " (Valid options: shiftjis, cp932, eucjp)" << endl; diff --git a/src/project.hpp.cfg b/src/project.hpp.cfg new file mode 100644 index 0000000..8f65606 --- /dev/null +++ b/src/project.hpp.cfg @@ -0,0 +1,19 @@ +#ifndef __MAIN_HPP +#define __MAIN_HPP + +#include + +/* + These values should be set within CMakeLists.txt +*/ +namespace PROJECT { + static unsigned int const VERSION_MAJOR{@PROJECT_VERSION_MAJOR@}; + static unsigned int const VERSION_MINOR{@PROJECT_VERSION_MINOR@}; + static unsigned int const VERSION_PATCH{@PROJECT_VERSION_PATCH@}; + static std::string const VERSION{"@PROJECT_VERSION@"}; + + static std::string const PROJECT_NAME{"@PROJECT_NAME@"}; + static std::string const PROJECT_CONTACT{"@PROJECT_CONTACT@"}; + static std::string const PROJECT_WEBSITE{"@PROJECT_WEBSITE@"}; +} +#endif