Skip to content

Commit

Permalink
Merge pull request #22 from wsjcpp/version-0.1.4
Browse files Browse the repository at this point in the history
Version 0.1.4
  • Loading branch information
sea5kg authored Sep 26, 2020
2 parents e75781f + 1a90d5d commit db997f3
Show file tree
Hide file tree
Showing 41 changed files with 2,696 additions and 703 deletions.
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

0 comments on commit db997f3

Please sign in to comment.