Jpp 21.0.0
the software that should make you happy
Loading...
Searching...
No Matches
JProperties.hh
Go to the documentation of this file.
1#ifndef __JEEP__JPROPERTIES__
2#define __JEEP__JPROPERTIES__
3
4#include <string>
5#include <istream>
6#include <ostream>
7#include <fstream>
8#include <sstream>
9#include <map>
10#include <vector>
11#include <memory>
12
14#include "JLang/JAbstractIO.hh"
15#include "JLang/JException.hh"
18#include "JLang/JEquation.hh"
20#include "JLang/JCategory.hh"
21#include "JLang/JClass.hh"
24#include "Jeep/JMessage.hh"
25
26
27/**
28 * \file
29 * Utility class to parse parameter values.
30 * \author mdejong
31 */
32namespace JEEP {}
33namespace JPP { using namespace JEEP; }
34
35namespace JEEP {
36
44 using JLANG::JEquation;
47
48
49 /**
50 * Check for stream state.
51 *
52 * Note that end-of-file is not defined as an error so to normally process e.g.\ std::string and std::vector.
53 *
54 * \param in input stream
55 * \return true if failure; else false
56 */
57 inline bool fail(std::istream& in)
58 {
59 return in.bad() || (in.fail() && !in.eof());
60 }
61
62
63 /**
64 * Interface for I/O of properties element.
65 */
67 public JStreamInput,
68 public JStreamOutput,
70 {
71 public:
72
75
76
77 /**
78 * Get properties type.
79 *
80 * \return false
81 */
82 virtual bool is_properties() const
83 {
84 return false;
85 }
86
87
88 /**
89 * Equality between property element interfaces.
90 *
91 * \param element properties element interface
92 * \return false
93 */
94 virtual bool equals(const JPropertiesElementInterface& element) const
95 {
96 return false;
97 }
98 };
99
100
101 class JPropertiesElement; // Forward declaration.
102
103
104 /**
105 * Template class for I/O of properties element.
106 *
107 * This class implements the JPropertiesElementInterface interface.
108 */
109 template<class T>
112 {
113
114 friend class JPropertiesElement;
115
116 public:
117 /**
118 * Constructor.
119 *
120 * \param value reference of template object
121 */
124 object(value)
125 {}
126
127
128 /**
129 * Stream input.
130 *
131 * \param in input stream
132 * \return input stream
133 */
134 virtual std::istream& read(std::istream& in) override
135 {
136 using namespace std;
137
138 readObject(in, object);
139
140 string buffer;
141
142 in >> buffer;
143
144 if (!buffer.empty()) {
145 THROW(JPropertiesException, "JProperties: pending data <" << buffer << (in.peek() != EOF ? "..." : "") << ">");
146 }
147
148 return in;
149 }
150
151
152 /**
153 * Stream output.
154 *
155 * \param out output stream
156 * \param prefix prefix
157 * \param postfix postfix
158 * \return output stream
159 */
160 virtual std::ostream& write(std::ostream& out,
161 const char* prefix,
162 const char postfix) const override
163 {
164 return writeObject(out, prefix, object, postfix);
165 }
166
167
168 /**
169 * Stream output.
170 *
171 * \param out output stream
172 * \return output stream
173 */
174 virtual std::ostream& write(std::ostream& out) const override
175 {
176 return writeObject(out, object);
177 }
178
179
180 /**
181 * Equality between property element interfaces.
182 *
183 * \param element properties element interface
184 * \return true if equal; else false
185 */
186 virtual bool equals(const JPropertiesElementInterface& element) const override
187 {
188 const JPropertiesTemplateElement<T>* p = dynamic_cast<const JPropertiesTemplateElement<T>*>(&element);
189
190 if (p != NULL)
191 return compareObjects(object, p->object);
192 else
193 return false;
194 }
195
196
197 protected:
199 };
200
201
202 /**
203 * Template specialisation of JPropertiesTemplateElement for const data type.
204 *
205 * This class implements the JPropertiesElementInterface interface.
206 */
207 template<class T>
210 {
211
212 friend class JPropertiesElement;
213
214 public:
215 /**
216 * Constructor.
217 *
218 * \param value reference of template object
219 */
220 JPropertiesTemplateElement(const T& value) :
222 object(value)
223 {}
224
225
226 /**
227 * Stream input.
228 *
229 * \param in input stream
230 * \return input stream
231 */
232 virtual std::istream& read(std::istream& in) override
233 {
234 THROW(JPropertiesException, "JPropertiesTemplateElement<>::read() reading of const data type.");
235 }
236
237
238 /**
239 * Stream output.
240 *
241 * \param out output stream
242 * \return output stream
243 */
244 virtual std::ostream& write(std::ostream& out) const override
245 {
246 return writeObject(out, object);
247 }
248
249
250 /**
251 * Stream output.
252 *
253 * \param out output stream
254 * \param prefix prefix
255 * \param postfix postfix
256 * \return output stream
257 */
258 virtual std::ostream& write(std::ostream& out,
259 const char* prefix,
260 const char postfix) const override
261 {
262 return writeObject(out, prefix, object, postfix);
263 }
264
265
266 /**
267 * Equality between property element interfaces.
268 *
269 * \param element properties element interface
270 * \return true if equal; else false
271 */
272 virtual bool equals(const JPropertiesElementInterface& element) const override
273 {
274 const JPropertiesTemplateElement<const T>* p = dynamic_cast<const JPropertiesTemplateElement<const T>*>(&element);
275
276 if (p != NULL)
277 return compareObjects(object, p->object);
278 else
279 return false;
280 }
281
282
283 protected:
284 const T& object;
285 };
286
287
288 /**
289 * The property value class.
290 * This class consists of a pointer to the JPropertiesElementInterface.
291 * This class implements the assignment and type conversion operators.
292 */
294 public std::shared_ptr<JPropertiesElementInterface>
295 {
296 public:
297 /**
298 * Default constructor.
299 */
301 end_marker(false)
302 {}
303
304
305 /**
306 * Constructor.
307 *
308 * \param value reference to template object
309 */
310 template<class T>
312 end_marker(false)
313 {
314 reset(new JPropertiesTemplateElement<T>(value));
315 }
316
317
318 /**
319 * Equality between property elements.
320 *
321 * \param element properties element
322 * \return true if equal; else false
323 */
324 bool equals(const JPropertiesElement& element) const
325 {
326 return get()->equals(*element.get());
327 }
328
329
330 /**
331 * Assignment operator.
332 *
333 * \param value reference to template object
334 * \return this JPropertiesElement
335 */
336 template<class T>
338 {
339 reset(new JPropertiesTemplateElement<T>(value));
340
341 return *this;
342 }
343
344
345 /**
346 * Get value.
347 *
348 * \return value of this JPropertiesElement
349 */
350 template<class T>
351 const T& getValue() const
352 {
353 const JPropertiesTemplateElement<T>* p = dynamic_cast<const JPropertiesTemplateElement<T>*>(this->get());
354
355 if (p != NULL)
356 return p->object;
357 else
358 THROW(JPropertiesException, "Inconsistent data type.");
359 }
360
361
362 /**
363 * Get value.
364 *
365 * \return value of this JPropertiesElement
366 */
367 template<class T>
369 {
370 JPropertiesTemplateElement<T>* p = dynamic_cast<JPropertiesTemplateElement<T>*>(this->get());
371
372 if (p != NULL)
373 return p->object;
374 else
375 THROW(JPropertiesException, "Inconsistent data type.");
376 }
377
378
379
380 /**
381 * Set value of this JPropertiesElement.
382 *
383 * \param value value
384 */
385 template<class T>
386 void setValue(const T& value)
387 {
388 JPropertiesTemplateElement<T>* p = dynamic_cast<JPropertiesTemplateElement<T>*>(this->get());
389
390 if (p != NULL)
391 p->object = value;
392 else
393 THROW(JPropertiesException, "Inconsistent data type.");
394 }
395
396
397 /**
398 * Convert to string.
399 *
400 * \return value of this JPropertiesElement
401 */
402 std::string toString() const
403 {
404 std::ostringstream os;
405
406 get()->write(os, "", '\0');
407
408 return os.str();
409 }
410
411
412 /**
413 * Convert to template type.
414 *
415 * \return value of this JPropertiesElement
416 */
417 template<class T>
418 T toValue() const
419 {
420 T value;
421
422 std::istringstream in(this->toString());
423
424 in >> value;
425
426 return value;
427 }
428
429
430 /**
431 * Type conversion operator.
432 *
433 * \return value of this JPropertiesElement
434 */
435 template<class T>
436 operator const T&() const
437 {
438 return getValue<T>();
439 }
440
441
442 /**
443 * Get end marker.
444 *
445 * \return end marker
446 */
447 bool getEndMarker() const
448 {
449 return end_marker;
450 }
451
452
453 /**
454 * Set end marker.
455 *
456 * \param marker if true stop reading after this properties element, else continue
457 */
458 void setEndMarker(const bool marker)
459 {
460 end_marker = marker;
461 }
462
463
464 private:
466 };
467
468
469 /**
470 * Utility class to parse parameter values.
471 *
472 * The mapping between a parameter (of any type) and a value
473 * has to be defined in the user's program, e.g.
474 *
475 *\code{.cpp}
476
477 #include "Jeep/JProperties.hh"
478
479 ifstream in(filename.c_str());
480
481 JProperties zap;
482
483 int integer_value;
484 double double_value;
485 string string_value;
486
487 zap.insert(make_property(integer_value)); // key == parameter name
488 zap.insert(make_property(double_value)); // key == parameter name
489
490 zap["mies"] = string_value;
491
492 zap.read(in);
493 zap.write(cout);
494 \endcode
495 */
496 class JProperties :
497 public std::map<std::string, JPropertiesElement>,
498 public JEquationParameters,
499 public JMessage<JProperties>
500 {
501 public:
502
504
506
507
508 /**
509 * Utility method to strip off all leading characters from a string until specified character(s).
510 *
511 * \param buffer input string
512 * \param sep last character(s) to strip
513 * \return modified string
514 */
515 static inline std::string getKey(const std::string& buffer, const std::string& sep)
516 {
517 using namespace std;
518
519 const size_type pos = buffer.find_last_of(sep);
520
521 if (pos != string::npos)
522 return buffer.substr(pos + 1);
523 else
524 return buffer;
525 }
526
527
528 /**
529 * Constructor.
530 *
531 * \param debug debug level
532 */
533 JProperties(const int debug = 0) :
534 JMap_t(),
536 {
537 this->debug = debug;
538 }
539
540
541 /**
542 * Constructor.
543 *
544 * \param parameters equation parameters
545 * \param debug debug level
546 */
548 const int debug = 0) :
549 JMap_t(),
550 JEquationParameters(parameters)
551 {
552 this->debug = debug;
553 }
554
555
556 /**
557 * Put object at given key.
558 *
559 * \param key key
560 * \param object object
561 */
562 template<class T>
563 void put(const std::string& key, T& object)
564 {
565 this->insert(value_type(key, JPropertiesElement(object)));
566 }
567
568
569 /**
570 * Join properties objects.
571 *
572 * \param properties properties
573 * \return properties
574 */
575 JProperties& join(const JProperties& properties)
576 {
577 JEquationParameters::join(properties);
578
579 insert(properties.begin(), properties.end());
580
581 return *this;
582 }
583
584
585 /**
586 * Read equation.
587 *
588 * \param equation equation
589 * \return status
590 */
591 bool read(const JEquation& equation)
592 {
593 using namespace std;
594
595 iterator p = find(equation.getKey());
596
597 DEBUG("Processing key: " << equation.getKey() << ' ' << (p != end()) << endl);
598
599 if (p != end()) {
600
601 istringstream is(equation.getValue());
602
603 if (isDivision(equation.getSeparator())) {
604
605 if (p->second->is_properties()) {
606
607 p->second->read(is);
608
609 } else {
610
611 ERROR("JProperties::read(): no properties object after division <" << equation.getKey() << ">" << endl);
612 }
613
614 } else if (isSeparator(equation.getSeparator())) {
615
616 try {
617 p->second->read(is);
618 }
619 catch(const exception& error) {
620 ERROR("JProperties::read(): read error at key <" << equation.getKey() << "> " << error.what() << endl);
621 }
622
623 } else {
624
625 ERROR("JProperties::read(): illegal character following key <" << equation.getKey() << "> " << equation.getSeparator() << endl);
626 }
627
628 if (p->second.getEndMarker()) {
629 return false;
630 }
631
632 if (fail(is)) {
633
634 ERROR("JProperties::read(): error reading data for key <" << equation.getKey() << "> " << equation.getValue() << endl);
635 }
636
637 } else {
638
639 WARNING("JProperties::read(): unknown key <" << equation.getKey() << ">" << endl);
640 }
641
642 return true;
643 }
644
645
646 /**
647 * Read from input string.
648 *
649 * \param buffer input string
650 * \return read status
651 */
652 bool read(const std::string& buffer)
653 {
654 std::istringstream in(buffer);
655
656 return !fail(read(in));
657 }
658
659
660 /**
661 * Read from input stream.
662 *
663 * The input format is:
664 * <pre>
665 * [<key><sub>]<key><sep><value><eol>
666 * [<key><sub>]<key><sep><value><eol>
667 * </pre>
668 * In this, white spaces are ignored.
669 * The reading of key and value pairs is controlled by the JLANG::JEquationFacet class.
670 *
671 * \param in input stream
672 * \return input stream
673 */
674 std::istream& read(std::istream& in)
675 {
676 using namespace std;
677 using namespace JPP;
678
679 JStringStream is(in);
680
681 is.imbue(locale(is.getloc(), new JEquationFacet(*this)));
682
683 for (JEquation equation; is >> equation && read(equation); ) {}
684
685 return in;
686 }
687
688
689 /**
690 * Read from input stream according given format.
691 *
692 * For each key in the format specification,
693 * a corresponding value will be read from the input stream.
694 *
695 * \param in input stream
696 * \param format format
697 * \return input stream
698 */
699 std::istream& read(std::istream& in, const std::string& format)
700 {
701 using namespace std;
702
703 istringstream is(format);
704
705 vector<string> buffer;
706
707 for (string key; is >> key; ) {
708 buffer.push_back(key);
709 }
710
711 return read(in, buffer.begin(), buffer.end());
712 }
713
714
715 /**
716 * Read from input stream according given format.
717 *
718 * For each key in the format specification,
719 * a corresponding value will be read from the input stream.
720 *
721 * \param in input stream
722 * \param __begin begin of format
723 * \param __end end of format
724 * \return input stream
725 */
726 template<class T>
727 std::istream& read(std::istream& in, T __begin, T __end)
728 {
729 using namespace std;
730
731 for (T i = __begin; i != __end; ++i) {
732
733 iterator p = find(*i);
734
735 if (p != end()) {
736
737 p->second->read(in);
738
739 } else {
740
741 WARNING("JProperties::read(): unknown key <" << *i << ">" << endl);
742 }
743 }
744
745 return in;
746 }
747
748
749 /**
750 * Write the current parameter values.
751 *
752 * The output format is
753 *
754 * [<key><sub>]<key><sep><value><eol>
755 * [<key><sub>]<key><sep><value><eol>
756 *
757 * in this, white spaces are omitted.
758 *
759 * \param out output stream
760 * \return output stream
761 */
762 std::ostream& write(std::ostream& out) const
763 {
764 using namespace std;
765
766 for (const_iterator i = begin(); i != end(); ++i) {
767
768 char c = ' ';
769
770 if (i->second->is_properties()) {
771 c = getDefaultDivision ();
772 } else {
774 }
775
776 i->second->write(out, (i->first + c).c_str(), getDefaultEndOfLine());
777 }
778
779 out << flush;
780
781 return out;
782 }
783
784
785 /**
786 * Write to output stream according given format.
787 *
788 * For each key in the format specification,
789 * a corresponding value will be written to the output stream.
790 *
791 * \param out output stream
792 * \param format format
793 * \return output stream
794 */
795 std::ostream& write(std::ostream& out, const std::string& format) const
796 {
797 using namespace std;
798
799 istringstream is(format);
800
801 vector<string> buffer;
802
803 for (string key; is >> key; ) {
804 buffer.push_back(key);
805 }
806
807 return write(out, buffer.begin(), buffer.end());
808 }
809
810
811 /**
812 * Write to output stream according given format.
813 *
814 * For each key in the format specification,
815 * a corresponding value will be written to the output stream.
816 *
817 * \param out output stream
818 * \param __begin begin of format
819 * \param __end end of format
820 * \return output stream
821 */
822 template<class T>
823 std::ostream& write(std::ostream& out, T __begin, T __end) const
824 {
825 using namespace std;
826
827 for (T i = __begin; i != __end; ++i) {
828
829 const_iterator p = find(*i);
830
831 if (p != end()) {
832
833 out << getDefaultWhiteSpace();
834
835 p->second->write(out);
836
837 } else {
838
839 WARNING("JProperties::write(): unknown key <" << *i << ">" << endl);
840 }
841 }
842
843 return out;
844 }
845
846
847 /**
848 * Stream editing of input format.
849 *
850 * For each key in the format specification,
851 * a corresponding value will be written to the output stream.
852 *
853 * \param format format
854 * \param prefix prefix key word
855 * \param postfix postfix key word
856 * \return output stream
857 */
858 std::string sed(const std::string& format,
859 const std::string& prefix = "",
860 const std::string& postfix = "")
861 {
862 using namespace std;
863
864 string buffer = format;
865
866 for (iterator i = begin(); i != end(); ++i) {
867
868 string::size_type ipos = 0;
869
870 while ((ipos = buffer.find(prefix + i->first + postfix, ipos)) != string::npos) {
871
872 ostringstream out;
873
874 i->second->write(out);
875
876 buffer.replace(ipos, prefix.length() + i->first.length() + postfix.length(), out.str());
877 }
878 }
879
880 return buffer;
881 }
882
883
884 /**
885 * Get value.
886 *
887 * \param key key
888 * \return value of this JPropertiesElement
889 */
890 template<class T>
891 const T& getValue(const std::string& key) const
892 {
893 const_iterator i = find(key);
894
895 if (i != end())
896 return i->second.getValue<T>();
897 else
898 THROW(JPropertiesException, "Key <" << key << "> not found at JPropertiesElement::getValue()");
899 }
900
901
902 /**
903 * Get value.
904 *
905 * \param key key
906 * \return value of this JPropertiesElement
907 */
908 template<class T>
909 T& getValue(const std::string& key)
910 {
911 iterator i = find(key);
912
913 if (i != end())
914 return i->second.getValue<T>();
915 else
916 THROW(JPropertiesException, "Key <" << key << "> not found at JPropertiesElement::getValue()");
917 }
918
919
920 /**
921 * Set value.
922 *
923 * \param key key
924 * \param value value
925 */
926 template<class T>
927 void setValue(const std::string& key, const T& value)
928 {
929 iterator i = find(key);
930
931 if (i != end())
932 return i->second.setValue<T>(value);
933 else
934 THROW(JPropertiesException, "Key <" << key << "> not found at JPropertiesElement::setValue()");
935 }
936
937
938 /**
939 * Get string value.
940 *
941 * \param key key
942 * \return value
943 */
944 std::string getString(const std::string& key) const
945 {
946 const_iterator i = find(key);
947
948 if (i != end())
949 return i->second.toString();
950 else
951 THROW(JPropertiesException, "Key <" << key << "> not found at JPropertiesElement::getString()");
952 }
953
954
955 /**
956 * Print the current parameter values.
957 *
958 * \param out output stream
959 * \return output stream
960 */
961 std::ostream& print(std::ostream& out) const
962 {
963 write(out);
964
965 return out;
966 }
967
968
969 /**
970 * Stream input.
971 *
972 * \param in input stream
973 * \param properties properties
974 * \return input stream
975 */
976 friend inline std::istream& operator>>(std::istream& in, JProperties& properties)
977 {
978 return properties.read(in);
979 }
980
981
982 /**
983 * Stream output.
984 *
985 * \param out output stream
986 * \param properties properties
987 * \return output stream
988 */
989 friend inline std::ostream& operator<<(std::ostream& out, const JProperties& properties)
990 {
991 return properties.write(out);
992 }
993 };
994
995
996 /**
997 * Template specialisation for JProperties.
998 */
999 template<>
1002 {
1003 public:
1004 /**
1005 * Constructor.
1006 *
1007 * \param value reference of template bject
1008 */
1011 object(value)
1012 {}
1013
1014
1015 /**
1016 * Stream input.
1017 *
1018 * \param in input stream
1019 * \return input stream
1020 */
1021 virtual std::istream& read(std::istream& in) override
1022 {
1023 object.read(in);
1024
1025 return in;
1026 }
1027
1028
1029 /**
1030 * Stream output.
1031 *
1032 * \param out output stream
1033 * \param prefix prefix
1034 * \param postfix postfix
1035 * \return output stream
1036 */
1037 virtual std::ostream& write(std::ostream& out,
1038 const char* prefix,
1039 const char postfix) const override
1040 {
1041 using namespace std;
1042
1043 for (JProperties::const_iterator i = object.begin(); i != object.end(); ++i) {
1044
1045 char c = ' ';
1046
1047 if (i->second->is_properties()) {
1048 c = object.getDefaultDivision ();
1049 } else {
1050 c = object.getDefaultSeparator();
1051 }
1052
1053 i->second->write(out, (prefix + i->first + c).c_str(), postfix);
1054 }
1055
1056 out << flush;
1057
1058 return out;
1059 }
1060
1061
1062 /**
1063 * Stream output.
1064 *
1065 * \param out output stream
1066 * \return output stream
1067 */
1068 virtual std::ostream& write(std::ostream& out) const override
1069 {
1070 return writeObject(out, object);
1071 }
1072
1073
1074 /**
1075 * Get properties type.
1076 *
1077 * \return true
1078 */
1079 virtual bool is_properties() const override
1080 {
1081 return true;
1082 }
1083
1084
1085 private:
1087 };
1088
1089
1090 /**
1091 * Get properties of a given object.
1092 *
1093 * This method transfers the making of the property object to the corresponding class
1094 * whilst preserving the constness of the argument.\n
1095 * The corresponding class should implement the method:
1096 * <pre>
1097 * template<bool is_constant>
1098 * static JProperties getProperties(typename JCategory<T, is_constant>::reference_type object,
1099 * const JEquationParameters& equation,
1100 * const int debug)
1101 * </pre>
1102 *
1103 * \param object object
1104 * \param parameters equation parameters
1105 * \param debug debug level
1106 */
1107 template<class T>
1108 inline JProperties& getProperties(T& object,
1109 const JEquationParameters& parameters = JEquationParameters(),
1110 const int debug = 1)
1111 {
1112 using namespace JPP;
1113
1114 static JProperties properties;
1115
1116 properties = T::template getProperties<JClass<T>::is_constant>(object, parameters, debug);
1117
1118 return properties;
1119 }
1120}
1121
1122
1124using JLANG::JCategory;
1125using JEEP::JProperties;
1127
1128
1129/**
1130 * macros to convert (template) parameter to JPropertiesElement object
1131 */
1132#define gmake_property(A) JProperties::value_type(JProperties::getKey(#A,".>/:"), JEEP::JPropertiesElement(A))
1133#define zmake_property(A) JProperties::value_type(#A, JEEP::JPropertiesElement(A))
1134
1135#endif
Exceptions.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define ERROR(A)
Definition JMessage.hh:66
int debug
debug level
Definition JSirene.cc:74
#define WARNING(A)
Definition JMessage.hh:65
Interface for I/O of properties element.
virtual bool is_properties() const
Get properties type.
virtual bool equals(const JPropertiesElementInterface &element) const
Equality between property element interfaces.
The property value class.
void setEndMarker(const bool marker)
Set end marker.
JPropertiesElement & operator=(T &value)
Assignment operator.
JPropertiesElement(T &value)
Constructor.
void setValue(const T &value)
Set value of this JPropertiesElement.
bool getEndMarker() const
Get end marker.
T & getValue()
Get value.
JPropertiesElement()
Default constructor.
const T & getValue() const
Get value.
T toValue() const
Convert to template type.
std::string toString() const
Convert to string.
bool equals(const JPropertiesElement &element) const
Equality between property elements.
virtual std::istream & read(std::istream &in) override
Stream input.
virtual std::ostream & write(std::ostream &out, const char *prefix, const char postfix) const override
Stream output.
JPropertiesTemplateElement(const JProperties &value)
Constructor.
virtual bool is_properties() const override
Get properties type.
virtual std::ostream & write(std::ostream &out) const override
Stream output.
virtual std::ostream & write(std::ostream &out, const char *prefix, const char postfix) const override
Stream output.
JPropertiesTemplateElement(const T &value)
Constructor.
virtual std::ostream & write(std::ostream &out) const override
Stream output.
virtual std::istream & read(std::istream &in) override
Stream input.
virtual bool equals(const JPropertiesElementInterface &element) const override
Equality between property element interfaces.
Template class for I/O of properties element.
virtual std::istream & read(std::istream &in) override
Stream input.
JPropertiesTemplateElement(T &value)
Constructor.
virtual std::ostream & write(std::ostream &out, const char *prefix, const char postfix) const override
Stream output.
virtual bool equals(const JPropertiesElementInterface &element) const override
Equality between property element interfaces.
virtual std::ostream & write(std::ostream &out) const override
Stream output.
Utility class to parse parameter values.
std::map< std::string, JPropertiesElement > JMap_t
std::istream & read(std::istream &in)
Read from input stream.
std::istream & read(std::istream &in, T __begin, T __end)
Read from input stream according given format.
bool read(const std::string &buffer)
Read from input string.
std::string getString(const std::string &key) const
Get string value.
static std::string getKey(const std::string &buffer, const std::string &sep)
Utility method to strip off all leading characters from a string until specified character(s).
T & getValue(const std::string &key)
Get value.
std::ostream & write(std::ostream &out) const
Write the current parameter values.
JProperties & join(const JProperties &properties)
Join properties objects.
void setValue(const std::string &key, const T &value)
Set value.
std::ostream & print(std::ostream &out) const
Print the current parameter values.
JProperties(const int debug=0)
Constructor.
std::istream & read(std::istream &in, const std::string &format)
Read from input stream according given format.
JProperties(const JEquationParameters &parameters, const int debug=0)
Constructor.
const T & getValue(const std::string &key) const
Get value.
std::string sed(const std::string &format, const std::string &prefix="", const std::string &postfix="")
Stream editing of input format.
friend std::istream & operator>>(std::istream &in, JProperties &properties)
Stream input.
friend std::ostream & operator<<(std::ostream &out, const JProperties &properties)
Stream output.
std::ostream & write(std::ostream &out, const std::string &format) const
Write to output stream according given format.
std::ostream & write(std::ostream &out, T __begin, T __end) const
Write to output stream according given format.
bool read(const JEquation &equation)
Read equation.
void put(const std::string &key, T &object)
Put object at given key.
Facet class to specify parsing of equations in currect locale (see class JLANG::JEquation).
Simple data structure to support I/O of equations (see class JLANG::JEquation).
bool isSeparator(const char c) const
Test for separator character.
bool isDivision(const char c) const
Test for division character.
const char getDefaultSeparator() const
Get default separator character.
JEquationParameters & join(const JEquationParameters &value)
Join equation parameters.
const char getDefaultEndOfLine() const
Get default end of line character.
const char getDefaultWhiteSpace() const
Get default white space character.
const char getDefaultDivision() const
Get default division character.
General purpose equation class.
Definition JEquation.hh:47
const std::string & getKey() const
Get key.
Definition JEquation.hh:163
const std::string & getValue() const
Get value.
Definition JEquation.hh:185
const char getSeparator() const
Get separator.
Definition JEquation.hh:174
Exception for opening of file.
Exception for reading of file.
Template definition of test availability of comparison operators.
Exception when parsing a value.
Interface for ASCII input using standard streams.
Interface for ASCII output using standard streams.
virtual std::ostream & write(std::ostream &out) const =0
Stream output.
Interface for ASCII output with prefix and postfix using standard streams.
virtual std::ostream & write(std::ostream &out, const char *prefix, const char postfix) const =0
Stream output.
Wrapper class around STL stringstream class to facilitate optional loading of data from file.
General puprpose classes and methods.
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
bool compareObjects(const T &first, const T &second, std::true_type)
Comparison of comparable objects.
std::istream & readObject(std::istream &in, T &object)
Stream input of object.
bool fail(std::istream &in)
Check for stream state.
JProperties & getProperties(T &object, const JEquationParameters &parameters=JEquationParameters(), const int debug=1)
Get properties of a given object.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary class for handling debug parameter within a class.
Definition JMessage.hh:44
Auxiliary class to define value, reference and pointer types for given data type and category.
Definition JCategory.hh:18