13#ifndef ___utilities___
14#define ___utilities___
40#include "smartpointer.h"
41#include "basevisitor.h"
51 enum timingItemKind { kMandatory, kOptional };
55 std::string description,
57 std::clock_t startClock,
58 std::clock_t endClock);
62 std::string description,
64 std::clock_t startClock,
65 std::clock_t endClock);
67 std::string fActivity;
68 std::string fDescription;
85 void appendTimingItem (
87 std::string description,
88 timingItem::timingItemKind
94 void print (std::ostream& os)
const;
98 std::list<S_timingItem>
101EXP std::ostream& operator<< (std::ostream& os,
const timing& tim);
108 indenter (std::string spacer =
" ");
112 int getIndent ()
const
116 indenter& operator++ (
const int value);
119 indenter& operator-- (
const int value);
129 bool operator == (
const int &value)
const
130 {
return fIndent == value; }
131 bool operator != (
const int &value)
const
132 {
return fIndent != value; }
135 void print (std::ostream& os)
const;
138 std::string getSpacer ()
const
142 std::string indentMultiLineString (std::string value);
152EXP std::ostream& operator<< (std::ostream& os,
const indenter& idtr);
155#define gIndenter indenter::gIndenter
156#define gTab indenter::gIndenter.getSpacer ()
187 std::ostream& fOutputSteam;
194 std::ostream& outputStream,
196 : fOutputSteam (outputStream),
202 {
return fIndenter; }
206 { fOutputSteam.flush (); }
237 : std::ostream (&fIndentedStreamBuf),
238 fIndentedStreamBuf (str, idtr)
247 { fIndentedStreamBuf.flush (); }
251 {
return fIndentedStreamBuf.getIndenter (); }
253 void incrIdentation ()
254 { fIndentedStreamBuf.getIndenter ()++; }
256 void decrIdentation ()
257 { fIndentedStreamBuf.getIndenter ()--; }
261 gOutputIndentedOstream;
265 gNullIndentedOstream;
269#define gOutputOstream indentedOstream::gOutputIndentedOstream
270#define gLogOstream indentedOstream::gLogIndentedOstream
271#define gNullOstream indentedOstream::gNullIndentedOstream
287 void operator() (
char ch)
const
292 target.push_back (
'\\');
294 target.push_back (ch);
315 void operator() (
char ch)
const
318 target.push_back (ch);
338 : target (t), ersatz (ch)
341 void operator() (
char ch)
const
344 target.push_back (ersatz);
346 target.push_back (ch);
351std::string replicateString (
356std::string replaceSubstringInString (
358 std::string subString,
362std::string int2EnglishWord (
int n);
365std::string stringNumbersToEnglishWords (std::string str);
368std::set<int> decipherNaturalNumbersSetSpecification (
369 std::string theSpecification,
370 bool debugMode =
false);
373std::set<std::string> decipherStringsSetSpecification (
374 std::string theSpecification,
375 bool debugMode =
false);
378std::list<int> extractNumbersFromString (
379 std::string theString,
380 bool debugMode =
false);
385inline std::string <rim (std::string &s) {
386 std::function <int (
int)>
388 [] (
int x) {
return isspace (x); };
395 std::not1 (checkSpace)
403inline std::string &rtrim (std::string &s) {
404 std::function <int (
int)>
406 [] (
int x) {
return isspace (x); };
412 std::not1 (checkSpace)
421inline std::string &trim (std::string &s) {
422 return ltrim (rtrim (s));
426std::pair<std::string, std::string> extractNamesPairFromString (
427 std::string theString,
429 bool debugMode =
false);
432std::string doubleQuoteStringIfNonAlpha (
433 std::string theString);
435std::string quoteStringIfNonAlpha (
436 std::string theString);
438std::string doubleQuoteString (
439 std::string theString);
441std::string quoteString (
442 std::string theString);
445std::string booleanAsString (
bool value);
448std::string singularOrPlural (
449 int number, std::string singularName, std::string pluralName);
451std::string singularOrPluralWithoutNumber (
452 int number, std::string singularName, std::string pluralName);
455void oahWarning (std::string warningMessage);
457void oahError (std::string errorMessage);
460std::string escapeDoubleQuotes (std::string s);
463void convertHTMLEntitiesToPlainCharacters (std::string& s);
466void splitStringIntoChunks (
467 std::string theString,
468 std::string theSeparator,
469 std::list<std::string>& chunksList);
471void splitRegularStringAtEndOfLines (
472 std::string theString,
473 std::list<std::string>& chunksList);
475void splitHTMLStringContainingEndOfLines (
476 std::string theString,
477 std::list<std::string>& chunksList);
480std::string baseName (
const std::string &filename);
484std::string makeSingleWordFromString (
const std::string& theString);
the smart pointer implementation
Definition: smartpointer.h:58
Definition: utilities.h:213
Definition: utilities.h:184
Definition: utilities.h:105
the base class for smart pointers implementation
Definition: smartpointer.h:29
Definition: utilities.h:49
Definition: utilities.h:76
Definition: utilities.h:275
Definition: utilities.h:300
Definition: utilities.h:325