MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
Ofstream.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGOfstream_HH_
6 #define _MGOfstream_HH_
7 #include "mg/MGCL.h"
8 
9 #include <stdio.h>
10 #include <fstream>
11 #include <map>
12 #include "mg/Pvector.h"
13 #include "mg/Plist.h"
14 
15 //forward declerations
16 class MGObject;
17 class MGGel;
18 class MGGroup;
19 
24 
31 class MG_DLL_DECLR MGOfstream{
32 
33 typedef std::map<const MGGel*, long> MGOutPtrMap;
34 typedef std::map<const MGGel*, long>::iterator mapitr;
35 
36 public:
37 
40  std::ofstream* m_file;
42 
44 
46 MGOfstream();
47 
49 MGOfstream(const TCHAR* file, bool map_clear=true);
50 
52 virtual ~MGOfstream();
53 
55 
60 MGOfstream& operator<< (const MGGel& gel);
61 void operator<<(const MGGroup& group);
62 
63 //The following two functions are provided to hold the compatibility with
64 //version 5. Users are recommended to use "void operator<<(const MGGroup&)"
65 //instead of these functions.
66 //void operator<<(MGPvector<MGObject>& vecgel);
67 //void operator<<(MGPlist<MGObject>& listgel);
68 
70 MGOfstream& operator<<(char ch){write1Byte(&ch);return *this;};
71 MGOfstream& operator<<(unsigned char uch){write1Byte(&uch);return *this;};
72 MGOfstream& operator<<(signed char sch){write1Byte(&sch);return *this;};
73 MGOfstream& operator<<(short s){write2Byte(&s);return *this;};
74 MGOfstream& operator<<(unsigned short us){write2Byte(&us);return *this;};
75 MGOfstream& operator<<(int n){write4Byte(&n);return *this;};
76 MGOfstream& operator<<(unsigned int un){write4Byte(&un);return *this;};
77 MGOfstream& operator<<(long l){write4Byte(&l);return *this;};
78 MGOfstream& operator<<(unsigned long ul){write4Byte(&ul);return *this;};
79 MGOfstream& operator<<(float f){write4Byte(&f);return *this;};
80 MGOfstream& operator<<(double d){write8Byte(&d);return *this;};
81 
83 
87 void close();
88 
93 long find(const MGGel* ptr);
94 
96 void mapClear();
97 
101 bool insert(const MGGel* ptr, long pid);
102 
108 int open(const TCHAR* file, bool map_clear=true);
109 
111 void set_map_clear(bool map_clear){m_map_clear=map_clear;};
112 
114 int tellp();
115 
117 MGOfstream& writenChar(const char* ps, int n);
118 
123 long WritePointer(const MGGel* obj);
124 
125 private:
127 
131 void write(const void* ps, int n);
132 
134 MGOfstream& write1Byte(const void* ps2);
135 
137 MGOfstream& write2Byte(const void* ps2);
138 
140 MGOfstream& write4Byte(const void* ps4);
141 
143 MGOfstream& write8Byte(const void* ps8);
144 
145 
147 
148 MGOutPtrMap* m_map;
149 
150 int m_position;
151 
152 bool m_map_clear;
153 
155 };
156  // end of FileInputOutput group
158 
159 #endif
MGOfstream & operator<<(unsigned int un)
Definition: Ofstream.h:76
MGOfstream & operator<<(unsigned short us)
Definition: Ofstream.h:74
std::ostream & operator<<(std::ostream &ostrm, const MGisect &is)
Debug Function.
Definition: isect.h:95
Is an abstract class which represents a whole geometry and a topology.
Definition: Object.h:42
MGOfstream & operator<<(unsigned char uch)
Definition: Ofstream.h:71
MGOfstream & operator<<(short s)
Definition: Ofstream.h:73
MGOfstream & operator<<(float f)
Definition: Ofstream.h:79
MGGel is an abstract class which represents a group element.
Definition: Gel.h:53
MGOfstream & operator<<(double d)
Definition: Ofstream.h:80
MGOfstream is a class to serialize all of the subclasses of MGGel.
Definition: Ofstream.h:31
MGOfstream & operator<<(unsigned long ul)
Definition: Ofstream.h:78
MGOfstream & operator<<(long l)
Definition: Ofstream.h:77
MGOfstream & operator<<(int n)
Definition: Ofstream.h:75
MGOfstream & operator<<(signed char sch)
Definition: Ofstream.h:72
MGGroup is a class which constains MGGel elements.
Definition: Group.h:35
void set_map_clear(bool map_clear)
Set map_clear flag.
Definition: Ofstream.h:111
std::ofstream * m_file
Definition: Ofstream.h:40
MGOfstream & operator<<(char ch)
基本型のファイル出力関数
Definition: Ofstream.h:70