# Caret.hpp
This File On Github
Ask A Question
API: latest
module: oatpp
#include "oatpp/core/parser/Caret.hpp"
# Caret
Helper class to do parsing operations
namespace oatpp { namespace parser {
class Caret {}
}}
# Methods
Return Type | Name | Summary |
---|---|---|
const char* | getData | Get pointer to a data, passed to Caret constructor |
const char* | getCurrData | Same as getData()[position] |
v_buff_size | getDataSize | Get size of a data |
std::shared_ptr<std::string> | getDataMemoryHandle | Get data memoryHandle. |
void | setPosition | Set caret position relative to data |
v_buff_size | getPosition | Get caret position relative to data |
void | setError | Set error message and error code. |
const char* | getErrorMessage | Get error message |
v_int64 | getErrorCode | Get error code |
bool | hasError | Check if error is set for the Caret |
void | clearError | Clear error message and error code |
Label | putLabel | Create Label(this); |
void | inc | Multiple implementations:
|
bool | skipBlankChars | Skip chars: [' ', '\t', '\n', '\r','\f'] |
bool | skipChar | Skip char |
bool | findChar | Find char. Position will be set to a found char. If |
bool | skipCharsFromSet | Multiple implementations:
|
v_buff_size | findCharFromSet | Multiple implementations:
|
bool | findRN | Find "\r\n" chars |
bool | skipRN | Skip "\r\n" |
bool | isAtRN | Check if caret at "\r\n" chars |
bool | findROrN | Find '\r' char of '\n' char |
bool | skipRNOrN | if at "\r\n" - skip. |
bool | skipAllRsAndNs | skip any sequence of '\r' and '\n' |
v_int64 | parseInt | parse integer value starting from the current position. |
v_uint64 | parseUnsignedInt | parse integer value starting from the current position. |
v_float32 | parseFloat32 | parse float value starting from the current position. |
v_float64 | parseFloat64 | parse float value starting from the current position. |
bool | isAtText | Multiple implementations:
|
bool | isAtTextNCS | Multiple implementations:
|
Label | parseStringEnclosed | Parse enclosed string. |
bool | findText | Multiple implementations:
|
bool | isAtCharFromSet | Multiple implementations:
|
bool | isAtChar | Check if caret is at char |
bool | isAtBlankChar | Check if caret is at one of chars [' ', '\t', '\n', '\r','\f'] |
bool | isAtDigitChar | Check if caret is at digit |
bool | canContinueAtChar | Multiple implementations:
|
bool | canContinue | Check if caret position < dataSize and not error is set |
# Caret::getData
Get pointer to a data, passed to Caret constructor
- @return
const char* getData()
# Caret::getCurrData
Same as getData()[position]
- @return
const char* getCurrData()
# Caret::getDataSize
Get size of a data
- @return
v_buff_size getDataSize()
# Caret::getDataMemoryHandle
Get data memoryHandle.
- @return
std::shared_ptr<std::string> getDataMemoryHandle()
# Caret::setPosition
Set caret position relative to data
- @param position
void setPosition(v_buff_size position)
# Caret::getPosition
Get caret position relative to data
- @return
v_buff_size getPosition()
# Caret::setError
Set error message and error code. Note that once error message is set, methods canContinue... will return false
- @param errorMessage
- @param errorCode
void setError(const char* errorMessage, v_int64 errorCode = 0)
# Caret::getErrorMessage
Get error message
- @return error message
const char* getErrorMessage()
# Caret::getErrorCode
Get error code
- @return error code
v_int64 getErrorCode()
# Caret::hasError
Check if error is set for the Caret
- @return
bool hasError()
# Caret::clearError
Clear error message and error code
void clearError()
# Caret::putLabel
Create Label(this);
- @return Label
Label putLabel()
# Caret::inc
- Increase caret position by one
void inc()
- Increase caret position by amount
- @param amount
void inc(v_buff_size amount)
# Caret::skipBlankChars
Skip chars: [' ', '\t', '\n', '\r','\f']
- @return true if other char found
bool skipBlankChars()
# Caret::skipChar
Skip char
- @param c
- @return true if other char found
bool skipChar(v_char8 c)
# Caret::findChar
Find char. Position will be set to a found char. If no such char found - position will be set to a dataSize;
- @param c
- @return true if found
bool findChar(v_char8 c)
# Caret::skipCharsFromSet
- Skip chars defined by set. ex. skipCharsFromSet("abc") - will skip all 'a', 'b', 'c' chars
- @param set
- @return true if other char found
bool skipCharsFromSet(const char* set)
- Skip chars defined by set. ex. skipCharsFromSet("abc", 3) - will skip all 'a', 'b', 'c' chars
- @param set
- @param setSize
- @return true if other char found
bool skipCharsFromSet(const char* set, v_buff_size setSize)
# Caret::findCharFromSet
- Find one of chars defined by set.
- @param set
- @return char found or -1 if no char found
v_buff_size findCharFromSet(const char* set)
- Find one of chars defined by set.
- @param set
- @param setSize
- @return char found or -1 if no char found
v_buff_size findCharFromSet(const char* set, v_buff_size setSize)
# Caret::findRN
Find "\r\n" chars
- @return true if found
bool findRN()
# Caret::skipRN
Skip "\r\n"
- @return True if position changes. False if caret not at "\r\n"
bool skipRN()
# Caret::isAtRN
Check if caret at "\r\n" chars
- @return
bool isAtRN()
# Caret::findROrN
Find '\r' char of '\n' char
- @return true if found '\r' or '\n'
bool findROrN()
# Caret::skipRNOrN
if at "\r\n" - skip. if at "\n" - skip.
- @return true if position changed
bool skipRNOrN()
# Caret::skipAllRsAndNs
skip any sequence of '\r' and '\n'
- @return true if position changed
bool skipAllRsAndNs()
# Caret::parseInt
parse integer value starting from the current position. Using function std::strtol() Warning: position may go out of Caret::getSize() bound.
- @param base - base is passed to std::strtol function
- @return parsed value
v_int64 parseInt(int base = 10)
# Caret::parseUnsignedInt
parse integer value starting from the current position. Using function std::strtoul() Warning: position may go out of Caret::getSize() bound.
- @param base - base is passed to std::strtoul function
- @return parsed value
v_uint64 parseUnsignedInt(int base = 10)
# Caret::parseFloat32
parse float value starting from the current position. Using function std::strtof() Warning: position may go out of Caret::getSize() bound.
- @return parsed value
v_float32 parseFloat32()
# Caret::parseFloat64
parse float value starting from the current position. Using function std::strtod() Warning: position may go out of Caret::getSize() bound.
- @return parsed value
v_float64 parseFloat64()
# Caret::isAtText
- Check if follows text
- @param text
- @param skipIfTrue - increase position if true
- @return
bool isAtText(const char* text, bool skipIfTrue = false)
- Check if follows text
- @param text
- @param textSize
- @param skipIfTrue - increase position if true
- @return
bool isAtText(const char* text, v_buff_size textSize, bool skipIfTrue = false)
# Caret::isAtTextNCS
- Check if follows text (Not Case Sensitive)
- @param text
- @param skipIfTrue - increase position if true
- @return
bool isAtTextNCS(const char* text, bool skipIfTrue = false)
- Check if follows text (Not Case Sensitive)
- @param text
- @param textSize
- @param skipIfTrue - increase position if true
- @return
bool isAtTextNCS(const char* text, v_buff_size textSize, bool skipIfTrue = false)
# Caret::parseStringEnclosed
Parse enclosed string. ex. for data "'let's go'" parseStringEnclosed(''', ''', '\') will return Label to "let's go" without enclosing ''' chars
- @param openChar
- @param closeChar
- @param escapeChar
- @return
Label parseStringEnclosed(char openChar, char closeChar, char escapeChar)
# Caret::findText
- Find text and set position to found text
- @param text
- @return true if found
bool findText(const char* text)
- Find text and set position to found text
- @param text
- @param textSize
- @return true if found
bool findText(const char* text, v_buff_size textSize)
# Caret::isAtCharFromSet
- Check if caret is at char defined by set ex. isAtCharFromSet("abc") - will return true for 'a', 'b', 'c' chars
- @param set
- @return
bool isAtCharFromSet(const char* set) const
- Check if caret is at char defined by set ex. isAtCharFromSet("abc", 3) - will return true for 'a', 'b', 'c' chars
- @param set
- @param setSize
- @return
bool isAtCharFromSet(const char* set, v_buff_size setSize) const
# Caret::isAtChar
Check if caret is at char
- @param c
- @return
bool isAtChar(v_char8 c) const
# Caret::isAtBlankChar
Check if caret is at one of chars [' ', '\t', '\n', '\r','\f']
- @return
bool isAtBlankChar() const
# Caret::isAtDigitChar
Check if caret is at digit
- @return
bool isAtDigitChar() const
# Caret::canContinueAtChar
- Check if caret is at char, and no error is set
- @param c
- @return
bool canContinueAtChar(v_char8 c) const
- Check if caret is at char, and no error is set. If true inc position by skipChars
- @param c
- @param skipChars
- @return
bool canContinueAtChar(v_char8 c, v_buff_size skipChars)
# Caret::canContinue
Check if caret position < dataSize and not error is set
- @return
bool canContinue() const
# Caret::Label
Class to label parsing data.
namespace oatpp { namespace parser {
class Caret {
class Label {}
};
}}
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | Label | Constructor. |
void | start | Set current caret position as a starting point for label. |
void | end | Fix current caret position as an end point for label. |
const char* | getData | Get pointer to a labeled data. |
v_buff_size | getSize | Get size of labeled data. |
v_buff_size | getStartPosition | Get start position of the label. |
v_buff_size | getEndPosition | Get end position of the label. |
oatpp::String | toString | Same astoString(true). |
std::string | std_str | Create std::string from labeled data. |
# Caret::Label::Label
Constructor.
- @param caret.
Label(Caret* caret)
# Caret::Label::start
Set current caret position as a starting point for label.
void start()
# Caret::Label::end
Fix current caret position as an end point for label.
void end()
# Caret::Label::getData
Get pointer to a labeled data.
- @return
const char* getData()
# Caret::Label::getSize
Get size of labeled data.
- @return
v_buff_size getSize()
# Caret::Label::getStartPosition
Get start position of the label.
- @return
v_buff_size getStartPosition()
# Caret::Label::getEndPosition
Get end position of the label.
- @return - end position of the label or
-1
if end() wasn't called yet.
v_buff_size getEndPosition()
# Caret::Label::toString
Same astoString(true).
- @return - oatpp::String.
oatpp::String toString()
# Caret::Label::std_str
Create std::string
from labeled data.
- @return -
std::string
.
std::string std_str()
# Caret::StateSaveGuard
Caret state saver guard.
namespace oatpp { namespace parser {
class Caret {
class StateSaveGuard {}
};
}}
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | StateSaveGuard | Constructor. |
[none] | ~StateSaveGuard | Destructor. Restore saved state. |
v_buff_size | getSavedPosition | Get caret saved position. |
const char* | getSavedErrorMessage | Get caret saved error message. |
v_int64 | getSavedErrorCode | Get caret saved error code. |
# Caret::StateSaveGuard::StateSaveGuard
Constructor.
- @param caret.
StateSaveGuard(Caret& caret)
# Caret::StateSaveGuard::~StateSaveGuard
Destructor. Restore saved state.
~StateSaveGuard()
# Caret::StateSaveGuard::getSavedPosition
Get caret saved position.
- @return
v_buff_size getSavedPosition()
# Caret::StateSaveGuard::getSavedErrorMessage
Get caret saved error message.
- @return
const char* getSavedErrorMessage()
# Caret::StateSaveGuard::getSavedErrorCode
Get caret saved error code.
- @return
v_int64 getSavedErrorCode()