This file is indexed.

/usr/include/osgEarth/StringUtils is in libosgearth-dev 2.5.0+dfsg-2+b2.

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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
 * Copyright 2008-2013 Pelican Mapping
 * http://osgearth.org
 *
 * osgEarth 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 2 of the License, or
 * (at your option) any later version.
 *
 * 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/>
 */
#ifndef OSGEARTH_STRING_UTILS_H
#define OSGEARTH_STRING_UTILS_H 1

#include <osgEarth/Common>
#include <osg/Vec3>
#include <osg/Vec3d>
#include <osg/Vec4>
#include <osg/Vec4ub>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#include <locale>
#include <iomanip>
#include <map>
#include <ctype.h>

namespace osgEarth
{
    extern OSGEARTH_EXPORT const std::string EMPTY_STRING;

    typedef std::vector<std::string> StringVector;

    /** Replaces all the instances of "pattern" with "replacement" in "in_out" */
    extern OSGEARTH_EXPORT std::string& replaceIn(
        std::string&       in_out, 
        const std::string& pattern, 
        const std::string& replacement );

    /** Replaces all the instances of "pattern" with "replacement" in "in_out" (case-insensitive) */
    extern OSGEARTH_EXPORT std::string& ciReplaceIn(
        std::string&       in_out, 
        const std::string& pattern, 
        const std::string& replacement );

    /**
     * Trims whitespace from the ends of a string.
     */
    extern OSGEARTH_EXPORT std::string trim( const std::string& in );

    /**
     * True is "ref" starts with "pattern"
     */
    extern OSGEARTH_EXPORT bool startsWith( 
        const std::string& ref, 
        const std::string& pattern, 
        bool               caseSensitive =true,
        const std::locale& locale        =std::locale() );

    /**
     * True is "ref" ends with "pattern"
     */
    extern OSGEARTH_EXPORT bool endsWith(
        const std::string& ref, 
        const std::string& pattern, 
        bool               caseSensitive =true,
        const std::locale& locale        =std::locale() );

    /**
     * Case-insensitive compare
     */
    extern OSGEARTH_EXPORT bool ciEquals(
        const std::string& lhs,
        const std::string& rhs,
        const std::locale& local = std::locale() );


    extern OSGEARTH_EXPORT std::string joinStrings( const StringVector& input, char delim );

    /** Returns a lower-case version of the input string. */
    extern OSGEARTH_EXPORT std::string toLower( const std::string& input );

    /** Parses a color string in the form "255 255 255 255" (r g b a [0..255]) into an OSG color. */
    extern OSGEARTH_EXPORT osg::Vec4ub stringToColor(const std::string& str, osg::Vec4ub default_value);

    /** Creates a string in the form "255 255 255 255" (r g b a [0..255]) from a color */
    extern OSGEARTH_EXPORT std::string colorToString( const osg::Vec4ub& c );

    /** Converts a string to a vec3f */
    extern OSGEARTH_EXPORT osg::Vec3f stringToVec3f( const std::string& str, const osg::Vec3f& default_value );

    /** Converts a vec3f to a string */
    extern OSGEARTH_EXPORT std::string vec3fToString( const osg::Vec3f& v );

    /** Parses an HTML color ("#rrggbb" or "#rrggbbaa") into an OSG color. */
    extern OSGEARTH_EXPORT osg::Vec4f htmlColorToVec4f( const std::string& html );

    /** Makes an HTML color ("#rrggbb" or "#rrggbbaa") from an OSG color. */
    extern OSGEARTH_EXPORT std::string vec4fToHtmlColor( const osg::Vec4f& c );

    /** Makes a valid filename, hopefully, out of a string (without touching slashes) */
    extern OSGEARTH_EXPORT std::string toLegalFileName( const std::string& input );

    /** Generates a hashed integer for a string (poor man's MD5) */
    extern OSGEARTH_EXPORT unsigned hashString( const std::string& input );
    
    //------------------------------------------------------------------------
    // conversion templates

    // converts a string to primitive using serialization
    template<typename T> inline T
    as( const std::string& str, const T& default_value )
    {
        T temp = default_value;
        std::istringstream strin( str );
        if ( !strin.eof() ) strin >> temp;
        return temp;
    }

    // template specialization for a bool
    template<> inline bool
    as<bool>( const std::string& str, const bool& default_value )
    {
        std::string temp = str;
        std::transform( temp.begin(), temp.end(), temp.begin(), ::tolower );
        return
            temp == "true" || temp == "yes" || temp == "on" ? true :
            temp == "false" || temp == "no" || temp == "off" ? false :
            default_value;
    }

    template<> inline osg::Vec3f
    as<osg::Vec3f>( const std::string& str, const osg::Vec3f& default_value )
    {
        return stringToVec3f(str, default_value);
    }

    // template specialization for string
    template<> inline std::string
    as<std::string>( const std::string& str, const std::string& default_value )
    {
        return str;
    }

    // snips a substring and parses it.
    template<typename T> inline bool
    as(const std::string& in, unsigned start, unsigned len, T default_value) 
    {
        std::string buf;
        std::copy( in.begin()+start, in.begin()+start+len, std::back_inserter(buf) );
        return as<T>(buf, default_value);
    }

    // converts a primitive to a string
    // TODO: precision??
    template<typename T> inline std::string
    toString(const T& value)
    {
        std::stringstream out;
		//out << std::setprecision(20) << std::fixed << value;
		out << std::setprecision(20) <<  value;
        std::string outStr;
        outStr = out.str();
        return outStr;
    }

    // template speciallization for a bool to print out "true" or "false"
    template<> inline std::string
    toString<bool>(const bool& value)
    {
        return value ? "true" : "false";
    }

    template<> inline std::string
    toString<osg::Vec3f>(const osg::Vec3f& value)
    {
        return vec3fToString(value);
    }

    /**
     * Assembles and returns an inline string using a stream-like << operator.
     * Example: 
     *     std::string str = Stringify() << "Hello, world " << variable;
     */
    struct Stringify
    {
        operator std::string () const
        {
            std::string result;
            result = buf.str();
            return result;
        }

        template<typename T>
        Stringify& operator << (const T& val) { buf << val; return (*this); }

        Stringify& operator << (const Stringify& val) { buf << (std::string)val; return (*this); }

    protected:
        std::stringstream buf;
    };

    template<> inline
    Stringify& Stringify::operator << <bool>(const bool& val) { buf << (val ? "true" : "false"); return (*this); }

    template<> inline
    Stringify& Stringify::operator << <osg::Vec3f>(const osg::Vec3f& val) {
        buf << val.x() << " " << val.y() << " " << val.z(); return (*this); }

    template<> inline
    Stringify& Stringify::operator << <osg::Vec3d>(const osg::Vec3d& val ) {
        buf << val.x() << " " << val.y() << " " << val.z(); return (*this); }

    template<> inline
    Stringify& Stringify::operator << <osg::Vec4f>(const osg::Vec4f& val) {
        buf << val.r() << " " << val.g() << " " << val.b() << " " << val.a(); return (*this); }

    /**
     * Splits a string up into a vector of strings based on a set of 
     * delimiters, quotes, and rules.
     */
    class OSGEARTH_EXPORT StringTokenizer
    {
    public:
        StringTokenizer( const std::string& delims =" \t\r\n", const std::string& quotes ="'\"" );

        StringTokenizer(
            const std::string& input, StringVector& output,
            const std::string& delims =" \t\r\n", const std::string& quotes ="'\"",
            bool keepEmpties =true, bool trimTokens =true);

        void tokenize( const std::string& input, StringVector& output ) const;

        bool& keepEmpties() { return _allowEmpties; }

        bool& trimTokens() { return _trimTokens; }

        void addDelim( char delim, bool keepAsToken =false );

        void addDelims( const std::string& delims, bool keepAsTokens =false );

        void addQuote( char delim, bool keepInToken =false );

        void addQuotes( const std::string& delims, bool keepInTokens =false );
        
    private:
        typedef std::map<char,bool> TokenMap;
        TokenMap _delims;
        TokenMap _quotes;
        bool     _allowEmpties;
        bool     _trimTokens;
    };
}

#endif // OSGEARTH_STRING_UTILS_H