/proc/self/cwd/pagespeed/kernel/base/writer.h
Line | Count | Source |
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 |
7 | | * "License"); you may not use this file except in compliance |
8 | | * with the License. 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, |
13 | | * software distributed under the License is distributed on an |
14 | | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
15 | | * KIND, either express or implied. See the License for the |
16 | | * specific language governing permissions and limitations |
17 | | * under the License. |
18 | | */ |
19 | | |
20 | | #ifndef PAGESPEED_KERNEL_BASE_WRITER_H_ |
21 | | #define PAGESPEED_KERNEL_BASE_WRITER_H_ |
22 | | |
23 | | #include "pagespeed/kernel/base/basictypes.h" |
24 | | #include "pagespeed/kernel/base/string_util.h" |
25 | | |
26 | | namespace net_instaweb { |
27 | | class MessageHandler; |
28 | | |
29 | | // Interface for writing bytes to an output stream. |
30 | | class Writer { |
31 | | public: |
32 | 43.5k | Writer() {} |
33 | | virtual ~Writer(); |
34 | | |
35 | | virtual bool Write(const StringPiece& str, MessageHandler* handler) = 0; |
36 | | virtual bool Flush(MessageHandler* message_handler) = 0; |
37 | | |
38 | | // Dumps the contents of what's been written to the Writer. Many |
39 | | // Writer implementations will not be able to do this, and the default |
40 | | // implementation will return false. But StringWriter and |
41 | | // SharedCircularBuffer can dump their contents, and override |
42 | | // this with implementations that return true. |
43 | | virtual bool Dump(Writer* writer, MessageHandler* message_handler); |
44 | | |
45 | | private: |
46 | | Writer(const Writer&) = delete; |
47 | | Writer& operator=(const Writer&) = delete; |
48 | | }; |
49 | | |
50 | | } // namespace net_instaweb |
51 | | |
52 | | #endif // PAGESPEED_KERNEL_BASE_WRITER_H_ |