|
Last change
on this file was
10953,
checked in by westram, 12 years ago
|
- do not depend on '_GLIBCXX_STRING' for definition of inline helper functions (should fix another clang error)
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | // =============================================================== // |
|---|
| 2 | // // |
|---|
| 3 | // File : arb_stdstr.h // |
|---|
| 4 | // Purpose : inlined string functions using std::string // |
|---|
| 5 | // // |
|---|
| 6 | // Coded by Ralf Westram (coder@reallysoft.de) in June 2002 // |
|---|
| 7 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 8 | // http://www.arb-home.de/ // |
|---|
| 9 | // // |
|---|
| 10 | // =============================================================== // |
|---|
| 11 | |
|---|
| 12 | #ifndef ARB_STDSTR_H |
|---|
| 13 | #define ARB_STDSTR_H |
|---|
| 14 | |
|---|
| 15 | inline bool beginsWith(const std::string& str, const std::string& start) { |
|---|
| 16 | return str.find(start) == 0; |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | inline bool endsWith(const std::string& str, const std::string& postfix) { |
|---|
| 20 | size_t slen = str.length(); |
|---|
| 21 | size_t plen = postfix.length(); |
|---|
| 22 | |
|---|
| 23 | if (plen>slen) { return false; } |
|---|
| 24 | return str.substr(slen-plen) == postfix; |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | #else |
|---|
| 28 | #error arb_stdstr.h included twice |
|---|
| 29 | #endif // ARB_STDSTR_H |
|---|
Note: See
TracBrowser
for help on using the repository browser.