FOX/ObjCryst++  1.10.X (development)
RefinableObj/IO.h
1 /* ObjCryst++ Object-Oriented Crystallographic Library
2  (c) 2000-2002 Vincent Favre-Nicolin vincefn@users.sourceforge.net
3  2000-2001 University of Geneva (Switzerland)
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #ifndef _REFOBJ_IO_H_
20 #define _REFOBJ_IO_H_
21 
22 #include <iostream>
23 #include <string>
24 #include <vector>
25 using namespace std;
26 
27 #include "ObjCryst/ObjCryst/General.h"
28 
29 namespace ObjCryst
30 {
31 class XMLCrystTag;
32 }
33 #ifdef __WX__CRYST__
34  #include "ObjCryst/wxCryst/wxCryst.h"
35 #endif
36 
37 namespace ObjCryst
38 {
47 float InputFloat(istream &is, const char endchar=' ');
48 
50 bool ISNAN_OR_INF(REAL r);
51 
52 #ifdef __WX__CRYST__
53 
57 class WXXMLCrystTag: public WXCrystObj
58 {
59  public:
60  WXXMLCrystTag(wxWindow *parent, XMLCrystTag*);
61  virtual void CrystUpdate();
62  virtual void SetObjName(const string&);
63  virtual string GetObjName()const;
64  virtual bool Show(const bool);
65  private:
66  XMLCrystTag* mpTag;
67 };
68 #endif
69 
73 {
74  public:
75  XMLCrystTag();
76  XMLCrystTag(istream &is);
77  XMLCrystTag(const string &tagName,const bool isEndTag=false, const bool isEmptyTag=false);
78  ~XMLCrystTag();
79  const string& GetName()const;
80  const string& GetClassName()const;
81  unsigned int GetNbAttribute()const;
82  void AddAttribute(const string &attName,const string &attValue);
83  void GetAttribute(const int attNum,string &attName,string &attValue);
84  const string& GetAttributeName(const int attNum)const;
85  const string& GetAttributeValue(const int attNum)const;
86  void SetIsEndTag(const bool isEndTag);
87  bool IsEndTag()const;
88  void SetIsEmptyTag(const bool isEmptyTag);
89  bool IsEmptyTag()const;
90  void Print()const;
91  private:
92  string mName;
93  bool mIsEndTag;
94  bool mIsEmptyTag;
95  vector<pair<std::string,std::string> > mvAttribute;
96  friend ostream& operator<< (ostream&, const XMLCrystTag&);
97  friend istream& operator>> (istream&, XMLCrystTag&);
98  #ifdef __WX__CRYST__
99  public:
101  WXCrystObj* WXCreate(wxWindow*);
102  WXCrystObj* WXGet();
103  void WXDelete();
104  void WXNotifyDelete();
105  protected:
106  WXXMLCrystTag *mpWXXMLCrystTag;
107  #endif
108 };
109 
111 ostream& operator<< (ostream&, const XMLCrystTag&);
113 istream& operator>> (istream&, XMLCrystTag&);
114 
115 #if 0
116 //OLD
117 
118 void IOCrystExtractNameSpace(istream &is,string &str);
119 void IOCrystExtractNameLine(istream &is,string &str);
120 void IOCrystExtractNameQuoted(istream &is,string &str);
121 void IOCrystXMLOutputNameQuoted(ostream &os,const string &str);
122 
123 #ifdef __WX__CRYST__
124 class IOCrystTag;
125 
126 class WXIOCrystTag: public WXCrystObj
127 {
128  public:
129  WXIOCrystTag(wxWindow *parent, IOCrystTag*);
130  virtual void CrystUpdate();
131  virtual void SetObjName(const string&);
132  virtual string GetObjName()const;
133  virtual bool Show(const bool);
134  private:
135  IOCrystTag* mpTag;
136 };
137 #endif
138 class IOCrystTag
143 {
144  public:
145  IOCrystTag(const string& type,const string& name, const unsigned long version=0);
146  IOCrystTag(istream &is);
147  virtual ~IOCrystTag();
148  void XMLInput(istream &is);
149  bool operator==(const IOCrystTag&)const;
150  const string &GetType()const;
151  const string &GetName()const;
152  unsigned long GetVersion()const;
153  bool IsClosingTag()const;
154  void Print()const;
156  const string &GetClassName()const;
157  private:
158  string mTagType;
159  string mTagName;
160  unsigned long mTagVersion;
161  bool mIsClosingTag;
162  #ifdef __WX__CRYST__
163  public:
165  virtual WXCrystObj* WXCreate(wxWindow*);
166  WXCrystObj* WXGet();
167  void WXDelete();
168  void WXNotifyDelete();
169  protected:
170  WXIOCrystTag *mpWXIOCrystTag;
171  #endif
172 };
173 #endif
174 
175 }//namespace ObjCryst
176 
177 #endif //_REFOBJ_IO_H_
bool ISNAN_OR_INF(REAL r)
Test if the value is a NaN.
Definition: ObjCryst/IO.cpp:97
float InputFloat(istream &is, const char endchar)
Safely read a floating-point value from a stream.
Definition: ObjCryst/IO.cpp:68
Base class for all displayed ObjCryst objects (with a title, and a sizer to stack objects)...
Definition: wxCryst.h:248
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: Atom.cpp:47
class to input or output a well-formatted xml beginning or ending tag.