ISIS Logo
UTILITIES
EPICS Utilities
trimString.cpp
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <string.h>
3 #include <stdio.h>
4 #include <iostream>
5 #include <string>
6 
7 #include <epicsStdlib.h>
8 #include <epicsString.h>
9 #include <registryFunction.h>
10 
11 #include <epicsExport.h>
12 
13 #include "utilities.h"
14 
15 epicsShareFunc std::string epicsShareAPI trimString(const std::string& str)
16 {
17  static const char* whitespace = " \n\r\t\f\v";
18  std::string s = str;
19  size_t pos = s.find_last_not_of(whitespace);
20  if (pos != std::string::npos)
21  {
22  s.erase(pos+1); // trim end
23  }
24  else
25  {
26  s.clear(); // all whitespace
27  }
28  pos = s.find_first_not_of(whitespace);
29  if (pos != std::string::npos)
30  {
31  s.erase(0, pos); // trim start
32  }
33  return s;
34 }
35 
36 //extern "C"
37 //{
38 // epicsRegisterFunction(trimString); // needs to be in utilities.dbd as well
39 //}
40 
epicsShareFunc std::string epicsShareAPI trimString(const std::string &str)
Definition: trimString.cpp:15
Copyright © 2013 Science and Technology Facilities Council | Generated by   doxygen 1.8.5