PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/RbfConv/TextFileWriter.h

http://modstudio2.googlecode.com/
C++ Header | 85 lines | 28 code | 9 blank | 48 comment | 0 complexity | 56f5909e79d4baf9690c0747b2612516 MD5 | raw file
 1/*
 2Copyright (c) 2008 Peter "Corsix" Cawley
 3
 4Permission is hereby granted, free of charge, to any person
 5obtaining a copy of this software and associated documentation
 6files (the "Software"), to deal in the Software without
 7restriction, including without limitation the rights to use,
 8copy, modify, merge, publish, distribute, sublicense, and/or sell
 9copies of the Software, and to permit persons to whom the
10Software is furnished to do so, subject to the following
11conditions:
12
13The above copyright notice and this permission notice shall be
14included in all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23OTHER DEALINGS IN THE SOFTWARE.
24*/
25
26#pragma once
27#define RAINMAN2_NO_WX
28#define RAINMAN2_NO_LUA
29#include <Rainman2.h>
30
31class RbfTxtWriter
32{
33public:
34  RbfTxtWriter(IFile *pOutputFile);
35  ~RbfTxtWriter();
36
37  void writeTable(IAttributeTable *pTable);
38  void writeValue(IAttributeValue *pValue);
39
40  //! Write the current indentation string
41  void writeLinePrefix();
42
43  void setUCS(UcsFile *pUcsFile, long iUcsReferenceThreshold = 100);
44
45  //! Configure indentation behaviour
46  /*!
47    \param iIndentSize The number of characters to use per indentation level
48    \param cIndentChar The character to use when indenting
49    \param cLevelMarker The character to use when indenting to mark the indentation level
50
51    This should be called before any writing occurs, as otherwise the changes will not
52    take effect fully or consistently.
53
54    If given the parameters (3, 'a', 'B'), indentation would be:
55    // indentation level 0
56    Baa // indentation level 1
57    BaaBaa // indentation level 2
58    BaaBaaBaa // indentation level 3
59    BaaBaaBaaBaa // indentation level 4
60    As can be seen, indentation always uses iIndentSize characters, the first of which is
61    cLevelMarker, the remainder being cIndentChar.
62  */
63  void setIndentProperties(int iIndentSize = 2, char cIndentChar = ' ', char cLevelMarker = '|');
64
65  //! Increase the indent level
66  void indent();
67
68  //! Decrease the indent level
69  /*!
70    Will not decrease the indent level to below 0.
71  */
72  void unindent();
73
74protected:
75  BufferingOutputStream<char> m_oOutput; //!< Buffer for writing output
76  char    *m_sIndentArray;
77  UcsFile *m_pUcsFile;
78  long     m_iUcsReferenceThreshold;
79  int      m_iIndentLevel, //!< The number of characters of indentation currently being used
80           m_iSpacesPerLevel, //!< The number of characters to use per indentation level
81           m_iIndentArrayLength;
82  char     m_sBuffer[32]; //!< Buffer to use for sprintf and similar calls
83  char     m_cIndentChar; //!< The major indentation character
84  char     m_cIndentLevelChar; //!< The indentation level character
85};