1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 #if !defined(PRINTWRITER_HEADER_GUARD_1357924680) 19 #define PRINTWRITER_HEADER_GUARD_1357924680 20 21 22 23 // Base include file. Must be first. 24 #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp> 25 26 27 28 // Base class header file. 29 #include <xalanc/PlatformSupport/Writer.hpp> 30 31 32 33 namespace XALAN_CPP_NAMESPACE { 34 35 36 37 class XALAN_PLATFORMSUPPORT_EXPORT PrintWriter : public Writer 38 { 39 public: 40 41 /** 42 * Constructor 43 * 44 * @param fAutoFlush if true, the output will not be buffered 45 */ 46 PrintWriter( bool fAutoFlush = false, MemoryManager& theManager XALAN_DEFAULT_MEMMGR); 47 48 MemoryManager& getMemoryManager()49 getMemoryManager() 50 { 51 return m_memoryManager; 52 } 53 54 virtual 55 ~PrintWriter(); 56 57 /** 58 * Flush the stream, then check the error status. 59 * 60 * @return true if no errors 61 */ 62 virtual bool 63 checkError() const = 0; 64 65 // Functions inherited from Writer... 66 67 virtual void 68 close() = 0; 69 70 virtual void 71 flush() = 0; 72 73 74 // Output functions inherited from Writer... 75 76 virtual void 77 write( 78 const char* s, 79 size_t theOffset = 0, 80 size_t theLength = npos) = 0; 81 82 virtual void 83 write( 84 const XalanDOMChar* s, 85 XalanDOMString::size_type theOffset = 0, 86 XalanDOMString::size_type theLength = XalanDOMString::npos) = 0; 87 88 virtual void 89 write(XalanDOMChar c) = 0; 90 91 virtual void 92 write( 93 const XalanDOMString& s, 94 XalanDOMString::size_type theOffset = 0, 95 XalanDOMString::size_type theLength = XalanDOMString::npos) = 0; 96 97 // Output functions which are new... 98 99 #if !defined(XALAN_BOOL_AS_INT) 100 virtual void 101 print(bool b) = 0; 102 #endif 103 104 virtual void 105 print(char c) = 0; 106 107 virtual void 108 print( 109 const char* s, 110 size_t theLength = npos) = 0; 111 112 virtual void 113 print( 114 const XalanDOMChar* s, 115 XalanDOMString::size_type theLength = XalanDOMString::npos) = 0; 116 117 virtual void 118 print(double d) = 0; 119 120 virtual void 121 print(XMLInt32 i) = 0; 122 123 virtual void 124 print(XMLInt64 l) = 0; 125 126 virtual void 127 print(const XalanDOMString& s) = 0; 128 129 virtual void 130 println() = 0; 131 132 #if !defined(XALAN_BOOL_AS_INT) 133 virtual void 134 println(bool b) = 0; 135 #endif 136 137 virtual void 138 println(char x) = 0; 139 140 virtual void 141 println( 142 const char* s, 143 size_t theLength = npos) = 0; 144 145 virtual void 146 println( 147 const XalanDOMChar* s, 148 XalanDOMString::size_type theLength = XalanDOMString::npos) = 0; 149 150 virtual void 151 println(double x) = 0; 152 153 virtual void 154 println(XMLInt32 x) = 0; 155 156 virtual void 157 println(XMLInt64 x) = 0; 158 159 virtual void 160 println(const XalanDOMString& s) = 0; 161 162 protected: 163 164 const bool m_fAutoFlush; 165 166 MemoryManager& m_memoryManager; 167 168 // Some static strings to help derived classes... 169 static const XalanDOMChar s_trueString[]; 170 171 static const XalanDOMChar s_falseString[]; 172 173 static const XalanDOMChar s_newlineString[]; 174 175 private: 176 177 // Not implemented 178 PrintWriter(const PrintWriter&); 179 180 PrintWriter& 181 operator=(const PrintWriter&); 182 183 bool 184 operator==(const PrintWriter&); 185 }; 186 187 188 189 } 190 191 192 193 #endif // PRINTWRITER_HEADER_GUARD_1357924680 194