CCCC - C and C++ Code Counter  9999-git
CCCC Development version (post-3.1.4)
Public Member Functions | Private Attributes | List of all members
CCCC_Item Class Reference

#include <cccc_itm.h>

Collaboration diagram for CCCC_Item:
[legend]

Public Member Functions

 CCCC_Item (const string &s, char c)
 
 CCCC_Item (const string &s)
 
 CCCC_Item ()
 
bool Insert (const string &s)
 
bool Insert (const char *cptr)
 
bool Extract (string &s)
 
bool Insert (int n)
 
bool Extract (int &n)
 
bool Insert (char c)
 
bool Extract (char &c)
 
bool Insert (float f)
 
bool Extract (float &f)
 
bool ToFile (ofstream &ofstr)
 
bool FromFile (ifstream &ifstr)
 

Private Attributes

char delimiter
 
string buffer
 
bool good
 

Detailed Description

Definition at line 15 of file cccc_itm.h.

Constructor & Destructor Documentation

CCCC_Item::CCCC_Item ( const string &  s,
char  c 
)

Definition at line 10 of file cccc_itm.cc.

11 {
12  buffer=s;
13  delimiter=c;
14  good=true;
15 }
string buffer
Definition: cccc_itm.h:19
bool good
Definition: cccc_itm.h:20
char delimiter
Definition: cccc_itm.h:18
CCCC_Item::CCCC_Item ( const string &  s)

Definition at line 17 of file cccc_itm.cc.

18 {
19  buffer=s;
20  delimiter='@';
21  good=true;
22 }
string buffer
Definition: cccc_itm.h:19
bool good
Definition: cccc_itm.h:20
char delimiter
Definition: cccc_itm.h:18
CCCC_Item::CCCC_Item ( )

Definition at line 24 of file cccc_itm.cc.

25 {
26  buffer="";
27  delimiter='@';
28  good=true;
29 }
string buffer
Definition: cccc_itm.h:19
bool good
Definition: cccc_itm.h:20
char delimiter
Definition: cccc_itm.h:18

Member Function Documentation

bool CCCC_Item::Extract ( string &  s)

Definition at line 47 of file cccc_itm.cc.

48 {
49  size_t delimiter_position=buffer.find(delimiter);
50  if(delimiter_position!=string::npos)
51  {
52  good=true;
53  s=buffer.substr(0,delimiter_position);
54  string tempBuffer=buffer.substr(delimiter_position+1);
55  buffer=tempBuffer;
56  }
57  else
58  {
59  good=false;
60  }
61  return good;
62 }
string buffer
Definition: cccc_itm.h:19
bool good
Definition: cccc_itm.h:20
char delimiter
Definition: cccc_itm.h:18

Here is the caller graph for this function:

bool CCCC_Item::Extract ( int &  n)

Definition at line 71 of file cccc_itm.cc.

72 {
73  string numstr;
74  bool retval=Extract(numstr);
75  n=atoi(numstr.c_str());
76  return retval;
77 }
bool Extract(string &s)
Definition: cccc_itm.cc:47

Here is the call graph for this function:

bool CCCC_Item::Extract ( char &  c)

Definition at line 86 of file cccc_itm.cc.

87 {
88  string charstr;
89  bool retval=Extract(charstr);
90  if(charstr.size()==1)
91  {
92  c=charstr[0];
93  }
94  return retval;
95 }
bool Extract(string &s)
Definition: cccc_itm.cc:47

Here is the call graph for this function:

bool CCCC_Item::Extract ( float &  f)

Definition at line 104 of file cccc_itm.cc.

105 {
106  string numstr;
107  bool retval=Extract(numstr);
108  f=atof(numstr.c_str());
109  return retval;
110 }
bool Extract(string &s)
Definition: cccc_itm.cc:47

Here is the call graph for this function:

bool CCCC_Item::FromFile ( ifstream &  ifstr)

Definition at line 119 of file cccc_itm.cc.

120 {
121  good=false;
122  char line_buffer[1024];
123  ifstr.getline(line_buffer,1023);
124  buffer=line_buffer;
125  if(ifstr.good() && buffer.size()>0 && buffer.size()<1023)
126  {
127  delimiter=buffer[buffer.size()-1];
128  good=true;
129 #if 0
130  cerr << "Delimiter is " << delimiter << endl;
131 #endif
132  }
133  return good;
134 }
string buffer
Definition: cccc_itm.h:19
bool good
Definition: cccc_itm.h:20
char delimiter
Definition: cccc_itm.h:18

Here is the caller graph for this function:

bool CCCC_Item::Insert ( const string &  s)

Definition at line 31 of file cccc_itm.cc.

32 {
33  buffer+=s;
35 #if 0
36  cerr << buffer << endl;
37 #endif
38  return good;
39 }
string buffer
Definition: cccc_itm.h:19
bool good
Definition: cccc_itm.h:20
char delimiter
Definition: cccc_itm.h:18

Here is the caller graph for this function:

bool CCCC_Item::Insert ( const char *  cptr)

Definition at line 41 of file cccc_itm.cc.

42 {
43  string s(cptr);
44  return Insert(s);
45 }
bool Insert(const string &s)
Definition: cccc_itm.cc:31

Here is the call graph for this function:

bool CCCC_Item::Insert ( int  n)

Definition at line 64 of file cccc_itm.cc.

65 {
66  char numbuf[64];
67  sprintf(numbuf,"%d",n);
68  return Insert(numbuf);
69 }
bool Insert(const string &s)
Definition: cccc_itm.cc:31

Here is the call graph for this function:

bool CCCC_Item::Insert ( char  c)

Definition at line 79 of file cccc_itm.cc.

80 {
81  char charbuf[2];
82  sprintf(charbuf,"%c",c);
83  return Insert(charbuf);
84 }
bool Insert(const string &s)
Definition: cccc_itm.cc:31

Here is the call graph for this function:

bool CCCC_Item::Insert ( float  f)

Definition at line 97 of file cccc_itm.cc.

98 {
99  char numbuf[64];
100  sprintf(numbuf,"%f",f);
101  return Insert(numbuf);
102 }
bool Insert(const string &s)
Definition: cccc_itm.cc:31

Here is the call graph for this function:

bool CCCC_Item::ToFile ( ofstream &  ofstr)

Definition at line 112 of file cccc_itm.cc.

113 {
114  ofstr << buffer << endl;
115  good=ofstr.good();
116  return good;
117 }
string buffer
Definition: cccc_itm.h:19
bool good
Definition: cccc_itm.h:20

Here is the caller graph for this function:

Member Data Documentation

string CCCC_Item::buffer
private

Definition at line 19 of file cccc_itm.h.

char CCCC_Item::delimiter
private

Definition at line 18 of file cccc_itm.h.

bool CCCC_Item::good
private

Definition at line 20 of file cccc_itm.h.


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