CBMC
identifier.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 #include "identifier.h"
10 
11 #include <cstring>
12 
13 std::string identifiert::as_string() const
14 {
15  std::string result;
16 
17  for(componentst::const_iterator it=components.begin();
18  it!=components.end(); it++)
19  {
20  if(it!=components.begin())
21  result+=ID_SEPARATOR;
22  result+=*it;
23  }
24 
25  return result;
26 }
27 
28 void identifiert::parse(const std::string &s)
29 {
30  std::string component;
31 
32  for(size_t i=0; i<s.size();)
33  {
34  for(; i<s.size(); i++)
35  {
36  if(strncmp(s.c_str()+i, ID_SEPARATOR, strlen(ID_SEPARATOR))==0)
37  {
38  i+=strlen(ID_SEPARATOR);
39  break;
40  }
41  else
42  component+=s[i];
43  }
44 
45  components.push_back(component);
46  component.clear();
47  }
48 }
void parse(const std::string &s)
Definition: identifier.cpp:28
std::string as_string() const
Definition: identifier.cpp:13
componentst components
Definition: identifier.h:30
#define ID_SEPARATOR
Definition: identifier.h:16
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
Definition: std_expr.cpp:97
int strncmp(const char *s1, const char *s2, size_t n)
Definition: string.c:464
size_t strlen(const char *s)
Definition: string.c:561