Loading [MathJax]/extensions/TeX/AMSsymbols.js

DUNE-ACFEM (unstable)

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