Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.1.4 #22

Merged
merged 29 commits into from
Sep 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8e44b09
Fixed #4 implemented removeElement for map
sea5kg Sep 20, 2020
d1c76a7
Fixed #3 Add test for removeElement and getLength (array)
sea5kg Sep 21, 2020
de75593
Moved 'enum WsjcppYamlParserLineStates' to source file
sea5kg Sep 21, 2020
7f9d90d
Added support quotes single/double
sea5kg Sep 21, 2020
0b57a80
Fixed #13 Added unit-tests for memory leaks
sea5kg Sep 22, 2020
95eae42
Fixed #12 Added unit-test for read yml like docker-compose samples
sea5kg Sep 23, 2020
251ea4c
Redesign code for unit_test_memory_leaks
sea5kg Sep 23, 2020
2444e17
Fixed #5 added setElementValue for bool, int, long
sea5kg Sep 23, 2020
3e54cae
Fixed #7 Added new methods get*Value
sea5kg Sep 23, 2020
40eb5c5
Added read-write unit-test
sea5kg Sep 23, 2020
80c7997
Fixed #15 removed dangerous operators
sea5kg Sep 23, 2020
b25e4d2
Prepare WsjcppYamlCursor #13
sea5kg Sep 23, 2020
8e91fa3
Partial fix for #13 WsjcppYamlCursor
sea5kg Sep 24, 2020
3ca6b38
Removed printing 'TODO: undefined'
sea5kg Sep 24, 2020
db87a3b
Fixed empty lines
sea5kg Sep 25, 2020
7e9308a
Improved reading yaml (docker-compose example) and prepared unit-test…
sea5kg Sep 25, 2020
c01d1bf
Fixed #19 Cleanup previously data
sea5kg Sep 25, 2020
c01e385
removed unused comments and refactored code
sea5kg Sep 25, 2020
5b01fc7
Fixed #18 Bug in parsing element of array with colon
sea5kg Sep 25, 2020
8d8bfd5
Renamed WsjcppYamlItemType to WsjcppYamlNodeType
sea5kg Sep 25, 2020
d555a8a
Fixed todo: Renamed WsjcppYamlItem to WsjcppYamlNode
sea5kg Sep 25, 2020
e068c59
Improved unit-test readyml
sea5kg Sep 25, 2020
40965c6
Removed class WsjcppYamlParserStatus (moved variables inside WsjcppYaml)
sea5kg Sep 25, 2020
784e071
Started #14 bug with intent
sea5kg Sep 25, 2020
623fdd1
Fixed keep user format intent (partial fix #14)
sea5kg Sep 26, 2020
9b1dbfc
Fixed #14 bug with intents
sea5kg Sep 26, 2020
3e5e206
Added unit-test for create yaml
sea5kg Sep 26, 2020
6e16e98
Fixed deepcode-ci warnings
sea5kg Sep 26, 2020
1a90d5d
Added deepcode badge
sea5kg Sep 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ tmp/*
.wsjcpp-cache/*
.wsjcpp-logs/*
.wsjcpp/*
unit-tests.wsjcpp/data-tests/read-write-file/docker-compose.output.yml

# Prerequisites
*.d
Expand Down
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# wsjcpp-yaml

[![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)

C++ Write/Reader yaml files
[![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)

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

## Integrate to your c++ project

Expand Down Expand Up @@ -54,19 +53,19 @@ int main(int argc, char* argv[]) {
return -1;
}

std::cout << "yaml is " << yaml["yaml1"].getValue() << std::endl;
std::cout << "some-map is " << yaml["some-map"].getValue() << std::endl;
std::cout << "some-map2 is " << yaml["some-map2"].getValue() << std::endl;
std::cout << "some-array has " << std::to_string(yaml["some-array"].getLength()) << std::endl;
std::cout << "some-array element 0 is " << yaml["some-array"][0].getValue() << std::endl;
std::cout << "some-array element 1 is " << yaml["some-array"][1].getValue() << std::endl;
std::cout << "some-am has " << std::to_string(yaml["some-am"].getLength()) << std::endl;
std::cout << "yaml is " << yaml["yaml1"].valStr() << std::endl;
std::cout << "some-map is " << yaml["some-map"].valStr() << std::endl;
std::cout << "some-map2 is " << yaml["some-map2"].valStr() << std::endl;
std::cout << "some-array has " << std::to_string(yaml["some-array"].valStr()) << std::endl;
std::cout << "some-array element 0 is " << yaml["some-array"][0].valStr() << std::endl;
std::cout << "some-array element 1 is " << yaml["some-array"][1].valStr() << std::endl;
std::cout << "some-am has " << std::to_string(yaml["some-am"].size()) << std::endl;
std::cout << "some-am is array: " << (yaml["some-am"].isArray() ? "yes" : "no") << std::endl;
std::cout << "some-am has comment " << yaml["some-am"].getComment() << std::endl;
std::cout << "some-am element 0 : p1 is " << yaml["some-am"][0]["p1"].getValue() << std::endl;
std::cout << "some-am element 0 : p2 is " << yaml["some-am"][0]["p2"].getValue() << std::endl;
std::cout << "some-am element 1 : p1 is " << yaml["some-am"][1]["p1"].getValue() << std::endl;
std::cout << "some-am element 1 : p2 is " << yaml["some-am"][1]["p2"].getValue() << std::endl;
std::cout << "some-am has comment " << yaml["some-am"].comment() << std::endl;
std::cout << "some-am element 0 : p1 is " << yaml["some-am"][0]["p1"].valStr() << std::endl;
std::cout << "some-am element 0 : p2 is " << yaml["some-am"][0]["p2"].valStr() << std::endl;
std::cout << "some-am element 1 : p1 is " << yaml["some-am"][1]["p1"].valStr() << std::endl;
std::cout << "some-am element 1 : p2 is " << yaml["some-am"][1]["p2"].valStr() << std::endl;

return 0;
}
Expand Down
5 changes: 1 addition & 4 deletions src.wsjcpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Automaticly generated by wsjcpp@v0.1.7
# Automaticly generated by wsjcpp@v0.2.0
cmake_minimum_required(VERSION 3.0)

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

# required-libraries
list (APPEND WSJCPP_LIBRARIES "-lpthread")


8 changes: 5 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ int main(int argc, char* argv[]) {
WsjcppCore::makeDir(appLogPath);
}
WsjcppYaml yaml;
if (!yaml.loadFromFile("./wsjcpp.yml")) {
WsjcppLog::err(TAG, "Could not read data from file");
std::string sError;
std::string sFilePath = "./unit-tests.wsjcpp/data-tests/read-file/example-voiting-app/docker-compose.yml";
if (!yaml.loadFromFile(sFilePath, sError)) {
WsjcppLog::err(TAG, "Could not read data from file: " + sError);
return -1;
}

if (!yaml.saveToFile("./wsjcpp.yml")) {
if (!yaml.saveToFile(sFilePath)) {
WsjcppLog::err(TAG, "Could not save data to file");
return -1;
}
Expand Down
Loading