KSquare Utilities
KKStrMatrix.h
Go to the documentation of this file.
1 /* KKStrMatrix.cpp -- 2D Matrix of Strings.
2  * Copyright (C) 1994-2014 Kurt Kramer
3  * For conditions of distribution and use, see copyright notice in KKB.h
4  */
5 #ifndef _KKSTRMATRIX_
6 #define _KKSTRMATRIX_
7 
8 #include <ostream>
9 #include <string>
10 
11 #ifdef WIN32
12 #else
13 #define __cdecl
14 #endif
15 
16 #include "KKBaseTypes.h"
17 #include "KKStr.h"
18 #include "KKStrMatrix.h"
19 
20 #define EnterChar 13
21 #define EscapeChar 27
22 
23 
24 namespace KKB
25 {
26  /**
27  *@class KKStrMatrix
28  *@brief A two dimensional matrix of Strings.
29  */
31  {
32  public:
34 
35 
36  KKStrMatrix (kkuint32 _numCols):
37  data (),
38  numCols (_numCols)
39  {
40  }
41 
42 
43  KKStrMatrix (kkuint32 _numCols,
44  kkuint32 _numRows
45  ):
46  numCols (_numCols)
47  {
48  while ((kkuint32)data.QueueSize () < _numRows)
49  AddRow ();
50  }
51 
52 
54  {
55  }
56 
57 
58  kkuint32 NumRows () const {return data.QueueSize ();}
59  kkuint32 NumCols () const {return numCols;}
60 
61 
62  KKStrList& operator[] (kkuint32 row);
63 
64  KKStrList& operator() (kkuint32 row);
65 
66  KKStr& operator() (kkuint32 row,
67  kkuint32 col
68  );
69 
70 
71  /**
72  *@brief Adds a list of Strings to the end of the Matrix.
73  *@details Will add another row to the matrix and populate its contents with the String List being passed in.
74  *@param[in] newRowData Will take ownership of this String list.
75  */
76  void AddRow (KKStrListPtr newRowData);
77 
78 
79  /**
80  *@brief Adds a row of empty string to the end of the matrix.
81  */
82  void AddRow ();
83 
84 
85  private:
86  KKQueue<KKStrList> data;
87  kkuint32 numCols;
88  }; /* KKStrMatrix */
89 
90 
91 
92  typedef KKStrMatrix::KKStrMatrixPtr KKStrMatrixPtr;
93 
94 } /* namespace KKB; */
95 
96 #endif
KKStrMatrix(kkuint32 _numCols, kkuint32 _numRows)
Definition: KKStrMatrix.h:43
A two dimensional matrix of Strings.
Definition: KKStrMatrix.h:30
kkuint32 NumCols() const
Definition: KKStrMatrix.h:59
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
kkuint32 NumRows() const
Definition: KKStrMatrix.h:58
KKTHread * KKTHreadPtr
void AddRow(KKStrListPtr newRowData)
Adds a list of Strings to the end of the Matrix.
Definition: KKStrMatrix.cpp:81
KKStrMatrix(kkuint32 _numCols)
Definition: KKStrMatrix.h:36
A typed container class/template that keeps track of entries via pointers only.
Definition: KKQueue.h:77
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of &#39;std::string&#39; strings.
Definition: KKStr.cpp:1082
KKStr & operator()(kkuint32 row, kkuint32 col)
Definition: KKStrMatrix.cpp:54
KKStrList & operator[](kkuint32 row)
Definition: KKStrMatrix.cpp:25
KKStrList & operator()(kkuint32 row)
Definition: KKStrMatrix.cpp:40
KKStrMatrix * KKStrMatrixPtr
Definition: KKStrMatrix.h:33
void AddRow()
Adds a row of empty string to the end of the matrix.
Definition: KKStrMatrix.cpp:90