Bayeux  3.4.1
Core Foundation library for SuperNEMO
properties.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2008-02-19
4  * Last modified: 2019-01-17
5  *
6  * License:
7  *
8  * Copyright (C) 2008-2019 Francois Mauger <mauger@lpccaen.in2p3.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or (at
13  * your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
23  * Boston, MA 02110-1301, USA.
24  *
25  * Description:
26  *
27  * A simple properties dictionary with I/O functionalities.
28  *
29  */
30 
31 #ifndef DATATOOLS_PROPERTIES_H
32 #define DATATOOLS_PROPERTIES_H
33 
34 // Standard Library:
35 #include <iostream>
36 #include <list>
37 #include <map>
38 #include <set>
39 #include <stdexcept>
40 #include <string>
41 #include <vector>
42 #include <memory>
43 
44 // Third Party:
45 // - Boost:
46 #include <boost/cstdint.hpp>
47 #include <boost/serialization/access.hpp>
48 
49 // This Project:
52 #include <datatools/i_tree_dump.h>
53 #include <datatools/i_clear.h>
54 #include <datatools/i_cloneable.h>
55 #include <datatools/bit_mask.h>
56 #include <datatools/exception.h>
57 
58 namespace datatools {
59 
61 
128  , public datatools::i_clear
129  , public datatools::i_cloneable
130  {
131  public:
132 
133  //----------------------------------------------------------------------
134  //
136  class data {
137 
138  public:
139  static const int ERROR_SUCCESS = 0;
140  static const int ERROR_FAILURE = 1;
141  static const int ERROR_BADTYPE = 2;
142  static const int ERROR_RANGE = 3;
143  static const int ERROR_LOCK = 4;
144 
145  static const uint8_t MASK_TYPE = 0x7; // = 00000111
146  static const uint8_t MASK_UNIT_SYMBOL = 0x8; // = 00001000 for real parameters
147  static const uint8_t MASK_EXPLICIT_PATH = 0x10; // = 00010000 for string parameters
148  static const uint8_t MASK_EXPLICIT_UNIT = 0x20; // = 00100000 for real parameters
149  static const uint8_t MASK_LOCK = 0x40; // = 01000000
150  static const uint8_t MASK_VECTOR = 0x80; // = 10000000
151 
152  static const uint8_t TYPE_NONE = 0x0; // = 000
153  static const uint8_t TYPE_BOOLEAN = 0x1; // = 001
154  static const uint8_t TYPE_INTEGER = 0x2; // = 010
155  static const uint8_t TYPE_REAL = 0x3; // = 011
156  static const uint8_t TYPE_STRING = 0x4; // = 100
157 
158  static const char TYPE_BOOLEAN_SYMBOL = 'B';
159  static const char TYPE_INTEGER_SYMBOL = 'I';
160  static const char TYPE_REAL_SYMBOL = 'R';
161  static const char TYPE_STRING_SYMBOL = 'S';
162 
163  static const char STRING_FORBIDDEN_CHAR = '"';
164 
165  static const int SCALAR_DEF = -1;
166  static const int SCALAR_SIZE = 1;
167 
169  struct defaults {
170  static bool boolean_value(); // return false
171  static int integer_value(); // return 0
172  static double real_value(); // return 0.0
173  static const std::string string_value(); // return empty string
174  };
175 
176  public:
177 
178  typedef std::vector<bool> vbool;
179  typedef std::vector<int32_t> vint;
180  typedef std::vector<double> vdouble;
181  typedef std::vector<std::string> vstring;
182 
183  public:
184 
186  data(char type_ = TYPE_INTEGER_SYMBOL,
187  int size_ = SCALAR_DEF);
188 
190  data(bool value_, int size_ = SCALAR_DEF);
191 
193  data(int value_, int size_ = SCALAR_DEF);
194 
196  data(double value_, int size_ = SCALAR_DEF);
197 
199  data(const std::string & value_, int size_ = SCALAR_DEF);
200 
202  data(const char* value_, int size_ = SCALAR_DEF);
203 
205  virtual ~data();
206 
208  bool has_description() const;
209 
211  void set_description(const std::string & description_);
212 
214  const std::string & get_description() const;
215 
219  int set_unit_symbol(const std::string & symbol_);
220 
222  const std::string & get_unit_symbol() const;
223 
225  bool has_type() const;
226 
228  int get_type() const;
229 
231  bool is_boolean() const;
232 
234  bool is_integer() const;
235 
237  bool is_real() const;
238 
240  bool is_string() const;
241 
243  bool is_path() const;
244 
246  bool is_scalar() const;
247 
249  bool is_vector() const;
250 
252  bool is_locked() const;
253 
255  bool has_unit_symbol() const;
256 
258  bool has_explicit_unit() const;
259 
261  bool is_explicit_path() const;
262 
264  bool is_unlocked() const;
265 
267  int boolean(int size_ = SCALAR_DEF);
268 
270  int integer(int size_ = SCALAR_DEF);
271 
273  int real(int size_ = SCALAR_DEF);
274 
276  int string(int size_ = SCALAR_DEF);
277 
279  int lock();
280 
282  int unlock();
283 
285  int32_t get_size() const;
286 
288  int32_t size() const;
289 
291  bool empty() const;
292 
294  bool index_is_valid(int index_) const;
295 
297  bool get_boolean_value(int index_ = 0) const;
298 
300  int get_integer_value(int index_ = 0) const;
301 
303  double get_real_value(int index_ = 0) const;
304 
306  std::string get_string_value(int index_ = 0) const;
307 
309  int set_value(bool value_, int index_ = 0);
310 
312  int set_value(int value_, int index_ = 0);
313 
315  int set_value(double value_, int index_ = 0, bool explicit_unit_ = false);
316 
318  int set_value_with_unit(double value_, int index_ = 0, const std::string & unit_symbol_ = "");
319 
321  int set_explicit_unit(bool explicit_unit_flag_);
322 
324  int set_explicit_path(bool explicit_path_flag_);
325 
327  int set_value(const std::string & value_, int index_ = 0, bool explicit_path_flag_ = false);
328 
330  int set_value(const char * value_, int index_ = 0, bool explicit_path_flag_ = false);
331 
333  int get_value(bool & value_, int index_ = 0) const;
334 
336  int get_value(int & value_, int index_ = 0) const;
337 
339  int get_value(double & value_, int index_ = 0) const;
340 
342  int get_value(std::string & value_, int index_ = 0) const;
343 
345  std::string get_type_label() const;
346 
348  std::string get_vector_label() const;
349 
351  static bool has_forbidden_char(const std::string & checked_);
352 
354  void dump(std::ostream & out_) const;
355 
357  void to_string(std::ostream & out_) const;
358 
360  static std::string get_error_message(int error_code_);
361 
363  virtual void tree_dump(std::ostream & out_ = std::clog,
364  const std::string & title_ = "",
365  const std::string & indent_ = "",
366  bool inherit_ = false) const;
367 
368  private:
369 
370  void clear_values_();
371 
372  void clear_unit_symbol_();
373 
374  int init_values_(char type_ = TYPE_INTEGER_SYMBOL,
375  int size_ = SCALAR_DEF);
376 
378 
379  private:
380  std::string _description_;
381 
390  uint8_t _flags_;
391  vbool _boolean_values_;
392  vint _integer_values_;
393  vdouble _real_values_;
394  vstring _string_values_;
395  std::string _unit_symbol_;
396 
397  }; //----- end of data inner class
398 
399 
400  //----------------------------------------------------------------------
401  // Key validator inner classes
404  : public std::unary_function<std::string,bool>
405  {
407  {
408  return;
409  }
410 
411  virtual bool operator()(const std::string & key_arg_) const = 0;
412  };
413 
416  : public basic_key_validator
417  {
418  public:
419  static const std::string & allowed_chars();
420 
423 
425  virtual ~default_key_validator();
426 
428  virtual bool operator()(const std::string & key_arg_) const;
429  };
430 
431  //----------------------------------------------------------------------
432  // Config inner class
433  //
434  friend class config;
436  class config {
437  public:
438 
439  static const std::string & lock_decorator();
440  static const std::string & as_directive();
441  static const std::string & in_directive();
442  static const std::string & path_decorator();
443  static const std::string & metacomment_prefix();
444 
449  MODE_BARE = 0,
450  MODE_HEADER_FOOTER = 1,
451  MODE_DEFAULT = MODE_BARE,
452  mode_bare = MODE_BARE,
453  mode_header_footer = MODE_HEADER_FOOTER
454  };
455 
458  SKIP_PRIVATE = bit_mask::bit00,
459  FORBID_VARIANTS = bit_mask::bit01,
460  LOG_MUTE = bit_mask::bit02,
461  LOG_DEBUG = bit_mask::bit03,
462  LOG_TRACE = bit_mask::bit04,
463  SMART_MODULO = bit_mask::bit05,
464  HEADER_FOOTER = bit_mask::bit06,
465  REQUESTED_TOPIC = bit_mask::bit07,
466  FORBID_INCLUDES = bit_mask::bit08,
467  DONT_CLEAR = bit_mask::bit09,
468  RESOLVE_PATH = bit_mask::bit10,
469  ALLOW_KEY_OVERRIDE = bit_mask::bit11,
470  LOG_WARNING = bit_mask::bit12
471  };
472 
474  config(uint32_t options_ = 0,
475  const std::string & topic_ = "",
476  const std::string & section_name_ = "",
477  int section_start_line_number_ = -1);
478 
480  virtual ~config();
481 
483  datatools::logger::priority get_logging() const;
484 
486  void set_logging(datatools::logger::priority);
487 
663  void read(std::istream & in_, properties & prop_);
664 
666  void read(const std::string & in_, properties & prop_);
667 
669  void write(std::ostream & out_, const properties & prop_);
670 
672  void write(const std::string & filename_, const properties & prop_);
673 
675  int get_current_line_number() const;
676 
678  void set_reader_input(const std::string & filename_, int line_count_ = -1);
679 
681  bool has_topic() const;
682 
684  void set_topic(const std::string & topic_);
685 
687  const std::string & get_topic() const;
688 
690  bool has_section_info() const;
691 
693  void set_section_info(const std::string & section_name_,
694  int section_start_line_number_);
695 
697  void reset_section_info();
698 
700  const std::string & get_section_name() const;
701 
703  int get_section_start_line_number() const;
704 
706  void reset();
707 
709  void write_metacomment(std::ostream & out_,
710  const std::string & tag_,
711  const std::string & value_ = "",
712  const std::string & comment_ = "");
713 
715  void write_data(std::ostream & out_,
716  const std::string & data_key_,
717  const properties::data& prop_data_,
718  const std::string & unit_symbol_ = "",
719  const std::string & unit_label_ = "",
720  const std::string & comment_ = "");
721 
722  private:
723 
725  void _init_defaults_();
726 
728  void _read_(std::istream & in_, properties & prop_);
729 
731  void _write_(std::ostream & out_, const properties & prop_);
732 
733  private:
734 
735  // Configuration:
736  logger::priority _logging_;
737  int _mode_;
738  bool _dont_clear_;
739  bool _use_smart_modulo_;
740  bool _write_public_only_;
741  bool _forbid_variants_;
742  bool _forbid_includes_;
743  bool _requested_topic_;
744  bool _resolve_path_;
745  bool _allow_key_override_ = false;
746  std::string _topic_;
747  std::string _section_name_;
748  int _section_start_line_number_;
749 
750  // Working parsing data:
751  size_t _current_line_number_;
752  std::string _current_filename_;
753 
754  }; //----- end of class config
755 
756  //----------------------------------------------------------------------
757  // properties class declarations
758  //
759  public:
760 
765  static const std::string & private_property_prefix();
766 
767  // Typedefs declarations:
768 
769  protected:
770 
771  typedef std::map<std::string, data> pmap;
772 
773  public:
774 
775  typedef std::vector<std::string> keys_col_type;
776 
777  public:
778 
780  properties();
781 
783  explicit properties(const std::string & desc_);
784 
786  properties(const std::string & desc_, const basic_key_validator &);
787 
789  explicit properties(const basic_key_validator &);
790 
791  /* with external key validator (deletion_on_destroy_==false)
792  * with internal key validator (deletion_on_destroy_==true)
793  * validator is deleted in the destructor.
794  */
795 
797  properties(const std::string & desc_, const basic_key_validator *,
798  bool deletion_on_destroy_ = true);
799 
801  explicit properties(const basic_key_validator *,
802  bool deletion_on_destroy_ = true);
803 
805  virtual ~properties();
806 
808  int32_t size() const;
809 
811  bool empty() const;
812 
839  void set_description(const std::string &);
840 
842  const std::string & get_description() const;
843 
845  bool fetch_short_description(std::string &) const;
846 
848  bool has_short_description() const;
849 
851  std::string get_short_description() const;
852 
854  bool has_auxiliary_descriptions() const;
855 
857  bool fetch_auxiliary_descriptions(std::vector<std::string> &) const;
858 
860  void unset_key_validator();
861 
864 
867 
870  bool deletion_on_destroy_ = true);
871 
873  std::vector<std::string> keys() const;
874 
876  const std::string & key (int) const;
877 
879  void keys(std::vector<std::string> &) const;
880 
882  const data & get(const std::string & prop_key_) const;
883 
885  void store(const std::string & key_, const data & value_);
886 
888  void keys_not_starting_with(std::vector<std::string> &, const std::string & prefix_) const;
889 
891  std::vector<std::string> keys_not_starting_with(const std::string & prefix_) const;
892 
894  void keys_starting_with(std::vector<std::string> &, const std::string & prefix_) const;
895 
897  std::vector<std::string> keys_starting_with(const std::string & prefix_) const;
898 
900  void keys_not_ending_with(std::vector<std::string> &, const std::string & suffix_) const;
901 
903  std::vector<std::string> keys_not_ending_with(const std::string & suffix_) const;
904 
906  void keys_ending_with(std::vector<std::string> &, const std::string & suffix_) const;
907 
909  std::vector<std::string> keys_ending_with(const std::string & suffix_) const;
910 
912  void lock(const std::string & prop_key_);
913 
915  void unlock(const std::string & prop_key_);
916 
918  bool is_locked(const std::string & prop_key_) const;
919 
921  static std::string make_private_key(const std::string & prop_key_);
922 
924  static bool key_is_private(const std::string & prop_key_);
925 
927  static bool key_is_public(const std::string & prop_key_);
928 
930  bool is_private(const std::string & prop_key_) const;
931 
933  bool is_public(const std::string & prop_key_) const;
934 
936  bool is_boolean(const std::string & prop_key_) const;
937 
939  bool is_integer(const std::string & prop_key_) const;
940 
942  bool is_real(const std::string & prop_key_) const;
943 
945  bool is_string(const std::string & prop_key_) const;
946 
948  bool is_scalar(const std::string & prop_key_) const;
949 
951  bool is_vector(const std::string & prop_key_) const;
952 
953  // 2012-11-14 FM : Should be deprecated
954  int32_t size(const std::string & prop_key_) const;
955 
957  int32_t key_size(const std::string & prop_key_) const;
958 
960  bool has_key(const std::string & prop_key_) const;
961 
963  void key_lock (const std::string & prop_key_);
964 
966  void key_unlock (const std::string & prop_key_);
967 
969  const std::string & get_key_description (const std::string & prop_key_) const;
970 
972  void set_key_description (const std::string & prop_key_, const std::string &desc_);
973 
974  // 2011-11-27 FM: could be useful
976  //void rename (const std::string & prop_key_, const std::string & a_new_key);
977 
979  void erase(const std::string & key_);
980 
982  void erase_all();
983 
985  void erase_all_starting_with(const std::string & prefix_);
986 
988  void erase_all_not_starting_with(const std::string & prefix_);
989 
991  void export_all(properties & props_) const;
992 
994  void export_all_adding_prefix(properties & props_, const std::string & prefix_) const;
995 
997  void export_starting_with(properties & props_,
998  const std::string & prop_key_prefix_) const;
999 
1002  const std::string & prop_key_prefix_,
1003  const std::string & new_prefix_) const;
1004 
1006  void export_not_starting_with(properties & props_,
1007  const std::string & prop_key_prefix_) const;
1008 
1010  template <class key_predicate>
1011  void export_if(properties & props_, const key_predicate & predicate_) const;
1012 
1014  template <class key_predicate>
1015  void export_not_if(properties & props_,
1016  const key_predicate & predicate_) const;
1017 
1019  void erase_all_ending_with(const std::string & suffix_);
1020 
1022  void erase_all_not_ending_with(const std::string & suffix_);
1023 
1025  void export_ending_with(properties & props_,
1026  const std::string & suffix_) const;
1027 
1029  void export_not_ending_with(properties & props,
1030  const std::string & suffix_) const;
1031 
1033  void clean(const std::string & prop_key_);
1034 
1036  virtual void clear();
1037 
1039  void reset();
1040 
1042  void store_flag(const std::string & prop_key_, const std::string & desc_ = "",
1043  bool lock_ = false);
1044 
1046 
1048  void set_flag(const std::string & prop_key_);
1049 
1051 
1053  void unset_flag(const std::string & prop_key_);
1054 
1056  void store(const std::string & prop_key_, bool value_,
1057  const std::string & desc_ = "", bool lock_ = false);
1058 
1060  void store_boolean(const std::string & prop_key_, bool value_,
1061  const std::string & desc_ = "", bool lock_ = false);
1062 
1064  void store(const std::string & prop_key_, int value_,
1065  const std::string & desc_ = "", bool lock_ = false);
1066 
1068  void store_integer(const std::string & prop_key_, int value_,
1069  const std::string & desc_ = "",
1070  bool lock_ = false);
1071 
1073  void store(const std::string & prop_key_, double value_,
1074  const std::string & desc_ = "", bool lock_ = false);
1075 
1077  void store_real(const std::string & prop_key_, double value_,
1078  const std::string & desc_ = "", bool lock_ = false);
1079 
1081 
1090  void store_real_with_explicit_unit(const std::string & prop_key_, double value_,
1091  const std::string & desc = "", bool lock_ = false);
1092 
1095  void store_with_explicit_unit(const std::string & prop_key_, double value_,
1096  const std::string & desc = "", bool lock_ = false);
1097 
1099  void set_explicit_unit(const std::string & prop_key_, bool a_explicit_unit = true);
1100 
1102  bool has_explicit_unit(const std::string & prop_key_) const;
1103 
1105  void set_unit_symbol(const std::string & prop_key_, const std::string & unit_symbol = "");
1106 
1108  bool has_unit_symbol(const std::string & prop_key_) const;
1109 
1111  const std::string & get_unit_symbol(const std::string & prop_key_) const;
1112 
1114  void set_explicit_path(const std::string & prop_key_, bool a_explicit_path = true);
1115 
1117  bool is_explicit_path(const std::string & prop_key_) const;
1118 
1120  void store(const std::string & prop_key_, const std::string & value_,
1121  const std::string & desc_ = "", bool lock_ = false);
1122 
1124  void store_string(const std::string & prop_key_, const std::string & value_,
1125  const std::string & desc_ = "", bool lock_ = false);
1126 
1128  void store_path(const std::string & prop_key_, const std::string & path_value_,
1129  const std::string & desc_ = "", bool lock_ = false);
1130 
1132  void store(const std::string & prop_key_, const char* value_,
1133  const std::string & desc_ = "", bool lock_ = false);
1134 
1136  void store(const std::string & prop_key_, const data::vbool & value_,
1137  const std::string & desc_ = "", bool lock_ = false);
1138 
1140  void store(const std::string & prop_key_, const data::vint & value_,
1141  const std::string & desc_ = "", bool lock_ = false);
1142 
1144  void store(const std::string & prop_key_, const data::vdouble & value_,
1145  const std::string & desc_ = "", bool lock_ = false);
1146 
1148  void store(const std::string & prop_key_, const data::vstring & value_,
1149  const std::string & desc_ = "", bool lock_ = false);
1150 
1152  void store_paths(const std::string & prop_key_, const data::vstring & path_value_,
1153  const std::string & desc_ = "", bool lock_ = false);
1154 
1156  void change(const std::string & key_, bool value_, int index_ = 0);
1157 
1159  void change_boolean(const std::string & key_, bool value_, int index_ = 0);
1160 
1162  void change_boolean_scalar(const std::string & key_, bool value_);
1163 
1165  void change_boolean_vector(const std::string & key_, bool value_, int index_);
1166 
1168  void change(const std::string & key_, int value_, int index_ = 0);
1169 
1171  void change_integer(const std::string & key_, int value_, int index_ = 0);
1172 
1174  void change_integer_scalar(const std::string & key_, int value_);
1175 
1177  void change_integer_vector(const std::string & key_, int value_, int index_);
1178 
1180  void change(const std::string & key_, double value_, int index_ = 0);
1181 
1183  void change_real(const std::string & key_, double value_, int index_ = 0);
1184 
1186  void change_real_scalar(const std::string & key_, double value_);
1187 
1189  void change_real_vector(const std::string & key_, double value_, int index_);
1190 
1192  void change(const std::string & key_, const std::string & value_,
1193  int index_ = 0);
1194 
1196  void change_string(const std::string & key_, const std::string & value_,
1197  int index_ = 0);
1198 
1200  void change_string_scalar(const std::string & key_, const std::string & value_);
1201 
1203  void change_string_vector(const std::string & key_, const std::string & value_,
1204  int index_);
1205 
1207  void change(const std::string & key_, const char * value_, int index_ = 0);
1208 
1210  void change(const std::string & key_, const data::vbool & values_);
1211 
1213  void change(const std::string & key_, const data::vint & values_);
1214 
1216  void change(const std::string & key_, const data::vdouble & values_);
1217 
1219  void change(const std::string & key_, const data::vstring & values_);
1220 
1222  void update_flag(const std::string & key_);
1223 
1225  void update(const std::string & key_, bool value_);
1226 
1228  void update_boolean(const std::string & key_, bool value_);
1229 
1231  void update(const std::string & key_, int value_);
1232 
1234  void update_integer(const std::string & key_, int value_);
1235 
1237  void update(const std::string & key_, double value_);
1238 
1240  void update_real(const std::string & key_, double value_);
1241 
1243  void update_real_with_explicit_unit(const std::string & key_, double value_);
1244 
1246  void update_with_explicit_unit(const std::string & key_, double value_);
1247 
1249  void update(const std::string & key_, const std::string & value_);
1250 
1252  void update(const std::string & key_, const char* value_);
1253 
1255  void update_string(const std::string & key_, const std::string & value);
1256 
1258  void update(const std::string & key_, const data::vbool & values_);
1259 
1261  void update(const std::string & key_, const data::vint & values_);
1262 
1264  void update(const std::string & key_, const data::vdouble & values_);
1265 
1267  void update(const std::string & key_, const data::vstring & values_);
1268 
1270  bool has_flag(const std::string & key_) const;
1271 
1273  void fetch(const std::string & key_, bool & value_, int index_ = 0) const;
1274 
1276  void fetch(const std::string & key_, int & value_, int index_ = 0) const;
1277 
1279  void fetch(const std::string & key_, double & value_, int index_ = 0) const;
1280 
1282  void fetch(const std::string & key_, std::string & value_,
1283  int index = 0) const;
1284 
1286  void fetch(const std::string & key_, data::vbool & values_) const;
1287 
1289  void fetch(const std::string & key_, data::vint & values_) const;
1290 
1292  void fetch(const std::string & key_, data::vdouble & values_) const;
1293 
1295  void fetch_dimensionless(const std::string & key_, data::vdouble & values_) const;
1296 
1298  void fetch(const std::string & key_, data::vstring & values_) const;
1299 
1301  void fetch(const std::string & key_, std::set<std::string> & values_, bool allow_duplication_ = false) const;
1302 
1304  void fetch_unique_ordered(const std::string & key_, std::vector<std::string> & values_) const;
1305 
1307  void fetch(const std::string & key_, std::set<int> & values, bool allow_duplication_ = false) const;
1308 
1310  void fetch_positive(const std::string & key_, std::set<unsigned int> & values_, bool allow_duplication_ = false) const;
1311 
1313  bool fetch_boolean(const std::string &, int index_ = 0) const;
1314 
1316  bool fetch_boolean_scalar(const std::string & name_) const;
1317 
1319  bool fetch_boolean_vector(const std::string & name_, int index_) const;
1320 
1322  int fetch_integer(const std::string & name_, int index_ = 0) const;
1323 
1325  unsigned int fetch_positive_integer(const std::string & name_, int index_ = 0) const;
1326 
1328  unsigned int fetch_strict_positive_integer(const std::string & name_, int index_ = 0) const;
1329 
1331  int fetch_range_integer(const std::string & name_, int min_, int max_, int index_ = 0) const;
1332 
1334  int fetch_integer_scalar(const std::string & name_) const;
1335 
1337  int fetch_integer_vector(const std::string & name_ , int index_) const;
1338 
1340  double fetch_real(const std::string & name_, int index_ = 0) const;
1341 
1343  double fetch_dimensionless_real(const std::string & name_, int index_ = 0) const;
1344 
1346  double fetch_real_with_explicit_unit(const std::string & name_, int index_ = 0) const;
1347 
1349  double fetch_real_with_explicit_dimension(const std::string & name_, const std::string & dimension_, int index_ = 0) const;
1350 
1352  double fetch_real_scalar(const std::string & name_) const;
1353 
1355  double fetch_real_vector(const std::string & name_, int index_) const;
1356 
1358  std::string fetch_string(const std::string & name_, int index_ = 0) const;
1359 
1361  char fetch_one_character(const std::string & name_, int index_ = 0) const;
1362 
1364  std::string fetch_string_scalar(const std::string & name_) const;
1365 
1367  std::string fetch_string_vector(const std::string & name_, int index_) const;
1368 
1370  std::string fetch_path(const std::string & name_, int index_ = 0) const;
1371 
1373  std::string fetch_path_scalar(const std::string & name_) const;
1374 
1376  std::string fetch_path_vector(const std::string & name_, int index_) const;
1377 
1379  void dump(std::ostream & out_ = std::clog) const;
1380 
1382  virtual void tree_dump(std::ostream & out_ = std::clog,
1383  const std::string & title_ = "",
1384  const std::string & indent_ = "",
1385  bool inherit_ = false) const;
1386 
1388  void print_tree(std::ostream & out_ = std::clog,
1389  const boost::property_tree::ptree & options_ = empty_options()) const override;
1390 
1391  std::string key_to_string(const std::string & key_) const;
1392 
1393  std::string key_to_property_string(const std::string & key_) const;
1394 
1395  void export_to_string_based_dictionary(std::map<std::string, std::string> & dict_,
1396  bool quoted_strings_ = true) const;
1397 
1399  void write_configuration(const std::string & filename_,
1400  uint32_t options_ = config::SMART_MODULO | config::SKIP_PRIVATE) const;
1401 
1405  void read_configuration(const std::string & filename_,
1406  uint32_t options_ = config::SMART_MODULO);
1407 
1409  static void write_config(const std::string & filename_,
1410  const properties & props_,
1411  uint32_t options_ = 0);
1412 
1416  static void read_config(const std::string & filename_,
1417  properties & props_,
1418  uint32_t options_ = 0);
1419 
1421  static std::string build_property_key(const std::string & prefix_,
1422  const std::string & subkey_);
1423 
1424 
1425  protected:
1426 
1429 
1430  private:
1431 
1432  void _check_nokey_(const std::string & prop_key_) const;
1433 
1434  void _check_key_(const std::string & prop_key_, data ** data_);
1435 
1436  void _check_key_(const std::string & prop_key_, const data ** data_) const;
1437 
1438  void _validate_key_(const std::string & prop_key_) const;
1439 
1440  void _clear_key_validator_();
1441 
1442  private:
1443 
1444  // Internal data:
1445  std::string _description_;
1446  pmap _props_;
1447 
1448  // Not serialized:
1449  const basic_key_validator * _key_validator_ = nullptr;
1450  bool _key_validator_deletion_;
1451 
1454 
1455 
1458 
1459 #ifndef Q_MOC_RUN
1460  DR_CLASS_RTTI()
1462 #endif // Q_MOC_RUN
1463 
1464  };
1465 
1467  const properties & empty_config();
1468 
1469  //----------------------------------------------------------------------
1470  // properties class template method definitions
1471  //
1472  template <class key_predicate>
1474  const key_predicate & predicate_) const
1475  {
1476  DT_THROW_IF (this == &props_,
1477  std::logic_error, "Self export is not allowed !");
1479  for (pmap::const_iterator iter = _props_.begin(); iter != _props_.end();
1480  ++iter) {
1481  if (predicate_(iter->first)) {
1482  ks.push_back(iter->first);
1483  }
1484  }
1485  for (keys_col_type::const_iterator i = ks.begin(); i != ks.end(); ++i) {
1486  properties & ptmp = const_cast<properties &>(*this);
1487  props_._props_[*i] = ptmp._props_[*i];
1488  }
1489  return;
1490  }
1491 
1492  template <class key_predicate>
1494  const key_predicate & predicate_) const
1495  {
1496  DT_THROW_IF (this == &props_,
1497  std::logic_error, "Self export is not allowed !");
1498  keys_col_type ks;
1499  for (pmap::const_iterator iter = _props_.begin(); iter != _props_.end();
1500  ++iter) {
1501  if (!predicate_(iter->first)) {
1502  ks.push_back(iter->first);
1503  }
1504  }
1505  for (keys_col_type::const_iterator i = ks.begin(); i != ks.end(); ++i) {
1506  properties & ptmp = const_cast<properties &>(*this);
1507  props_._props_[*i] = ptmp._props_[*i];
1508  }
1509  return;
1510  }
1511 
1512 } // end of namespace datatools
1513 
1514 // Support for serialization tag :
1516 // Support for old serialization tag :
1518 
1519 #ifdef __clang__
1520 #pragma clang diagnostic push
1521 #pragma clang diagnostic ignored "-Wunused-local-typedef"
1522 #endif
1523 #include <boost/serialization/export.hpp>
1524 #ifdef __clang__
1525 #pragma clang diagnostic pop
1526 #endif
1527 
1528 BOOST_CLASS_EXPORT_KEY2(datatools::properties, "datatools::properties")
1529 
1530 #ifndef Q_MOC_RUN
1531 // Activate reflection layer for the 'datatools::properties' class:
1533 #endif // Q_MOC_RUN
1534 
1535 // Explicit class version:
1536 #include <boost/serialization/version.hpp>
1537 BOOST_CLASS_VERSION(datatools::properties::data, 2)
1538 BOOST_CLASS_VERSION(datatools::properties, 2)
1539 
1540 #endif // DATATOOLS_PROPERTIES_H
1541 
1542 // Local Variables: --
1543 // mode: c++ --
1544 // c-file-style: "gnu" --
1545 // tab-width: 2 --
1546 // End: --
static const boost::property_tree::ptree & empty_options()
#define DR_CLASS_INIT(Introspectable)
Inform Camp that class Introspectable exists and trigger the automatic registration of dedicated refl...
Definition: reflection_interface.h:149
void change_integer_vector(const std::string &key_, int value_, int index_)
Change the value of an existing integer vector property with a given key/name and index.
void store_flag(const std::string &prop_key_, const std::string &desc_="", bool lock_=false)
Set a boolean 'true' flag with a given key/name, a description string and a lock request.
#define DATATOOLS_CLONEABLE_DECLARATION(Copyable)
Definition: i_cloneable.h:113
char fetch_one_character(const std::string &name_, int index_=0) const
Fetch a single character value stored with a given key/name and index.
static const char TYPE_REAL_SYMBOL
Definition: properties.h:160
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Method for smart printing (from the datatools::i_tree_dump interface).
void fetch_dimensionless(const std::string &key_, data::vdouble &values_) const
Fetch the dimensionless real vector value stored with a given key/name.
void store_string(const std::string &prop_key_, const std::string &value_, const std::string &desc_="", bool lock_=false)
Store a string property with a given key/name and value.
Use smart modulo (write)
Definition: properties.h:463
static const char TYPE_STRING_SYMBOL
Definition: properties.h:161
static const uint32_t bit08
Definition: bit_mask.h:35
Base abstract class of all serializable (and possibly introspectable) classes.
Definition: i_serializable.h:51
virtual ~properties()
Destructor.
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
std::string key_to_string(const std::string &key_) const
void change(const std::string &key_, bool value_, int index_=0)
Change the value of an existing boolean property with a given key/name and index.
bool is_explicit_path() const
Check if the (string only) data has been initialized with explicit path.
bool is_unlocked() const
Check if the data is not locked (can be modified)
std::vector< int32_t > vint
Container for integer data.
Definition: properties.h:179
int set_explicit_unit(bool explicit_unit_flag_)
Set the explicit unit flag.
Default abstract class for key validator.
Definition: properties.h:415
friend class config
Definition: properties.h:434
void store_integer(const std::string &prop_key_, int value_, const std::string &desc_="", bool lock_=false)
Store an integer property with a given key/name and value.
virtual ~data()
Destructor.
static const uint32_t bit07
Definition: bit_mask.h:34
std::string fetch_path(const std::string &name_, int index_=0) const
Fetch a file path from a string value stored with a given key/name and index.
std::string get_short_description() const
Get the short description string associated to the container.
std::string get_type_label() const
Get a string label associated to the type of the stored data.
void fetch_positive(const std::string &key_, std::set< unsigned int > &values_, bool allow_duplication_=false) const
Fetch a set of unsigned integer values from the vector value stored with a given key/name.
void erase_all_not_ending_with(const std::string &suffix_)
Erase all properties with key/name not ending with a given suffix.
decoration_mode_type
Decoration mode.
Definition: properties.h:448
static const int ERROR_BADTYPE
Definition: properties.h:141
std::vector< std::string > keys_col_type
Definition: properties.h:775
void update_real(const std::string &key_, double value_)
Update a real flag with a given key/name and value.
int32_t key_size(const std::string &prop_key_) const
Returns the size of the data stored with a given key/name.
const std::string & get_key_description(const std::string &prop_key_) const
Get the description string associated to a property with given key/name.
void export_all_adding_prefix(properties &props_, const std::string &prefix_) const
Export all properties into another properties container adding a prefix.
std::vector< std::string > keys() const
Returns the list of keys stored in the map (read-only).
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
#define DATATOOLS_SERIALIZATION_DECLARATION_ADVANCED(ClassName)
Definition: i_serializable.h:371
int fetch_range_integer(const std::string &name_, int min_, int max_, int index_=0) const
Fetch the ranged integer value stored with a given key/name and index.
static const uint32_t bit01
Definition: bit_mask.h:28
void fetch(const std::string &key_, bool &value_, int index_=0) const
Fetch the boolean value stored with a given key/name and index.
static const uint8_t MASK_VECTOR
Definition: properties.h:150
void change_boolean_vector(const std::string &key_, bool value_, int index_)
Change the value of an existing vector boolean property with a given key/name and index.
static const uint32_t bit09
Definition: bit_mask.h:36
static const uint32_t bit03
Definition: bit_mask.h:30
bool get_boolean_value(int index_=0) const
Get the boolean value stored at a given rank.
const std::string & key(int) const
Returns the ith key.
int set_value_with_unit(double value_, int index_=0, const std::string &unit_symbol_="")
Set the real value at a given rank.
static const int SCALAR_DEF
Definition: properties.h:165
Skip private properties bit.
Definition: properties.h:458
static std::string get_error_message(int error_code_)
Returns an error message from an integer error code.
void store_boolean(const std::string &prop_key_, bool value_, const std::string &desc_="", bool lock_=false)
Store a boolean property with a given key/name and value.
bool has_short_description() const
Check if a short description string is associated to the container.
int get_value(bool &value_, int index_=0) const
Get the boolean value by reference stored at a given rank.
void change_string_scalar(const std::string &key_, const std::string &value_)
Change the value of an existing string scalar property with a given key/name.
void export_starting_with(properties &props_, const std::string &prop_key_prefix_) const
Export all properties with key/name starting with a given prefix to another properties container.
options_flag
Option flags used at construction.
Definition: properties.h:457
void change_integer(const std::string &key_, int value_, int index_=0)
Change the value of an existing integer property with a given key/name and index.
void change_real_vector(const std::string &key_, double value_, int index_)
Change the value of an existing real vector property with a given key/name and index.
std::string fetch_string_scalar(const std::string &name_) const
Fetch the string scalar value stored with a given key/name.
#define DATATOOLS_SERIALIZATION_EXT_SERIAL_TAG_DECLARATION(ClassName)
Template support for serializable type (backward compatibility support)
Definition: i_serializable.h:101
static const uint32_t bit04
Definition: bit_mask.h:31
static std::string make_private_key(const std::string &prop_key_)
Return a static key.
void keys_not_starting_with(std::vector< std::string > &, const std::string &prefix_) const
builds the list of keys (by reference) stored in the map that start with prefix.
void keys_ending_with(std::vector< std::string > &, const std::string &suffix_) const
builds the list of keys (by reference) stored in the map that end with suffix.
static const uint32_t bit06
Definition: bit_mask.h:33
void export_not_starting_with(properties &props_, const std::string &prop_key_prefix_) const
Export all properties with key/name not starting with a given suffix to another properties container.
static const uint8_t MASK_LOCK
Definition: properties.h:149
int get_integer_value(int index_=0) const
Get the integer value stored at a given rank.
void clean(const std::string &prop_key_)
Remove a property with a given key/name.
int boolean(int size_=SCALAR_DEF)
Assign N boolean values.
Utility macros for exception handling.
void update_real_with_explicit_unit(const std::string &key_, double value_)
Update a real flag with a given key/name and value.
int real(int size_=SCALAR_DEF)
Assign N real values.
static void write_config(const std::string &filename_, const properties &props_, uint32_t options_=0)
Store the properties' container object in an ASCII text file.
void set_description(const std::string &description_)
Set the description string associated to the stored data.
int fetch_integer_vector(const std::string &name_, int index_) const
Fetch the integer vector value stored with a given key/name and index.
static const int ERROR_LOCK
Definition: properties.h:143
std::vector< bool > vbool
Container for boolean data.
Definition: properties.h:178
double fetch_real_with_explicit_unit(const std::string &name_, int index_=0) const
Fetch the physical quantity (with its explicit unit) value stored with a given key/name and index.
std::string fetch_path_scalar(const std::string &name_) const
Fetch a file path from a string scalar value stored with a given key/name.
void export_to_string_based_dictionary(std::map< std::string, std::string > &dict_, bool quoted_strings_=true) const
void read_configuration(const std::string &filename_, uint32_t options_=config::SMART_MODULO)
bool fetch_boolean(const std::string &, int index_=0) const
Fetch the boolean value stored with a given key/name and index.
void export_all(properties &props_) const
Export all properties into another properties container.
void keys_not_ending_with(std::vector< std::string > &, const std::string &suffix_) const
builds the list of keys (by reference) stored in the map that end with suffix.
double get_real_value(int index_=0) const
Get the real value stored at a given rank.
bool is_string() const
Check if the data is a string value.
static const uint32_t bit11
Definition: bit_mask.h:38
static const char TYPE_BOOLEAN_SYMBOL
Definition: properties.h:158
std::string fetch_string_vector(const std::string &name_, int index_) const
Fetch the string vector value stored with a given key/name and index.
void export_not_ending_with(properties &props, const std::string &suffix_) const
Export all properties with key/name not ending with a given suffix to another properties container.
#define DATATOOLS_SERIALIZATION_EXT_BACKWARD_SERIAL_TAG_DECLARATION(ClassName)
Definition: i_serializable.h:180
const data & get(const std::string &prop_key_) const
Access to a non-mutable reference to a property data object.
void export_not_if(properties &props_, const key_predicate &predicate_) const
Export all properties with key/name not fulfilling a given predicate.
bool is_path() const
Check if the data is a path string value.
keys_col_type ks
Definition: properties.h:1478
int lock()
Lock the value (make it unmutable)
void change_string_vector(const std::string &key_, const std::string &value_, int index_)
Change the value of an existing string vector property with a given key/name and index.
void set_key_description(const std::string &prop_key_, const std::string &desc_)
Set the description string associated to a property with given key/name.
static default_key_validator & global_default_key_validator()
Default global key validator (singleton)
void erase_all_starting_with(const std::string &prefix_)
Erase all properties with key/name starting with prefix.
int string(int size_=SCALAR_DEF)
Assign N string values.
bool has_auxiliary_descriptions() const
Check if some auxiliary descriptions are set.
static const char STRING_FORBIDDEN_CHAR
Definition: properties.h:163
static const int ERROR_RANGE
Definition: properties.h:142
static const uint8_t TYPE_STRING
Definition: properties.h:156
void update_flag(const std::string &key_)
Update a boolean flag to true with a given key/name.
void export_ending_with(properties &props_, const std::string &suffix_) const
Export all properties with key/name ending with a given suffix to another properties container.
Class for ASCII file I/O operations with properties objects.
Definition: properties.h:436
void change_string(const std::string &key_, const std::string &value_, int index_=0)
Change the value of an existing string property with a given key/name and index.
virtual void clear()
Reset method (from the datatools::i_clear interface).
void key_lock(const std::string &prop_key_)
Lock a property with given key/name.
void dump(std::ostream &out_) const
Basic print.
data(char type_=TYPE_INTEGER_SYMBOL, int size_=SCALAR_DEF)
Constructor.
bool empty() const
Check if the value array is empty.
bool has_flag(const std::string &key_) const
Check if a boolean value with a given key/name exists with value 'true'.
bool has_description() const
Check is description is set.
void store(const std::string &key_, const data &value_)
Store data item with supplied key.
void store_paths(const std::string &prop_key_, const data::vstring &path_value_, const std::string &desc_="", bool lock_=false)
Store a path string vector property with a given key/name and value.
int set_explicit_path(bool explicit_path_flag_)
Set the explicit path flag.
void change_boolean_scalar(const std::string &key_, bool value_)
Change the value of an existing scalar boolean property with a given key/name.
bool has_key(const std::string &prop_key_) const
Check if a property with given key/name exists.
static const uint32_t bit10
Definition: bit_mask.h:37
double fetch_real(const std::string &name_, int index_=0) const
Fetch the real value stored with a given key/name and index.
static const char TYPE_INTEGER_SYMBOL
Definition: properties.h:159
static const uint32_t bit02
Definition: bit_mask.h:29
void export_and_rename_starting_with(properties &props_, const std::string &prop_key_prefix_, const std::string &new_prefix_) const
Export all properties with key/name starting with a given prefix to another properties container but ...
static const uint8_t TYPE_BOOLEAN
Definition: properties.h:153
static void read_config(const std::string &filename_, properties &props_, uint32_t options_=0)
void erase(const std::string &key_)
Rename a property with a new name.
void reset()
Reset method.
A pure abstract class (interface) for inherited clearable classes.
Definition: i_clear.h:9
void store_path(const std::string &prop_key_, const std::string &path_value_, const std::string &desc_="", bool lock_=false)
Store a path property with a given key/name and value.
static const uint32_t bit05
Definition: bit_mask.h:32
bool fetch_boolean_vector(const std::string &name_, int index_) const
Fetch the boolean vector value stored with a given key/name and index.
std::vector< std::string > vstring
Container for character string data.
Definition: properties.h:181
bool has_unit_symbol() const
Check if the data has an unit symbol.
bool fetch_boolean_scalar(const std::string &name_) const
Fetch the boolean scalar value stored with a given key/name.
void set_flag(const std::string &prop_key_)
Set a boolean 'true' flag with a given key/name.
static const std::string string_value()
#define DATATOOLS_SERIALIZATION_BACKWARD_SERIAL_TAG_SUPPORT()
Definition: i_serializable.h:174
static const uint8_t MASK_TYPE
Definition: properties.h:145
int get_type() const
Return type.
Pure abstract class for key validator.
Definition: properties.h:403
const std::string & get_unit_symbol() const
Get the unit symbol associated to the stored real data.
int set_unit_symbol(const std::string &symbol_)
static const std::string & private_property_prefix()
void update_with_explicit_unit(const std::string &key_, double value_)
Update a real flag with a given key/name and value.
bool has_explicit_unit() const
Check if the (real only) data has been initialized with explicit unit.
std::map< std::string, data > pmap
Definition: properties.h:771
virtual ~basic_key_validator()
Definition: properties.h:406
#define DT_THROW_IF(Condition, ExceptionType, Message)
Definition: exception.h:76
bool is_locked() const
Check if the data is locked (cannot be modified)
static bool key_is_private(const std::string &prop_key_)
Check if a string matches a private 'prop_key_'.
bool is_scalar() const
Check if the data is scalar (exactly one value)
void unset_flag(const std::string &prop_key_)
Remove a boolean flag with a given key/name.
Internal data stored within the dictionary of the properties class.
Definition: properties.h:136
void update_string(const std::string &key_, const std::string &value)
Update a string flag with a given key/name and value.
static const uint8_t MASK_EXPLICIT_UNIT
Definition: properties.h:148
int unlock()
Unlock the value (make it mutable)
void unset_key_validator()
Unset the current key validator.
A pure abstract class (interface) for inherited cloneable classes.
Definition: i_cloneable.h:75
static const int ERROR_FAILURE
Definition: properties.h:140
std::vector< double > vdouble
Container for real data.
Definition: properties.h:180
void set_default_key_validator()
Use the default key validator.
void set_key_validator(const basic_key_validator &)
Set the current key validator.
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
static std::string build_property_key(const std::string &prefix_, const std::string &subkey_)
Build a new property key from a prefix and a key.
double fetch_real_scalar(const std::string &name_) const
Fetch the real scalar value stored with a given key/name.
bool is_public(const std::string &prop_key_) const
Check if data with name 'prop_key_' is public.
void change_boolean(const std::string &key_, bool value_, int index_=0)
Change the value of an existing boolean property with a given key/name and index.
void update_integer(const std::string &key_, int value_)
Update an integer flag with a given key/name and value.
std::string fetch_path_vector(const std::string &name_, int index_) const
Fetch a file path from a string vector value stored with a given key/name and index.
bool is_private(const std::string &prop_key_) const
Check if data with name 'prop_key_' is private.
int integer(int size_=SCALAR_DEF)
Assign N integer values.
double fetch_dimensionless_real(const std::string &name_, int index_=0) const
Fetch the dimensionless real value stored with a given key/name and index.
unsigned int fetch_positive_integer(const std::string &name_, int index_=0) const
Fetch the positive integer value stored with a given key/name and index.
void change_real(const std::string &key_, double value_, int index_=0)
Change the value of an existing real property with a given key/name and index.
void key_unlock(const std::string &prop_key_)
Unlock a property with given key/name.
void write_configuration(const std::string &filename_, uint32_t options_=config::SMART_MODULO|config::SKIP_PRIVATE) const
Store the properties' container object in an ASCII text file.
int set_value(bool value_, int index_=0)
Set the boolean value at a given rank.
static const uint8_t MASK_UNIT_SYMBOL
Definition: properties.h:146
void store_real(const std::string &prop_key_, double value_, const std::string &desc_="", bool lock_=false)
Store a real property with a given key/name and value.
void keys_starting_with(std::vector< std::string > &, const std::string &prefix_) const
builds the list of keys (by reference) stored in the map that start with prefix.
void store_with_explicit_unit(const std::string &prop_key_, double value_, const std::string &desc="", bool lock_=false)
bool fetch_auxiliary_descriptions(std::vector< std::string > &) const
Fetch the auxiliary description strings associated to the container.
void update_boolean(const std::string &key_, bool value_)
Update a boolean flag with a given key/name and value.
Describe the datatools API configuration.
static const uint32_t bit00
Definition: bit_mask.h:27
bool is_boolean() const
Check if the data is a boolean value.
int32_t get_size() const
Returns the size of the array of stored values (1 if scalar, >=0 if vector)
static const uint32_t bit12
Definition: bit_mask.h:39
static bool key_is_public(const std::string &prop_key_)
Check if a string matches a public 'prop_key_'.
std::string get_string_value(int index_=0) const
Get the string value stored at a given rank.
void erase_all()
Erase all properties.
static bool has_forbidden_char(const std::string &checked_)
Check if a string contains a forbidden character.
void print_tree(std::ostream &out_=std::clog, const boost::property_tree::ptree &options_=empty_options()) const override
Smart print.
#define DR_CLASS_RTTI()
Declare Camp RTTI within class declaration.
Definition: reflection_interface.h:46
static const uint8_t TYPE_NONE
Definition: properties.h:152
bool fetch_short_description(std::string &) const
Fetch the short description string associated to the container.
int fetch_integer_scalar(const std::string &name_) const
Fetch the integer scalar value stored with a given key/name.
properties()
Default constructor with embedded default key validator.
bool is_integer() const
Check if the data is a integer value.
std::string get_vector_label() const
Get a string label associated to the scalar/vector trait of the stored data.
static const int SCALAR_SIZE
Definition: properties.h:166
int32_t size() const
Returns the size of the array of stored values (1 if scalar, >=0 if vector)
void fetch_unique_ordered(const std::string &key_, std::vector< std::string > &values_) const
Fetch a list of unique string values from the vector value stored with a given key/name.
const properties & empty_config()
Return a non mutable reference to a singleton empty configuration container (can be used as default e...
static const int ERROR_SUCCESS
Definition: properties.h:139
static const uint8_t MASK_EXPLICIT_PATH
Definition: properties.h:147
void to_string(std::ostream &out_) const
Convert to string and print in an output stream.
unsigned int fetch_strict_positive_integer(const std::string &name_, int index_=0) const
Fetch the strict positive integer value stored with a given key/name and index.
void change_real_scalar(const std::string &key_, double value_)
Change the value of an existing real scalar property with a given key/name.
static const uint8_t TYPE_REAL
Definition: properties.h:155
double fetch_real_with_explicit_dimension(const std::string &name_, const std::string &dimension_, int index_=0) const
Fetch the physical quantity (with its explicit dimension) value stored with a given key/name and inde...
void update(const std::string &key_, bool value_)
Update a boolean flag with a given key/name and value.
void export_if(properties &props_, const key_predicate &predicate_) const
Export all properties with key/name fulfilling a given predicate.
bool has_type() const
Check if the data type is valid.
void erase_all_not_starting_with(const std::string &prefix_)
Erase all properties with key/name not starting with prefix.
void change_integer_scalar(const std::string &key_, int value_)
Change the value of an existing integer scalar property with a given key/name.
double fetch_real_vector(const std::string &name_, int index_) const
Fetch the real vector value stored with a given key/name and index.
const std::string & get_description() const
Get the description string associated to the stored data.
void store_real_with_explicit_unit(const std::string &prop_key_, double value_, const std::string &desc="", bool lock_=false)
Store a real property with a given key/name and value with the explicit unit flag.
std::string key_to_property_string(const std::string &key_) const
#define BOOST_SERIALIZATION_BASIC_DECLARATION()
Definition: serialization_macros.h:62
Provides static method for default values for each supported type.
Definition: properties.h:169
int fetch_integer(const std::string &name_, int index_=0) const
Fetch the integer value stored with a given key/name and index.
bool index_is_valid(int index_) const
Check if array index is valid.
std::string fetch_string(const std::string &name_, int index_=0) const
Fetch the string value stored with a given key/name and index.
A dictionary of arbitrary properties.
Definition: properties.h:125
static const uint8_t TYPE_INTEGER
Definition: properties.h:154
bool is_vector() const
Check if the data is vector (>=0 stored values in an array)
void erase_all_ending_with(const std::string &suffix_)
Erase all properties with key/name ending with a given suffix.
bool is_real() const
Check if the data is a real value.