33 #define HURRICANE_COMMONS_H
69 template<
typename DboType>
72 inline void operator() ( DboType* dbo ) { dbo->destroy(); }
76 template<
typename DboType>
77 class dbo_ptr :
public std::shared_ptr<DboType> {
79 dbo_ptr ( DboType* dbo ) : std::shared_ptr<DboType>(dbo,DboDestroy<DboType>()) { }
90 inline string _TName (
const string& s ) {
return s; }
91 inline string _PName (
const string& s ) {
return "Hurricane::" + s; }
94 inline Type abs (
const Type& value ) {
return (value<0) ? -value : value; }
97 inline string demangle (
string symbol ) {
return demangle(symbol.c_str()); }
100 template<
typename Element>
101 inline void erase_element ( vector<Element*>& v,
const Element* e )
103 for (
auto ielement = v.begin() ; ielement != v.end() ; ++ielement )
104 if (*ielement == e) { v.erase( ielement );
return; }
112 inline int floatCompare (
float a,
float b )
114 assert (
sizeof(
float) ==
sizeof(
int) );
116 if ( a == b )
return 0;
117 return *(
int*)&a - *(
int*)&b;
120 inline int floatDifference (
float a,
float b,
int threshold )
122 int difference = floatCompare(a,b);
123 if ( abs(difference) < threshold )
return 0;
125 return (difference<0) ? -1 : 1;
129 inline void floatRound (
float& value,
float precision )
131 float rounded = roundf ( value*precision );
132 value = rounded / precision;
136 inline float roundfp (
float value,
float precision=100.0 ) {
return roundf(value*precision)/precision; }
139 template<
typename Type>
inline void order ( Type& a, Type& b ) {
if (a>b) std::swap(a,b); }
141 template<
typename Type>
inline Type setInBound ( Type lower, Type upper, Type& value )
143 if (value < lower) value = lower;
144 else if (value > upper) value = upper;
149 string& split ( std::string& );
155 #include "hurricane/Record.h"
167 template<
typename Data>
inline Hurricane::Slot* getSlot ( std::string name, Data );
175 template<
typename Data>
inline std::string getString ( Data data )
176 {
return std::string(
"<type ")
178 + std::string(
" unsupported by getString()>"); }
182 template<>
inline std::string getString<const bool&> (
const bool& b )
183 {
return (b)?
"True":
"False" ; }
185 template<>
inline std::string getString<const int&> (
const int& i )
186 { std::ostringstream os (
""); os << i;
return os.str(); }
188 template<>
inline std::string getString<const long&> (
const long& l )
189 { std::ostringstream os (
""); os << l;
return os.str(); }
191 template<>
inline std::string getString<const unsigned int&> (
const unsigned int& u )
192 { std::ostringstream os (
""); os << u;
return os.str(); }
194 template<>
inline std::string getString<const unsigned long&> (
const unsigned long& ul )
195 { std::ostringstream os (
""); os << ul;
return os.str(); }
197 template<>
inline std::string getString<const unsigned long long&> (
const unsigned long long& ull )
198 { std::ostringstream os (
""); os << ull;
return os.str(); }
200 template<>
inline std::string getString<const unsigned short int&> (
const unsigned short int& us )
201 { std::ostringstream os (
""); os << us;
return os.str(); }
203 template<>
inline std::string getString<const float&> (
const float& f )
204 { std::ostringstream os (
""); os << f;
return os.str(); }
206 template<>
inline std::string getString<const double&> (
const double& d )
207 { std::ostringstream os; os << d;
return os.str(); }
209 template<>
inline std::string getString<const std::string&> (
const std::string& s )
214 template<>
inline std::string getString<const bool*> (
const bool* b )
215 {
return (*b)?
"True":
"False" ; }
217 template<>
inline std::string getString<const char*> (
const char* c )
220 template<>
inline std::string getString<const int*> (
const int* i )
221 { std::ostringstream os (
""); os << *i;
return os.str(); }
223 template<>
inline std::string getString<const long*> (
const long* l )
224 { std::ostringstream os (
""); os << *l;
return os.str(); }
226 template<>
inline std::string getString<const unsigned int*> (
const unsigned int* u )
227 { std::ostringstream os (
""); os << *u;
return os.str(); }
229 template<>
inline std::string getString<const unsigned long*> (
const unsigned long* ul )
230 { std::ostringstream os (
""); os << *ul;
return os.str(); }
232 template<>
inline std::string getString<const unsigned long long*> (
const unsigned long long* ull )
233 { std::ostringstream os (
""); os << *ull;
return os.str(); }
235 template<>
inline std::string getString<const unsigned short int*> (
const unsigned short int* us )
236 { std::ostringstream os (
""); os << *us;
return os.str(); }
238 template<>
inline std::string getString<const float*> (
const float* f )
239 { std::ostringstream os (
""); os << *f;
return os.str(); }
241 template<>
inline std::string getString<const double*> (
const double* d )
242 { std::ostringstream os; os << *d;
return os.str(); }
244 template<>
inline std::string getString<const void*> (
const void* p )
245 { std::ostringstream os (
"0x"); os << std::hex << p;
return os.str(); }
247 template<>
inline std::string getString<const std::string*> (
const std::string* s )
253 template<>
inline std::string getString<bool*> (
bool* b )
254 {
return (*b)?
"True":
"False" ; }
256 template<>
inline std::string getString<char*> (
char* c )
259 template<>
inline std::string getString<int*> (
int* i )
260 { std::ostringstream os (
""); os << *i;
return os.str(); }
262 template<>
inline std::string getString<long*> (
long* l )
263 { std::ostringstream os (
""); os << *l;
return os.str(); }
265 template<>
inline std::string getString<unsigned int*> (
unsigned int* u )
266 { std::ostringstream os (
""); os << *u;
return os.str(); }
268 template<>
inline std::string getString<unsigned long*> (
unsigned long* ul )
269 { std::ostringstream os (
""); os << *ul;
return os.str(); }
271 template<>
inline std::string getString<unsigned long long*> (
unsigned long long* ull )
272 { std::ostringstream os (
""); os << *ull;
return os.str(); }
274 template<>
inline std::string getString<unsigned short int*> (
unsigned short int* us )
275 { std::ostringstream os (
""); os << *us;
return os.str(); }
277 template<>
inline std::string getString<float*> (
float* f )
278 { std::ostringstream os (
""); os << *f;
return os.str(); }
280 template<>
inline std::string getString<double*> (
double* d )
281 { std::ostringstream os; os << *d;
return os.str(); }
283 template<>
inline std::string getString<void*> (
void* p )
284 { std::ostringstream os (
"0x"); os << std::hex << p;
return os.str(); }
286 template<>
inline std::string getString<std::string*> ( std::string* s )
292 template<>
inline std::string getString<bool> (
bool b )
293 {
return (b)?
"True":
"False" ; }
295 template<>
inline std::string getString<char> (
char c )
296 {
return std::string(1,c); }
298 template<>
inline std::string getString<int> (
int i )
299 { std::ostringstream os (
""); os << i;
return os.str(); }
301 template<>
inline std::string getString<long> (
long l )
302 { std::ostringstream os (
""); os << l;
return os.str(); }
304 template<>
inline std::string getString<unsigned int> (
unsigned int u )
305 { std::ostringstream os (
""); os << u;
return os.str(); }
307 template<>
inline std::string getString<unsigned long> (
unsigned long ul )
308 { std::ostringstream os (
""); os << ul;
return os.str(); }
310 template<>
inline std::string getString<unsigned long long> (
unsigned long long ull )
311 { std::ostringstream os (
""); os << ull;
return os.str(); }
313 template<>
inline std::string getString<unsigned short int> (
unsigned short int us )
314 { std::ostringstream os (
""); os << us;
return os.str(); }
316 template<>
inline std::string getString<float> (
float f )
317 { std::ostringstream os (
""); os << f;
return os.str(); }
319 template<>
inline std::string getString<double> (
double d )
320 { std::ostringstream os; os << d;
return os.str(); }
322 template<>
inline std::string getString<std::string> ( std::string s )
326 template<
typename Data>
inline Hurricane::Record* getRecord ( Data data )
336 template<
typename T,
typename U>
337 inline std::string getString (
const std::pair<T,U>& p )
339 return "const std::pair<T,U>";
343 template<
typename T,
typename U>
344 inline Hurricane::Record* getRecord (
const std::pair<T,U>& p )
346 Hurricane::Record* record = NULL;
347 record =
new Hurricane::Record (
"const std::pair<T,U>" );
348 record->add( getSlot<const T>(std::string(
"first" ), &p.first ) );
349 record->add( getSlot<const U>(std::string(
"second"), &p.second) );
354 template<
typename T,
typename U>
355 inline std::string getString ( std::pair<T,U>& p )
357 return "std::pair<T,U>";
361 template<
typename T,
typename U>
362 inline Hurricane::Record* getRecord ( std::pair<T,U>& p )
364 Hurricane::Record* record = NULL;
365 record =
new Hurricane::Record (
"std::pair<T,U>" );
366 record->add( getSlot<T>(std::string(
"first" ), &p.first ) );
367 record->add( getSlot<U>(std::string(
"second"), &p.second) );
376 template<
typename Element,
size_t N>
377 inline std::string getString ( std::array<Element,N>* v )
379 std::string name =
"const std::array<Element,N>:";
380 return name + getString<size_t>(v->size());
384 template<
typename Element,
size_t N>
385 inline Hurricane::Record* getRecord ( std::array<Element,N>* v )
387 Hurricane::Record* record = NULL;
389 record =
new Hurricane::Record (
"std::array<Element,N>" );
391 typename std::array<Element,N>::iterator iterator = v->begin();
392 while ( iterator != v->end() ) {
393 record->add ( getSlot<Element>(getString(n++), *iterator) );
401 template<
typename Element,
size_t N>
402 inline std::string getString (
const std::array<Element,N>* v )
404 std::string name =
"const std::array<Element,N>:";
405 return name + getString<size_t>(v->size());
409 template<
typename Element,
size_t N>
410 inline Hurricane::Record* getRecord (
const std::array<Element,N>* v )
412 Hurricane::Record* record = NULL;
414 record =
new Hurricane::Record (
"const std::array<Element,N>" );
416 typename std::array<Element,N>::const_iterator iterator = v->begin();
417 while ( iterator != v->end() ) {
418 record->add ( getSlot<const Element>(getString(n++), *iterator) );
426 template<
typename Element,
size_t N>
427 inline std::string getString ( std::array<Element,N>& v )
429 std::string name =
"std::array<Element,N>&:";
430 return name + getString<size_t>(v.size());
434 template<
typename Element,
size_t N>
435 inline Hurricane::Record* getRecord ( std::array<Element,N>& v )
437 Hurricane::Record* record = NULL;
439 record =
new Hurricane::Record (
"std::array<Element,N>&" );
441 for (
auto element : v )
442 record->add( getSlot<Element>(getString(n++), element) );
448 template<
typename Element,
size_t N>
449 inline std::string getString (
const std::array<Element,N>& v )
451 std::string name =
"const std::array<Element,N>&:";
452 return name + getString<size_t>(v.size());
456 template<
typename Element,
size_t N>
457 inline Hurricane::Record* getRecord (
const std::array<Element,N>& v )
459 Hurricane::Record* record = NULL;
461 record =
new Hurricane::Record (
"const std::array<Element,N>&" );
463 for (
auto element : v )
464 record->add( getSlot<Element>(getString(n++), element) );
474 template<
typename Element>
475 inline std::string getString ( std::vector<Element>* v )
477 std::string name =
"std::vector<Element>*:";
478 return name + getString<size_t>(v->size());
482 template<
typename Element>
483 inline Hurricane::Record* getRecord ( std::vector<Element>* v )
485 Hurricane::Record* record = NULL;
487 record =
new Hurricane::Record (
"std::vector<Element>*" );
489 typename std::vector<Element>::iterator iterator = v->begin();
490 while ( iterator != v->end() ) {
491 record->add ( getSlot<const Element*>(getString(n++), &(*iterator)) );
503 template<
typename Element>
504 inline std::string getString ( std::vector<Element*>* v )
506 std::string name =
"std::vector<Element*>*:";
507 return name + getString<size_t>(v->size());
511 template<
typename Element>
512 inline Hurricane::Record* getRecord ( std::vector<Element*>* v )
514 Hurricane::Record* record = NULL;
516 record =
new Hurricane::Record (
"std::vector<Element*>*" );
518 typename std::vector<Element*>::iterator iterator = v->begin();
519 while ( iterator != v->end() ) {
520 record->add ( getSlot<Element*>(getString(n++), *iterator) );
532 template<
typename Element>
533 inline std::string getString (
const std::vector<Element>* v )
535 std::string name =
"const std::vector<Element>*:";
536 return name + getString<size_t>(v->size());
540 template<
typename Element>
541 inline Hurricane::Record* getRecord (
const std::vector<Element>* v )
543 Hurricane::Record* record = NULL;
545 record =
new Hurricane::Record (
"const std::vector<Element>*" );
547 typename std::vector<Element>::const_iterator iterator = v->begin();
548 while ( iterator != v->end() ) {
549 record->add ( getSlot<const Element*>(getString(n++), &(*iterator)) );
561 template<
typename Element>
562 inline std::string getString (
const std::vector<Element*>* v )
564 std::string name =
"const std::vector<Element*>*:";
565 return name + getString<size_t>(v->size());
569 template<
typename Element>
570 inline Hurricane::Record* getRecord (
const std::vector<Element*>* v )
572 Hurricane::Record* record = NULL;
573 if (not v->empty()) {
574 record =
new Hurricane::Record (
"const std::vector<Element*>*" );
576 typename std::vector<Element*>::const_iterator iterator = v->begin();
577 while (iterator != v->end()) {
578 record->add ( getSlot<const Element*>(getString(n++), *iterator) );
590 template<
typename Element>
591 inline std::string getString (
const std::list<Element>* l )
593 std::string name =
"const std::list<Element>*:";
594 return name + getString<size_t>(l->size());
598 template<
typename Element>
599 inline Hurricane::Record* getRecord (
const std::list<Element>* l )
601 Hurricane::Record* record = NULL;
603 record =
new Hurricane::Record (
"const std::list<Element>" );
605 typename std::list<Element>::const_iterator iterator = l->begin();
606 while ( iterator != l->end() ) {
607 record->add ( getSlot<const Element*>(getString(n++), &(*iterator)) );
615 template<
typename Element>
616 inline std::string getString ( std::list<Element>* l )
618 std::string name =
"std::list<Element>*:";
619 return name + getString<size_t>(l->size());
623 template<
typename Element>
624 inline Hurricane::Record* getRecord ( std::list<Element>* l )
626 Hurricane::Record* record = NULL;
628 record =
new Hurricane::Record (
"std::list<Element>" );
630 typename std::list<Element>::iterator iterator = l->begin();
631 while ( iterator != l->end() ) {
632 record->add ( getSlot<const Element*>(getString(n++), &(*iterator)) );
644 template<
typename Key,
typename Element>
645 inline std::string getString ( std::map<Key,Element>* m )
647 std::string name =
"std::map<Element>:";
648 return name + getString<size_t>(m->size());
652 template<
typename Key,
typename Element>
653 inline Hurricane::Record* getRecord ( std::map<Key,Element>* m )
655 Hurricane::Record* record = NULL;
657 record =
new Hurricane::Record (
"std::map<Element>" );
658 typename std::map<Key,Element>::iterator iterator = m->begin();
659 while ( iterator != m->end() ) {
660 record->add ( getSlot<Element>(getString(iterator->first), iterator->second) );
668 template<
typename Key,
typename Element>
669 inline std::string getString (
const std::map<Key,Element>* m )
671 std::string name =
"const std::map<Element>:";
672 return name + getString<size_t>(m->size());
676 template<
typename Key,
typename Element>
677 inline Hurricane::Record* getRecord (
const std::map<Key,Element>* m )
679 Hurricane::Record* record = NULL;
681 record =
new Hurricane::Record (
"const std::map<Element>" );
682 typename std::map<Key,Element>::const_iterator iterator = m->begin();
683 while ( iterator != m->end() ) {
684 record->add ( getSlot<const Element>(getString(iterator->first), iterator->second) );
696 template<
typename Key,
typename Element,
typename Compare>
697 inline std::string getString ( std::map<Key,Element,Compare>* m )
699 std::string name =
"std::map<Element>:";
700 return name + getString<size_t>(m->size());
704 template<
typename Key,
typename Element,
typename Compare>
705 inline Hurricane::Record* getRecord ( std::map<Key,Element,Compare>* m )
707 Hurricane::Record* record = NULL;
709 record =
new Hurricane::Record (
"std::map<Element>" );
710 typename std::map<Key,Element,Compare>::iterator iterator = m->begin();
711 while ( iterator != m->end() ) {
712 record->add ( getSlot<Element>(getString(iterator->first), iterator->second) );
720 template<
typename Key,
typename Element,
typename Compare>
721 inline std::string getString (
const std::map<Key,Element,Compare>* m )
723 std::string name =
"const std::map<Element>:";
724 return name + getString<size_t>(m->size());
728 template<
typename Key,
typename Element,
typename Compare>
729 inline Hurricane::Record* getRecord (
const std::map<Key,Element,Compare>* m )
731 Hurricane::Record* record = NULL;
733 record =
new Hurricane::Record (
"const std::map<Element>" );
734 typename std::map<Key,Element,Compare>::const_iterator iterator = m->begin();
735 while ( iterator != m->end() ) {
736 record->add ( getSlot<const Element>(getString(iterator->first), iterator->second) );
748 template<
typename Key,
typename Element,
typename Compare>
749 inline std::string getString (
const std::multimap<Key,Element,Compare>* m )
751 std::string name =
"const std::multimap<Element>:";
752 return name + getString<size_t>(m->size());
756 template<
typename Key,
typename Element,
typename Compare>
757 inline Hurricane::Record* getRecord (
const std::multimap<Key,Element,Compare>* m )
759 Hurricane::Record* record = NULL;
761 record =
new Hurricane::Record (
"const std::multimap<Element>" );
762 typename std::multimap<Key,Element,Compare>::const_iterator iterator = m->begin();
763 while ( iterator != m->end() ) {
764 record->add ( getSlot<const Element>(getString(iterator->first), iterator->second) );
772 template<
typename Key,
typename Element,
typename Compare>
773 inline std::string getString ( std::multimap<Key,Element,Compare>* m )
775 std::string name =
"std::multimap<Element>:";
776 return name + getString<size_t>(m->size());
780 template<
typename Key,
typename Element,
typename Compare>
781 inline Hurricane::Record* getRecord ( std::multimap<Key,Element,Compare>* m )
783 Hurricane::Record* record = NULL;
785 record =
new Hurricane::Record (
"std::multimap<Element>" );
786 typename std::multimap<Key,Element,Compare>::iterator iterator = m->begin();
787 while ( iterator != m->end() ) {
788 record->add ( getSlot<Element>(getString(iterator->first), iterator->second) );
800 template<
typename Element,
typename Compare>
801 inline std::string getString (
const std::set<Element,Compare>* s )
803 std::string name =
"const std::set<Element>:";
804 return name + getString<size_t>(s->size());
808 template<
typename Element,
typename Compare>
809 inline Hurricane::Record* getRecord (
const std::set<Element,Compare>* s )
811 Hurricane::Record* record = NULL;
813 record =
new Hurricane::Record (
"const std::set<Element>" );
815 typename std::set<Element,Compare>::const_iterator iterator = s->begin();
816 while ( iterator != s->end() ) {
817 record->add ( getSlot<const Element>(getString(n++), *iterator) );
825 template<
typename Element,
typename Compare,
typename Allocator >
826 inline std::string getString ( std::set<Element,Compare,Allocator>* s )
828 std::string name =
"std::set<Element>:";
829 return name + getString<size_t>(s->size());
833 template<
typename Element,
typename Compare,
typename Allocator >
834 inline Hurricane::Record* getRecord ( std::set<Element,Compare,Allocator>* s )
836 Hurricane::Record* record = NULL;
837 if (not s->empty()) {
838 record =
new Hurricane::Record (
"std::set<Element>" );
840 typename std::set<Element,Compare,Allocator>::iterator iterator = s->begin();
841 while ( iterator != s->end() ) {
842 record->add( getSlot<Element>(getString(n++), *iterator) );
853 template<
typename Element,
typename Compare>
854 inline std::string getString (
const std::set<Element,Compare>& s )
856 std::string name =
"const std::set<Element>:";
857 return name + getString<size_t>(s.size());
861 template<
typename Element,
typename Compare>
862 inline Hurricane::Record* getRecord (
const std::set<Element,Compare>& s )
864 Hurricane::Record* record = NULL;
866 record =
new Hurricane::Record (
"const std::set<Element>" );
868 typename std::set<Element,Compare>::const_iterator iterator = s.begin();
869 while ( iterator != s.end() ) {
870 record->add ( getSlot<Element>(getString(n++), *iterator) );
881 template<
typename Element,
typename Compare>
882 inline std::string getString (
const std::multiset<Element,Compare>* s )
884 std::string name =
"std::multiset<Element>:";
885 return name + getString<size_t>(s->size());
889 template<
typename Element,
typename Compare>
890 inline Hurricane::Record* getRecord (
const std::multiset<Element,Compare>* s )
892 Hurricane::Record* record = NULL;
894 record =
new Hurricane::Record (
"std::multiset<Element>" );
896 typename std::multiset<Element,Compare>::const_iterator iterator = s->begin();
897 while ( iterator != s->end() ) {
898 record->add ( getSlot<Element>(getString(n++), *iterator) );
906 # define GETSTRING_POINTER_SUPPORT(Data) \
907 template<> inline std::string getString<Data*>( Data* data ) \
909 if (!data) return "NULL [" #Data "]"; \
910 return data->_getString(); \
913 template<> inline std::string getString<const Data*>( const Data* data ) \
914 { if (!data) return "NULL [const " #Data "]"; return data->_getString(); }
917 # define IOSTREAM_POINTER_SUPPORT(Data) \
918 inline std::ostream& operator<< ( std::ostream& o, Data* d ) \
920 if (!d) return o << "NULL [" #Data "]"; \
921 return o << "&" << getString<const Data*>(d); \
923 inline std::ostream& operator<< ( std::ostream& o, const Data* d ) \
925 if (!d) return o << "NULL [const " #Data "]"; \
926 return o << "&" << getString<const Data*>(d); \
930 # define GETRECORD_POINTER_SUPPORT(Data) \
931 template<> inline Hurricane::Record* getRecord<Data*>( Data* data ) \
932 { if (!data) return NULL; return data->_getRecord(); } \
934 template<> inline Hurricane::Record* getRecord<const Data*>( const Data* data ) \
935 { if (!data) return NULL; return data->_getRecord(); }
938 # define GETSTRING_REFERENCE_SUPPORT(Data) \
939 template<> inline std::string getString<Data&>( Data& data ) \
940 { return data._getString(); } \
942 template<> inline std::string getString<const Data&>( const Data& data ) \
943 { return data._getString(); }
946 # define IOSTREAM_REFERENCE_SUPPORT(Data) \
947 inline std::ostream& operator<< ( std::ostream& o, Data& d ) \
948 { return o << getString<Data&>(d); } \
950 inline std::ostream& operator<< ( std::ostream& o, const Data& d ) \
951 { return o << getString<const Data&>(d); } \
954 # define GETRECORD_REFERENCE_SUPPORT(Data) \
955 template<> inline Hurricane::Record* getRecord<Data&>( Data& data ) \
956 { return data._getRecord(); } \
958 template<> inline Hurricane::Record* getRecord<const Data&>( const Data& data ) \
959 { return data._getRecord(); }
962 # define GETSTRING_VALUE_SUPPORT(Data) \
963 template<> inline std::string getString<Data>( Data data ) \
964 { return data._getString(); }
967 # define IOSTREAM_VALUE_SUPPORT(Data) \
968 inline std::ostream& operator<< ( std::ostream& o, Data d ) \
969 { return o << getString<Data>(d); }
972 # define GETRECORD_VALUE_SUPPORT(Data) \
973 template<> inline Hurricane::Record* getRecord<Data>( Data data ) \
974 { return data._getRecord(); }
977 # define INSPECTOR_P_SUPPORT(Data) \
978 GETRECORD_POINTER_SUPPORT(Data) \
979 GETSTRING_POINTER_SUPPORT(Data) \
980 IOSTREAM_POINTER_SUPPORT(Data)
983 # define INSPECTOR_R_SUPPORT(Data) \
984 GETRECORD_REFERENCE_SUPPORT(Data) \
985 GETSTRING_REFERENCE_SUPPORT(Data) \
986 IOSTREAM_REFERENCE_SUPPORT(Data)
989 # define INSPECTOR_PR_SUPPORT(Data) \
990 GETSTRING_POINTER_SUPPORT(Data) \
991 GETSTRING_REFERENCE_SUPPORT(Data) \
992 GETSTRING_VALUE_SUPPORT(Data) \
993 IOSTREAM_POINTER_SUPPORT(Data) \
994 IOSTREAM_REFERENCE_SUPPORT(Data) \
995 GETRECORD_POINTER_SUPPORT(Data) \
996 GETRECORD_REFERENCE_SUPPORT(Data)
999 # define INSPECTOR_PV_SUPPORT(Data) \
1000 GETSTRING_POINTER_SUPPORT(Data) \
1001 GETSTRING_VALUE_SUPPORT(Data) \
1002 IOSTREAM_POINTER_SUPPORT(Data) \
1003 IOSTREAM_VALUE_SUPPORT(Data) \
1004 GETRECORD_POINTER_SUPPORT(Data) \
1005 GETRECORD_VALUE_SUPPORT(Data)
1008 #include "hurricane/Tabulation.h"
1018 inline int getMinLevel ()
const;
1019 inline int getMaxLevel ()
const;
1020 inline int setMinLevel (
int );
1021 inline int setMaxLevel (
int );
1022 inline int getLevel ()
const;
1023 inline int setLevel (
int );
1024 inline bool enabled ()
const;
1025 inline bool enabled (
int )
const;
1026 inline tstream& log (
int level,
int count=0 );
1027 inline tstream& tabw (
int level,
int count );
1028 inline tstream ( std::ostream & );
1029 inline tstream& put (
char c );
1033 inline tstream& _tabw (
int count );
1036 inline tstream& operator<< ( std::ostream& (*pf)(std::ostream &) );
1045 inline tstream::tstream ( std::ostream& s )
1046 : std::ostream(s.rdbuf())
1047 , _minLevel (100000)
1059 inline bool tstream::enabled ()
const {
return (_level >= _minLevel) and (_level < _maxLevel); }
1062 inline tstream& tstream::put (
char c ) {
if (
enabled())
static_cast<std::ostream*
>(
this)->put(c);
return *
this; }
1063 inline tstream& tstream::flush () {
if (
enabled())
static_cast<std::ostream*
>(
this)->flush();
return *
this; }
1064 inline tstream& tstream::operator<< ( std::ostream& (*pf)(std::ostream&) ) {
if (
enabled()) (*pf)(*this);
return *
this; }
1067 inline tstream& tstream::_tab () {
if (
enabled()) (*this) << _tabulation;
return *
this; }
1068 inline tstream& tstream::_tabw (
int count )
1071 if (count > 0)
while(count--) _tabulation++;
1072 else if (count < 0)
while(count++) _tabulation--;
1078 {
setLevel(level); _tab();
return _tabw(count); }
1082 {
if (o.
enabled()) {
static_cast<std::ostream&
>(o) << s; }
return o; };
1089 template<
typename T>
1091 {
if (o.
enabled()) {
static_cast<std::ostream&
>(o) << getString<T*>(t); }
return o; };
1097 template<
typename T>
1099 {
if (o.
enabled()) {
static_cast<std::ostream&
>(o) << getString<T>(t); }
return o; };
1101 template<
typename T>
1103 {
if (o.
enabled()) {
static_cast<std::ostream&
>(o) << getString<const T*>(t); }
return o; };
1106 inline tstream& operator<< (
tstream& o, std::ios_base& (*pf)(std::ios_base&) )
1107 {
if (o.
enabled()) {
static_cast<std::ostream&
>(o) << pf; }
return o; };
1109 struct _Tsetw {
int n_; };
1110 inline _Tsetw tsetw (
int n ) {
return { n }; }
1112 struct _Tsetf {
int n_; };
1113 inline _Tsetf tsetf (
int n ) {
return { n }; }
1117 {
if (o.
enabled()) {
static_cast<std::ostream&
>(o) << std::setw(manip.n_); }
return o; }
1122 #define cdebug_log(level,indent) if (cdebug.enabled(level)) cdebug.log(level,indent)
1123 #define cdebug_tabw(level,indent) cdebug.tabw(level,indent)
1130 #include "hurricane/Slot.h"
1131 #include "hurricane/Initializer.h"
1132 #include "hurricane/JsonWriter.h"
1133 #include "hurricane/JsonObject.h"
Tabulation description (API)
Definition: Tabulation.h:35
Trace & indentation enabled stream.
Definition: Commons.h:1016
bool enabled() const
Definition: Commons.h:1059
int getLevel() const
Definition: Commons.h:1057
int setMinLevel(int)
Definition: Commons.h:1055
tstream & log(int level, int count=0)
Definition: Commons.h:1077
int setLevel(int)
Definition: Commons.h:1058
tstream & tabw(int level, int count)
Definition: Commons.h:1061
int setMaxLevel(int)
Definition: Commons.h:1056
int getMinLevel() const
Definition: Commons.h:1053
int getMaxLevel() const
Definition: Commons.h:1054
Contains Almost Everything.
Definition: BasicLayer.h:39
string demangle(const char *symbol)