OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chromeos/dbus/ibus/ibus_object.h" | 5 #include "chromeos/dbus/ibus/ibus_object.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chromeos/dbus/ibus/ibus_text.h" |
8 #include "dbus/message.h" | 9 #include "dbus/message.h" |
9 | 10 |
10 namespace chromeos { | 11 namespace chromeos { |
| 12 // TODO(nona): Remove ibus namespace after complete libibus removal. |
| 13 namespace ibus { |
11 | 14 |
12 /////////////////////////////////////////////////////////////////////////////// | 15 /////////////////////////////////////////////////////////////////////////////// |
13 // IBusObjectReader | 16 // IBusObjectReader |
14 IBusObjectReader::IBusObjectReader(const std::string& type_name, | 17 IBusObjectReader::IBusObjectReader(const std::string& type_name, |
15 dbus::MessageReader* reader) | 18 dbus::MessageReader* reader) |
16 : type_name_(type_name), | 19 : type_name_(type_name), |
17 original_reader_(reader), | 20 original_reader_(reader), |
18 top_variant_reader_(NULL), | 21 top_variant_reader_(NULL), |
19 contents_reader_(NULL), | 22 contents_reader_(NULL), |
20 check_result_(IBUS_OBJECT_NOT_CHECKED) { | 23 check_result_(IBUS_OBJECT_NOT_CHECKED) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 DCHECK(contents_reader_.get()); | 88 DCHECK(contents_reader_.get()); |
86 return IsValid() && contents_reader_->PopString(out); | 89 return IsValid() && contents_reader_->PopString(out); |
87 } | 90 } |
88 | 91 |
89 bool IBusObjectReader::PopUint32(uint32* out) { | 92 bool IBusObjectReader::PopUint32(uint32* out) { |
90 DCHECK_NE(IBUS_OBJECT_NOT_CHECKED, check_result_); | 93 DCHECK_NE(IBUS_OBJECT_NOT_CHECKED, check_result_); |
91 DCHECK(contents_reader_.get()); | 94 DCHECK(contents_reader_.get()); |
92 return IsValid() && contents_reader_->PopUint32(out); | 95 return IsValid() && contents_reader_->PopUint32(out); |
93 } | 96 } |
94 | 97 |
| 98 bool IBusObjectReader::PopInt32(int32* out) { |
| 99 DCHECK_NE(IBUS_OBJECT_NOT_CHECKED, check_result_); |
| 100 DCHECK(contents_reader_.get()); |
| 101 return IsValid() && contents_reader_->PopInt32(out); |
| 102 } |
| 103 |
| 104 bool IBusObjectReader::PopBool(bool* out) { |
| 105 DCHECK_NE(IBUS_OBJECT_NOT_CHECKED, check_result_); |
| 106 DCHECK(contents_reader_.get()); |
| 107 return IsValid() && contents_reader_->PopBool(out); |
| 108 } |
| 109 |
95 bool IBusObjectReader::PopArray(dbus::MessageReader* reader) { | 110 bool IBusObjectReader::PopArray(dbus::MessageReader* reader) { |
96 DCHECK_NE(IBUS_OBJECT_NOT_CHECKED, check_result_); | 111 DCHECK_NE(IBUS_OBJECT_NOT_CHECKED, check_result_); |
97 DCHECK(contents_reader_.get()); | 112 DCHECK(contents_reader_.get()); |
98 return IsValid() && contents_reader_->PopArray(reader); | 113 return IsValid() && contents_reader_->PopArray(reader); |
99 } | 114 } |
100 | 115 |
| 116 bool IBusObjectReader::PopIBusText(IBusText* text) { |
| 117 DCHECK_NE(IBUS_OBJECT_NOT_CHECKED, check_result_); |
| 118 DCHECK(contents_reader_.get()); |
| 119 return IsValid() && chromeos::ibus::PopIBusText(contents_reader_.get(), text); |
| 120 } |
| 121 |
| 122 bool IBusObjectReader::PopStringFromIBusText(std::string* text) { |
| 123 DCHECK_NE(IBUS_OBJECT_NOT_CHECKED, check_result_); |
| 124 DCHECK(contents_reader_.get()); |
| 125 return IsValid() && chromeos::ibus::PopStringFromIBusText( |
| 126 contents_reader_.get(), text); |
| 127 } |
| 128 |
101 bool IBusObjectReader::HasMoreData() { | 129 bool IBusObjectReader::HasMoreData() { |
102 DCHECK_NE(IBUS_OBJECT_NOT_CHECKED, check_result_); | 130 DCHECK_NE(IBUS_OBJECT_NOT_CHECKED, check_result_); |
103 DCHECK(contents_reader_.get()); | 131 DCHECK(contents_reader_.get()); |
104 return IsValid() && contents_reader_->HasMoreData(); | 132 return IsValid() && contents_reader_->HasMoreData(); |
105 } | 133 } |
106 | 134 |
107 bool IBusObjectReader::PopIBusObject(IBusObjectReader* reader) { | 135 bool IBusObjectReader::PopIBusObject(IBusObjectReader* reader) { |
108 DCHECK(contents_reader_.get()); | 136 DCHECK(contents_reader_.get()); |
109 if (!IsValid()) | 137 if (!IsValid()) |
110 return false; | 138 return false; |
(...skipping 23 matching lines...) Expand all Loading... |
134 void IBusObjectWriter::AppendString(const std::string& input) { | 162 void IBusObjectWriter::AppendString(const std::string& input) { |
135 DCHECK(IsInitialized()); | 163 DCHECK(IsInitialized()); |
136 contents_writer_->AppendString(input); | 164 contents_writer_->AppendString(input); |
137 } | 165 } |
138 | 166 |
139 void IBusObjectWriter::AppendUint32(uint32 input) { | 167 void IBusObjectWriter::AppendUint32(uint32 input) { |
140 DCHECK(IsInitialized()); | 168 DCHECK(IsInitialized()); |
141 contents_writer_->AppendUint32(input); | 169 contents_writer_->AppendUint32(input); |
142 } | 170 } |
143 | 171 |
| 172 void IBusObjectWriter::AppendInt32(int32 input) { |
| 173 DCHECK(IsInitialized()); |
| 174 contents_writer_->AppendInt32(input); |
| 175 } |
| 176 |
| 177 void IBusObjectWriter::AppendBool(bool input) { |
| 178 DCHECK(IsInitialized()); |
| 179 contents_writer_->AppendBool(input); |
| 180 } |
| 181 |
144 void IBusObjectWriter::OpenArray(const std::string& signature, | 182 void IBusObjectWriter::OpenArray(const std::string& signature, |
145 dbus::MessageWriter* writer) { | 183 dbus::MessageWriter* writer) { |
146 DCHECK(IsInitialized()); | 184 DCHECK(IsInitialized()); |
147 contents_writer_->OpenArray(signature, writer); | 185 contents_writer_->OpenArray(signature, writer); |
148 } | 186 } |
149 | 187 |
| 188 void IBusObjectWriter::AppendIBusText(const IBusText& text) { |
| 189 DCHECK(IsInitialized()); |
| 190 chromeos::ibus::AppendIBusText(text, contents_writer_.get()); |
| 191 } |
| 192 |
| 193 void IBusObjectWriter::AppendStringAsIBusText(const std::string& text) { |
| 194 DCHECK(IsInitialized()); |
| 195 chromeos::ibus::AppendStringAsIBusText(text, contents_writer_.get()); |
| 196 } |
| 197 |
150 void IBusObjectWriter::CloseContainer(dbus::MessageWriter* writer) { | 198 void IBusObjectWriter::CloseContainer(dbus::MessageWriter* writer) { |
151 DCHECK(IsInitialized()); | 199 DCHECK(IsInitialized()); |
152 contents_writer_->CloseContainer(writer); | 200 contents_writer_->CloseContainer(writer); |
153 } | 201 } |
154 | 202 |
155 void IBusObjectWriter::AppendIBusObject(IBusObjectWriter* writer) { | 203 void IBusObjectWriter::AppendIBusObject(IBusObjectWriter* writer) { |
156 DCHECK(IsInitialized()); | 204 DCHECK(IsInitialized()); |
157 DCHECK(!writer->IsInitialized()) << "Given writer is already initialized"; | 205 DCHECK(!writer->IsInitialized()) << "Given writer is already initialized"; |
158 | 206 |
159 writer->InitWithParentWriter(contents_writer_.get()); | 207 writer->InitWithParentWriter(contents_writer_.get()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 top_variant_writer_->CloseContainer(contents_writer_.get()); | 239 top_variant_writer_->CloseContainer(contents_writer_.get()); |
192 original_writer_->CloseContainer(top_variant_writer_.get()); | 240 original_writer_->CloseContainer(top_variant_writer_.get()); |
193 top_variant_writer_.reset(); | 241 top_variant_writer_.reset(); |
194 contents_writer_.reset(); | 242 contents_writer_.reset(); |
195 } | 243 } |
196 | 244 |
197 bool IBusObjectWriter::IsInitialized() const { | 245 bool IBusObjectWriter::IsInitialized() const { |
198 return contents_writer_.get() != NULL; | 246 return contents_writer_.get() != NULL; |
199 } | 247 } |
200 | 248 |
| 249 } // namespace ibus |
201 } // namespace chromeos | 250 } // namespace chromeos |
OLD | NEW |