systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
Utility.cpp
Go to the documentation of this file.
1#include "Utility.h"
2
3using namespace systemc_clang;
4/*
5void Utility::tabit(raw_ostream &os, int tabn) {
6 for (int i = 0; i < tabn; i++) {
7 os << " ";
8 }
9}
10
11string Utility::strip(string s, string sub) {
12 // sub has "struct "
13 size_t pos = s.find(sub);
14
15 if (pos == string::npos) {
16 return s;
17 }
18
19 return s.erase(pos, sub.length());
20}
21
22template <typename vec> vec Utility::removeDuplicate(vec vecInput) {
23 for (unsigned int i = 0; i < vecInput.size(); i++) {
24 for (unsigned int j = 0; j < vecInput.size(); j++) {
25 if (i != j && vecInput.at(i) == vecInput.at(j)) {
26 vecInput.erase(vecInput.begin() + j);
27 }
28 }
29 }
30 return vecInput;
31}
32
33template <typename vec, typename element>
34bool Utility::isElementPresent(vec vecInput, element elemInput) {
35 for (unsigned int i = 0; i < vecInput.size(); i++) {
36 if (elemInput == vecInput.at(i)) {
37 return true;
38 }
39 }
40 return false;
41}
42
43template <typename expressionArg> string getArgumentName(expressionArg *exp) {
44 if (exp == NULL) {
45 return string("NULL");
46
47 clang::LangOptions LangOpts;
48 LangOpts.CPlusPlus = true;
49 clang::PrintingPolicy Policy(LangOpts);
50
51 string TypeS;
52
53 llvm::raw_string_ostream s(TypeS);
54
55 exp->printPretty(s, 0, Policy);
56
57 return s.str();
58 }
59}
60
61Utility::Utility() {}
62*/
A set of utility functions in the Utility class.