Git Product home page Git Product logo

configmaps's Introduction

Documentation can be found at doc.

In the restructured branch the internal representation is refactored. Instead of using the map/vector/map/vector principle we now have a map of ConfigItems and a ConfigItem is of type map, vector, or atom. The api is mainly kept the same. Main difference is that the children property is removed. The master api is also adapted to allow code that compiles against the restructured and the "old" master branch. Changes that are needed to compile against both branches are listed below:

Remove use of the children property:

   map["foo"][0].children["blub"] = "test";
   ->  map["foo"]["blub"] = "test";

   it = map["foo"][0].children.begin();
   ->  it = map["foo"].beginMap();

   The same for end() and find().

   A hasKey() function is added:
   map.hasKey("foo");          // for map["foo"]
   map["foo"].hasKey("blub");  // for map["foo"]["blub"]

Remove use of getInt(), getULong(), etc. methods:

   map["foo"][0].getInt();
   ->  map["foo"];
   map["foo"][0].getStirng();
   ->  (std::string)map["foo"];

Do not use the first vector element to access the first item:

   int i = map["foo"][0];
   ->  int i = map["foo"]

Operators provide pointers to subelements:

   ConfigMap &m = map["foo"][0].children;
   -> ConfigMap &m = map["foo"];

   ConfigMap *m = &(map["foo"][0].children);
   -> ConfigMap *m = map["foo"];

   The same for ConfigVector and ConfigItem;

To get the size of a submap:

   map["foo"][0].children.size();
   -> ((ConfigMap&)map["foo"]).size();
   The cast is only needed to be compatible to the olde implementation.

Don't use the ConfigItem constructor:

   map["foo"].push_back(ConfigItem("blub"));
   ->  map["foo"].push_back("blub");

   map["foo"] = ConfigItem("blub");
   ->  map["foo"] = "blub";

Assign value to std::string is ambiguous:

   std::string s = map["foo"];  // ok because uses the std::string constructor
   s = map["foo"]; // is ambiguous due to operator=(std::string) and operator=(char)

   alternative:
   s << map["foo"];
   
   you can use the streaming operator as general configmap assign operator:
   double d;
   d << map["some_value"];
   map["another_value"] << 3.14;

CMAKE

To use this library from a CMake project, it should be locatable directly with find_package() and the namespaced imported target from the generated package configuration should be used:

# CMakeLists.txt
find_package(configmaps REQUIRED)
...
add_library(foo ...)
...
target_link_libraries(foo PRIVATE configmaps::configmaps)

configmaps's People

Contributors

malter avatar priyanka328 avatar goldhoorn avatar planthaber avatar annaborn avatar jakobs avatar maltewi avatar

Stargazers

servercraft17 avatar  avatar  avatar

Watchers

 avatar James Cloos avatar  avatar Kai von Szadkowski avatar  avatar Michael Rohn avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

configmaps's Issues

Make this package compatible to yaml-cpp 0.5

To increase the compatibility to different systems it would be gread that this package support yaml-cpp 0.5 and yaml-cpp 0.3.

To make this possible follow this steps:
Rework this lines:

https://github.com/rock-simulation/configmaps/blob/master/CMakeLists.txt#L9-L14

to somethig like (untested):

pkg_check_modules(YAML REQUIRED
        yaml-cpp
)
include_directories(${YAML_INCLUDE_DIRS})
link_directories(${YAML_LIBRARY_DIRS})
add_definitions(${YAML_CFLAGS_OTHER})  #flags excluding the ones with -I

STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" $YAML_MAJOR_VERSION ${YAML_VERSION}") 
STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" $YAML_MINOR_VERSION ${YAML_VERSION}") 
STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" $YAML_PATCH_VERSION ${YAML_VERSION}") 
add_definitions("-DYAML_MINOR_VERSION=${YAML_MINOR_VERSION})
add_definitions("-DYAML_MAJOR_VERSION=${YAML_MAJOR_VERSION})
add_definitions("-DYAML_PATCH_VERSION=${YAML_PATCH_VERSION})

add_definitions(${PKGCONFIG_CFLAGS_OTHER})  #flags excluding the ones with -I

In the c++ code you can then identify the version by:

#if YAML_MAJOR_VERSION == 0
  #if YAML_MINOR_VERSION == 3
//Put here the old-code
  #endif
#endif
//Put here the new-code and hope they keep the API backward compatible

json header path

@malter

configmaps/ConfigAtom.hpp:33:10: fatal error: json/json.h: No such file or directory
     #include <json/json.h>
          ^~~~~~~~~~~~~

on ubuntu include for libjsoncpp-dev ist:
#include <jsoncpp/json/json.h>

Cannot build configmaps

During aup

...
installing OS packages: libjsoncpp-dev
Command finished successfully at 2017-08-14 11:37:09 +0200

seems to be successful, however, I get the following error:

$ make
[ 16%] Building CXX object CMakeFiles/configmaps.dir/src/ConfigMap.cpp.o
In file included from /home/dfki.uni-bremen.de/afabisch/tmp/envire/tools/configmaps/src/ConfigMap.cpp:7:0:
/home/dfki.uni-bremen.de/afabisch/tmp/envire/tools/configmaps/src/ConfigAtom.hpp:33:23: fatal error: json/json.h: No such file or directory
compilation terminated.
CMakeFiles/configmaps.dir/build.make:62: recipe for target 'CMakeFiles/configmaps.dir/src/ConfigMap.cpp.o' failed
make[2]: *** [CMakeFiles/configmaps.dir/src/ConfigMap.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/configmaps.dir/all' failed
make[1]: *** [CMakeFiles/configmaps.dir/all] Error 2
Makefile:116: recipe for target 'all' failed
make: *** [all] Error 2

configmaps depend on pkg-config

I am trying to build tools/configmaps with autoproj in a clean docker container. pkg-config is required to build it but is not listed in the manifest.

Const-correctness

Hi please check const-correctness. It is not given e.g. for getString

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.