Skip to content

Commit db997f3

Browse files
authored
Merge pull request #22 from wsjcpp/version-0.1.4
Version 0.1.4
2 parents e75781f + 1a90d5d commit db997f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2696
-703
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ tmp/*
55
.wsjcpp-cache/*
66
.wsjcpp-logs/*
77
.wsjcpp/*
8+
unit-tests.wsjcpp/data-tests/read-write-file/docker-compose.output.yml
89

910
# Prerequisites
1011
*.d

README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# wsjcpp-yaml
22

3-
[![Build Status](https://api.travis-ci.com/wsjcpp/wsjcpp-yaml.svg?branch=master)](https://travis-ci.com/wsjcpp/wsjcpp-yaml) [![Github Stars](https://img.shields.io/github/stars/wsjcpp/wsjcpp-yaml.svg?label=github%20%E2%98%85)](https://github.com/wsjcpp/wsjcpp-yaml) [![Github Stars](https://img.shields.io/github/contributors/wsjcpp/wsjcpp-yaml.svg)](https://github.com/wsjcpp/wsjcpp-yaml) [![Github Forks](https://img.shields.io/github/forks/wsjcpp/wsjcpp-yaml.svg?label=github%20forks)](https://github.com/wsjcpp/wsjcpp-yaml/network/members) [![Total alerts](https://img.shields.io/lgtm/alerts/g/wsjcpp/wsjcpp-yaml.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/wsjcpp/wsjcpp-yaml/alerts/) [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/wsjcpp/wsjcpp-yaml.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/wsjcpp/wsjcpp-yaml/context:cpp)
4-
5-
C++ Write/Reader yaml files
3+
[![Build Status](https://api.travis-ci.com/wsjcpp/wsjcpp-yaml.svg?branch=master)](https://travis-ci.com/wsjcpp/wsjcpp-yaml) [![Github Stars](https://img.shields.io/github/stars/wsjcpp/wsjcpp-yaml.svg?label=github%20%E2%98%85)](https://github.com/wsjcpp/wsjcpp-yaml) [![Github Stars](https://img.shields.io/github/contributors/wsjcpp/wsjcpp-yaml.svg)](https://github.com/wsjcpp/wsjcpp-yaml) [![Github Forks](https://img.shields.io/github/forks/wsjcpp/wsjcpp-yaml.svg?label=github%20forks)](https://github.com/wsjcpp/wsjcpp-yaml/network/members) [![Total alerts](https://img.shields.io/lgtm/alerts/g/wsjcpp/wsjcpp-yaml.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/wsjcpp/wsjcpp-yaml/alerts/) [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/wsjcpp/wsjcpp-yaml.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/wsjcpp/wsjcpp-yaml/context:cpp) [![deepcode](https://www.deepcode.ai/api/gh/badge?key=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwbGF0Zm9ybTEiOiJnaCIsIm93bmVyMSI6IndzamNwcCIsInJlcG8xIjoid3NqY3BwLXlhbWwiLCJpbmNsdWRlTGludCI6ZmFsc2UsImF1dGhvcklkIjoxNTY0MSwiaWF0IjoxNjAxMTQxMDc2fQ.Ueb89NfeP0aM8Bn9xpHiqQ8u5q_VF65O6PeO8aLPQ_E)](https://www.deepcode.ai/app/gh/wsjcpp/wsjcpp-yaml/_/dashboard?utm_content=gh%2Fwsjcpp%2Fwsjcpp-yaml)
64

5+
C++ YAML parser/reader and writer of *.yaml/*.yml files with keeping user formatting
76

87
## Integrate to your c++ project
98

@@ -54,19 +53,19 @@ int main(int argc, char* argv[]) {
5453
return -1;
5554
}
5655

57-
std::cout << "yaml is " << yaml["yaml1"].getValue() << std::endl;
58-
std::cout << "some-map is " << yaml["some-map"].getValue() << std::endl;
59-
std::cout << "some-map2 is " << yaml["some-map2"].getValue() << std::endl;
60-
std::cout << "some-array has " << std::to_string(yaml["some-array"].getLength()) << std::endl;
61-
std::cout << "some-array element 0 is " << yaml["some-array"][0].getValue() << std::endl;
62-
std::cout << "some-array element 1 is " << yaml["some-array"][1].getValue() << std::endl;
63-
std::cout << "some-am has " << std::to_string(yaml["some-am"].getLength()) << std::endl;
56+
std::cout << "yaml is " << yaml["yaml1"].valStr() << std::endl;
57+
std::cout << "some-map is " << yaml["some-map"].valStr() << std::endl;
58+
std::cout << "some-map2 is " << yaml["some-map2"].valStr() << std::endl;
59+
std::cout << "some-array has " << std::to_string(yaml["some-array"].valStr()) << std::endl;
60+
std::cout << "some-array element 0 is " << yaml["some-array"][0].valStr() << std::endl;
61+
std::cout << "some-array element 1 is " << yaml["some-array"][1].valStr() << std::endl;
62+
std::cout << "some-am has " << std::to_string(yaml["some-am"].size()) << std::endl;
6463
std::cout << "some-am is array: " << (yaml["some-am"].isArray() ? "yes" : "no") << std::endl;
65-
std::cout << "some-am has comment " << yaml["some-am"].getComment() << std::endl;
66-
std::cout << "some-am element 0 : p1 is " << yaml["some-am"][0]["p1"].getValue() << std::endl;
67-
std::cout << "some-am element 0 : p2 is " << yaml["some-am"][0]["p2"].getValue() << std::endl;
68-
std::cout << "some-am element 1 : p1 is " << yaml["some-am"][1]["p1"].getValue() << std::endl;
69-
std::cout << "some-am element 1 : p2 is " << yaml["some-am"][1]["p2"].getValue() << std::endl;
64+
std::cout << "some-am has comment " << yaml["some-am"].comment() << std::endl;
65+
std::cout << "some-am element 0 : p1 is " << yaml["some-am"][0]["p1"].valStr() << std::endl;
66+
std::cout << "some-am element 0 : p2 is " << yaml["some-am"][0]["p2"].valStr() << std::endl;
67+
std::cout << "some-am element 1 : p1 is " << yaml["some-am"][1]["p1"].valStr() << std::endl;
68+
std::cout << "some-am element 1 : p2 is " << yaml["some-am"][1]["p2"].valStr() << std::endl;
7069

7170
return 0;
7271
}

src.wsjcpp/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Automaticly generated by wsjcpp@v0.1.7
1+
# Automaticly generated by wsjcpp@v0.2.0
22
cmake_minimum_required(VERSION 3.0)
33

44
add_definitions(-DWSJCPP_APP_VERSION="v0.1.3")
@@ -22,7 +22,4 @@ list (APPEND WSJCPP_INCLUDE_DIRS "./src.wsjcpp/wsjcpp_core/")
2222
list (APPEND WSJCPP_SOURCES "./src.wsjcpp/wsjcpp_core/wsjcpp_core.cpp")
2323
list (APPEND WSJCPP_SOURCES "./src.wsjcpp/wsjcpp_core/wsjcpp_core.h")
2424

25-
# required-libraries
26-
list (APPEND WSJCPP_LIBRARIES "-lpthread")
27-
2825

src/main.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ int main(int argc, char* argv[]) {
1515
WsjcppCore::makeDir(appLogPath);
1616
}
1717
WsjcppYaml yaml;
18-
if (!yaml.loadFromFile("./wsjcpp.yml")) {
19-
WsjcppLog::err(TAG, "Could not read data from file");
18+
std::string sError;
19+
std::string sFilePath = "./unit-tests.wsjcpp/data-tests/read-file/example-voiting-app/docker-compose.yml";
20+
if (!yaml.loadFromFile(sFilePath, sError)) {
21+
WsjcppLog::err(TAG, "Could not read data from file: " + sError);
2022
return -1;
2123
}
2224

23-
if (!yaml.saveToFile("./wsjcpp.yml")) {
25+
if (!yaml.saveToFile(sFilePath)) {
2426
WsjcppLog::err(TAG, "Could not save data to file");
2527
return -1;
2628
}

0 commit comments

Comments
 (0)