## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# csAnsiParser Class Reference
[Utilities]

Helper to parse a string for ANSI codes. More...

`#include <csutil/ansiparse.h>`

List of all members.

## Public Types

| attrBlink
| 'Blink' attribute
| attrBold
| 'Bold' attribute
| attrDim
| 'Dim' attribute
| attrInvisible
| 'Invisible' attribute
| attrItalics
| 'Italics' attribute
| attrReverse
| 'Reverse' attribute
| attrStrikethrough
| 'Strikethrough' attribute
| attrUnderline
| 'Underline' attribute
| classClear
| A screen clear sequence was found.
| classCursor
| A cursor movement sequence was found.
| classFormat
| A formatting sequence was found.
| classNone
| No ANSI sequence was found.
| classUnknown
| An ANSI sequence was found, but not recognized.
| cmdClearLine
| 'Clear end of line'
| cmdClearScreen
| 'Clear screen'
| cmdCursorMoveRelative
| Move cursor specified number of lines and columns relative to current position.
| cmdCursorSetPosition
| 'Set cursor position'
| cmdFormatAttrBackground
| 'Set background color'
| cmdFormatAttrDisable
| 'Disable attribute'
| cmdFormatAttrEnable
| 'Enable attribute'
| cmdFormatAttrForeground
| 'Set foreground color'
| cmdFormatAttrReset
| Reset all attributes.
| cmdUnknown
| Command was unrecognized.
| colBlack
| Black.
| colBlue
| Blue.
| colCyan
| Cyan.
| colGreen
| Green.
| colMagenta
| Magenta.
| colNone = -1
| None specified.
| colRed
| Red.
| colWhite
| White.
| colYellow
| Yellow.
enum | Command { cmdUnknown, cmdFormatAttrReset, cmdFormatAttrEnable, cmdFormatAttrDisable, cmdFormatAttrForeground, cmdFormatAttrBackground, cmdClearScreen, cmdClearLine, cmdCursorSetPosition, cmdCursorMoveRelative }
| Identifier for the ANSI command. More...
enum | CommandClass { classNone, classUnknown, classFormat, classClear, classCursor }
| Classification of the command sequence. More...
enum | FormatAttr { attrBold, attrItalics, attrUnderline, attrBlink, attrReverse, attrStrikethrough, attrDim, attrInvisible }
| Types of attributes in the cmdFormatAttrEnable/cmdFormatAttrBackground command. More...
enum | FormatColor { colNone = -1, colBlack, colRed, colGreen, colYellow, colBlue, colMagenta, colCyan, colWhite }
| Values for foreground/background color. More...

## Static Public Member Functions

static bool | DecodeCommand (const char *&cmd, size_t &cmdLen, Command &command, CommandParams &commandParams)
| Decode an ANSI code sequence.
static bool | ParseAnsi (const char *str, size_t &ansiCommandLen, CommandClass &cmdClass, size_t &textLen)
| Parse a string for ANSI codes.

## Classes

struct | CommandParams
| Parameters to ANSI command. More...
struct | CursorParams

## Detailed Description

Helper to parse a string for ANSI codes.

Definition at line 33 of file ansiparse.h.

## Member Enumeration Documentation

enum csAnsiParser::Command

Identifier for the ANSI command.

Enumerator:

  cmdUnknown | Command was unrecognized.
  cmdFormatAttrReset | Reset all attributes.
  cmdFormatAttrEnable | 'Enable attribute'
  cmdFormatAttrDisable | 'Disable attribute'
  cmdFormatAttrForeground | 'Set foreground color'
  cmdFormatAttrBackground | 'Set background color'
  cmdClearScreen | 'Clear screen'
  cmdClearLine | 'Clear end of line'
  cmdCursorSetPosition | 'Set cursor position'
  cmdCursorMoveRelative | Move cursor specified number of lines and columns relative to current position.

Definition at line 37 of file ansiparse.h.

enum csAnsiParser::CommandClass

Classification of the command sequence.

Enumerator:

  classNone | No ANSI sequence was found.
  classUnknown | An ANSI sequence was found, but not recognized.
  classFormat | A formatting sequence was found.
  classClear | A screen clear sequence was found.
  classCursor | A cursor movement sequence was found.

Definition at line 61 of file ansiparse.h.

enum csAnsiParser::FormatAttr

Types of attributes in the cmdFormatAttrEnable/cmdFormatAttrBackground command.

Enumerator:

  attrBold | 'Bold' attribute
  attrItalics | 'Italics' attribute
  attrUnderline | 'Underline' attribute
  attrBlink | 'Blink' attribute
  attrReverse | 'Reverse' attribute
  attrStrikethrough | 'Strikethrough' attribute
  attrDim | 'Dim' attribute
  attrInvisible | 'Invisible' attribute

Definition at line 78 of file ansiparse.h.

enum csAnsiParser::FormatColor

Values for foreground/background color.

Enumerator:

  colNone | None specified.
  colBlack | Black.
  colRed | Red.
  colGreen | Green.
  colYellow | Yellow.
  colBlue | Blue.
  colMagenta | Magenta.
  colCyan | Cyan.
  colWhite | White.

Definition at line 98 of file ansiparse.h.

## Member Function Documentation

static bool csAnsiParser::DecodeCommand | ( | const char *& | cmd,
|  | size_t & | cmdLen,
|  | Command & | command,
|  | CommandParams & | commandParams |
| ) |  |  | `[static]`

Decode an ANSI code sequence.

Decodes a part of an ANSI code sequence, if known.

Remarks:
  Multiple sequences might occur, repeated call this function until `false` is returned.

Parameters:

  | cmd | String to decode. Updated to point to the start of the next sequence part.
  | cmdLen | Returns length of the command in chars.
  | command | The decoded command.
  | commandParams | Parameters for the decoded command.

Returns:
  Whether the decoding was successful.

static bool csAnsiParser::ParseAnsi | ( | const char * | str,
|  | size_t & | ansiCommandLen,
|  | CommandClass & | cmdClass,
|  | size_t & | textLen |
| ) |  |  | `[static]`

Parse a string for ANSI codes.

Looks if a string contains an ANSI code sequence at the beginning. If yes, the ansiCommandLen parameter is filled with the length of the sequence.

Parameters:

  | str | String to parse.
  | ansiCommandLen | Returns number of chars that the ANSI command takes up.
  | cmdClass | Returns the ANSI command class.
  | textLen | Contains the number of chars up to the next ANSI sequence or the end of the string of no sequence was found.

Returns:
  Whether the parsing was successful.

The documentation for this class was generated from the following file:

- csutil/ansiparse.h