KSquare Utilities
KKLSC::ScannerHeaderFields Class Reference

Represents a list of header fields from a Scanner File. More...

#include <ScannerHeaderFields.h>

+ Inheritance diagram for KKLSC::ScannerHeaderFields:

Public Types

typedef map< KKStr, KKStr >::iterator iterator
 
typedef ScannerHeaderFieldsScannerHeaderFieldsPtr
 

Public Member Functions

 ScannerHeaderFields ()
 
 ScannerHeaderFields (const ScannerHeaderFields &fields)
 
 ~ScannerHeaderFields ()
 
void Add (ScannerHeaderFieldsPtr fields)
 
void Add (const KKB::KKStr &fieldName, const KKB::KKStr &fieldValue)
 
void Add (const KKB::KKStr &fieldName, bool fieldValue)
 
void Add (const KKStr &fieldName, kkint32 fieldValue)
 
void Add (const KKStr &fieldName, kkint64 fieldValue)
 
void Add (const KKStr &fieldName, double fieldValue)
 
void Add (const KKStr &fieldName, KKB::DateTime fieldValue)
 
void Clear ()
 
void EndBlock ()
 
bool FieldExists (const KKStr &fieldName) const
 
const KKStrGetValue (const KKStr &fieldName) const
 
float GetValueFloat (const KKStr &fieldName) const
 
kkint32 GetValueInt32 (const KKStr &fieldName) const
 
kkint32 MemoryConsumedEstimated ()
 
void StartBlock ()
 

Detailed Description

Represents a list of header fields from a Scanner File.

All ScannerFiles will start with a Header section that consists of text with each line consisting of a "FieldName" allowed by a "FieldValue" separated by the tab character.

Definition at line 17 of file ScannerHeaderFields.h.

Member Typedef Documentation

Definition at line 69 of file ScannerHeaderFields.h.

Constructor & Destructor Documentation

ScannerHeaderFields::ScannerHeaderFields ( )

Definition at line 25 of file ScannerHeaderFields.cpp.

References KKB::GoalKeeper::Create(), and ScannerHeaderFields().

Referenced by KKLSC::ScannerFile::AddHeaderField(), KKLSC::ScannerFile::ReadHeader(), and ScannerHeaderFields().

25  :
26  map<KKStr,KKStr> (),
27  goalie (NULL)
28 {
29  GoalKeeper::Create ("ScannerHeaderFields", goalie);
30 }
ScannerHeaderFields::ScannerHeaderFields ( const ScannerHeaderFields fields)

Definition at line 34 of file ScannerHeaderFields.cpp.

References KKB::GoalKeeper::Create(), and ScannerHeaderFields().

Referenced by KKLSC::ScannerFile::GetScannerFileParameters(), and ScannerHeaderFields().

34  :
35  map<KKStr,KKStr> (),
36  goalie (NULL)
37 {
38  GoalKeeper::Create ("ScannerHeaderFields", goalie);
39  ScannerHeaderFields::const_iterator idx;
40  for (idx = fields.begin (); idx != fields.end (); ++idx)
41  Add (idx->first, idx->second);
42 }
void Add(ScannerHeaderFieldsPtr fields)
ScannerHeaderFields::~ScannerHeaderFields ( )

Definition at line 46 of file ScannerHeaderFields.cpp.

References KKB::GoalKeeper::Destroy().

47 {
48  GoalKeeper::Destroy (goalie);
49  goalie = NULL;
50 }

Member Function Documentation

void ScannerHeaderFields::Add ( ScannerHeaderFieldsPtr  fields)

Definition at line 74 of file ScannerHeaderFields.cpp.

75 {
76  if (!fields)
77  return;
78  ScannerHeaderFields::const_iterator idx;
79  for (idx = fields->begin (); idx != fields->end (); ++idx)
80  Add (idx->first, idx->second);
81 }
void Add(ScannerHeaderFieldsPtr fields)
void ScannerHeaderFields::Add ( const KKB::KKStr fieldName,
const KKB::KKStr fieldValue 
)

Definition at line 85 of file ScannerHeaderFields.cpp.

References KKB::GoalKeeper::EndBlock(), and KKB::GoalKeeper::StartBlock().

Referenced by Add(), KKLSC::ScannerFile::AddHeaderField(), and KKLSC::ScannerFile::ReadHeader().

88 {
89  goalie->StartBlock ();
90 
91  idx1 = this->find (fieldName);
92  if (idx1 == end ())
93  insert (pair<KKStr,KKStr>(fieldName, fieldValue));
94  else
95  idx1->second = fieldValue;
96 
97  goalie->EndBlock ();
98 }
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
Definition: GoalKeeper.cpp:214
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
Definition: GoalKeeper.cpp:295
void ScannerHeaderFields::Add ( const KKB::KKStr fieldName,
bool  fieldValue 
)

Definition at line 101 of file ScannerHeaderFields.cpp.

References Add(), and KKB::KKStr::Concat().

104 {
105  KKStr fieldValueStr = (fieldValue ? "Yes" : "No");
106  Add (fieldName, fieldValueStr);
107 }
void Add(ScannerHeaderFieldsPtr fields)
void KKLSC::ScannerHeaderFields::Add ( const KKStr &  fieldName,
kkint32  fieldValue 
)
void KKLSC::ScannerHeaderFields::Add ( const KKStr &  fieldName,
kkint64  fieldValue 
)
void KKLSC::ScannerHeaderFields::Add ( const KKStr &  fieldName,
double  fieldValue 
)
void KKLSC::ScannerHeaderFields::Add ( const KKStr &  fieldName,
KKB::DateTime  fieldValue 
)
void ScannerHeaderFields::Clear ( )

Erases contents

Definition at line 154 of file ScannerHeaderFields.cpp.

References KKB::GoalKeeper::EndBlock(), and KKB::GoalKeeper::StartBlock().

155 {
156  goalie->StartBlock ();
157  clear ();
158  goalie->EndBlock ();
159 }
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
Definition: GoalKeeper.cpp:214
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
Definition: GoalKeeper.cpp:295
void ScannerHeaderFields::EndBlock ( )

Definition at line 216 of file ScannerHeaderFields.cpp.

References KKB::GoalKeeper::EndBlock().

Referenced by KKLSC::ScannerFile::AddHeaderFields().

217 {
218  goalie->EndBlock ();
219 }
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
Definition: GoalKeeper.cpp:295
bool ScannerHeaderFields::FieldExists ( const KKStr fieldName) const

Definition at line 163 of file ScannerHeaderFields.cpp.

References KKB::GoalKeeper::EndBlock(), and KKB::GoalKeeper::StartBlock().

164 {
165  bool exists = false;
166  goalie->StartBlock ();
167  idx2 = this->find (fieldName);
168  exists = (idx2 != end ());
169  goalie->EndBlock ();
170  return exists;
171 }
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
Definition: GoalKeeper.cpp:214
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
Definition: GoalKeeper.cpp:295
const KKStr & ScannerHeaderFields::GetValue ( const KKStr fieldName) const

Definition at line 175 of file ScannerHeaderFields.cpp.

References KKB::KKStr::Concat(), KKB::GoalKeeper::EndBlock(), and KKB::GoalKeeper::StartBlock().

Referenced by KKLSC::ScannerFile::GetValue(), GetValueFloat(), and GetValueInt32().

176 {
177  const KKStr* value = NULL;
178 
179  goalie->StartBlock ();
180  idx2 = this->find (fieldName);
181  if (idx2 == end ())
182  value = &(KKStr::EmptyStr ());
183  else
184  value = &(idx2->second);
185  goalie->EndBlock ();
186 
187  return *value;
188 }
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
Definition: GoalKeeper.cpp:214
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
Definition: GoalKeeper.cpp:295
float ScannerHeaderFields::GetValueFloat ( const KKStr fieldName) const

Definition at line 192 of file ScannerHeaderFields.cpp.

References KKB::KKStr::Concat(), GetValue(), and KKB::KKStr::ToFloat().

Referenced by KKLSC::ScannerFile::GetValueFloat().

193 {
194  KKStr s = GetValue (fieldName);
195  return s.ToFloat ();
196 }
const KKStr & GetValue(const KKStr &fieldName) const
float ToFloat() const
Definition: KKStr.cpp:3553
kkint32 ScannerHeaderFields::GetValueInt32 ( const KKStr fieldName) const

Definition at line 200 of file ScannerHeaderFields.cpp.

References KKB::KKStr::Concat(), GetValue(), and KKB::KKStr::ToInt32().

201 {
202  KKStr s = GetValue (fieldName);
203  return s.ToInt32 ();
204 }
kkint32 ToInt32() const
Definition: KKStr.cpp:3587
const KKStr & GetValue(const KKStr &fieldName) const
kkint32 ScannerHeaderFields::MemoryConsumedEstimated ( )

Definition at line 54 of file ScannerHeaderFields.cpp.

References KKB::GoalKeeper::EndBlock(), KKB::GoalKeeper::MemoryConsumedEstimated(), and KKB::GoalKeeper::StartBlock().

Referenced by KKLSC::ScannerFile::MemoryConsumedEstimated().

55 {
56  goalie->StartBlock ();
57 
58  kkint32 mem = sizeof (*this);
59 
60  if (goalie) mem += goalie->MemoryConsumedEstimated ();
61 
62  for (idx2 = begin (); idx2 != end (); ++idx2)
63  {
64  mem = mem + (idx2->first.MemoryConsumedEstimated () + idx2->second.MemoryConsumedEstimated ());
65  }
66 
67  goalie->EndBlock ();
68 
69  return mem;
70 }
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 MemoryConsumedEstimated() const
Definition: GoalKeeper.cpp:166
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
Definition: GoalKeeper.cpp:214
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
Definition: GoalKeeper.cpp:295
void ScannerHeaderFields::StartBlock ( )

Definition at line 209 of file ScannerHeaderFields.cpp.

References KKB::GoalKeeper::StartBlock().

Referenced by KKLSC::ScannerFile::AddHeaderFields().

210 {
211  goalie->StartBlock ();
212 }
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
Definition: GoalKeeper.cpp:214

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