This file is indexed.

/usr/include/Bpp/Text/TextTools.h is in libbpp-core-dev 2.1.0-1.

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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
//
// File: TextTools.h
// Created by: Julien Dutheil
// Created on: Fri Aug  8 12:57:50 2003
//

/*
   Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)

   This software is a computer program whose purpose is to provide basal and
   utilitary classes. This file belongs to the Bio++ Project.

   This software is governed by the CeCILL  license under French law and
   abiding by the rules of distribution of free software.  You can  use, 
   modify and/ or redistribute the software under the terms of the CeCILL
   license as circulated by CEA, CNRS and INRIA at the following URL
   "http://www.cecill.info". 

   As a counterpart to the access to the source code and  rights to copy,
   modify and redistribute granted by the license, users are provided only
   with a limited warranty  and the software's author,  the holder of the
   economic rights,  and the successive licensors  have only  limited
   liability. 

   In this respect, the user's attention is drawn to the risks associated
   with loading,  using,  modifying and/or developing or reproducing the
   software by the user in light of its specific status of free software,
   that may mean  that it is complicated to manipulate,  and  that  also
   therefore means  that it is reserved for developers  and  experienced
   professionals having in-depth computer knowledge. Users are therefore
   encouraged to load and test the software's suitability as regards their
   requirements in conditions enabling the security of their systems and/or 
   data to be ensured and,  more generally, to use and operate it in the 
   same conditions as regards security. 

   The fact that you are presently reading this means that you have had
   knowledge of the CeCILL license and that you accept its terms.
   */

#ifndef _TEXTTOOLS_H_
#define _TEXTTOOLS_H_

#include "../Exceptions.h"


// From the STL:
#include <string>
#include <vector>
#include <sstream>
#include <iomanip>

namespace bpp
{

  /**
   * @brief Some utilitary functions that work on strings.
   */
  class TextTools
  {
    public:

      /**
       * @brief Tell if a string is empty.
       *
       * A string is considered to be 'empty' if it is only made of white
       * spaces.
       *
       * @param s The string to check.
       * @return True if the string has only white characters.
       */
      static bool isEmpty(const std::string& s);

      /**
       * @brief Make the string uppercase.
       *
       * @param s The string to analyse.
       * @return A copy of the string with all chars uppercase.
       */
      static std::string toUpper(const std::string& s);

      /**
       * @brief Make the string lowercase.
       *
       * @param s The string to analyse.
       * @return A copy of the string with all chars lowercase.
       */
      static std::string toLower(const std::string& s);

      /**
       * @brief Tell if a character is a white space or not.
       *
       * @param c The character to check.
       * @return True if c is one of the following: ' ', '\\t', '\\n', '\\r' or '\\f'.
       */
      static bool isWhiteSpaceCharacter(char c);

      /**
       * @brief Remove all white spaces characters in a string.
       *
       * @param s The string to parse.
       * @return A copy of 's' without white spaces characters.
       */
      static std::string removeWhiteSpaces (const std::string& s);

      /**
       * @brief Remove all white spaces characters at the beginning of a string.
       *
       * @param s The string to parse.
       * @return A copy of 's' beginning with the first non-white character.
       */
      static std::string removeFirstWhiteSpaces (const std::string& s);

      /**
       * @brief Remove all white spaces characters at the end of a string.
       *
       * @param s The string to parse.
       * @return A copy of 's' ending with the last non-white character.
       */
      static std::string removeLastWhiteSpaces (const std::string& s);

      /**
       * @brief Remove all white spaces characters at the beginning and the end of a string.
       *
       * @param s The string to parse.
       * @return A copy of 's' beginning with the first non-white character
       * and ending with the last one.
       */
      static std::string removeSurroundingWhiteSpaces(const std::string& s);

      /**
       * @brief Tell if a character is a new line character or not.
       *
       * @param c The character to check.
       * @return True if c is one of the following: '\\n' or '\\r'.
       */
      static bool isNewLineCharacter(char c);

      /**
       * @brief Remove all new line characters in a string.
       *
       * @param s The string to parse.
       * @return A copy of 's' without new line characters.
       */
      static std::string removeNewLines (const std::string& s);

      /**
       * @brief Remove all new line characters at the end of a string.
       *
       * @param s The string to parse.
       * @return A copy of 's' ending with the last non-new line character.
       */
      static std::string removeLastNewLines(const std::string& s);

      /**
       * @brief Tell is a given character describes a decimal number.
       *
       * @param c The character to check.
       * @return true if the given character is the reprensentation of a decimal number.
       */
      static bool isDecimalNumber(char c);

      /**
       * @brief Tell is a given character string describes a decimal number.
       *
       * NB: for now, this parser will not recognize thousands delimiters, and not the scientific notation neither.
       * @param s The string to parse.
       * @param dec The decimal separator.
       * @param scientificNotation character to use for scientific notation (typically 'e' or 'E').
       * @return true if the given string is the representation of a decimal number.
       */
      static bool isDecimalNumber(const std::string& s, char dec = '.', char scientificNotation = 'e');

      /**
       * @brief Tell is a given character string describes a decimal integer.
       *
       * NB: for now, this parser will not recognize thousands delimiters, and not the scientific notation neither.
       * @param s The string to parse.
       * @param scientificNotation character to use for scientific notation (typically 'e' or 'E').
       * @return true if the given string is the representation of a decimal integer.
       */
      static bool isDecimalInteger(const std::string& s, char scientificNotation = 'e');

      /**
       * @brief General template method to convert to a string.
       *
       * @param t The object to convert.
       * @return A string equal to t.
       */
      template<class T> static std::string toString(T t)
      {
        std::ostringstream oss;
        oss << t;
        return oss.str();
      }

      /**
       * @brief Template string conversion.
       * 
       * @param t The object to convert.
       * @param precision To use (for numbers).
       * @return A string equal to t.
       */
      template<class T>
        static std::string toString(T t, int precision)
        {
          std::ostringstream oss;
          oss << std::setprecision(precision) << t;
          return oss.str();
        }

      /**
       * @brief General template method to convert from string.
       *
       * @param s The string to convert.
       * @return An object from string t.
       */
      template<class T> static T fromString(const std::string& s)
      {
        std::istringstream iss(s);
        T obj;
        iss >> obj;
        return obj;
      }

      /**
       * @brief Convert from int to string.
       *
       * @param i The integer to convert.
       * @return A string equal to i.
       */
      static std::string toString(int i);

      /**
       * @brief Convert from char to string.
       *
       * @param c The character to convert.
       * @return A string equal to c.
       */
      static std::string toString(char c);

      /**
       * @brief Convert from double to string.
       *
       * @param d The double to convert.
       * @param precision To use (for numbers).
       * @return A string equal to d.
       */
      static std::string toString(double d, int precision = 6);

      /**
       * @brief Convert from string to int.
       *
       * @param s The string to parse.
       * @return The integer corresponding to s.
       * @throw Exception if the string does not specify a valid number.
       */
      static int toInt(const std::string& s) throw (Exception);

      /**
       * @brief Convert from string to double.
       *
       * @param s The string to parse.
       * @return The double corresponding to s.
       * @throw Exception if the string does not specify a valid number.
       */
      static double toDouble(const std::string& s) throw (Exception);

      /**
       * @brief Template to string conversion.
       * 
       * @param s The string to parse.
       * @return An object of class R corresponding to s.
       */
      template<class T>
      static T to(const std::string& s)
      {
        std::istringstream iss(s);
        T t;
        iss >> t;
        return t;
      }

      /**
       * @brief Send a string of size 'newSize', which is a copy of 's' truncated or
       * filled with character 'fill' at the end.
       *
       * @param s       The string to parse.
       * @param newSize The new string size.
       * @param fill    The character to use to fill the string id length < newSize.
       * @return A string of size newsize which is a copy from the left of s.
       */
      static std::string resizeRight(const std::string& s, size_t newSize, char fill = ' ');

      /**
       * @brief Send a string of size 'newSize', which is a copy of 's' truncated or
       * filled with character 'fill' at the beginning.
       *
       * @param s       The string to parse.
       * @param newSize The new string size.
       * @param fill    The character to use to fill the string id length < newSize.
       * @return A string of size newsize which is a copy from the right of s.
       */
      static std::string resizeLeft(const std::string& s, size_t newSize, char fill = ' ');

      /**
       * @brief Split a string into parts of size 'n'.
       *
       * The last part may contain < n chars.
       *
       * @param s The string to parse.
       * @param n The number of tokens.
       * @return A vector of strings with all tokens.
       */
      static std::vector<std::string> split(const std::string& s, size_t n);

      /**
       * @brief Remove substrings from a string.
       *
       * All substrings beginning with blockBeginning
       * and ending with blockEnding will be removed.
       * Nesting blocks are allowed, the most extern block will be removed.
       *
       * @param s The string to parse.
       * @param blockBeginning The character specifying the beginning of each block.
       * @param blockEnding    The character specifying the end of each block.
       * @return The string with all blocks removed.
       * @throw Exception If some blocks are not well formed.
       */
      static std::string removeSubstrings(const std::string& s, char blockBeginning, char blockEnding)
        throw (Exception);
  
      /**
       * @brief Remove substrings from a string, unless they match some specific substrings.
       *
       * All substrings beginning with blockBeginning
       * and ending with blockEnding will be removed, except if they begin with 
       * a string included in the vector exceptionsBeginning or end with a string
       * included in the vector exceptionsEnding.
       * Nesting blocks are allowed, the most extern block will be removed.
       *
       * @param s The string to parse.
       * @param blockBeginning The character specifying the beginning of each block.
       * @param blockEnding    The character specifying the end of each block.
       * @param exceptionsBeginning A vector containing all strings specifying the beginning of blocks that should not be removed. 
       * @param exceptionsEnding A vector containing all strings specifying the ending of blocks that should not be removed.
       * @return The string with all blocks removed.
       * @throw Exception If some blocks are not well formed.
       */
      static std::string removeSubstrings(const std::string& s, char blockBeginning, char blockEnding, std::vector<std::string>& exceptionsBeginning, std::vector<std::string>& exceptionsEnding)
        throw (Exception);
  
      /**
       * @brief Remove all occurences of a character in a string.
       *
       * @param s The string to parse.
       * @param c The character to remove.
       * @return The string with all specified chars removed.
       */
      static std::string removeChar(const std::string& s, char c);

      /**
       * @brief Count the occurences of a given pattern in a string.
       *
       * @param s The string to search.
       * @param pattern The pattern to use (this is a mere string, not a regexp!).
       * @return The number of occurences of 'pattern' in 's'.
       */
      static unsigned int count(const std::string& s, const std::string& pattern);

      /**
       * @brief Tell is a string begins with a certain motif.
       *
       * @param s The string to search.
       * @param pattern The pattern to use (this is a mere string, not a regexp!).
       * @return true/false
       */
      static bool startsWith(const std::string& s, const std::string& pattern);

      /**
       * @brief Tell is a string ends with a certain motif.
       *
       * @param s The string to search.
       * @param pattern The pattern to use (this is a mere string, not a regexp!).
       * @return true/false
       */
      static bool endsWith(const std::string& s, const std::string& pattern);

      /**
       * @brief Tell is a string contains a certain motif.
       *
       * @param s The string to search.
       * @param pattern The pattern to use (this is a mere string, not a regexp!).
       * @return true/false
       */
      static bool hasSubstring(const std::string& s, const std::string& pattern);

      /**
       * @brief Replacement of all non-overlapping occurrences of a certain motif in a string.
       *
       * @param target String to be modified
       * @param query The motif to look for
       * @param replacement The replacement string
       */
      static void replaceAll(std::string& target, const std::string& query, const std::string& replacement);
     
  };

} //end of namespace bpp.

#endif	//_TEXTTOOLS_H_