This file is indexed.

/usr/include/unity/util/IniParser.h is in libunity-api-dev 8.7+17.04.20170404-0ubuntu1.

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
159
160
161
/*
 * Copyright (C) 2013 Canonical Ltd
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Jussi Pakkanen <jussi.pakkanen@canonical.com>
 */

#ifndef UNITY_UTIL_INIPARSER_H
#define UNITY_UTIL_INIPARSER_H

#include <unity/SymbolExport.h>
#include <unity/util/DefinesPtrs.h>

#include <string>
#include <vector>

namespace unity
{

namespace util
{

namespace internal
{
struct IniParserPrivate;
}

/**
\brief Helper class to read and write configuration files.

This class reads configuration files in the .ini format
and provides for a simple and type safe way of extracting
and inserting information. A typical ini file looks like this:

~~~
[group1]

key1 = value1
key2 = value2

[group2]

key1 = othervalue1
key2 = othervalue2
~~~

To extract/insert a value, simply specify the group and key
names to the get/set methods of this class, respectively.
The array methods use a semicolon as a separator.

To write unsaved changes back to the configuration file, call
sync(). The sync() method will throw a FileException if it
fails to write to file.

The get methods indicate errors by throwing LogicException.

All methods are thread-safe.
*/

class UNITY_API IniParser final {
public:
    /** Parse the given file. */
    IniParser(const char* filename);
    ~IniParser() noexcept;

    /// @cond
    UNITY_DEFINES_PTRS(IniParser);

    IniParser(const IniParser& ip) = delete;
    IniParser() = delete;
    /// @endcond

    //{@

    /** @name Read Methods
     * These member functions provide read access to configuration entries by group and key.<br>
     * Attempts to retrieve a value as the wrong type (such as retrieving a string value as an
     * integer) or to retrieve a value for a non-existent group or key throw LogicException.
     **/

    bool has_group(const std::string& group) const noexcept;
    bool has_key(const std::string& group, const std::string& key) const;

    std::string get_string(const std::string& group, const std::string& key) const;
    std::string get_locale_string(const std::string& group,
                                  const std::string& key,
                                  const std::string& locale = std::string()) const;
    bool get_boolean(const std::string& group, const std::string& key) const;
    int get_int(const std::string& group, const std::string& key) const;
    double get_double(const std::string& group, const std::string& key) const;

    std::vector<std::string> get_string_array(const std::string& group, const std::string& key) const;
    std::vector<std::string> get_locale_string_array(const std::string& group,
                                                     const std::string& key,
                                                     const std::string& locale = std::string()) const;
    std::vector<bool> get_boolean_array(const std::string& group, const std::string& key) const;
    std::vector<int> get_int_array(const std::string& group, const std::string& key) const;
    std::vector<double> get_double_array(const std::string& group, const std::string& key) const;

    std::string get_start_group() const;
    std::vector<std::string> get_groups() const;
    std::vector<std::string> get_keys(const std::string& group) const;

    /** @name Write Methods
     * These member functions provide write access to configuration entries by group and key.<br>
     * Attempts to remove groups or keys that do not exist throw LogicException.<br>
     * The set methods replace the value for a key if the key exists. Calling a set method for a
     * non-existent group and/or key creates the group and/or key.
      **/

    bool remove_group(const std::string& group);
    bool remove_key(const std::string& group, const std::string& key);

    void set_string(const std::string& group, const std::string& key, const std::string& value);
    void set_locale_string(const std::string& group,
                           const std::string& key,
                           const std::string& value,
                           const std::string& locale = std::string());
    void set_boolean(const std::string& group, const std::string& key, bool value);
    void set_int(const std::string& group, const std::string& key, int value);
    void set_double(const std::string& group, const std::string& key, double value);

    void set_string_array(const std::string& group, const std::string& key, const std::vector<std::string>& value);
    void set_locale_string_array(const std::string& group,
                                 const std::string& key,
                                 const std::vector<std::string>& value,
                                 const std::string& locale = std::string());
    void set_boolean_array(const std::string& group, const std::string& key, const std::vector<bool>& value);
    void set_int_array(const std::string& group, const std::string& key, const std::vector<int>& value);
    void set_double_array(const std::string& group, const std::string& key, const std::vector<double>& value);

    /** @name Sync Method
     * This member function writes unsaved changes back to the configuration file.<br>
     * A failure to write to the file throws a FileException.
      **/

    void sync();

    //@}

private:
    internal::IniParserPrivate* p;
};


} // namespace util

} // namespace unity

#endif