AMF-Placer  2.0
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
stringCheck.cc
Go to the documentation of this file.
1 
25 #include "stringCheck.h"
26 #include <cstring>
27 #include <iostream>
28 #include <vector>
29 
30 bool strContains(std::string target, std::string substring)
31 {
32  return (target.find(substring) != std::string::npos);
33 }
34 
35 void strSplit(const std::string &s, std::vector<std::string> &sv, const char *delim)
36 {
37  sv.clear();
38  char *buffer = new char[s.size() + 1];
39  buffer[s.size()] = '\0';
40  std::copy(s.begin(), s.end(), buffer);
41  char *p = std::strtok(buffer, delim);
42  do
43  {
44  sv.push_back(p);
45  } while ((p = std::strtok(NULL, delim)));
46  delete[] buffer;
47  return;
48 }
49 
50 void replaceAll(std::string &str, const std::string from, const std::string to)
51 {
52  if (from.empty())
53  return;
54  std::string::size_type start_pos = 0;
55  while ((start_pos = str.find(from, start_pos)) != std::string::npos)
56  {
57  str.replace(start_pos, from.length(), to);
58  start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'
59  }
60 }
delayVisualization.s
s
Definition: delayVisualization.py:99
strContains
bool strContains(std::string target, std::string substring)
Definition: stringCheck.cc:30
stringCheck.h
strSplit
void strSplit(const std::string &s, std::vector< std::string > &sv, const char *delim)
Definition: stringCheck.cc:35
replaceAll
void replaceAll(std::string &str, const std::string from, const std::string to)
Definition: stringCheck.cc:50