Skip to content

Commit a42350b

Browse files
committed
Init version
1 parent caf1d16 commit a42350b

25 files changed

+1900
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
.wsjcpp/*
2+
tmp/*
3+
.logs/*
4+
wsjcpp-parse-conf
5+
16
# Prerequisites
27
*.d
38

.travis.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
language: cpp
2+
3+
branches:
4+
only:
5+
- master
6+
7+
dist: bionic
8+
9+
addons:
10+
apt:
11+
packages:
12+
- cmake
13+
- make
14+
- g++
15+
- pkg-config
16+
17+
# Build steps
18+
script:
19+
- ./build_simple.sh
20+
- cd unit-tests.wsjcpp
21+
- ./build_simple.sh
22+
- ./unit-tests
23+

CMakeLists.txt

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
cmake_minimum_required(VERSION 3.0)
2+
3+
project(wsjcpp-parse-conf C CXX)
4+
5+
include(${CMAKE_CURRENT_SOURCE_DIR}/src.wsjcpp/CMakeLists.txt)
6+
7+
set(CMAKE_CXX_STANDARD 11)
8+
set(EXECUTABLE_OUTPUT_PATH ${wsjcpp-parse-conf_SOURCE_DIR})
9+
10+
# include header dirs
11+
list (APPEND WSJCPP_INCLUDE_DIRS "src")
12+
13+
list (APPEND WSJCPP_SOURCES "src/main.cpp")
14+
15+
#### BEGIN_WSJCPP_APPEND
16+
#### END_WSJCPP_APPEND
17+
18+
include_directories(${WSJCPP_INCLUDE_DIRS})
19+
20+
list (APPEND WSJCPP_SOURCES "./src/wsjcpp_parse_conf.h")
21+
list (APPEND WSJCPP_SOURCES "./src/wsjcpp_parse_conf.cpp")
22+
23+
add_executable (wsjcpp-parse-conf ${WSJCPP_SOURCES})
24+
target_link_libraries(wsjcpp-parse-conf ${WSJCPP_LIBRARIES})
25+
26+
install(
27+
TARGETS
28+
wsjcpp-parse-conf
29+
RUNTIME DESTINATION
30+
/usr/bin
31+
)
32+
33+

README.md

+61
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,63 @@
11
# wsjcpp-parse-conf
22
Primitive parser for *.conf files
3+
4+
## How to integrate
5+
6+
```
7+
$ wsjcpp install "https://github.com/wsjcpp/wsjcpp-parse-conf:master"
8+
```
9+
10+
or include files to your project:
11+
12+
* src.wsjcpp/wsjcpp_core/wsjcpp_core.h
13+
* src.wsjcpp/wsjcpp_core/wsjcpp_core.cpp
14+
* src/wsjcpp_parse_conf.h
15+
* src/wsjcpp_parse_conf.cpp
16+
17+
## Example usage
18+
19+
```
20+
#include <string>
21+
#include <iostream>
22+
#include <wsjcpp_core.h>
23+
#include <wsjcpp_parse_conf.h>
24+
25+
int main(int argc, const char* argv[]) {
26+
std::string TAG = "MAIN";
27+
std::string appName = std::string(WSJCPP_NAME);
28+
std::string appVersion = std::string(WSJCPP_VERSION);
29+
if (!WsjcppCore::dirExists(".logs")) {
30+
WsjcppCore::makeDir(".logs");
31+
}
32+
WsjcppLog::setPrefixLogFile("wsjcpp");
33+
WsjcppLog::setLogDirectory(".logs");
34+
35+
WsjcppParseConf conf("./example.conf");
36+
if (!conf.load()) {
37+
std::cout << "Could not load file conf" << std::endl;
38+
return -1;
39+
}
40+
41+
if (conf.has("testBool")) {
42+
bool bResult = conf.getBoolValue("testBool", false);
43+
std::cout << "testBool = " << (bResult ? "true" : "false" ) << std::endl;
44+
}
45+
46+
if (conf.has("testInt")) {
47+
int nResult = conf.getIntValue("testInt", 0);
48+
std::cout << "testInt = " << nResult << std::endl;
49+
}
50+
51+
if (conf.has("testString")) {
52+
std::string sResult = conf.getStringValue("testString", "");
53+
std::cout << "testString = " << sResult << std::endl;
54+
}
55+
56+
if (conf.has("testString2")) {
57+
std::string sResult2 = conf.getStringValue("testString2", "");
58+
std::cout << "testString2 = " << sResult2 << std::endl;
59+
}
60+
61+
return 0;
62+
}
63+
```

build_simple.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
if [ ! -d tmp ]; then
4+
mkdir -p tmp
5+
fi
6+
7+
cd tmp
8+
cmake ..
9+
make
10+

example.conf

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# this is comment
3+
4+
testBool = yes # comment too
5+
6+
testInt = 12334
7+
testString = Some string
8+
testString2 = "Some string"

src.wsjcpp/.gitkeep

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src.wsjcpp/CMakeLists.txt

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Automaticly generated by wsjcpp@v0.1.4
2+
cmake_minimum_required(VERSION 3.0)
3+
4+
add_definitions(-DWSJCPP_VERSION="v0.1.0")
5+
add_definitions(-DWSJCPP_NAME="wsjcpp-parse-conf")
6+
7+
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
8+
set(MACOSX TRUE)
9+
endif()
10+
11+
set(CMAKE_CXX_STANDARD 11)
12+
13+
set (WSJCPP_LIBRARIES "")
14+
set (WSJCPP_INCLUDE_DIRS "")
15+
set (WSJCPP_SOURCES "")
16+
17+
find_package(Threads REQUIRED)
18+
list (APPEND WSJCPP_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
19+
20+
# wsjcpp-core:v0.1.5
21+
list (APPEND WSJCPP_INCLUDE_DIRS "./src.wsjcpp/wsjcpp_core/")
22+
list (APPEND WSJCPP_SOURCES "./src.wsjcpp/wsjcpp_core/wsjcpp_core.cpp")
23+
list (APPEND WSJCPP_SOURCES "./src.wsjcpp/wsjcpp_core/wsjcpp_core.h")
24+
list (APPEND WSJCPP_SOURCES "./src.wsjcpp/wsjcpp_core/wsjcpp_resources_manager.h")
25+
list (APPEND WSJCPP_SOURCES "./src.wsjcpp/wsjcpp_core/wsjcpp_resources_manager.cpp")
26+
27+

src.wsjcpp/wsjcpp_core/generate.Class

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/wsjcpp-safe-scripting
2+
3+
# log_info rootdir
4+
# log_info script_filename
5+
6+
make_dir "src"
7+
8+
var user_class_name
9+
set_value user_class_name arg1
10+
normalize_class_name user_class_name
11+
convert_CamelCase_to_snake_case user_class_name user_class_name
12+
13+
var class_name
14+
set_value class_name arg1
15+
normalize_class_name class_name
16+
17+
var base_filename
18+
convert_CamelCase_to_snake_case class_name base_filename
19+
# log_info base_filename
20+
21+
var filename_cpp
22+
concat filename_cpp "./src/" base_filename ".cpp"
23+
24+
var filename_h
25+
concat filename_h "./src/" base_filename ".h"
26+
27+
var ifndef_header
28+
set_value ifndef_header base_filename
29+
concat ifndef_header "_H"
30+
31+
to_upper_case ifndef_header
32+
33+
var content_header
34+
concat content_header "#ifndef " ifndef_header "
35+
#define " ifndef_header "
36+
37+
#include <string>
38+
39+
class " class_name " {
40+
public:
41+
" class_name "();
42+
43+
private:
44+
std::string TAG;
45+
};
46+
47+
#endif // " ifndef_header
48+
49+
50+
var content_source
51+
concat content_source "
52+
#include \"" base_filename ".h\"
53+
#include <wsjcpp_core.h>
54+
55+
// ---------------------------------------------------------------------
56+
// " class_name "
57+
58+
" class_name "::" class_name "() {
59+
TAG = \"" class_name "\";
60+
}
61+
62+
"
63+
64+
var file_source
65+
concat file_source "src/" filename_cpp
66+
67+
write_file filename_h content_header
68+
write_file filename_cpp content_source
69+
70+
log_info "
71+
======
72+
Generated class:
73+
- " class_name "
74+
Generated files:
75+
- " filename_h "
76+
- " filename_cpp "
77+
======
78+
"
79+
80+
cmakelists_txt_append_wsjcpp filename_h
81+
cmakelists_txt_append_wsjcpp filename_cpp
+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
wsjcpp_version: v0.0.1
2+
cmake_cxx_standard: 11
3+
cmake_minimum_required: 3.0
4+
5+
name: wsjcpp-core
6+
version: v0.1.5
7+
description: Basic Utils for wsjcpp
8+
issues: https://github.com/wsjcpp/wsjcpp-core/issues
9+
repositories:
10+
- type: main
11+
url: "https://github.com/wsjcpp/wsjcpp-core"
12+
keywords:
13+
- c++
14+
- wsjcpp
15+
16+
authors:
17+
- name: Evgenii Sopov
18+
email: mrseakg@gmail.com
19+
20+
distribution:
21+
- source-file: src/wsjcpp_core.cpp
22+
target-file: wsjcpp_core.cpp
23+
type: "source-code"
24+
- source-file: src/wsjcpp_core.h
25+
target-file: wsjcpp_core.h
26+
type: "source-code" # todo must be header-file
27+
- source-file: "src/wsjcpp_unit_tests.cpp"
28+
target-file: "wsjcpp_unit_tests.cpp"
29+
type: "unit-tests"
30+
- source-file: "src/wsjcpp_unit_tests.h"
31+
target-file: "wsjcpp_unit_tests.h"
32+
type: "unit-tests"
33+
- source-file: "src/wsjcpp_unit_tests_main.cpp"
34+
target-file: "wsjcpp_unit_tests_main.cpp"
35+
type: "unit-tests"
36+
- source-file: "scripts.wsjcpp/generate.Class"
37+
target-file: "generate.Class"
38+
type: "safe-scripting-generate"
39+
- source-file: "src/wsjcpp_resources_manager.h"
40+
target-file: "wsjcpp_resources_manager.h"
41+
type: "source-code"
42+
- source-file: "src/wsjcpp_resources_manager.cpp"
43+
target-file: "wsjcpp_resources_manager.cpp"
44+
type: "source-code"
45+
46+
unit-tests:
47+
cases:
48+
- name: CoreNormalizePath
49+
description: Check function normalizePath
50+
- name: CoreUuid
51+
description: Check test generate uuid function
52+
- name: CoreExtractFilename
53+
description: Check function extract filenane from path
54+
- name: "ToUpper"
55+
description: "String to upper"
56+
- name: "CreateUuid"
57+
description: "Test generation uuids"
58+
- name: "GetEnv"
59+
description: "Test getEnv function"
60+
- name: "ToLower"
61+
description: "Test toLower"
62+
- name: "ReplaceAll"
63+
description: "Test replace all"
64+
- name: "DecodeUriComponent"
65+
description: "Check decoding"
66+
- name: "EncodeUriComponent"
67+
description: "Check encoding"
68+
- name: "Uint2HexString"
69+
description: "Test convert unsigned int to hex string"
70+
- name: "Split"
71+
description: "Test split function"
72+
- name: "CreateEmptyFile"
73+
description: "Test create empty file"
74+
- name: "ReadFileToBuffer"
75+
description: "test for readFileToBuffer"
76+
- name: "Join"
77+
description: "Test join function"
78+
- name: "getHumanSizeBytes"
79+
description: "Test function get human size in bytes"
80+
- name: "TestResources"
81+
description: "Test basic resources"

0 commit comments

Comments
 (0)