mydxffile.hpp

Go to the documentation of this file.
00001 
00005 /* Copyright (c) 2010 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 
00123     void set_warning_level( int wlevel ) { _wlevel = wlevel; }
00124 
00127     int wlevel( void ) { return( _wlevel ); }
00128 
00129 
00130 
00133     void write_group( int code, const char *data );
00134 
00137     void write_group( int code, double data );
00138 
00141     void write_group( int code, bool data );
00142 
00145     void write_group( int code, int8_t data );
00146 
00149     void write_group( int code, int16_t data );
00150 
00153     void write_group( int code, int32_t data );
00154 
00157     void write_group( int code, int64_t data );
00158 
00159 
00160 
00166     int read_group( void );
00167 
00170     int group_get_code( void ) const;
00171 
00176     std::string group_get_string( void ) const;
00177 
00182     double group_get_double( void ) const;
00183 
00188     bool group_get_bool( void ) const;
00189 
00194     int8_t group_get_int8( void ) const;
00195 
00200     int16_t group_get_int16( void ) const;
00201 
00206     int32_t group_get_int32( void ) const;
00207 
00212     int64_t group_get_int64( void ) const;
00213 
00216     int linec( void ) const { return( _linec ); }
00217 
00218 
00219 
00220 
00221 
00224     class MyDXFEntities *get_entities( void ) { return( _entities ); };
00225 
00228     const class MyDXFEntities *get_entities( void ) const { return( _entities ); };
00229 
00230 
00231 
00234     class MyDXFBlocks *get_blocks( void ) { return( _blocks ); };
00235 
00238     const class MyDXFBlocks *get_blocks( void ) const { return( _blocks ); };
00239 
00240 
00241 
00242 
00245     void debug_print( std::ostream &os ) const;
00246 };
00247 
00248 
00249 #endif
00250 
00251 
00252 

Generated on Thu Apr 21 13:39:59 2011 for IBSimu by  doxygen 1.4.7