Skip to content

Commit

Permalink
Fixed some goofball mistakes, added standard project constants
Browse files Browse the repository at this point in the history
  • Loading branch information
drojaazu committed Jan 28, 2021
1 parent 7e36ecd commit 45e3897
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 10 deletions.
17 changes: 11 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 ([email protected])")
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)
Expand All @@ -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)
1 change: 1 addition & 0 deletions inc/enc_cp932.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class cp932 : public shift_jis
{
public:
u8 is_valid(u8 const *data);
~cp932(){};
};

} // namespace encodings
Expand Down
1 change: 1 addition & 0 deletions inc/enc_eucjp.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class euc : public encoding
public:
euc() : encoding(3){};
u8 is_valid(u8 const *data);
~euc(){};
};

} // namespace encodings
Expand Down
1 change: 1 addition & 0 deletions inc/enc_shiftjis.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class shift_jis : public encoding
public:
shift_jis() : encoding(2){};
u8 is_valid(u8 const *data);
~shift_jis(){};
};

} // namespace encodings
Expand Down
2 changes: 2 additions & 0 deletions inc/encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions inc/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <memory>
#include <stdint.h>
#include <vector>
#include <sys/types.h>

typedef uint8_t u8;
typedef uint16_t u16;
Expand Down
7 changes: 3 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#include "main.h"
#include "project.hpp"

#ifdef DEBUG
#include <chrono>
#endif

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;
Expand Down Expand Up @@ -79,7 +78,7 @@ int main(int argc, char **argv)
// --- if yes, add string to list
// -- clear temp string
// start over
vector<found_string> found_strings();
vector<found_string> found_strings;
u8 databuff[DATABUFF_SIZE];
streamsize bytecount;
u32 work_iter;
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 19 additions & 0 deletions src/project.hpp.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef __MAIN_HPP
#define __MAIN_HPP

#include <string>

/*
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

0 comments on commit 45e3897

Please sign in to comment.