mydxffile.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2010-2011 Taneli Kalvas. All rights reserved.
6  *
7  * You can redistribute this software and/or modify it under the terms
8  * of the GNU General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this library (file "COPYING" included in the package);
19  * if not, write to the Free Software Foundation, Inc., 51 Franklin
20  * Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  * If you have questions about your rights to use or distribute this
23  * software, please contact Berkeley Lab's Technology Transfer
24  * Department at TTD@lbl.gov. Other questions, comments and bug
25  * reports should be sent directly to the author via email at
26  * taneli.kalvas@jyu.fi.
27  *
28  * NOTICE. This software was developed under partial funding from the
29  * U.S. Department of Energy. As such, the U.S. Government has been
30  * granted for itself and others acting on its behalf a paid-up,
31  * nonexclusive, irrevocable, worldwide license in the Software to
32  * reproduce, prepare derivative works, and perform publicly and
33  * display publicly. Beginning five (5) years after the date
34  * permission to assert copyright is obtained from the U.S. Department
35  * of Energy, and subject to any subsequent five (5) year renewals,
36  * the U.S. Government is granted for itself and others acting on its
37  * behalf a paid-up, nonexclusive, irrevocable, worldwide license in
38  * the Software to reproduce, prepare derivative works, distribute
39  * copies to the public, perform publicly and display publicly, and to
40  * permit others to do so.
41  */
42 
43 #ifndef MY_DXF_FILE_HPP
44 #define MY_DXF_FILE_HPP 1
45 
46 
47 
48 //#define MYDXF_DEBUG 1
49 
50 
51 
52 #include <fstream>
53 #include "mydxfheader.hpp"
54 #include "mydxftables.hpp"
55 #include "mydxfblocks.hpp"
56 #include "mydxfentities.hpp"
57 
58 
59 
60 
68 class MyDXFFile
69 {
70  std::ifstream _istr;
71  std::ofstream _ostr;
72  bool _ascii;
73  int _linec;
74 
75  int _wlevel;
76 
77  int _group_code;
78  int _group_type;
79 
80  std::string _group_string;
81  double _group_double;
82  bool _group_bool;
83  int8_t _group_int8;
84  int16_t _group_int16;
85  int32_t _group_int32;
86  int64_t _group_int64;
87 
88  class MyDXFHeader *_header;
89  class MyDXFTables *_tables;
90  class MyDXFBlocks *_blocks;
91  class MyDXFEntities *_entities;
92 
93 
94 public:
95 
98  MyDXFFile();
99 
102  MyDXFFile( const std::string &filename );
103 
106  ~MyDXFFile();
107 
110  void read( const std::string &filename );
111 
114  void write( const std::string &filename );
115 
124  void set_warning_level( int wlevel ) { _wlevel = wlevel; }
125 
128  int wlevel( void ) { return( _wlevel ); }
129 
130 
131 
134  void write_group( int code, const char *data );
135 
138  void write_group( int code, double data );
139 
142  void write_group( int code, bool data );
143 
146  void write_group( int code, int8_t data );
147 
150  void write_group( int code, int16_t data );
151 
154  void write_group( int code, int32_t data );
155 
158  void write_group( int code, int64_t data );
159 
160 
161 
167  int read_group( void );
168 
171  int group_get_code( void ) const;
172 
177  std::string group_get_string( void ) const;
178 
183  double group_get_double( void ) const;
184 
189  bool group_get_bool( void ) const;
190 
195  int8_t group_get_int8( void ) const;
196 
201  int16_t group_get_int16( void ) const;
202 
207  int32_t group_get_int32( void ) const;
208 
213  int64_t group_get_int64( void ) const;
214 
217  int linec( void ) const { return( _linec ); }
218 
219 
220 
221 
222 
225  class MyDXFEntities *get_entities( void ) { return( _entities ); };
226 
229  const class MyDXFEntities *get_entities( void ) const { return( _entities ); };
230 
231 
232 
235  class MyDXFBlocks *get_blocks( void ) { return( _blocks ); };
236 
239  const class MyDXFBlocks *get_blocks( void ) const { return( _blocks ); };
240 
241 
244  class MyDXFTables *get_tables( void ) { return( _tables ); };
245 
248  const class MyDXFTables *get_tables( void ) const { return( _tables ); };
249 
250 
251 
252 
255  void debug_print( std::ostream &os ) const;
256 };
257 
258 
259 #endif
260 
261 
262 
263 
int64_t group_get_int64(void) const
Get the value of the last group read assuming it is a int64.
DXF header class.
Definition: mydxfheader.hpp:58
DXF tables class.
Definition: mydxftables.hpp:216
int16_t group_get_int16(void) const
Get the value of the last group read assuming it is a int16.
DXF Blocks.
int read_group(void)
Read next group from open file and return group code.
double group_get_double(void) const
Get the value of the last group read assuming it is a double.
const class MyDXFBlocks * get_blocks(void) const
Get a const pointer to the blocks of DXF file.
Definition: mydxffile.hpp:239
int linec(void) const
Get the current line number in DXF file during read.
Definition: mydxffile.hpp:217
DXF Entities.
bool group_get_bool(void) const
Get the value of the last group read assuming it is a bool.
int wlevel(void)
Get the level of warning messages.
Definition: mydxffile.hpp:128
void read(const std::string &filename)
Read DXF file.
int8_t group_get_int8(void) const
Get the value of the last group read assuming it is a int8.
DXF file class.
Definition: mydxffile.hpp:68
DXF Header.
DXF blocks class.
Definition: mydxfblocks.hpp:136
void set_warning_level(int wlevel)
Set the level of warning messages.
Definition: mydxffile.hpp:124
class MyDXFBlocks * get_blocks(void)
Get a pointer to the blocks of DXF file.
Definition: mydxffile.hpp:235
class MyDXFEntities * get_entities(void)
Get a pointer to the entities of DXF file.
Definition: mydxffile.hpp:225
~MyDXFFile()
Destructor.
void write_group(int code, const char *data)
Write string group to output file.
MyDXFFile()
Construct empty DXF file.
int32_t group_get_int32(void) const
Get the value of the last group read assuming it is a int32.
class MyDXFTables * get_tables(void)
Get a pointer to the tables of DXF file.
Definition: mydxffile.hpp:244
DXF entity database.
Definition: mydxfentities.hpp:279
void debug_print(std::ostream &os) const
Print debugging information to os.
DXF Tables.
std::string group_get_string(void) const
Get the value of the last group read assuming it is a string.
const class MyDXFTables * get_tables(void) const
Get a const pointer to the tables of DXF file.
Definition: mydxffile.hpp:248
const class MyDXFEntities * get_entities(void) const
Get a const pointer to the entities of DXF file.
Definition: mydxffile.hpp:229
void write(const std::string &filename)
Write DXF file.
int group_get_code(void) const
Get code of the last group read.