38 |
#ifndef _PCRE_STRINGPIECE_H |
#ifndef _PCRE_STRINGPIECE_H |
39 |
#define _PCRE_STRINGPIECE_H |
#define _PCRE_STRINGPIECE_H |
40 |
|
|
41 |
#include <string.h> |
#include <cstring> |
42 |
#include <string> |
#include <string> |
43 |
#include <iosfwd> // for ostream forward-declaration |
#include <iosfwd> // for ostream forward-declaration |
44 |
|
|
45 |
#if @pcre_has_type_traits@ |
#if @pcre_have_type_traits@ |
46 |
#define HAVE_TYPE_TRAITS |
#define HAVE_TYPE_TRAITS |
47 |
#include <type_traits.h> |
#include <type_traits.h> |
48 |
#elif @pcre_has_bits_type_traits@ |
#elif @pcre_have_bits_type_traits@ |
49 |
#define HAVE_TYPE_TRAITS |
#define HAVE_TYPE_TRAITS |
50 |
#include <bits/type_traits.h> |
#include <bits/type_traits.h> |
51 |
#endif |
#endif |
52 |
|
|
53 |
|
#include <pcre.h> |
54 |
|
|
55 |
|
using std::memcmp; |
56 |
|
using std::strlen; |
57 |
using std::string; |
using std::string; |
58 |
|
|
59 |
namespace pcrecpp { |
namespace pcrecpp { |
60 |
|
|
61 |
class StringPiece { |
class PCRECPP_EXP_DEFN StringPiece { |
62 |
private: |
private: |
63 |
const char* ptr_; |
const char* ptr_; |
64 |
int length_; |
int length_; |
70 |
StringPiece() |
StringPiece() |
71 |
: ptr_(NULL), length_(0) { } |
: ptr_(NULL), length_(0) { } |
72 |
StringPiece(const char* str) |
StringPiece(const char* str) |
73 |
: ptr_(str), length_(static_cast<int>(strlen(str))) { } |
: ptr_(str), length_(static_cast<int>(strlen(ptr_))) { } |
74 |
|
StringPiece(const unsigned char* str) |
75 |
|
: ptr_(reinterpret_cast<const char*>(str)), |
76 |
|
length_(static_cast<int>(strlen(ptr_))) { } |
77 |
StringPiece(const string& str) |
StringPiece(const string& str) |
78 |
: ptr_(str.data()), length_(static_cast<int>(str.size())) { } |
: ptr_(str.data()), length_(static_cast<int>(str.size())) { } |
79 |
StringPiece(const char* offset, int len) |
StringPiece(const char* offset, int len) |