KSquare Utilities
KKB::KKStrMatrix Class Reference

A two dimensional matrix of Strings. More...

#include <KKStrMatrix.h>

Public Types

typedef KKStrMatrixKKStrMatrixPtr
 

Public Member Functions

 KKStrMatrix (kkuint32 _numCols)
 
 KKStrMatrix (kkuint32 _numCols, kkuint32 _numRows)
 
 ~KKStrMatrix ()
 
void AddRow (KKStrListPtr newRowData)
 Adds a list of Strings to the end of the Matrix. More...
 
void AddRow ()
 Adds a row of empty string to the end of the matrix. More...
 
kkuint32 NumCols () const
 
kkuint32 NumRows () const
 
KKStrListoperator() (kkuint32 row)
 
KKStroperator() (kkuint32 row, kkuint32 col)
 
KKStrListoperator[] (kkuint32 row)
 

Detailed Description

A two dimensional matrix of Strings.

Definition at line 30 of file KKStrMatrix.h.

Member Typedef Documentation

Definition at line 33 of file KKStrMatrix.h.

Constructor & Destructor Documentation

KKB::KKStrMatrix::KKStrMatrix ( kkuint32  _numCols)
inline

Definition at line 36 of file KKStrMatrix.h.

References KKStrMatrix().

Referenced by KKStrMatrix().

36  :
37  data (),
38  numCols (_numCols)
39  {
40  }
KKB::KKStrMatrix::KKStrMatrix ( kkuint32  _numCols,
kkuint32  _numRows 
)
inline

Definition at line 43 of file KKStrMatrix.h.

45  :
46  numCols (_numCols)
47  {
48  while ((kkuint32)data.QueueSize () < _numRows)
49  AddRow ();
50  }
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
void AddRow()
Adds a row of empty string to the end of the matrix.
Definition: KKStrMatrix.cpp:90
KKB::KKStrMatrix::~KKStrMatrix ( )
inline

Definition at line 53 of file KKStrMatrix.h.

54  {
55  }

Member Function Documentation

void KKStrMatrix::AddRow ( KKStrListPtr  newRowData)

Adds a list of Strings to the end of the Matrix.

Will add another row to the matrix and populate its contents with the String List being passed in.

Parameters
[in]newRowDataWill take ownership of this String list.

Definition at line 81 of file KKStrMatrix.cpp.

82 {
83  while ((kkuint32)newRowData->QueueSize () < numCols)
84  newRowData->PushOnBack (new KKStr ());
85  data.PushOnBack (newRowData);
86 }
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
virtual void PushOnBack(EntryPtr _entry)
Definition: KKQueue.h:398
kkint32 QueueSize() const
Definition: KKQueue.h:313
void KKStrMatrix::AddRow ( )

Adds a row of empty string to the end of the matrix.

Definition at line 90 of file KKStrMatrix.cpp.

References KKB::KKStrList::KKStrList().

91 {
92  KKStrListPtr newRowData = new KKStrList (true);
93  while ((kkuint32)newRowData->QueueSize () < numCols)
94  newRowData->PushOnBack (new KKStr ());
95  data.PushOnBack (newRowData);
96 }
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
virtual void PushOnBack(EntryPtr _entry)
Definition: KKQueue.h:398
kkint32 QueueSize() const
Definition: KKQueue.h:313
kkuint32 KKB::KKStrMatrix::NumCols ( ) const
inline

Definition at line 59 of file KKStrMatrix.h.

59 {return numCols;}
kkuint32 KKB::KKStrMatrix::NumRows ( ) const
inline

Definition at line 58 of file KKStrMatrix.h.

58 {return data.QueueSize ();}
KKStrList & KKStrMatrix::operator() ( kkuint32  row)

Definition at line 40 of file KKStrMatrix.cpp.

41 {
42  if (row >= (kkuint32)data.QueueSize ())
43  {
44  KKStr errMsg = "KKStrMatrix::operator[] Row dimension[" + StrFormatInt (row, "0") + "] invalid; Rows Available["
45  + StrFormatInt (data.QueueSize (), "0") + "]";
46  cerr << errMsg << std::endl;
47  throw errMsg;
48  }
49  return data[row];
50 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
KKStr StrFormatInt(kkint32 val, const char *mask)
Definition: KKStr.cpp:5004
KKStr & KKStrMatrix::operator() ( kkuint32  row,
kkuint32  col 
)

Definition at line 54 of file KKStrMatrix.cpp.

57 {
58  if (row >= (kkuint32)data.QueueSize ())
59  {
60  KKStr errMsg = "KKStrMatrix::operator[] Row dimension[" + StrFormatInt (row, "0") + "] invalid; Rows Available["
61  + StrFormatInt (data.QueueSize (), "0") + "]";
62  cerr << errMsg << std::endl;
63  throw errMsg;
64  }
65 
66  KKStrList& rowOfData = data[row];
67  if (col >= (kkuint32)rowOfData.QueueSize ())
68  {
69  KKStr errMsg = "KKStrMatrix::operator[] Col dimension[" + StrFormatInt (col, "0") + "] invalid; Rows Available["
70  + StrFormatInt (rowOfData.QueueSize (), "0") + "]";
71  cerr << errMsg << std::endl;
72  throw errMsg;
73  }
74 
75  return rowOfData[col];
76 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
KKStr StrFormatInt(kkint32 val, const char *mask)
Definition: KKStr.cpp:5004
kkint32 QueueSize() const
Definition: KKQueue.h:313
KKStrList & KKStrMatrix::operator[] ( kkuint32  row)

Definition at line 25 of file KKStrMatrix.cpp.

26 {
27  if (row >= (kkuint32)data.QueueSize ())
28  {
29  KKStr errMsg = "KKStrMatrix::operator[] Row dimension[" + StrFormatInt (row, "0") + "] invalid; Rows Available["
30  + StrFormatInt (data.QueueSize (), "0") + "]";
31  cerr << errMsg << std::endl;
32  throw errMsg;
33  }
34  return data[row];
35 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
KKStr StrFormatInt(kkint32 val, const char *mask)
Definition: KKStr.cpp:5004

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