Pakman
utils.h File Reference
#include <string>
#include <vector>
#include <map>
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool is_whitespace (const char letter)
 
std::vector< std::string > parse_command_tokens (const std::string &raw_command)
 
std::vector< std::string > parse_tokens (const std::string &str, const std::string &delimiters=" ")
 
std::map< std::string, std::string > parse_key_value_pairs (const std::string &str)
 

Detailed Description

Utility functions.

Definition in file utils.h.

Function Documentation

◆ is_whitespace()

bool is_whitespace ( const char  letter)

Check if letter is a space, tab or newline.

Parameters
letterletter to check.
Returns
whether letter is space, tab or newline.

Definition at line 11 of file utils.cc.

◆ parse_command_tokens()

std::vector<std::string> parse_command_tokens ( const std::string &  raw_command)

Parses raw command string.

Parameters
raw_commandraw command string.
Returns
vector of command tokens.

Definition at line 18 of file utils.cc.

◆ parse_key_value_pairs()

std::map<std::string, std::string> parse_key_value_pairs ( const std::string &  str)

Splits string into key value pairs.

The raw string must contain key value pairs in the format key1=value1; key2=value2; ...; keyn=valuen. The characters = and ; may be escaped with the backslash (\) if it appears in the key or the value string.

Parameters
strraw string.
Returns
map of key value pairs.

Definition at line 209 of file utils.cc.

◆ parse_tokens()

std::vector<std::string> parse_tokens ( const std::string &  str,
const std::string &  delimiters = " " 
)

Splits string into tokens with given delimiters.

Parameters
strraw string.
delimitersstring containing all delimiters.
Returns
vector of tokens.

Definition at line 190 of file utils.cc.