You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.2 KiB

  1. /****************************************************************************
  2. ** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
  3. ** Copyright (C) 2001 Robert J. Campbell Jr.
  4. **
  5. ** This file is part of the dxflib project.
  6. **
  7. ** This file is free software; you can redistribute it and/or modify
  8. ** it under the terms of the GNU General Public License as published by
  9. ** the Free Software Foundation; either version 2 of the License, or
  10. ** (at your option) any later version.
  11. **
  12. ** Licensees holding valid dxflib Professional Edition licenses may use
  13. ** this file in accordance with the dxflib Commercial License
  14. ** Agreement provided with the Software.
  15. **
  16. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  17. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  18. **
  19. ** See http://www.ribbonsoft.com for further details.
  20. **
  21. ** Contact info@ribbonsoft.com if any conditions of this licensing are
  22. ** not clear to you.
  23. **
  24. **********************************************************************/
  25. #ifndef DL_WRITER_ASCII_H
  26. #define DL_WRITER_ASCII_H
  27. #include "dl_global.h"
  28. #include "dl_writer.h"
  29. #include <fstream>
  30. #include <string>
  31. /**
  32. * Implements functions defined in DL_Writer for writing low
  33. * level DXF constructs to an ASCII format DXF file.
  34. *
  35. * @param fname File name of the file to be created.
  36. * @param version DXF version. Defaults to DL_VERSION_2002.
  37. *
  38. * @todo What if \c fname is NULL? Or \c fname can't be opened for
  39. * another reason?
  40. */
  41. class DXFLIB_EXPORT DL_WriterA : public DL_Writer
  42. {
  43. public:
  44. DL_WriterA( const char* afname, DL_Codes::version aversion = DL_VERSION_2000 )
  45. : DL_Writer( aversion ), m_ofile( afname ) {}
  46. virtual ~DL_WriterA() {}
  47. bool openFailed() const;
  48. void close() const;
  49. void dxfReal( int gc, double value ) const override;
  50. void dxfInt( int gc, int value ) const override;
  51. void dxfHex( int gc, int value ) const override;
  52. void dxfString( int gc, const char* value ) const override;
  53. void dxfString( int gc, const std::string& value ) const override;
  54. static void strReplace( char* str, char src, char dest );
  55. private:
  56. /**
  57. * DXF file to be created.
  58. */
  59. mutable std::ofstream m_ofile;
  60. };
  61. #endif