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 //======================================================================
cSimpleStringList::eMAX_LINES
@ eMAX_LINES
Definition: simplestringlist.h:80
cSimpleStringList::current_line
int current_line
the index of the current line. For empty cSimpleStringLists this is -1.
Definition: simplestringlist.h:75
cSimpleStringList::Reset
void Reset()
reset list
Definition: simplestringlist.cpp:123
USING_NAMESPACE_SDH
#define USING_NAMESPACE_SDH
Definition: sdhlibrary_settings.h:81
cSimpleStringList
A simple string list. (Fixed maximum number of strings of fixed maximum length)
Definition: simplestringlist.h:70
NAMESPACE_SDH_END
#define NAMESPACE_SDH_END
Definition: sdhlibrary_settings.h:80
cSimpleStringList::operator[]
char * operator[](int index)
return ptr to line with index.
Definition: simplestringlist.cpp:95
cSimpleStringList::line
char line[eMAX_LINES][eMAX_CHARS]
a fixed length array of lines with fixed length
Definition: simplestringlist.h:120
cSimpleStringList::cSimpleStringList
cSimpleStringList()
Default constructor: init members.
Definition: simplestringlist.cpp:65
cSimpleStringList::CurrentLine
char * CurrentLine()
Return the current line.
Definition: simplestringlist.cpp:72
dbg.h
This file contains interface and implementation of class #SDH::cDBG, a class for colorfull debug mess...
cSimpleStringList::NextLine
char * NextLine()
Return the next line, this increases current_line.
Definition: simplestringlist.cpp:79
operator<<
NAMESPACE_SDH_START std::ostream & operator<<(std::ostream &stream, cSimpleStringList const &ssl)
Output of cSimpleStringList objects in 'normal' output streams.
Definition: simplestringlist.cpp:132
cSimpleStringList::Length
int Length() const
Return number of lines stored.
Definition: simplestringlist.cpp:88
simplestringlist.h
Interface of class #SDH::cSimpleStringList.
NAMESPACE_SDH_START
#define NAMESPACE_SDH_START
Definition: sdhlibrary_settings.h:79


sdhlibrary_cpp
Author(s): Dirk Osswald
autogenerated on Wed Mar 2 2022 01:00:58