simplestringlist.cpp
Go to the documentation of this file.
1 //======================================================================
28 //======================================================================
29 
30 //----------------------------------------------------------------------
31 // System Includes - include with <>
32 //----------------------------------------------------------------------
33 
34 #include <assert.h>
35 
36 //----------------------------------------------------------------------
37 // Project Includes - include with ""
38 //----------------------------------------------------------------------
39 
40 #include "dbg.h"
41 #include "simplestringlist.h"
42 
44 
45 //----------------------------------------------------------------------
46 // Defines, enums, unions, structs,
47 //----------------------------------------------------------------------
48 
49 
50 //----------------------------------------------------------------------
51 // Global variables
52 //----------------------------------------------------------------------
53 
54 
55 //----------------------------------------------------------------------
56 // Function definitions
57 //----------------------------------------------------------------------
58 
59 
60 //----------------------------------------------------------------------
61 // Class definitions
62 //----------------------------------------------------------------------
63 
64 
66 {
67  Reset();
68 }
69 //-----------------------------------------------------------------
70 
71 
73 {
74  return line[ current_line ];
75 }
76 //-----------------------------------------------------------------
77 
78 
80 {
81  current_line++;
82  assert( current_line < eMAX_LINES );
83  return line[ current_line ];
84 }
85 //-----------------------------------------------------------------
86 
87 
89 {
90  return current_line+1;
91 }
92 //-----------------------------------------------------------------
93 
94 
96 {
97  int i;
98  if (index < 0)
99  i = Length() + index;
100  else
101  i = index;
102 
103  assert( 0 <= i && i <= current_line );
104  return line[ i ];
105 }
106 //-----------------------------------------------------------------
107 
108 
109 char const* cSimpleStringList::operator[]( int index ) const
110 {
111  int i;
112  if (index < 0)
113  i = Length() + index;
114  else
115  i = index;
116 
117  assert( 0 <= i && i <= current_line );
118  return line[ i ];
119 }
120 //-----------------------------------------------------------------
121 
122 
124 {
125  current_line = -1;
126 }
127 //-----------------------------------------------------------------
128 
129 
131 
132 std::ostream &operator<<( std::ostream &stream, cSimpleStringList const& ssl )
133 {
134  for ( int i = 0; i < ssl.Length(); i++ )
135  stream << "line[" << i << "]='" << ssl[i] << "'\n";
136 
137  return stream;
138 }
139 
141 
142 //-----------------------------------------------------------------
143 
144 
145 
146 //======================================================================
147 /*
148  Here are some settings for the emacs/xemacs editor (and can be safely ignored):
149  (e.g. to explicitely set C++ mode for *.h header files)
150 
151  Local Variables:
152  mode:C++
153  mode:ELSE
154  End:
155 */
156 //======================================================================
void Reset()
reset list
char * CurrentLine()
Return the current line.
char line[eMAX_LINES][eMAX_CHARS]
a fixed length array of lines with fixed length
cSimpleStringList()
Default constructor: init members.
Interface of class #SDH::cSimpleStringList.
This file contains interface and implementation of class #SDH::cDBG, a class for colorfull debug mess...
#define NAMESPACE_SDH_START
int current_line
the index of the current line. For empty cSimpleStringLists this is -1.
NAMESPACE_SDH_START std::ostream & operator<<(std::ostream &stream, cSimpleStringList const &ssl)
Output of cSimpleStringList objects in &#39;normal&#39; output streams.
char * NextLine()
Return the next line, this increases current_line.
#define USING_NAMESPACE_SDH
char * operator[](int index)
return ptr to line with index.
A simple string list. (Fixed maximum number of strings of fixed maximum length)
#define NAMESPACE_SDH_END
int Length() const
Return number of lines stored.


sdhlibrary_cpp
Author(s): Dirk Osswald
autogenerated on Mon Feb 28 2022 23:41:51