blob: 1c074e65c8f5aa01bd8e3ae87f19bc55060c1982 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_BUFFEREDTEXTOUTPUT_H
18#define ANDROID_BUFFEREDTEXTOUTPUT_H
19
Mathias Agopian002e1e52013-05-06 20:20:50 -070020#include <binder/TextOutput.h>
Colin Crossf5f8fa02013-07-23 14:52:34 -070021#include <sys/uio.h>
Andrei Homescu8028ff42022-03-14 22:11:54 +000022#include <utils/Mutex.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080023
24// ---------------------------------------------------------------------------
25namespace android {
26
Frederick Maylef7b65d12024-05-14 16:55:14 -070027class LIBBINDER_INTERNAL_EXPORTED BufferedTextOutput : public TextOutput {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080028public:
29 //** Flags for constructor */
30 enum {
31 MULTITHREADED = 0x0001
32 };
33
Chih-Hung Hsieh5ca1ea42018-12-20 15:42:22 -080034 explicit BufferedTextOutput(uint32_t flags = 0);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080035 virtual ~BufferedTextOutput();
36
37 virtual status_t print(const char* txt, size_t len);
38 virtual void moveIndent(int delta);
39
40 virtual void pushBundle();
41 virtual void popBundle();
42
43protected:
44 virtual status_t writeLines(const struct iovec& vec, size_t N) = 0;
45
46private:
47 struct BufferState;
48 struct ThreadState;
Elliott Hughes308e9802020-12-03 15:42:02 -080049
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080050 BufferState*getBuffer() const;
51
52 uint32_t mFlags;
53 const int32_t mSeq;
54 const int32_t mIndex;
55
56 Mutex mLock;
57 BufferState* mGlobalState;
58};
59
60// ---------------------------------------------------------------------------
Steven Moreland61ff8492019-09-26 16:05:45 -070061} // namespace android
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080062
63#endif // ANDROID_BUFFEREDTEXTOUTPUT_H