/* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INCLUDE_PERFETTO_PROTOZERO_SCATTERED_HEAP_BUFFER_H_ #define INCLUDE_PERFETTO_PROTOZERO_SCATTERED_HEAP_BUFFER_H_ #include <memory> #include <string> #include <vector> #include "perfetto/base/export.h" #include "perfetto/base/logging.h" #include "perfetto/protozero/root_message.h" #include "perfetto/protozero/scattered_stream_writer.h" namespace protozero { class Message; class PERFETTO_EXPORT_COMPONENT ScatteredHeapBuffer : public protozero::ScatteredStreamWriter::Delegate { … }; // Helper function to create heap-based protozero messages in one line. // Useful when manually serializing a protozero message (primarily in // tests/utilities). So instead of the following: // protozero::MyMessage msg; // protozero::ScatteredHeapBuffer shb; // protozero::ScatteredStreamWriter writer(&shb); // shb.set_writer(&writer); // msg.Reset(&writer); // ... // You can write: // protozero::HeapBuffered<protozero::MyMessage> msg; // msg->set_stuff(...); // msg.SerializeAsString(); template <typename T = ::protozero::Message> class HeapBuffered { … }; } // namespace protozero #endif // INCLUDE_PERFETTO_PROTOZERO_SCATTERED_HEAP_BUFFER_H_