Skip to content

Commit 51e6992

Browse files
authored
Merge pull request #7 from wsjcpp/version-0.2.1
Version 0.2.1
2 parents 7d6c520 + 8f4a45b commit 51e6992

32 files changed

+651
-506
lines changed

CHANGELOG.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,23 @@ All notable changes to wsjcpp-yaml project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## [v0.2.0] - 2025-06-29 (2025 Jule 29)
8+
## [v0.2.1] - 2026-03-05 (2026 March 5)
9+
10+
- Fixed: renamed 'recoursiveTestDependencies' to 'recursiveTestDependencies'
11+
- Fixed-names: renamed 'inited' to 'initialized'
12+
- Added define REGISTRY_WSJCPP_EMPLOY
13+
- Fixed namings: renamed REGISTRY_WJSCPP_SERVICE_LOCATOR to REGISTRY_WSJCPP_SERVICE_LOCATOR
14+
- Fixed build tests
15+
- Removed define WSJCPP_EMPLOYEES_VERSION_0_2_0
16+
- Added define WSJCPP_EMPLOYEES_VERSION_0_2_1
17+
- Removed define REGISTRY_WSJCPP_SERVICE_LOCATOR
18+
- Moved all tests for ctest (before exclude dependency wsjcpp_core)
19+
- Fixed #6 remove dependencies to wsjcpp-core
20+
21+
## [v0.2.0] - 2025-06-29 (2025 July 29)
922

1023
- Updated wsjcpp-core to v0.2.3 (Up C++ from 11 to 17)
11-
- Change single name registartion to multiple names
24+
- Change single name registration to multiple names
1225
- Added silent mode
1326
- Added class for simplify init `WsjcppEmployeesInit`
1427
- Added copyrights to files

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ install(
3131
/usr/bin
3232
)
3333

34-
34+
# enable testing functionality
35+
enable_testing()
36+
add_subdirectory(src/tests)

README.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# wsjcpp-employees
22

3-
[![Build Status](https://api.travis-ci.org/wsjcpp/wsjcpp-employees.svg?branch=master)](https://travis-ci.org/wsjcpp/wsjcpp-employees) [![Github Stars](https://img.shields.io/github/stars/wsjcpp/wsjcpp-employees.svg?label=github%20%E2%98%85)](https://github.com/wsjcpp/wsjcpp-employees/stargazers) [![Github Stars](https://img.shields.io/github/contributors/wsjcpp/wsjcpp-employees.svg)](https://github.com/wsjcpp/wsjcpp-employees/) [![Github Forks](https://img.shields.io/github/forks/wsjcpp/wsjcpp-employees.svg?label=github%20forks)](https://github.com/wsjcpp/wsjcpp-employees/network/members) [![Total alerts](https://img.shields.io/lgtm/alerts/g/wsjcpp/wsjcpp-employees.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/wsjcpp/wsjcpp-employees/alerts/) [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/wsjcpp/wsjcpp-employees.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/wsjcpp/wsjcpp-employees/context:cpp)
3+
[![Github Stars](https://img.shields.io/github/stars/wsjcpp/wsjcpp-employees.svg?label=github%20%E2%98%85)](https://github.com/wsjcpp/wsjcpp-employees) [![Github Stars](https://img.shields.io/github/contributors/wsjcpp/wsjcpp-employees.svg)](https://github.com/wsjcpp/wsjcpp-employees/) [![Github Forks](https://img.shields.io/github/forks/wsjcpp/wsjcpp-employees.svg?label=github%20forks)](https://github.com/wsjcpp/wsjcpp-employees/network/members) [![Total alerts](https://img.shields.io/lgtm/alerts/g/wsjcpp/wsjcpp-employees.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/wsjcpp/wsjcpp-employees/alerts/) [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/wsjcpp/wsjcpp-employees.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/wsjcpp/wsjcpp-employees/context:cpp)
44

55
C++ classes for service-architecture
66

@@ -13,8 +13,6 @@ $ wsjcpp install https://github.com/wsjcpp/wsjcpp-employees:master
1313

1414
or include this files:
1515

16-
- src.wsjcpp/wsjcpp_core/wsjcpp_core.h
17-
- src.wsjcpp/wsjcpp_core/wsjcpp_core.cpp
1816
- src/wsjcpp_employees.h
1917
- src/wsjcpp_employees.cpp
2018

@@ -27,6 +25,30 @@ Example main func:
2725
#include <wsjcpp_core.h>
2826
#include <wsjcpp_employees.h>
2927
28+
// logger
29+
class EmployeesLogger : public IWsjcppEmployeesLogger {
30+
public:
31+
virtual void info(const std::string &tag, const std::string &message) override {
32+
WsjcppLog::info(tag, message);
33+
}
34+
35+
virtual void ok(const std::string &tag, const std::string &message) override {
36+
WsjcppLog::ok(tag, message);
37+
}
38+
39+
virtual void warn(const std::string &tag, const std::string &message) override {
40+
WsjcppLog::warn(tag, message);
41+
}
42+
43+
virtual void err(const std::string &tag, const std::string &message) override {
44+
WsjcppLog::err(tag, message);
45+
}
46+
47+
virtual void throw_err(const std::string &tag, const std::string &message) override {
48+
WsjcppLog::throw_err(tag, message);
49+
}
50+
};
51+
3052
int main(int argc, const char* argv[]) {
3153
std::string TAG = "MAIN";
3254
std::string appName = std::string(WSJCPP_NAME);
@@ -36,11 +58,12 @@ int main(int argc, const char* argv[]) {
3658
}
3759
WsjcppLog::setPrefixLogFile("wsjcpp-employees");
3860
WsjcppLog::setLogDirectory(".logs");
61+
WsjcppEmployees::setLogger(new EmployeesLogger());
3962
4063
// init employees
4164
bool bSilent = false;
42-
WsjcppEmployeesInit empls({}, bSilent);
43-
if (!empls.inited) {
65+
WsjcppEmployeesInit employees({}, bSilent);
66+
if (!employees.initialized) {
4467
WsjcppLog::err(TAG, "Could not init employees");
4568
return -1;
4669
}
@@ -53,6 +76,8 @@ Example output:
5376
% ./wsjcpp-employees
5477
2020-03-22 11:32:31.750, 0x0x110c21dc0 [INFO] WJSCppEmployRuntimeGlobalCache: init
5578
2020-03-22 11:32:31.750, 0x0x110c21dc0 [OK] Employees_init: Init WJSCppEmployRuntimeGlobalCache ... OK
79+
2026-03-05 16:49:45.106, 0x00007139fa6fb740 [INFO] WsjcppEmployRuntimeGlobalCache: deinit
80+
2026-03-05 16:49:45.106, 0x00007139fa6fb740 [OK] WsjcppEmployees::deinit: WsjcppEmployRuntimeGlobalCache ... DEINIT_OK
5681
```
5782

5883
Now you can call from any place:
@@ -120,7 +145,7 @@ Example source-code `src/employ_my_impl.cpp`:
120145
// ---------------------------------------------------------------------
121146
// EmployMyImpl
122147

123-
REGISTRY_WJSCPP_SERVICE_LOCATOR(EmployMyImpl)
148+
REGISTRY_WSJCPP_EMPLOY(EmployMyImpl)
124149

125150
EmployMyImpl::EmployMyImpl()
126151
: WsjcppEmployBase({IMyImpl::name()}, {}) {
@@ -158,6 +183,13 @@ void someFunc() {
158183
pYourEmploy->doSomething();
159184
}
160185
186+
void someFunc2() {
187+
// if not found then no call throw exception
188+
YourEmploy *pYourEmploy2 = findWsjcppEmploy<YourEmploy2>(false);
189+
if (pYourEmploy2)
190+
pYourEmploy2->doSomething();
191+
}
192+
161193
void main() {
162194
...
163195
WsjcppEmployeesInit empls({});

build_simple.sh

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
11
#!/bin/bash
22

3-
if [ ! -d tmp ]; then
4-
mkdir -p tmp
5-
fi
63

7-
cd tmp
8-
cmake ..
9-
make
4+
check_ret() {
5+
if [ $1 -ne 0 ]; then
6+
echo ""
7+
echo "!!! FAIL: $2"
8+
echo "********************************************************************************"
9+
echo ""
10+
exit $1
11+
else
12+
echo ""
13+
echo "*** SUCCESS: $2"
14+
echo "********************************************************************************"
15+
echo ""
16+
fi
17+
}
1018

19+
# if [ ! -d tmp ]; then
20+
# mkdir -p tmp
21+
# fi
22+
23+
cmake -H. -Btmp/release -DCMAKE_BUILD_TYPE=Release
24+
check_ret $? "configure"
25+
26+
cmake --build tmp/release --config Release
27+
check_ret $? "make"
28+
29+
cd ./tmp/release && ctest --output-on-failure

scripts.wsjcpp/generate.WsjcppEmploy.wsjcpp-script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ concat content_source "
8080
// ---------------------------------------------------------------------
8181
// " class_name "
8282

83-
REGISTRY_WJSCPP_SERVICE_LOCATOR(" class_name ")
83+
REGISTRY_WSJCPP_EMPLOY(" class_name ")
8484

8585
" class_name "::" class_name "()
8686
: WsjcppEmployBase({I" employ_name "::name()}, {}) {

src.wsjcpp/.gitkeep

Lines changed: 0 additions & 1 deletion
This file was deleted.

src.wsjcpp/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Automaticly generated by wsjcpp@v0.2.5
1+
# Automaticly generated by wsjcpp@v0.2.7
22
cmake_minimum_required(VERSION 3.5)
33

4-
add_definitions(-DWSJCPP_APP_VERSION="v0.2.0")
4+
add_definitions(-DWSJCPP_APP_VERSION="v0.2.1")
55
add_definitions(-DWSJCPP_APP_NAME="wsjcpp-employees")
66

77
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@@ -17,7 +17,7 @@ set (WSJCPP_SOURCES "")
1717
find_package(Threads REQUIRED)
1818
list (APPEND WSJCPP_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
1919

20-
# wsjcpp-core:v0.2.3
20+
# wsjcpp-core:v0.2.4
2121
list (APPEND WSJCPP_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/./src.wsjcpp/wsjcpp_core/")
2222
list (APPEND WSJCPP_SOURCES "${CMAKE_SOURCE_DIR}/./src.wsjcpp/wsjcpp_core/wsjcpp_core.cpp")
2323
list (APPEND WSJCPP_SOURCES "${CMAKE_SOURCE_DIR}/./src.wsjcpp/wsjcpp_core/wsjcpp_core.h")

src.wsjcpp/wsjcpp_core/wsjcpp.hold.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_cxx_standard: 17
33
cmake_minimum_required: 3.0
44

55
name: wsjcpp-core
6-
version: v0.2.3
6+
version: v0.2.4
77
description: Basic Utils for wsjcpp
88
issues: https://github.com/wsjcpp/wsjcpp-core/issues
99
repositories:
@@ -21,32 +21,32 @@ distribution:
2121
- source-file: src/wsjcpp_core.cpp
2222
target-file: wsjcpp_core.cpp
2323
type: "source-code"
24-
sha1: "9153a6eff17ea98ac510d96de7060dd25053bdb3"
24+
sha1: "602b7a2a8e909e7ba439261f81a6eaf3c87d135f"
2525
- source-file: src/wsjcpp_core.h
2626
target-file: wsjcpp_core.h
2727
type: "source-code" # todo must be header-file
28-
sha1: "c2056e306e9cda6b90b764e83709b3c4e0199b8d"
28+
sha1: "14a1d9a252631de959962d12c32122e8d8fe5444"
2929
- source-file: "src/wsjcpp_unit_tests.cpp"
3030
target-file: "wsjcpp_unit_tests.cpp"
3131
type: "unit-tests"
32-
sha1: "fd5989d1a83c8b90bdc4d5e9bc9c3051eaa1e6d2"
32+
sha1: "b96d9d06775069d0777cb168da16d432f019d5e9"
3333
- source-file: "src/wsjcpp_unit_tests.h"
3434
target-file: "wsjcpp_unit_tests.h"
3535
type: "unit-tests"
36-
sha1: "83d4b6e046b6b58c42882ccae4be413e03c401c1"
36+
sha1: "aa581f5678795a4a6b0ecc488181bb5289a03c6b"
3737
- source-file: "src/wsjcpp_unit_tests_main.cpp"
3838
target-file: "wsjcpp_unit_tests_main.cpp"
3939
type: "unit-tests"
40-
sha1: "388ae269b325c5e161f6c3a5c598575714a4bffc"
40+
sha1: "cd50e0ba4b0ff7501ad0dc8e6c6ce9f5c735a787"
4141
- source-file: "scripts.wsjcpp/generate.WsjcppUnitTest.wsjcpp-script"
4242
target-file: "generate.WsjcppUnitTest.wsjcpp-script"
4343
type: "safe-scripting-generate"
4444
sha1: "a7c9c2d19bf81c5b00e659384b0b92a99319a4c1"
4545
- source-file: "scripts.wsjcpp/generate.Class.wsjcpp-script"
4646
target-file: "generate.Class.wsjcpp-script"
4747
type: "safe-scripting-generate"
48-
4948
sha1: "de1799907c685d606b93e08b821b540c2faa2db1"
49+
5050
unit-tests:
5151
cases:
5252
- name: CoreNormalizePath

src.wsjcpp/wsjcpp_core/wsjcpp_core.cpp

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,37 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2019-2026 Evgenii Sopov
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
// original source-code: https://github.com/wsjcpp/wsjcpp-core
26+
127
#include "wsjcpp_core.h"
228

329
#ifndef _MSC_VER
430
#include <dirent.h>
531
#include <sys/time.h>
632
#include <unistd.h>
733
#include <arpa/inet.h>
8-
#else
34+
#else
935
#include <direct.h>
1036
#define PATH_MAX 256
1137
#endif
@@ -1297,3 +1323,36 @@ bool WsjcppResourcesManager::extractFiles(const std::string &sWorkspace) {
12971323
}
12981324
*/
12991325

1326+
namespace wsjcpp {
1327+
1328+
const std::string &Core::englishAlphabetLowerCase() {
1329+
static const std::string ret = "abcdefghijklmnopqrstuvwxyz";
1330+
return ret;
1331+
}
1332+
1333+
const std::string &Core::englishAlphabetUpperCase() {
1334+
static const std::string ret = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
1335+
return ret;
1336+
}
1337+
1338+
const std::string &Core::englishAlphabetBothCase() {
1339+
static const std::string ret = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
1340+
return ret;
1341+
}
1342+
1343+
const std::string &Core::englishAlphabetBothCaseAndNumbers() {
1344+
static const std::string ret = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
1345+
return ret;
1346+
}
1347+
1348+
std::string Core::randomString(const std::string &alphabet, int length) {
1349+
std::string ret = "";
1350+
ret.resize(length, alphabet[0]);
1351+
int alphabet_len = alphabet.length();
1352+
for (int i = 0; i < length; i++) {
1353+
ret[i] = alphabet[rand() % alphabet_len];
1354+
}
1355+
return ret;
1356+
}
1357+
1358+
} // namespace wsjcpp

src.wsjcpp/wsjcpp_core/wsjcpp_core.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2019-2026 Evgenii Sopov
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
// original source-code: https://github.com/wsjcpp/wsjcpp-core
26+
127
#ifndef WSJCPP_CORE_H
228
#define WSJCPP_CORE_H
329

30+
#define WSJCPP_CORE_VER_0
31+
#define WSJCPP_CORE_VER_0_2
32+
#define WSJCPP_CORE_VER_0_2_4
33+
434
#include <string>
535
#include <vector>
636
#include <map>
@@ -234,6 +264,18 @@ class WsjcppResourcesManager {
234264
#define REGISTRY_WSJCPP_RESOURCE_FILE( classname ) \
235265
static classname * pRegistryWsjcppResourceFile ## classname = new classname(); \
236266

267+
namespace wsjcpp {
268+
269+
class Core {
270+
public:
271+
static const std::string &englishAlphabetLowerCase();
272+
static const std::string &englishAlphabetUpperCase();
273+
static const std::string &englishAlphabetBothCase();
274+
static const std::string &englishAlphabetBothCaseAndNumbers();
275+
static std::string randomString(const std::string &alphabet, int length);
276+
};
277+
278+
} // namespace wsjcpp
237279

238280
#endif // WSJCPP_CORE_H
239281

0 commit comments

Comments
 (0)