1/*
2 * Copyright (C) 2016 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#include "generic_message.h"
18
19GenericMessage::GenericMessage()
20{
21}
22
23GenericMessage::~GenericMessage()
24{
25}
26
27void
28GenericMessage::addInt32(int32_t fieldId, uint32_t value)
29{
30    Node node;
31    node.type = TYPE_VALUE32;
32    node.value32 = value;
33    mNodes.insert(pair<int32_t,Node>(fieldId, node));
34}
35
36void
37GenericMessage::addInt64(int32_t fieldId, uint64_t value)
38{
39    Node node;
40    node.type = TYPE_VALUE64;
41    node.value64 = value;
42    mNodes.insert(pair<int32_t,Node>(fieldId, node));
43}
44
45GenericMessage*
46GenericMessage::addMessage(int32_t fieldId)
47{
48    GenericMessage* result = new GenericMessage();
49    Node node;
50    node.type = TYPE_MESSAGE;
51    node.message = result;
52    mNodes.insert(pair<int32_t,Node>(fieldId, node));
53    return result;
54}
55
56void
57GenericMessage::addString(int32_t fieldId, const string& value)
58{
59    Node node;
60    node.type = TYPE_STRING;
61    node.str = new string(value);
62    mNodes.insert(pair<int32_t,Node>(fieldId, node));
63}
64
65GenericMessage::const_iterator_pair
66GenericMessage::find(int fieldId) const
67{
68    return mNodes.equal_range(fieldId);
69}
70
71