C++ main module for gpm Package  1.0
CORE_File.h
Go to the documentation of this file.
1 #ifndef CORE_File_H
2 #define CORE_File_H
3 
4 
5 #include "CORE_Object.h"
6 #include "CORE_Object.h"
7 
8 
9 
10 
11 
19 
20 class CORE_File : public CORE_Object { // class
21  SP_OBJECT(CORE_File);
22 
23  // ATTRIBUTES
24 
25 public:
26  static const tFlag READ;
27  static const tFlag WRITE;
28  static const tFlag APPEND;
29  static const tFlag UNDEFINED;
30 
31  static const tString PATH_SEPARATOR;
32 
33 private:
34 
35  ifstream *mFin;
36  ofstream *mFout;
37  tFlag mType;
38 
39  int mBegin;
40  int mEnd;
41 
42  tString mExtension;
43 
44  // ASSOCIATIONS
45 
46 
47  // METHODS
48 
49 
50 protected:
51  // CONSTRUCTORS
54  CORE_File();
55 
56 
57 
58 
59  // DESTRUCTORS
63  virtual ~CORE_File(void);
64 
65 
66 public:
67  // NEW
70  inline static SP::CORE_File New(){
71  SP::CORE_File p(new CORE_File(),CORE_File::Delete());
72  return p;
73  };
74 
75 
76 
77  // SET
78 
81  static tString getExtension(const tString& fileName);
84  static void setExtension(const tString& ext,tString& fileName);
85 
88  inline tString getExtension() const {
89  return mExtension;
90  }
91 
92 
95  tBoolean open(const tString& fileName,const tFlag& type);
96 
99  void close();
100 
103  inline void move(const int& index) {
104  mBegin+=index;
105  mBegin=(mBegin<mEnd)?mBegin:mEnd;
106  }
107 
110  inline void begin() {
111  mBegin=0;
112  }
113 
116  tString read(const int& from,const int& to);
119  inline tString read(const int& to){
120  return read(0,to-1);
121  }
122 
127  tBoolean search(const tString& word,const int& from,const int& to,int& cur);
132  inline tBoolean search(const tString& word,const int& from,int& cur) {
133  return search(word,from,-1,cur);
134  }
139  inline tBoolean search(const tString& word,int& cur) {
140  return search(word,0,-1,cur);
141  }
142 
145  template<class T>
146  ostream& operator << (const T& obj) {
147  ASSERT_IN(mFout!=null);
148  return *mFout<<obj;
149  };
152  template<class T>
153  istream& operator >> (const T& obj) {
154  ASSERT_IN(mFin!=null);
155  return *mFin<<obj;
156  };
157 
158 
159 };
160 
161 #endif
void close()
close the file
Definition: CORE_File.cpp:69
tString read(const int &from, const int &to)
read the file betwen included position [from,to]
Definition: CORE_File.cpp:83
ostream & operator<<(const T &obj)
writing operator
Definition: CORE_File.h:146
static const tString PATH_SEPARATOR
Definition: CORE_File.h:31
static void setExtension(const tString &ext, tString &fileName)
set the extension of the file
Definition: CORE_File.cpp:175
istream & operator>>(const T &obj)
reading operator
Definition: CORE_File.h:153
this class describes the output by default write on standart output
Definition: CORE_File.h:20
void move(const int &index)
translate of index position
Definition: CORE_File.h:103
DEFINE_SPTR(CORE_File)
#define tBoolean
Definition: types.h:35
CORE_File()
build a CORE_File
Definition: CORE_File.cpp:16
tBoolean open(const tString &fileName, const tFlag &type)
open file
Definition: CORE_File.cpp:29
tBoolean search(const tString &word, const int &from, int &cur)
search the worf in file between position from and end
Definition: CORE_File.h:132
static SP::CORE_File New()
create a CORE_out class
Definition: CORE_File.h:70
tBoolean search(const tString &word, const int &from, const int &to, int &cur)
search the worf in file between position from and end
Definition: CORE_File.cpp:114
#define null
Definition: types.h:13
tBoolean search(const tString &word, int &cur)
search the worf in file between position from and end
Definition: CORE_File.h:139
virtual ~CORE_File(void)
destroy a CORE_File
Definition: CORE_File.cpp:23
static const tFlag WRITE
Definition: CORE_File.h:27
abstract base class for most classes.
Definition: CORE_Object.h:30
#define tString
Definition: types.h:36
static const tFlag UNDEFINED
Definition: CORE_File.h:29
tString read(const int &to)
read the to first characters of file
Definition: CORE_File.h:119
tString getExtension() const
get the extension
Definition: CORE_File.h:88
static const tFlag READ
Definition: CORE_File.h:26
static const tFlag APPEND
Definition: CORE_File.h:28
void begin()
put the current positon to 0
Definition: CORE_File.h:110
#define ASSERT_IN(a)
Definition: types.h:82
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14