ppap4lmp  0.7.2
add_map.h
Go to the documentation of this file.
1 
9 #ifndef ADD_MAP_H
10 #define ADD_MAP_H
11 
12 #include <adders/adder.h>
13 
27 class AddMap : public Adder {
32  bool do_overwrite = false;
50  protected:
69  virtual void compute_impl(
70  Json &data,
71  JsonToVoidFunc check_required_keys,
72  JsonToBoolFunc check_optional_keys) override;
73  public:
105  AddMap(
106  const Str &key_ref_,
107  const Str &key_new_,
108  const Map<Json,Json> &mapping_);
109  virtual ~AddMap() = default;
129  bool do_overwrite_ = true);
130 };
131 
132 #endif
ShPtr< AddMap > overwrite(bool do_overwrite_=true)
Allow overwriting an existing property by a new property with the same name.
Definition: add_map.cpp:59
Str key_ref
Definition: add_map.h:36
Adder adds new properties to a non-empty Element object.
Definition: adder.h:24
std::function< bool(const Json &)> JsonToBoolFunc
An alias for a function accepts a Json object and returns a bool.
Definition: updater.h:20
Str key_new
Definition: add_map.h:40
Map< Json, Json > mapping
Definition: add_map.h:49
std::string Str
Str is an alias for string.
Definition: std.h:21
bool do_overwrite
Definition: add_map.h:32
nlohmann::json Json
Json is an alias for nlohmann::json.
Definition: json.h:22
virtual void compute_impl(Json &data, JsonToVoidFunc check_required_keys, JsonToBoolFunc check_optional_keys) override
This method overrides Updater::compute_impl.
Definition: add_map.cpp:28
AddMap(const Str &key_ref_, const Str &key_new_, const Map< Json, Json > &mapping_)
Constructor of AddMap class.
Definition: add_map.cpp:16
This file has a definition of Adder class, which is a subclass of Updater class.
AddMap adds a new property by mapping from an existing property.
Definition: add_map.h:27
std::function< void(const Json &)> JsonToVoidFunc
An alias for a function accepts a Json object.
Definition: updater.h:18
std::shared_ptr< T > ShPtr
ShPtr is an alias for shared pointer.
Definition: std.h:16
std::unordered_map< T, U > Map
Map is an alias for unordered map (same as dict in Python).
Definition: std.h:38