BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
IfdStrKey Class Reference

#include <IfdStrKey.h>

Inheritance diagram for IfdStrKey:

Public Types

enum  { IFDKEY_BUFSIZE = 32 }
enum  { IFDKEY_BUFSIZE = 32 }
enum  { IFDKEY_BUFSIZE = 32 }

Public Member Functions

 IfdStrKey (const char *s)
 IfdStrKey (const std::string &s)
virtual ~IfdStrKey ()
virtual int operator== (const IfdKey &k) const
virtual int operator< (const IfdKey &k) const
virtual IfdKeyclone (void) const
const char * asString (void) const
virtual void print (std::ostream &o) const
 IfdStrKey (const char *s)
 IfdStrKey (const std::string &s)
virtual ~IfdStrKey ()
virtual int operator== (const IfdKey &k) const
virtual int operator< (const IfdKey &k) const
virtual IfdKeyclone (void) const
const char * asString (void) const
virtual void print (std::ostream &o) const
 IfdStrKey (const char *s)
 IfdStrKey (const std::string &s)
virtual ~IfdStrKey ()
virtual int operator== (const IfdKey &k) const
virtual int operator< (const IfdKey &k) const
virtual IfdKeyclone (void) const
const char * asString (void) const
virtual void print (std::ostream &o) const
Public Member Functions inherited from IfdKey
virtual ~IfdKey ()
int operator!= (const IfdKey &k) const
virtual void add (const IfdKey &)
int cardinality (void) const
virtual unsigned int hash (void) const
virtual ~IfdKey ()
int operator!= (const IfdKey &k) const
virtual void add (const IfdKey &)
int cardinality (void) const
virtual unsigned int hash (void) const
virtual ~IfdKey ()
int operator!= (const IfdKey &k) const
virtual void add (const IfdKey &)
int cardinality (void) const
virtual unsigned int hash (void) const

Additional Inherited Members

Static Public Member Functions inherited from IfdKey
static unsigned int nHashBuckets (void)
static unsigned int nHashBuckets (void)
static unsigned int nHashBuckets (void)
Public Attributes inherited from IfdKey
unsigned int _hashVal
Protected Types inherited from IfdKey
enum  { _nHashBuckets = 1031 }
enum  keyKind {
  intKey , strKey , compositeKey , typeKey ,
  odfTypeKey , intKey , strKey , compositeKey ,
  typeKey , odfTypeKey , intKey , strKey ,
  compositeKey , typeKey , odfTypeKey
}
enum  { _nHashBuckets = 1031 }
enum  keyKind {
  intKey , strKey , compositeKey , typeKey ,
  odfTypeKey , intKey , strKey , compositeKey ,
  typeKey , odfTypeKey , intKey , strKey ,
  compositeKey , typeKey , odfTypeKey
}
enum  { _nHashBuckets = 1031 }
enum  keyKind {
  intKey , strKey , compositeKey , typeKey ,
  odfTypeKey , intKey , strKey , compositeKey ,
  typeKey , odfTypeKey , intKey , strKey ,
  compositeKey , typeKey , odfTypeKey
}
Protected Member Functions inherited from IfdKey
 IfdKey (keyKind kind)
IfdKey::keyKind getKeyKind (void) const
 IfdKey (keyKind kind)
IfdKey::keyKind getKeyKind (void) const
 IfdKey (keyKind kind)
IfdKey::keyKind getKeyKind (void) const
Protected Attributes inherited from IfdKey
keyKind _myKeyKind
int _myCardinality
union { 
   int   intVal 
   unsigned int   uintVal 
   char *   strVal 
}; 
union { 
   int   intVal 
   unsigned int   uintVal 
   char *   strVal 
}; 
union { 
   int   intVal 
   unsigned int   uintVal 
   char *   strVal 
}; 

Detailed Description

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
IFDKEY_BUFSIZE 

Definition at line 41 of file Reconstruction/MdcPatRec/ProxyDict/include/ProxyDict/IfdStrKey.h.

41{ IFDKEY_BUFSIZE = 32 }; // See comments for _string

◆ anonymous enum

anonymous enum
Enumerator
IFDKEY_BUFSIZE 

Definition at line 41 of file InstallArea/x86_64-el9-gcc13-opt/include/ProxyDict/IfdStrKey.h.

41{ IFDKEY_BUFSIZE = 32 }; // See comments for _string

◆ anonymous enum

anonymous enum
Enumerator
IFDKEY_BUFSIZE 

Definition at line 41 of file InstallArea/x86_64-el9-gcc13-dbg/include/ProxyDict/IfdStrKey.h.

41{ IFDKEY_BUFSIZE = 32 }; // See comments for _string

Constructor & Destructor Documentation

◆ IfdStrKey() [1/6]

IfdStrKey::IfdStrKey ( const char * s)

Definition at line 29 of file IfdStrKey.cxx.

32 : IfdKey( strKey )
33
34{
35
36 // NB: strncpy would be nice below, but we've already died in strlen
37 // if thats an issue.
38
39 register size_t strSize = strlen( s ) + 1;
40
41 // If the space allocated in this instance of IfdStrKey is big enough
42 // to hold the string, then put it there; otherwise do the slower operation
43 // of allocating it in the heap. Either way, make strVal point at it
44 // to avoid "if allocated" sort of logic later.
45
46 if ( strSize < IFDKEY_BUFSIZE )
47 {
48 strcpy( _stringBuf, s );
49 strVal = &_stringBuf[0];
50 _onHeap = false;
51 }
52 else
53 {
54 strVal = new char[strSize];
55 strcpy( strVal, s );
56 _onHeap = true;
57 }
58
59 enum {
60 MaxChar = 64 // Limit computation. Don't need strlen()
61 };
62
63 _hashVal = 0;
64
65 size_t n = 0;
66 while ( ( s[n] != '\0' ) && ( n < MaxChar ) )
67 {
68 _hashVal = ( ( _hashVal << 8 ) + s[n] ) % _nHashBuckets;
69 n++;
70 }
71}
const Int_t n
XmlRpcServer s
IfdKey(keyKind kind)
Definition IfdKey.cxx:23

Referenced by print().

◆ IfdStrKey() [2/6]

IfdStrKey::IfdStrKey ( const std::string & s)

Definition at line 75 of file IfdStrKey.cxx.

78 : IfdKey( strKey )
79
80{
81 using std::string;
82 const char* s = str.c_str();
83 register size_t strSize = str.size() + 1;
84
85 // register size_t strSize = strlen(s)+1;
86
87 // If the space allocated in this instance of IfdStrKey is big enough
88 // to hold the string, then put it there; otherwise do the slower operation
89 // of allocating it in the heap. Either way, make strVal point at it
90 // to avoid "if allocated" sort of logic later.
91
92 if ( strSize < IFDKEY_BUFSIZE )
93 {
94 strcpy( _stringBuf, s );
95 strVal = &_stringBuf[0];
96 _onHeap = false;
97 }
98 else
99 {
100 strVal = new char[strSize];
101 strcpy( strVal, s );
102 _onHeap = true;
103 }
104
105 enum {
106 MaxChar = 64 // Limit computation. Don't need strlen()
107 };
108
109 _hashVal = 0;
110
111 size_t n = 0;
112 while ( ( s[n] != '\0' ) && ( n < MaxChar ) )
113 {
114 _hashVal = ( ( _hashVal << 8 ) + s[n] ) % _nHashBuckets;
115 n++;
116 }
117}

◆ ~IfdStrKey() [1/3]

IfdStrKey::~IfdStrKey ( )
virtual

Definition at line 152 of file IfdStrKey.cxx.

152 {
153 //****************************************************************************
154 if ( _onHeap ) delete[] strVal;
155 strVal = 0;
156}

◆ IfdStrKey() [3/6]

IfdStrKey::IfdStrKey ( const char * s)

◆ IfdStrKey() [4/6]

IfdStrKey::IfdStrKey ( const std::string & s)

◆ ~IfdStrKey() [2/3]

virtual IfdStrKey::~IfdStrKey ( )
virtual

◆ IfdStrKey() [5/6]

IfdStrKey::IfdStrKey ( const char * s)

◆ IfdStrKey() [6/6]

IfdStrKey::IfdStrKey ( const std::string & s)

◆ ~IfdStrKey() [3/3]

virtual IfdStrKey::~IfdStrKey ( )
virtual

Member Function Documentation

◆ asString() [1/3]

const char * IfdStrKey::asString ( void ) const
inline

◆ asString() [2/3]

const char * IfdStrKey::asString ( void ) const
inline

◆ asString() [3/3]

const char * IfdStrKey::asString ( void ) const
inline

◆ clone() [1/3]

IfdKey * IfdStrKey::clone ( void ) const
virtual

Implements IfdKey.

Definition at line 159 of file IfdStrKey.cxx.

159 {
160 //****************************************************************************
161 return new IfdStrKey( strVal, _hashVal );
162}

◆ clone() [2/3]

virtual IfdKey * IfdStrKey::clone ( void ) const
virtual

Implements IfdKey.

◆ clone() [3/3]

virtual IfdKey * IfdStrKey::clone ( void ) const
virtual

Implements IfdKey.

◆ operator<() [1/3]

int IfdStrKey::operator< ( const IfdKey & k) const
virtual

Definition at line 185 of file IfdStrKey.cxx.

185 {
186 //****************************************************************************
187 return ( strKey == k.getKeyKind() ) && ( strcmp( strVal, k.strVal ) < 0 );
188}

◆ operator<() [2/3]

virtual int IfdStrKey::operator< ( const IfdKey & k) const
virtual

◆ operator<() [3/3]

virtual int IfdStrKey::operator< ( const IfdKey & k) const
virtual

◆ operator==() [1/3]

int IfdStrKey::operator== ( const IfdKey & k) const
virtual

Implements IfdKey.

Definition at line 165 of file IfdStrKey.cxx.

165 {
166 //****************************************************************************
167
168 if ( ( strKey == k.getKeyKind() ) && ( _hashVal == k._hashVal ) )
169 {
170
171 // Then they might actually match! Check the strings.
172 // We used to use strcmp, but this is faster by x2.2.
173 char* s1 = strVal;
174 char* s2 = k.strVal;
175 while ( *s1 == *s2++ )
176 {
177 if ( *s1++ == '\0' ) return 1; // NB: == in while => *s2 == \0 too.
178 }
179 }
180
181 return 0;
182}

◆ operator==() [2/3]

virtual int IfdStrKey::operator== ( const IfdKey & k) const
virtual

Implements IfdKey.

◆ operator==() [3/3]

virtual int IfdStrKey::operator== ( const IfdKey & k) const
virtual

Implements IfdKey.

◆ print() [1/3]

virtual void IfdStrKey::print ( std::ostream & o) const
virtual

Implements IfdKey.

◆ print() [2/3]

virtual void IfdStrKey::print ( std::ostream & o) const
virtual

Implements IfdKey.

◆ print() [3/3]

virtual void IfdStrKey::print ( std::ostream & o) const
virtual

Implements IfdKey.


The documentation for this class was generated from the following files: