Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions source/cppassist/include/cppassist/memory/offsetof.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ namespace cppassist
{


/**
* @brief
* Determines the offset of a member within a class
*
* @param[in] member
* Pointer to class member
*
* @return
* Offset of member
*/
template <typename Class, typename Type>
std::ptrdiff_t offset(Type Class::*member);

Expand Down
78 changes: 39 additions & 39 deletions source/cppassist/include/cppassist/tokenizer/Tokenizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ class CPPASSIST_API Tokenizer
*/
enum Option
{
OptionParseStrings = 1 ///< Parse strings (use setQuotationMarks to set string characters)
OptionParseStrings = 1 ///< Parse strings (use #setQuotationMarks to set string characters)
, OptionParseNumber = 2 ///< Parse numbers
, OptionParseBoolean = 4 ///< Parse boolean values
, OptionParseNull = 8 ///< Parse null value
, OptionCStyleComments = 16 ///< Enable "/* */" for multi-line comments
, OptionCppStyleComments = 32 ///< Enable "//" for one-line comments
, OptionShellStyleComments = 64 ///< Enable "#" for one-line comments
, OptionCStyleComments = 16 ///< Enable '`/* */`' for multi-line comments
, OptionCppStyleComments = 32 ///< Enable '`//`' for one-line comments
, OptionShellStyleComments = 64 ///< Enable '`#`' for one-line comments
, OptionIncludeComments = 128 ///< Include comments in the output of the tokenizer
};

Expand All @@ -48,34 +48,34 @@ class CPPASSIST_API Tokenizer
enum TokenType
{
TokenEndOfStream ///< No token read, end of stream reached
, TokenWhitespace ///< Token contains only whitespace
, TokenComment ///< Token contains a comment
, TokenStandalone ///< Token contains a standalone string
, TokenString ///< Token contains a string
, TokenNumber ///< Token contains number
, TokenBoolean ///< Token contains a boolean value
, TokenNull ///< Token contains a null value
, TokenSingleChar ///< Token contains a single character
, TokenWord ///< Token contains a regular word (any other than above)
, TokenWhitespace ///< %Token contains only whitespace
, TokenComment ///< %Token contains a comment
, TokenStandalone ///< %Token contains a standalone string
, TokenString ///< %Token contains a string
, TokenNumber ///< %Token contains number
, TokenBoolean ///< %Token contains a boolean value
, TokenNull ///< %Token contains a null value
, TokenSingleChar ///< %Token contains a single character
, TokenWord ///< %Token contains a regular word (any other than above)
};

/**
* @brief
* Token
* %Token
*/
struct Token
{
TokenType type; ///< Type of token (see TokenType)
std::string content; ///< Token content (the actual string read)
int intValue; ///< Only valid if type == TokenNumber
double numberValue; ///< Only valid if type == TokenNumber
std::string stringValue; ///< Only valid if type == TokenString
bool booleanValue; ///< Only valid if type == TokenBoolean
bool isDouble; ///< If type == TokenNumber and isDouble, use numberValue
TokenType type; ///< Type of token (see #TokenType)
std::string content; ///< %Token content (the actual string read)
int intValue; ///< Only valid if type == #TokenNumber
double numberValue; ///< Only valid if type == #TokenNumber
std::string stringValue; ///< Only valid if type == #TokenString
bool booleanValue; ///< Only valid if type == #TokenBoolean
bool isDouble; ///< If type == #TokenNumber and isDouble, use #numberValue
const char * begin; ///< Pointer to the first character of the token
const char * end; ///< Pointer to the first character after the token
unsigned int line; ///< Line number where the token begins
unsigned int column; ///< Columns number where the token begins
unsigned int column; ///< Column number where the token begins
};

/**
Expand All @@ -84,8 +84,8 @@ class CPPASSIST_API Tokenizer
*/
struct Lookahead
{
TokenType type; ///< Type of token (see TokenType)
std::string hint; ///< Hint about value or type (only valid for TokenComment or TokenStandalone)
TokenType type; ///< Type of token (see #TokenType)
std::string hint; ///< Hint about value or type (only valid for #TokenComment or #TokenStandalone)
};


Expand Down Expand Up @@ -125,7 +125,7 @@ class CPPASSIST_API Tokenizer
* Check if a specific parsing option is set
*
* @return
* 'true' if option is set, else 'false'
* `true` if option is set, else `false`
*/
bool hasOption(Option option) const;

Expand Down Expand Up @@ -209,7 +209,7 @@ class CPPASSIST_API Tokenizer
* Filename of text document
*
* @return
* 'true' if file could be loaded, else 'false'
* `true` if file could be loaded, else `false`
*/
bool loadDocument(const std::string & filename);

Expand Down Expand Up @@ -238,10 +238,10 @@ class CPPASSIST_API Tokenizer
* Parse and return the next token
*
* @return
* Token
* %Token
*
* @remarks
* If there are no tokens left, token.type is set to TokenEndOfStream.
* If there are no tokens left, Token::type is set to #TokenEndOfStream.
*/
Token parseToken();

Expand All @@ -252,7 +252,7 @@ class CPPASSIST_API Tokenizer
* Read next token
*
* @return
* Token
* %Token
*/
Token readToken();

Expand Down Expand Up @@ -300,7 +300,7 @@ class CPPASSIST_API Tokenizer
* Read string
*
* @param[in] endChar
* Character that marks the end of the string (usually " or ')
* Character that marks the end of the string (usually `"` or `'`)
*
* @remarks
* Advances the position until the end of the string is reached
Expand Down Expand Up @@ -398,7 +398,7 @@ class CPPASSIST_API Tokenizer
* Check if a standalone string matches at the current position
*
* @return
* Standalone string that matches, "" if none does
* Standalone string that matches, `""` if none does
*/
const std::string & matchStandaloneStrings() const;

Expand All @@ -407,7 +407,7 @@ class CPPASSIST_API Tokenizer
* Check if there is a (floating point) number at the current position
*
* @return
* Number string, "" if no number was found
* Number string, `""` if no number was found
*/
std::string matchNumber() const;

Expand All @@ -434,7 +434,7 @@ class CPPASSIST_API Tokenizer
* Convert token value into a number
*
* @param[in,out] token
* Token
* %Token
*/
void decodeNumber(Token & token);

Expand All @@ -443,7 +443,7 @@ class CPPASSIST_API Tokenizer
* Convert token value into a double value
*
* @param[in,out] token
* Token
* %Token
*/
void decodeDouble(Token & token);

Expand All @@ -452,7 +452,7 @@ class CPPASSIST_API Tokenizer
* Convert token value into string
*
* @param[in,out] token
* Token
* %Token
*/
void decodeString(Token & token);

Expand All @@ -468,7 +468,7 @@ class CPPASSIST_API Tokenizer
* Unicode value
*
* @return
* 'true' on success, 'false' on error
* `true` on success, `false` on error
*/
bool decodeUnicodeCodePoint(const char * & current, const char * end, unsigned int & unicode) const;

Expand All @@ -484,7 +484,7 @@ class CPPASSIST_API Tokenizer
* Unicode value
*
* @return
* 'true' on success, 'false' on error
* `true` on success, `false` on error
*/
bool decodeUnicodeEscapeSequence(const char * & current, const char * end, unsigned int & unicode) const;

Expand All @@ -510,7 +510,7 @@ class CPPASSIST_API Tokenizer
* Character set
*
* @return
* 'true' if c is on of the characters in chars, else 'false'
* `true` if `c` is on of the characters in chars, else `false`
*/
bool charIn(char c, const std::string & chars) const;

Expand All @@ -530,7 +530,7 @@ class CPPASSIST_API Tokenizer
const char * m_current; ///< Current position in the document
unsigned int m_line; ///< Current line number (starts with 1)
unsigned int m_column; ///< Current column number (starts with 1)
bool m_lastCR; ///< 'true' if the last character read was '\r', else 'false'
bool m_lastCR; ///< `true` if the last character read was `\r`, else `false`
};


Expand Down