Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
json_writer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Google Inc.
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 
18 
19 #ifndef PAGESPEED_KERNEL_BASE_JSON_WRITER_H_
20 #define PAGESPEED_KERNEL_BASE_JSON_WRITER_H_
21 
22 #include <utility>
23 #include <vector>
24 
29 
30 namespace Json {
31 class Value;
32 }
33 
34 namespace net_instaweb {
35 
36 static const char kInstanceHtml[] = "instance_html";
37 
38 class HtmlElement;
40 
42 typedef std::pair<HtmlElement*, Json::Value*> ElementJsonPair;
43 
45 class JsonWriter : public Writer {
46  public:
49  JsonWriter(Writer* writer,
50  const std::vector<ElementJsonPair>* element_json_stack);
51  virtual ~JsonWriter();
52 
53  virtual bool Write(const StringPiece& str, MessageHandler* message_handler);
54  virtual bool Flush(MessageHandler* message_handler);
56  void UpdateDictionary();
57 
58  private:
59  Writer* writer_;
60  GoogleString buffer_;
61  const std::vector<ElementJsonPair>* element_json_stack_;
62 
63 
64 };
65 
66 }
67 
68 #endif
JsonWriter(Writer *writer, const std::vector< ElementJsonPair > *element_json_stack)
Writes bytes to top json of the stack.
Definition: json_writer.h:45
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
std::pair< HtmlElement *, Json::Value * > ElementJsonPair
Pair of panel json and start Element corresponding to the panel.
Definition: json_writer.h:39
Interface for writing bytes to an output stream.
Definition: writer.h:29
void UpdateDictionary()
Updates the json dictionary with the buffer content so far.
Definition: message_handler.h:39