mydxffile.hpp
Go to the documentation of this file.
00001 00005 /* Copyright (c) 2010-2011 Taneli Kalvas. All rights reserved. 00006 * 00007 * You can redistribute this software and/or modify it under the terms 00008 * of the GNU General Public License as published by the Free Software 00009 * Foundation; either version 2 of the License, or (at your option) 00010 * any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this library (file "COPYING" included in the package); 00019 * if not, write to the Free Software Foundation, Inc., 51 Franklin 00020 * Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 * 00022 * If you have questions about your rights to use or distribute this 00023 * software, please contact Berkeley Lab's Technology Transfer 00024 * Department at TTD@lbl.gov. Other questions, comments and bug 00025 * reports should be sent directly to the author via email at 00026 * taneli.kalvas@jyu.fi. 00027 * 00028 * NOTICE. This software was developed under partial funding from the 00029 * U.S. Department of Energy. As such, the U.S. Government has been 00030 * granted for itself and others acting on its behalf a paid-up, 00031 * nonexclusive, irrevocable, worldwide license in the Software to 00032 * reproduce, prepare derivative works, and perform publicly and 00033 * display publicly. Beginning five (5) years after the date 00034 * permission to assert copyright is obtained from the U.S. Department 00035 * of Energy, and subject to any subsequent five (5) year renewals, 00036 * the U.S. Government is granted for itself and others acting on its 00037 * behalf a paid-up, nonexclusive, irrevocable, worldwide license in 00038 * the Software to reproduce, prepare derivative works, distribute 00039 * copies to the public, perform publicly and display publicly, and to 00040 * permit others to do so. 00041 */ 00042 00043 #ifndef MY_DXF_FILE_HPP 00044 #define MY_DXF_FILE_HPP 1 00045 00046 00047 00048 //#define MYDXF_DEBUG 1 00049 00050 00051 00052 #include <fstream> 00053 #include "mydxfheader.hpp" 00054 #include "mydxftables.hpp" 00055 #include "mydxfblocks.hpp" 00056 #include "mydxfentities.hpp" 00057 00058 00059 00060 00068 class MyDXFFile 00069 { 00070 std::ifstream _istr; 00071 std::ofstream _ostr; 00072 bool _ascii; 00073 int _linec; 00074 00075 int _wlevel; 00076 00077 int _group_code; 00078 int _group_type; 00079 00080 std::string _group_string; 00081 double _group_double; 00082 bool _group_bool; 00083 int8_t _group_int8; 00084 int16_t _group_int16; 00085 int32_t _group_int32; 00086 int64_t _group_int64; 00087 00088 class MyDXFHeader *_header; 00089 class MyDXFTables *_tables; 00090 class MyDXFBlocks *_blocks; 00091 class MyDXFEntities *_entities; 00092 00093 00094 public: 00095 00098 MyDXFFile(); 00099 00102 MyDXFFile( const std::string &filename ); 00103 00106 ~MyDXFFile(); 00107 00110 void read( const std::string &filename ); 00111 00114 void write( const std::string &filename ); 00115 00124 void set_warning_level( int wlevel ) { _wlevel = wlevel; } 00125 00128 int wlevel( void ) { return( _wlevel ); } 00129 00130 00131 00134 void write_group( int code, const char *data ); 00135 00138 void write_group( int code, double data ); 00139 00142 void write_group( int code, bool data ); 00143 00146 void write_group( int code, int8_t data ); 00147 00150 void write_group( int code, int16_t data ); 00151 00154 void write_group( int code, int32_t data ); 00155 00158 void write_group( int code, int64_t data ); 00159 00160 00161 00167 int read_group( void ); 00168 00171 int group_get_code( void ) const; 00172 00177 std::string group_get_string( void ) const; 00178 00183 double group_get_double( void ) const; 00184 00189 bool group_get_bool( void ) const; 00190 00195 int8_t group_get_int8( void ) const; 00196 00201 int16_t group_get_int16( void ) const; 00202 00207 int32_t group_get_int32( void ) const; 00208 00213 int64_t group_get_int64( void ) const; 00214 00217 int linec( void ) const { return( _linec ); } 00218 00219 00220 00221 00222 00225 class MyDXFEntities *get_entities( void ) { return( _entities ); }; 00226 00229 const class MyDXFEntities *get_entities( void ) const { return( _entities ); }; 00230 00231 00232 00235 class MyDXFBlocks *get_blocks( void ) { return( _blocks ); }; 00236 00239 const class MyDXFBlocks *get_blocks( void ) const { return( _blocks ); }; 00240 00241 00244 class MyDXFTables *get_tables( void ) { return( _tables ); }; 00245 00248 const class MyDXFTables *get_tables( void ) const { return( _tables ); }; 00249 00250 00251 00252 00255 void debug_print( std::ostream &os ) const; 00256 }; 00257 00258 00259 #endif 00260 00261 00262