/usr/include/tjutils/tjstring.h is in libodin-dev 1.8.8-2ubuntu1.
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 | /***************************************************************************
tjstring.h - description
-------------------
begin : Mon Mar 10 2003
copyright : (C) 2000-2014 by Thies Jochimsen
email : thies@jochimsen.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef TJSTRING_H
#define TJSTRING_H
#include <tjutils/tjutils.h>
//#include <tjutils/tjstream.h>
#include <tjutils/tjtools.h>
/**
* @addtogroup tjutils
* @{
*/
#define _DEFAULT_DIGITS_ 5
#define _DEFAULT_LINEWIDTH_ 74
#ifdef USING_WIN32
#define SEPARATOR_STR "\\"
#define SEPARATOR_CHAR '\\'
#else
#define SEPARATOR_STR "/"
#define SEPARATOR_CHAR '/'
#endif
//////////////////////////////////////////////////////////////
// class for debugging string component
class StringComp {
public:
static const char* get_compName();
};
//////////////////////////////////////////////////////////////
/**
* Enum to flag replacement policy:
* - allOccurences: All occurences will be replaced
* - firstOccurence: Only the first occurence is replaced
*/
enum whichOccurences {allOccurences,firstOccurence};
///////////////////////////////////////////////////////////////////////////////
// String helper functions
/**
*
* Returns a string where occurences of 'searchstring' are replaced by 'replacement' in s.
* The 'mode' parameter determines whether only the first or all occurences should be replaced.
*/
STD_string replaceStr(const STD_string& s, const STD_string& searchstring, const STD_string& replacement, whichOccurences mode=allOccurences);
/**
*
* returns a block of characters within s that is enclosed by 'blockbegin' and
* 'blockend'; the delimiters itself are not returned; If hierachical
* is true the nesting is considered, e.g. extract("(a(b)c)", "(", ")", true)
* will return "a(b)c" and not "a(b" ; beginpos is the position
* to start searching;
* If 'blockbegin' is a zero-length string, extraction will start at the beginning of the string;
* If 'blockend' is a zero-length string, extraction will stop at the end of the string;
*/
STD_string extract(const STD_string& s, const STD_string& blockbegin, const STD_string& blockend, bool hierachical=false, int beginpos=0);
/**
*
* Returns s whereby a block of characters that is enclosed by 'blockbegin' and
* 'blockend' is removed; the flags rmbegin/rmend specify whether the delimiters
* itself should be removed.
* If 'rmall' is true, the last possible end delimiter will be used, otherwise the first.
* If 'hierachical' is true the nesting is considered, e.g. extract("(",")",true) applied
* to "(a(b)c)" will return "a(b)c" and not "a(b"
*/
STD_string rmblock(const STD_string& s, const STD_string& blockbegin, const STD_string& blockend,
bool rmbegin=true, bool rmend=true, bool rmall=true, bool hierachical=false);
/**
*
* returns s, but with all lowercase characters transformed to uppercase
*/
STD_string toupperstr(const STD_string& s);
/**
*
* returns s, but with all uppercase characters transformed to lowercase
*/
STD_string tolowerstr(const STD_string& s);
/**
* Enum to flag exponential printing of floating point numbers:
* - autoExp: Automatic
* - alwaysExp: Always use exponential format
* - neverExp: Never use exponential format
*/
enum expFormat {autoExp, alwaysExp, neverExp};
/**
*
* returns a string that contains the formatted floating point number 'f' with precision 'digits' and exponential usage 'eformat'
*/
STD_string ftos (double f, unsigned int digits=_DEFAULT_DIGITS_, expFormat eformat=autoExp);
/**
*
* returns a string that contains the formatted integer 'i'.
* If 'maxabs' is non-zero, the string will be formatted to
* have the same number of (possibly zero-padded) digits as 'maxabs'.
*/
STD_string itos (int i, unsigned int maxabs=0);
/**
*
* returns a string that contains the address of pointer 'p'
*/
STD_string ptos (const void* p);
/**
*
* Returns n times s, e.g. n_times("3",3) ---> "333"
*/
STD_string n_times(const STD_string& s, unsigned int n);
/**
*
* returns a justification of s with the specified indention and linewidth
*/
STD_string justificate(const STD_string& s, unsigned int indention=0,bool ignore_firstline=false, unsigned int linewidth=_DEFAULT_LINEWIDTH_);
/**
*
* Gives the position of the first non-speparator character in s.
* Search starts at 'startpos'.
* Blanks, tabs and newlines or 'custom_separator' if non-zero are considered as separators.
*/
int textbegin(const STD_string& s, int startpos=0, const char custom_separator=0);
/**
*
* Gives the position of the first speparator character in s.
* Search starts at 'startpos'.
* Blanks, tabs and newlines or 'custom_separator' if non-zero are considered as separators.
*/
int sepbegin(const STD_string& s, int startpos=0, const char custom_separator=0);
/**
*
* Remove all blanks, tabs and newlines from the string s
*/
STD_string shrink(const STD_string& s);
/**
*
* searches for number of occurences of 'searchstring' in s, returns number of matches
* otherwise 0
*/
int noccur(const STD_string& s, const STD_string& searchstring);
/**
*
* Replaces all '0d0a' sequences by '0a' in the string
*/
STD_string dos2unix(const STD_string& s);
/**
*
* Loads 'str' from the ASCII-file 'filename'.
* Returns 0 on success, -1 otherwise.
*/
int load (STD_string& str, const STD_string& filename);
/**
*
* Writes 'str' to the ASCII-file 'filename', the 'mode' determines
* whether data will be appended/overwritten if the file already exists.
* Returns 0 on success, -1 otherwise.
*/
int write (const STD_string& str, const STD_string& filename, fopenMode mode=overwriteMode);
/** @}
*/
#endif
|