MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
Ifstream.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGIfstream_HH_
6 #define _MGIfstream_HH_
7 
8 #include <stdio.h>
9 #include <fstream>
10 #include <map>
11 #include "mg/Object.h"
12 #include "mg/Pvector.h"
13 #include "mg/Plist.h"
14 
15 //forward declerations
16 class MGGel;
17 class MGGroup;
18 class MGInPtrMap;
19 
24 
30 class MG_DLL_DECLR MGIfstream{
31 
32 typedef std::map<long, MGGel*>::iterator mapitr;
33 typedef std::map<long, MGGel*>pmap;
34 
35 public:
36 
39  std::ifstream* m_file;
41 
43 MGIfstream();
44 
46 MGIfstream(const TCHAR* file, bool map_clear=true);
47 
49 virtual ~MGIfstream();
50 
52 
58 void operator>>(MGGroup& group);
59 
63 MGIfstream& operator>>(MGGel*& gel);
64 
66 MGIfstream& operator >>( char& ch){read1Byte(&ch);return *this;};
67 MGIfstream& operator >>( unsigned char& uch){read1Byte(&uch);return *this;};
68 MGIfstream& operator >>( short& s){read2Byte(&s);return *this;};
69 MGIfstream& operator >>( unsigned short& us){read2Byte(&us);return *this;};
70 MGIfstream& operator >>( int& n){read4Byte(&n);return *this;};
71 MGIfstream& operator >>( unsigned int& un){read4Byte(&un);return *this;};
72 MGIfstream& operator >>( long& l){read4Byte(&l);return *this;};
73 MGIfstream& operator >>( unsigned long& ul){read4Byte(&ul);return *this;};
74 MGIfstream& operator >>( float& f){read4Byte(&f);return *this;};
75 MGIfstream& operator >>( double& d){read8Byte(&d);return *this;};
76 
78 
82 void close();
83 
85 void mapClear();
86 
90 MGGel* find(long pid);
91 
96 bool insert(long pid, MGGel* ptr);
97 
105 int open(const TCHAR* file, bool map_clear=true);
106 
110 MGGel* ReadPointer();
111 
113 MGIfstream& readnChar(char* ps4, int n);
114 
116 void set_map_clear(bool map_clear){m_map_clear=map_clear;};
117 
120 long tellg();
121 
123 const char* version()const{return m_version;};
124 char* version(){return m_version;};
125 
126 private:
127 
132 bool MGCLHeader(std::ifstream&);
133 
137 void read(void* ps, int n);
138 
140 MGIfstream& read1Byte(void* ps2);
141 
143 MGIfstream& read2Byte(void* ps2);
144 
146 MGIfstream& read4Byte(void* ps4);
147 
149 MGIfstream& read8Byte(void* ps4);
150 
151 private:
152 
154 MGInPtrMap* m_map;
155 
157 int m_position;
158 
161 bool m_map_clear;
162 
164 char m_version[8];
165 
166 };
167 
169 //Private Helper Class.
170 class MGInPtrMap{
171 public:
172  std::map<long, MGGel*> pmap;
173 };
175  // end of FileInputOutput group
177 
178 #endif //#ifndef _MGIfstream_HH_
std::ifstream * m_file
Definition: Ifstream.h:39
char * version()
Definition: Ifstream.h:124
MGIfstream is a class to read the serialized data generated by MGOfstream.
Definition: Ifstream.h:30
MGGel is an abstract class which represents a group element.
Definition: Gel.h:53
const char * version() const
Obtain the version number of the stream.
Definition: Ifstream.h:123
MGGroup is a class which constains MGGel elements.
Definition: Group.h:35
void set_map_clear(bool map_clear)
Set map_clear flag.
Definition: Ifstream.h:116