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"
167template<
typename Data>
inline Hurricane::Slot* getSlot ( std::string name, Data );
175template<
typename Data>
inline std::string getString ( Data data )
176{
return std::string(
"<type ")
178 + std::string(
" unsupported by getString()>"); }
182template<>
inline std::string getString<const bool&> (
const bool& b )
183{
return (b)?
"True":
"False" ; }
185template<>
inline std::string getString<const int&> (
const int& i )
186{ std::ostringstream os (
""); os << i;
return os.str(); }
188template<>
inline std::string getString<const long&> (
const long& l )
189{ std::ostringstream os (
""); os << l;
return os.str(); }
191template<>
inline std::string getString<const unsigned int&> (
const unsigned int& u )
192{ std::ostringstream os (
""); os << u;
return os.str(); }
194template<>
inline std::string getString<const unsigned long&> (
const unsigned long& ul )
195{ std::ostringstream os (
""); os << ul;
return os.str(); }
197template<>
inline std::string getString<const unsigned long long&> (
const unsigned long long& ull )
198{ std::ostringstream os (
""); os << ull;
return os.str(); }
200template<>
inline std::string getString<const unsigned short int&> (
const unsigned short int& us )
201{ std::ostringstream os (
""); os << us;
return os.str(); }
203template<>
inline std::string getString<const float&> (
const float& f )
204{ std::ostringstream os (
""); os << f;
return os.str(); }
206template<>
inline std::string getString<const double&> (
const double& d )
207{ std::ostringstream os; os << d;
return os.str(); }
209template<>
inline std::string getString<const std::string&> (
const std::string& s )
214template<>
inline std::string getString<const bool*> (
const bool* b )
215{
return (*b)?
"True":
"False" ; }
217template<>
inline std::string getString<const char*> (
const char* c )
220template<>
inline std::string getString<const int*> (
const int* i )
221{ std::ostringstream os (
""); os << *i;
return os.str(); }
223template<>
inline std::string getString<const long*> (
const long* l )
224{ std::ostringstream os (
""); os << *l;
return os.str(); }
226template<>
inline std::string getString<const unsigned int*> (
const unsigned int* u )
227{ std::ostringstream os (
""); os << *u;
return os.str(); }
229template<>
inline std::string getString<const unsigned long*> (
const unsigned long* ul )
230{ std::ostringstream os (
""); os << *ul;
return os.str(); }
232template<>
inline std::string getString<const unsigned long long*> (
const unsigned long long* ull )
233{ std::ostringstream os (
""); os << *ull;
return os.str(); }
235template<>
inline std::string getString<const unsigned short int*> (
const unsigned short int* us )
236{ std::ostringstream os (
""); os << *us;
return os.str(); }
238template<>
inline std::string getString<const float*> (
const float* f )
239{ std::ostringstream os (
""); os << *f;
return os.str(); }
241template<>
inline std::string getString<const double*> (
const double* d )
242{ std::ostringstream os; os << *d;
return os.str(); }
244template<>
inline std::string getString<const void*> (
const void* p )
245{ std::ostringstream os (
"0x"); os << std::hex << p;
return os.str(); }
247template<>
inline std::string getString<const std::string*> (
const std::string* s )
253template<>
inline std::string getString<bool*> (
bool* b )
254{
return (*b)?
"True":
"False" ; }
256template<>
inline std::string getString<char*> (
char* c )
259template<>
inline std::string getString<int*> (
int* i )
260{ std::ostringstream os (
""); os << *i;
return os.str(); }
262template<>
inline std::string getString<long*> (
long* l )
263{ std::ostringstream os (
""); os << *l;
return os.str(); }
265template<>
inline std::string getString<unsigned int*> (
unsigned int* u )
266{ std::ostringstream os (
""); os << *u;
return os.str(); }
268template<>
inline std::string getString<unsigned long*> (
unsigned long* ul )
269{ std::ostringstream os (
""); os << *ul;
return os.str(); }
271template<>
inline std::string getString<unsigned long long*> (
unsigned long long* ull )
272{ std::ostringstream os (
""); os << *ull;
return os.str(); }
274template<>
inline std::string getString<unsigned short int*> (
unsigned short int* us )
275{ std::ostringstream os (
""); os << *us;
return os.str(); }
277template<>
inline std::string getString<float*> (
float* f )
278{ std::ostringstream os (
""); os << *f;
return os.str(); }
280template<>
inline std::string getString<double*> (
double* d )
281{ std::ostringstream os; os << *d;
return os.str(); }
283template<>
inline std::string getString<void*> (
void* p )
284{ std::ostringstream os (
"0x"); os << std::hex << p;
return os.str(); }
286template<>
inline std::string getString<std::string*> ( std::string* s )
292template<>
inline std::string getString<bool> (
bool b )
293{
return (b)?
"True":
"False" ; }
295template<>
inline std::string getString<char> (
char c )
296{
return std::string(1,c); }
298template<>
inline std::string getString<int> (
int i )
299{ std::ostringstream os (
""); os << i;
return os.str(); }
301template<>
inline std::string getString<long> (
long l )
302{ std::ostringstream os (
""); os << l;
return os.str(); }
304template<>
inline std::string getString<unsigned int> (
unsigned int u )
305{ std::ostringstream os (
""); os << u;
return os.str(); }
307template<>
inline std::string getString<unsigned long> (
unsigned long ul )
308{ std::ostringstream os (
""); os << ul;
return os.str(); }
310template<>
inline std::string getString<unsigned long long> (
unsigned long long ull )
311{ std::ostringstream os (
""); os << ull;
return os.str(); }
313template<>
inline std::string getString<unsigned short int> (
unsigned short int us )
314{ std::ostringstream os (
""); os << us;
return os.str(); }
316template<>
inline std::string getString<float> (
float f )
317{ std::ostringstream os (
""); os << f;
return os.str(); }
319template<>
inline std::string getString<double> (
double d )
320{ std::ostringstream os; os << d;
return os.str(); }
322template<>
inline std::string getString<std::string> ( std::string s )
326template<
typename Data>
inline Hurricane::Record* getRecord ( Data data )
336template<
typename T,
typename U>
337inline std::string getString (
const std::pair<T,U>& p )
339 return "const std::pair<T,U>";
343template<
typename T,
typename U>
344inline 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) );
354template<
typename T,
typename U>
355inline std::string getString ( std::pair<T,U>& p )
357 return "std::pair<T,U>";
361template<
typename T,
typename U>
362inline 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) );
376template<
typename Element,
size_t N>
377inline 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());
384template<
typename Element,
size_t N>
385inline 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) );
401template<
typename Element,
size_t N>
402inline 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());
409template<
typename Element,
size_t N>
410inline 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) );
426template<
typename Element,
size_t N>
427inline std::string getString ( std::array<Element,N>& v )
429 std::string name =
"std::array<Element,N>&:";
430 return name + getString<size_t>(v.size());
434template<
typename Element,
size_t N>
435inline 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) );
448template<
typename Element,
size_t N>
449inline 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());
456template<
typename Element,
size_t N>
457inline 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) );
474template<
typename Element>
475inline std::string getString ( std::vector<Element>* v )
477 std::string name =
"std::vector<Element>*:";
478 return name + getString<size_t>(v->size());
482template<
typename Element>
483inline 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)) );
503template<
typename Element>
504inline std::string getString ( std::vector<Element*>* v )
506 std::string name =
"std::vector<Element*>*:";
507 return name + getString<size_t>(v->size());
511template<
typename Element>
512inline 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) );
532template<
typename Element>
533inline std::string getString (
const std::vector<Element>* v )
535 std::string name =
"const std::vector<Element>*:";
536 return name + getString<size_t>(v->size());
540template<
typename Element>
541inline 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)) );
561template<
typename Element>
562inline std::string getString (
const std::vector<Element*>* v )
564 std::string name =
"const std::vector<Element*>*:";
565 return name + getString<size_t>(v->size());
569template<
typename Element>
570inline 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) );
590template<
typename Element>
591inline std::string getString (
const std::list<Element>* l )
593 std::string name =
"const std::list<Element>*:";
594 return name + getString<size_t>(l->size());
598template<
typename Element>
599inline 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)) );
615template<
typename Element>
616inline std::string getString ( std::list<Element>* l )
618 std::string name =
"std::list<Element>*:";
619 return name + getString<size_t>(l->size());
623template<
typename Element>
624inline 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)) );
644template<
typename Key,
typename Element>
645inline std::string getString ( std::map<Key,Element>* m )
647 std::string name =
"std::map<Element>:";
648 return name + getString<size_t>(m->size());
652template<
typename Key,
typename Element>
653inline 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) );
668template<
typename Key,
typename Element>
669inline 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());
676template<
typename Key,
typename Element>
677inline 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) );
696template<
typename Key,
typename Element,
typename Compare>
697inline std::string getString ( std::map<Key,Element,Compare>* m )
699 std::string name =
"std::map<Element>:";
700 return name + getString<size_t>(m->size());
704template<
typename Key,
typename Element,
typename Compare>
705inline 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) );
720template<
typename Key,
typename Element,
typename Compare>
721inline 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());
728template<
typename Key,
typename Element,
typename Compare>
729inline 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) );
748template<
typename Key,
typename Element,
typename Compare>
749inline 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());
756template<
typename Key,
typename Element,
typename Compare>
757inline 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) );
772template<
typename Key,
typename Element,
typename Compare>
773inline std::string getString ( std::multimap<Key,Element,Compare>* m )
775 std::string name =
"std::multimap<Element>:";
776 return name + getString<size_t>(m->size());
780template<
typename Key,
typename Element,
typename Compare>
781inline 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) );
800template<
typename Element,
typename Compare>
801inline 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());
808template<
typename Element,
typename Compare>
809inline 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) );
825template<
typename Element,
typename Compare,
typename Allocator >
826inline std::string getString ( std::set<Element,Compare,Allocator>* s )
828 std::string name =
"std::set<Element>:";
829 return name + getString<size_t>(s->size());
833template<
typename Element,
typename Compare,
typename Allocator >
834inline 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) );
853template<
typename Element,
typename Compare>
854inline 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());
861template<
typename Element,
typename Compare>
862inline 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) );
881template<
typename Element,
typename Compare>
882inline std::string getString (
const std::multiset<Element,Compare>* s )
884 std::string name =
"std::multiset<Element>:";
885 return name + getString<size_t>(s->size());
889template<
typename Element,
typename Compare>
890inline 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"
1025 inline bool enabled (
int )
const;
1026 inline tstream&
log (
int level,
int count=0 );
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 &) );
1045inline tstream::tstream ( std::ostream& s )
1046 : std::ostream(s.rdbuf())
1047 , _minLevel (100000)
1059inline bool tstream::enabled ()
const {
return (_level >= _minLevel) and (_level < _maxLevel); }
1062inline tstream& tstream::put (
char c ) {
if (
enabled())
static_cast<std::ostream*
>(
this)->put(c);
return *
this; }
1063inline tstream& tstream::flush () {
if (
enabled())
static_cast<std::ostream*
>(
this)->flush();
return *
this; }
1064inline tstream& tstream::operator<< ( std::ostream& (*pf)(std::ostream&) ) {
if (
enabled()) (*pf)(*this);
return *
this; }
1067inline tstream& tstream::_tab () {
if (
enabled()) (*this) << _tabulation;
return *
this; }
1068inline 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; };
1091{
if (o.
enabled()) {
static_cast<std::ostream&
>(o) << getString<T*>(t); }
return o; };
1099{
if (o.
enabled()) {
static_cast<std::ostream&
>(o) << getString<T>(t); }
return o; };
1103{
if (o.
enabled()) {
static_cast<std::ostream&
>(o) << getString<const T*>(t); }
return o; };
1106inline tstream& operator<< (
tstream& o, std::ios_base& (*pf)(std::ios_base&) )
1107{
if (o.
enabled()) {
static_cast<std::ostream&
>(o) << pf; }
return o; };
1109struct _Tsetw {
int n_; };
1110inline _Tsetw tsetw (
int n ) {
return { n }; }
1112struct _Tsetf {
int n_; };
1113inline _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)