Doxygen
reg::PToken类 参考

Class representing a token in the compiled regular expression token stream. 更多...

Public 类型

enum  Kind : uint16_t {
  Kind::End = 0x0000, Kind::WhiteSpace = 0x1001, Kind::Digit = 0x1002, Kind::Alpha = 0x1003,
  Kind::AlphaNum = 0x1004, Kind::CharClass = 0x2001, Kind::NegCharClass = 0x2002, Kind::BeginOfLine = 0x4001,
  Kind::EndOfLine = 0x4002, Kind::BeginOfWord = 0x4003, Kind::EndOfWord = 0x4004, Kind::BeginCapture = 0x4005,
  Kind::EndCapture = 0x4006, Kind::Any = 0x4007, Kind::Star = 0x4008, Kind::Optional = 0x4009,
  Kind::Character = 0x8000
}
 The kind of token. 更多...
 

Public 成员函数

const char * kindStr () const
 returns a string representation of the tokens kind (useful for debugging). 更多...
 
 PToken ()
 Creates a token of kind 'End' 更多...
 
 PToken (Kind k)
 Creates a token of the given kind k 更多...
 
 PToken (char c)
 Create a token for an ASCII character 更多...
 
 PToken (uint16_t v)
 Create a token for a byte of an UTF-8 character 更多...
 
 PToken (uint16_t from, uint16_t to)
 Create a token representing a range from one character from to another character to 更多...
 
void setValue (uint16_t value)
 Sets the value for a token 更多...
 
Kind kind () const
 Returns the kind of the token 更多...
 
uint16_t from () const
 Returns the 'from' part of the character range. 更多...
 
uint16_t to () const
 Returns the 'to' part of the character range. 更多...
 
uint16_t value () const
 Returns the value for this token 更多...
 
char asciiValue () const
 Returns the value for this token as a ASCII character 更多...
 
bool isRange () const
 Returns true iff this token represents a range of characters 更多...
 
bool isCharClass () const
 Returns true iff this token is a positive or negative character class 更多...
 

Private 属性

uint32_t m_rep
 

详细描述

Class representing a token in the compiled regular expression token stream.

A token has a kind and an optional value whose meaning depends on the kind. It is also possible to store a (from,to) character range in a token.

在文件 regex.cpp58 行定义.

成员枚举类型说明

◆ Kind

enum reg::PToken::Kind : uint16_t
strong

The kind of token.

Ranges per bit mask:

  • 0x00FF from part of a range, except for 0x0000 which is the End marker
  • 0x1FFF built-in ranges
  • 0x2FFF user defined ranges
  • 0x4FFF special operations
  • 0x8000 literal character
枚举值
End 
WhiteSpace 
Digit 
Alpha 
AlphaNum 
CharClass 
NegCharClass 
BeginOfLine 
EndOfLine 
BeginOfWord 
EndOfWord 
BeginCapture 
EndCapture 
Any 
Star 
Optional 
Character 

在文件 regex.cpp70 行定义.

70  : uint16_t
71  {
72  End = 0x0000,
73  WhiteSpace = 0x1001, // \s range [ \t\r\n]
74  Digit = 0x1002, // \d range [0-9]
75  Alpha = 0x1003, // \a range [a-z_A-Z\x80-\xFF]
76  AlphaNum = 0x1004, // \w range [a-Z_A-Z0-9\x80-\xFF]
77  CharClass = 0x2001, // []
78  NegCharClass = 0x2002, // [^]
79  BeginOfLine = 0x4001, // ^
80  EndOfLine = 0x4002, // $
81  BeginOfWord = 0x4003, // <
82  EndOfWord = 0x4004, // >
83  BeginCapture = 0x4005, // (
84  EndCapture = 0x4006, // )
85  Any = 0x4007, // .
86  Star = 0x4008, // *
87  Optional = 0x4009, // ?
88  Character = 0x8000 // c
89  };

构造及析构函数说明

◆ PToken() [1/5]

reg::PToken::PToken ( )
inline

Creates a token of kind 'End'

在文件 regex.cpp124 行定义.

124 : m_rep(0) {}

◆ PToken() [2/5]

reg::PToken::PToken ( Kind  k)
inlineexplicit

Creates a token of the given kind k

在文件 regex.cpp127 行定义.

127 : m_rep(static_cast<uint32_t>(k)<<16) {}

◆ PToken() [3/5]

reg::PToken::PToken ( char  c)
inline

Create a token for an ASCII character

在文件 regex.cpp130 行定义.

130  : m_rep((static_cast<uint32_t>(Kind::Character)<<16) |
131  static_cast<uint32_t>(c)) {}

◆ PToken() [4/5]

reg::PToken::PToken ( uint16_t  v)
inline

Create a token for a byte of an UTF-8 character

在文件 regex.cpp134 行定义.

134  : m_rep((static_cast<uint32_t>(Kind::Character)<<16) |
135  static_cast<uint32_t>(v)) {}

◆ PToken() [5/5]

reg::PToken::PToken ( uint16_t  from,
uint16_t  to 
)
inline

Create a token representing a range from one character from to another character to

在文件 regex.cpp138 行定义.

138 : m_rep(static_cast<uint32_t>(from)<<16 | to) {}

成员函数说明

◆ asciiValue()

char reg::PToken::asciiValue ( ) const
inline

Returns the value for this token as a ASCII character

在文件 regex.cpp156 行定义.

156 { return static_cast<char>(m_rep); }

引用了 m_rep.

被这些函数引用 reg::Ex::Private::compile(), reg::Ex::match() , 以及 reg::Ex::Private::matchAt().

◆ from()

uint16_t reg::PToken::from ( ) const
inline

Returns the 'from' part of the character range.

Only valid if this token represents a range

在文件 regex.cpp147 行定义.

147 { return m_rep>>16; }

引用了 m_rep.

被这些函数引用 isRange() , 以及 reg::Ex::Private::matchAt().

◆ isCharClass()

bool reg::PToken::isCharClass ( ) const
inline

Returns true iff this token is a positive or negative character class

在文件 regex.cpp162 行定义.

162 { return kind()==Kind::CharClass || kind()==Kind::NegCharClass; }

引用了 CharClass, kind() , 以及 NegCharClass.

被这些函数引用 reg::Ex::Private::matchAt().

◆ isRange()

bool reg::PToken::isRange ( ) const
inline

Returns true iff this token represents a range of characters

在文件 regex.cpp159 行定义.

159 { return m_rep!=0 && from()<=to(); }

引用了 from(), m_rep , 以及 to().

◆ kind()

Kind reg::PToken::kind ( ) const
inline

Returns the kind of the token

在文件 regex.cpp144 行定义.

144 { return static_cast<Kind>(m_rep>>16); }

引用了 m_rep.

被这些函数引用 reg::Ex::Private::compile(), isCharClass(), reg::Ex::match() , 以及 reg::Ex::Private::matchAt().

◆ kindStr()

const char* reg::PToken::kindStr ( ) const
inline

returns a string representation of the tokens kind (useful for debugging).

在文件 regex.cpp92 行定义.

93  {
94  if ((m_rep>>16)>=0x1000 || m_rep==0)
95  {
96  switch(static_cast<Kind>((m_rep>>16)))
97  {
98  case Kind::End: return "End";
99  case Kind::Alpha: return "Alpha";
100  case Kind::AlphaNum: return "AlphaNum";
101  case Kind::WhiteSpace: return "WhiteSpace";
102  case Kind::Digit: return "Digit";
103  case Kind::CharClass: return "CharClass";
104  case Kind::NegCharClass: return "NegCharClass";
105  case Kind::Character: return "Character";
106  case Kind::BeginOfLine: return "BeginOfLine";
107  case Kind::EndOfLine: return "EndOfLine";
108  case Kind::BeginOfWord: return "BeginOfWord";
109  case Kind::EndOfWord: return "EndOfWord";
110  case Kind::BeginCapture: return "BeginCapture";
111  case Kind::EndCapture: return "EndCapture";
112  case Kind::Any: return "Any";
113  case Kind::Star: return "Star";
114  case Kind::Optional: return "Optional";
115  }
116  }
117  else
118  {
119  return "Range";
120  }
121  }

引用了 Alpha, AlphaNum, Any, BeginCapture, BeginOfLine, BeginOfWord, Character, CharClass, Digit, End, EndCapture, EndOfLine, EndOfWord, m_rep, NegCharClass, Optional, Star , 以及 WhiteSpace.

◆ setValue()

void reg::PToken::setValue ( uint16_t  value)
inline

Sets the value for a token

在文件 regex.cpp141 行定义.

141 { m_rep = (m_rep & 0xFFFF0000) | value; }

引用了 m_rep , 以及 value().

◆ to()

uint16_t reg::PToken::to ( ) const
inline

Returns the 'to' part of the character range.

Only valid if this token represents a range

在文件 regex.cpp150 行定义.

150 { return m_rep & 0xFFFF; }

引用了 m_rep.

被这些函数引用 isRange() , 以及 reg::Ex::Private::matchAt().

◆ value()

uint16_t reg::PToken::value ( ) const
inline

Returns the value for this token

在文件 regex.cpp153 行定义.

153 { return m_rep & 0xFFFF; }

引用了 m_rep.

被这些函数引用 reg::Ex::Private::compile(), reg::Ex::Private::matchAt() , 以及 setValue().

类成员变量说明

◆ m_rep

uint32_t reg::PToken::m_rep
private

在文件 regex.cpp165 行定义.

被这些函数引用 asciiValue(), from(), isRange(), kind(), kindStr(), setValue(), to() , 以及 value().


该类的文档由以下文件生成:
reg::PToken::Kind::Alpha
@ Alpha
reg::PToken::kind
Kind kind() const
Returns the kind of the token
Definition: regex.cpp:144
reg::PToken::Kind::Any
@ Any
reg::PToken::Kind::End
@ End
reg::PToken::m_rep
uint32_t m_rep
Definition: regex.cpp:165
reg::PToken::Kind::Character
@ Character
reg::PToken::Kind::EndOfWord
@ EndOfWord
reg::PToken::Kind::EndOfLine
@ EndOfLine
reg::PToken::to
uint16_t to() const
Returns the 'to' part of the character range.
Definition: regex.cpp:150
reg::PToken::Kind::Digit
@ Digit
reg::PToken::Kind::CharClass
@ CharClass
reg::PToken::Kind::AlphaNum
@ AlphaNum
reg::PToken::Kind::Optional
@ Optional
reg::PToken::Kind::BeginOfWord
@ BeginOfWord
reg::PToken::Kind::WhiteSpace
@ WhiteSpace
reg::PToken::Kind::BeginOfLine
@ BeginOfLine
reg::PToken::Kind::Star
@ Star
reg::PToken::Kind::BeginCapture
@ BeginCapture
reg::PToken::Kind::EndCapture
@ EndCapture
reg::PToken::value
uint16_t value() const
Returns the value for this token
Definition: regex.cpp:153
reg::PToken::Kind
Kind
The kind of token.
Definition: regex.cpp:70
reg::PToken::from
uint16_t from() const
Returns the 'from' part of the character range.
Definition: regex.cpp:147
reg::PToken::Kind::NegCharClass
@ NegCharClass