proxygen
StructuredHeadersEncoder.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 
11 #pragma once
12 
14 #include <ostream>
15 #include <string>
16 #include <unordered_map>
17 #include <vector>
18 #include <boost/iostreams/device/back_inserter.hpp>
19 #include <boost/iostreams/stream_buffer.hpp>
20 
21 namespace proxygen {
22 
23 using namespace StructuredHeaders;
24 
25 using string_buf = boost::iostreams::stream_buffer<
26  boost::iostreams::back_insert_device<std::string> >;
27 
29 
30  public:
31 
33 
34  EncodeError encodeParameterisedList(const ParameterisedList& input);
35 
36  EncodeError encodeDictionary(const Dictionary& input);
37 
38  EncodeError encodeList(const std::vector<StructuredHeaderItem>& input);
39 
40  EncodeError encodeItem(const StructuredHeaderItem& input);
41 
42  EncodeError encodeIdentifier(const std::string& input);
43 
44  std::string get();
45 
46  private:
47 
48  EncodeError encodeBinaryContent(const std::string& input);
49 
50  EncodeError encodeString(const std::string& input);
51 
52  EncodeError encodeInteger(int64_t input);
53 
54  EncodeError encodeFloat(double input);
55 
56  EncodeError handleEncodeError(EncodeError err,
57  const std::string& badContent);
58 
59  EncodeError handleEncodeError(EncodeError err);
60 
63  std::ostream outputStream_;
64 
65 };
66 
67 }
std::vector< StructuredHeaders::ParameterisedIdentifier > ParameterisedList
std::unordered_map< std::string, StructuredHeaderItem > Dictionary
const char * string
Definition: Conv.cpp:212
boost::iostreams::stream_buffer< boost::iostreams::back_insert_device< std::string > > string_buf