DUNE-ACFEM (2.5.1)

stringhelper.hh
1#ifndef __DUNE_ACFEM_STRINGHELPER_HH__
2#define __DUNE_ACFEM_STRINGHELPER_HH__
3
4#include <string>
5#include <iostream>
6#include <sstream>
7
8namespace Dune {
9
10 namespace ACFem {
11
24 static inline
25 bool checkParenthesis(const std::string& name, unsigned start, unsigned end)
26 {
27 int parenCount = 0;
28 for (auto i = start; i < end; ++i) {
29 parenCount += name[i] == '(';
30 parenCount -= name[i] == ')';
31 if (parenCount < 0) {
32 return false;
33 }
34 }
35 return parenCount == 0;
36 }
37
39 static inline
40 void trimParenthesis(std::string& name)
41 {
42 while (!name.empty() &&
43 name.front() == '(' &&
44 name.back() == ')' &&
45 checkParenthesis(name, 1, name.size()-1)) {
46 name.erase(0, 1);
47 name.erase(name.size()-1, 1);
48 }
49 }
50
52
53 } // ACFem::
54
55} // Dune::
56
57#endif // __DUNE_ACFEM_STRINGHELPER_HH__
static bool checkParenthesis(const std::string &name, unsigned start, unsigned end)
Check name for correct parenthesis.
Definition: stringhelper.hh:25
static void trimParenthesis(std::string &name)
Remove any outer redundant parenthesis.
Definition: stringhelper.hh:40
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Mar 12, 23:28, 2025)