19 #ifndef OST_STRING_REF_HH
20 #define OST_STRING_REF_HH
50 const char*
begin()
const {
return begin_; }
51 const char*
end()
const {
return end_; }
52 const char*
data()
const {
return begin_; }
54 size_t size()
const {
return end_-begin_; }
55 size_t length()
const {
return this->size(); }
59 assert(!this->empty());
86 if (n==std::string::npos) {
87 assert(begin_+pos<=end_);
88 return StringRef(begin_+pos, this->length()-pos);
90 assert(begin_+pos+n<=end_);
94 std::string
str()
const
96 return std::string(begin_, end_-begin_);
100 assert(!this->empty());
104 const char&
operator[](
int index)
const {
return begin_[index]; }
107 return this->length()==rhs.
length() &&
108 !memcmp(rhs.
data(), this->data(), this->size());
117 while(--s>begin_ && isspace(*s)) {
123 const char* s=begin_;
124 while(s<end_ && isspace(*s)) {
131 return this->rtrim().
ltrim();
146 bool empty()
const {
return begin_==end_; }
149 std::vector<StringRef>
split(
char p)
const;
152 std::vector<StringRef>
split()
const;
convenient datatype for referencing character data
std::pair< bool, float > to_float() const
convert to float
bool operator==(const StringRef &rhs) const
std::pair< bool, int > to_int() const
convert to integer
const char * const_iterator
const char * data() const
std::vector< StringRef > split() const
split string into chunks delimited by whitespace
const_iterator find(char p) const
find character in StringRef
const char * begin() const
StringRef trim() const
strip space characters on the left and the right
StringRef substr(size_t pos, size_t n=std::string::npos) const
returns a substring of the string
std::string str_no_whitespace() const
returns a new string with all whitespace removed from this StringRef
const char & operator[](int index) const
StringRef rtrim() const
strip space characters on the right
bool operator!=(const StringRef &rhs) const
StringRef ltrim() const
strip space characters on the left
std::vector< StringRef > split(char p) const
split string into chunks delimited by p
StringRef(const char *begin, size_t len)
#define DLLEXPORT_OST_BASE
bool DLLEXPORT_OST_GEOM operator==(const Line2 &l1, const Line2 &l2)
pointer_it< T > begin(const std::vector< T > &values)
DLLEXPORT_OST_BASE std::ostream & operator<<(std::ostream &stream, const StringRef &strref)