Skip to content
Snippets Groups Projects
Commit e898fb5d authored by BIOPZ-Haas Juergen's avatar BIOPZ-Haas Juergen
Browse files

restoring docu and removing check >=0 of unsigned var

parent ea127b53
Branches
No related tags found
No related merge requests found
...@@ -59,7 +59,9 @@ public: ...@@ -59,7 +59,9 @@ public:
assert(!this->empty()); assert(!this->empty());
return *begin_; return *begin_;
} }
/// \brief find character in StringRef
/// \return iterator position when found, else iterator pointing to the end
const_iterator find(char p) const { const_iterator find(char p) const {
const char* s=begin_; const char* s=begin_;
while (s!=end_) { while (s!=end_) {
...@@ -70,13 +72,22 @@ public: ...@@ -70,13 +72,22 @@ public:
} }
return s; return s;
} }
/// \brief returns a substring of the string
///
/// \param pos the starting position of the substring
/// \param length is the length of the string. if std::string::npos, the
/// substring goes from \p pos to the end of the string
/// The function does on purpose not perform any boundary check in release
/// mode. It's the duty of the caller to make sure the string has the required
/// length.
StringRef substr(size_t pos, size_t n=std::string::npos) const StringRef substr(size_t pos, size_t n=std::string::npos) const
{ {
if (n==std::string::npos) { if (n==std::string::npos) {
assert(pos>=0 && begin_+pos<=end_); assert(begin_+pos<=end_);
return StringRef(begin_+pos, this->length()-pos); return StringRef(begin_+pos, this->length()-pos);
} else { } else {
assert(pos>=0 && begin_+pos+n<=end_); assert(begin_+pos+n<=end_);
return StringRef(begin_+pos, n); return StringRef(begin_+pos, n);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment