activemq-cpp-3.8.2
Writer.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef _DECAF_IO_WRITER_H
18 #define _DECAF_IO_WRITER_H
19 
20 #include <string>
21 #include <vector>
22 #include <decaf/io/IOException.h>
23 #include <decaf/io/Closeable.h>
24 #include <decaf/io/Flushable.h>
25 #include <decaf/lang/Appendable.h>
28 
29 namespace decaf{
30 namespace io{
31 
32  /*
33  * Abstract class for writing to character streams. The only methods that a
34  * subclass must implement are write( char*, size_t, size_t ), flush(), and
35  * close(). Most subclasses, however, will override some of the methods
36  * defined here in order to provide higher efficiency, additional functionality,
37  * or both.
38  *
39  * @since 1.0
40  */
42  private:
43 
44  Writer(const Writer&);
45  Writer& operator=(const Writer&);
46 
47  public:
48 
49  Writer();
50 
51  virtual ~Writer();
52 
61  virtual void write(char v);
62 
71  virtual void write(const std::vector<char>& buffer);
72 
84  virtual void write(const char* buffer, int size);
85 
102  virtual void write(const char* buffer, int size, int offset, int length);
103 
112  virtual void write(const std::string& str);
113 
127  virtual void write(const std::string& str, int offset, int length);
128 
129  virtual decaf::lang::Appendable& append(char value);
130 
131  virtual decaf::lang::Appendable& append(const decaf::lang::CharSequence* csq);
132 
133  virtual decaf::lang::Appendable& append(const decaf::lang::CharSequence* csq, int start, int end);
134 
135  protected:
136 
144  virtual void doWriteArrayBounded(const char* buffer, int size, int offset, int length) = 0;
145 
146  protected:
147 
148  virtual void doWriteChar(char v);
149 
150  virtual void doWriteVector(const std::vector<char>& buffer);
151 
152  virtual void doWriteArray(const char* buffer, int size);
153 
154  virtual void doWriteString(const std::string& str);
155 
156  virtual void doWriteStringBounded(const std::string& str, int offset, int length);
157 
158  virtual decaf::lang::Appendable& doAppendChar(char value);
159 
160  virtual decaf::lang::Appendable& doAppendCharSequence(const decaf::lang::CharSequence* csq);
161 
162  virtual decaf::lang::Appendable& doAppendCharSequenceStartEnd(const decaf::lang::CharSequence* csq, int start, int end);
163 
164  };
165 
166 }}
167 
168 #endif /*_DECAF_IO_WRITER_H*/
A CharSequence is a readable sequence of char values.
Definition: CharSequence.h:36
An object to which char sequences and values can be appended.
Definition: Appendable.h:47
Interface for a class that implements the close method.
Definition: Closeable.h:30
Definition: Writer.h:41
#define DECAF_API
Definition: Config.h:29
A Flushable is a destination of data that can be flushed.
Definition: Flushable.h:34
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25