This file is indexed.

/usr/include/camp-xml/common.inl is in libcamp0.7-dev 0.7.1.1-1ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/****************************************************************************
**
** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
** Contact: Technogerma Systems France Information (contact@technogerma.fr)
**
** This file is part of the CAMP library.
**
** CAMP is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
** 
** CAMP is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU Lesser General Public License for more details.
** 
** You should have received a copy of the GNU Lesser General Public License
** along with CAMP.  If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/

namespace camp
{
namespace xml
{
namespace detail
{
//-------------------------------------------------------------------------------------------------
template <typename Proxy>
void serialize(const UserObject& object, typename Proxy::NodeType node, const Value& exclude)
{
    // Iterate over the object's properties using its metaclass
    const Class& metaclass = object.getClass();
    for (std::size_t i = 0; i < metaclass.propertyCount(); ++i)
    {
        const Property& property = metaclass.property(i);

        // If the property has the exclude tag, ignore it
        if ((exclude != Value::nothing) && property.hasTag(exclude))
            continue;

        // Create a child node for the new property
        typename Proxy::NodeType child = Proxy::addChild(node, property.name());
        if (!Proxy::isValid(child))
            continue;

        if (property.type() == userType)
        {
            // The current property is a composed type: serialize it recursively
            serialize<Proxy>(property.get(object).to<UserObject>(), child, exclude);
        }
        else if (property.type() == arrayType)
        {
            // The current property is an array
            const ArrayProperty& arrayProperty = static_cast<const ArrayProperty&>(property);

            // Iterate over the array elements
            std::size_t count = arrayProperty.size(object);
            for (std::size_t j = 0; j < count; ++j)
            {
                // Add a new XML node for each array element
                typename Proxy::NodeType item = Proxy::addChild(child, "item");
                if (Proxy::isValid(item))
                {
                    if (arrayProperty.elementType() == userType)
                    {
                        // The array elements are composed objects: serialize them recursively
                        serialize<Proxy>(arrayProperty.get(object, j).to<UserObject>(), item, exclude);
                    }
                    else
                    {
                        // The array elements are simple properties: write them as the text of their XML node
                        Proxy::setText(item, arrayProperty.get(object, j));
                    }
                }
            }
        }
        else
        {
            // The current property is a simple property: write its value as the node's text
            Proxy::setText(child, property.get(object));
        }
    }
}

//-------------------------------------------------------------------------------------------------
template <typename Proxy>
void deserialize(const UserObject& object, typename Proxy::NodeType node, const Value& exclude)
{
    // Iterate over the object's properties using its metaclass
    const Class& metaclass = object.getClass();
    for (std::size_t i = 0; i < metaclass.propertyCount(); ++i)
    {
        const Property& property = metaclass.property(i);

        // If the property has the exclude tag, ignore it
        if ((exclude != Value::nothing) && property.hasTag(exclude))
            continue;

        // Find the child node corresponding to the new property
        typename Proxy::NodeType child = Proxy::findFirstChild(node, property.name());
        if (!Proxy::isValid(child))
            continue;

        if (property.type() == userType)
        {
            // The current property is a composed type: deserialize it recursively
            deserialize<Proxy>(property.get(object).to<UserObject>(), child, exclude);
        }
        else if (property.type() == arrayType)
        {
            // The current property is an array
            const ArrayProperty& arrayProperty = static_cast<const ArrayProperty&>(property);

            // Iterate over the child XML node and extract all the array elements
            std::size_t index = 0;
            for (typename Proxy::NodeType item = Proxy::findFirstChild(child, "item")
                ; Proxy::isValid(item)
                ; item = Proxy::findNextSibling(item, "item"))
            {
                // Make sure that there are enough elements in the array
                std::size_t count = arrayProperty.size(object);
                if (index >= count)
                {
                    if (arrayProperty.dynamic())
                        arrayProperty.resize(object, index + 1);
                    else
                        break;
                }

                if (arrayProperty.elementType() == userType)
                {
                    // The array elements are composed objects: deserialize them recursively
                    deserialize<Proxy>(arrayProperty.get(object, index).to<UserObject>(), item, exclude);
                }
                else
                {
                    // The array elements are simple properties: read their value from the text of their XML node
                    arrayProperty.set(object, index, Proxy::getText(item));
                }

                index++;
            }
        }
        else
        {
            // The current property is a simple property: read its value from the node's text
            property.set(object, Proxy::getText(child));
        }
    }
}

} // namespace detail

} // namespace xml

} // namespace camp