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