Click
Loading...
Searching...
No Matches
confparse.hh File Reference

Support for parsing configuration strings. More...

Go to the source code of this file.

Functions

Argument Manipulation
const char * cp_skip_space (const char *begin, const char *end)
 Find the first nonspace character in the string [begin, end).
 
const char * cp_skip_comment_space (const char *begin, const char *end)
 Find the first nonspace, noncomment character in the string [begin, end).
 
const char * cp_skip_double_quote (const char *begin, const char *end)
 Return the first character after a double-quoted string starting at begin.
 
bool cp_eat_space (String &str)
 Remove spaces from the beginning of str.
 
bool cp_is_space (const String &str)
 Test if str is all spaces.
 
bool cp_is_word (const String &str)
 Test whether str is a valid "word".
 
bool cp_is_click_id (const String &str)
 Test if str is a valid Click identifier.
 
String cp_uncomment (const String &str)
 Simplify str's whitespace and replace comments by spaces, returning the result.
 
String cp_unquote (const String &str)
 Remove one level of quoting from str, returning the result.
 
const char * cp_process_backslash (const char *begin, const char *end, StringAccum &sa)
 Process a backslash escape, appending results to sa.
 
String cp_quote (const String &str, bool allow_newlines=false)
 Return a quoted version of str.
 
void cp_argvec (const String &str, Vector< String > &conf)
 Separate a configuration string into arguments at commas.
 
String cp_unargvec (const Vector< String > &conf)
 Join the strings of conf with commas and return the result.
 
void cp_spacevec (const String &str, Vector< String > &conf)
 Separate a configuration string into arguments at unquoted spaces.
 
String cp_shift_spacevec (String &str)
 Remove and return the first space-separated argument from str.
 
String cp_unspacevec (const String *begin, const String *end)
 Join the strings in [begin, end) with spaces and return the result.
 
String cp_unspacevec (const Vector< String > &conf)
 Join the strings in conf with spaces and return the result.
 
String cp_shift_delimiter (String &str, char delim)
 Remove and return the first delimiter-separated argument from str.
 
Unparsing
String cp_unparse_bool (bool value)
 
String cp_unparse_real2 (int32_t value, int frac_bits)
 
String cp_unparse_real2 (uint32_t value, int frac_bits)
 
String cp_unparse_real2 (int64_t value, int frac_bits)
 
String cp_unparse_real2 (uint64_t value, int frac_bits)
 
String cp_unparse_real10 (int32_t value, int frac_digits)
 
String cp_unparse_real10 (uint32_t value, int frac_digits)
 
String cp_unparse_milliseconds (uint32_t value)
 
String cp_unparse_microseconds (uint32_t value)
 
String cp_unparse_interval (const Timestamp &value)
 
String cp_unparse_interval (const struct timeval &value)
 
String cp_unparse_bandwidth (uint32_t value)
 
Legacy Functions
int cp_va_parse (const Vector< String > &conf, const Element *context, ErrorHandler *errh,...)
 Legacy function for parsing a list of arguments.
 
int cp_va_parse (const String &str, const Element *context, ErrorHandler *errh,...)
 Legacy function for parsing a comma-separated argument string.
 
int cp_va_space_parse (const String &str, const Element *context, ErrorHandler *errh,...)
 Legacy function for parsing a space-separated argument string.
 
int cp_va_parse_keyword (const String &str, const Element *context, ErrorHandler *errh,...)
 Legacy function for parsing a single argument.
 
int cp_va_parse_remove_keywords (Vector< String > &conf, int first, const Element *context, ErrorHandler *errh,...)
 Legacy function for parsing and removing matching arguments from conf.
 

Direct Parsing Functions

#define CP_REAL2_MAX_FRAC_BITS   28
 
enum  CpErrors {
  CPE_OK = 0 , CPE_FORMAT , CPE_NEGATIVE , CPE_OVERFLOW ,
  CPE_INVALID , CPE_MEMORY , CPE_NOUNITS
}
 
enum  { cp_basic_integer_whole = 64 }
 
int cp_errno
 
bool cp_string (const String &str, String *result, String *rest=0)
 Parse a string from str.
 
bool cp_word (const String &str, String *result, String *rest=0)
 Parse a word from str.
 
bool cp_keyword (const String &str, String *result, String *rest=0)
 Parse a keyword from str.
 
bool cp_bool (const String &str, bool *result)
 Parse a boolean from str.
 
const char * cp_basic_integer (const char *begin, const char *end, int flags, int size, void *result)
 
const char * cp_integer (const char *begin, const char *end, int base, int *result)
 Parse an integer from [begin, end) in base base.
 
const char * cp_integer (const char *begin, const char *end, int base, unsigned *result)
 
const char * cp_integer (const char *begin, const char *end, int base, long *result)
 
const char * cp_integer (const char *begin, const char *end, int base, unsigned long *result)
 
const char * cp_integer (const char *begin, const char *end, int base, int64_t *result)
 
const char * cp_integer (const char *begin, const char *end, int base, uint64_t *result)
 
bool cp_integer (const String &str, int base, int *result)
 Parse an integer from str in base base.
 
bool cp_integer (const String &str, int base, unsigned int *result)
 
bool cp_integer (const String &str, int base, long *result)
 
bool cp_integer (const String &str, int base, unsigned long *result)
 
bool cp_integer (const String &str, int base, int64_t *result)
 
bool cp_integer (const String &str, int base, uint64_t *result)
 
bool cp_integer (const String &str, int *result)
 Parse an integer from str in base 0.
 
bool cp_integer (const String &str, unsigned int *result)
 
bool cp_integer (const String &str, long *result)
 
bool cp_integer (const String &str, unsigned long *result)
 
bool cp_integer (const String &str, int64_t *result)
 
bool cp_integer (const String &str, uint64_t *result)
 
bool cp_real2 (const String &str, int frac_bits, int32_t *result)
 Parse a fixed-point number from str.
 
bool cp_real2 (const String &str, int frac_bits, uint32_t *result)
 
bool cp_real10 (const String &str, int frac_digits, int32_t *result)
 Parse a real number from str, representing the result as an integer with frac_digits decimal digits of fraction.
 
bool cp_real10 (const String &str, int frac_digits, uint32_t *result)
 
bool cp_real10 (const String &str, int frac_digits, uint32_t *result_int, uint32_t *result_frac)
 Parse a real number from str, representing the result as an integer with frac_digits decimal digits of fraction.
 
bool cp_double (const String &str, double *result)
 Parse a real number from str.
 
bool cp_seconds_as (const String &str, int frac_digits, uint32_t *result)
 Parse an amount of time from str.
 
bool cp_seconds_as_milli (const String &str, uint32_t *result)
 Parse an amount of time in milliseconds from str.
 
bool cp_seconds_as_micro (const String &str, uint32_t *result)
 Parse an amount of time in microseconds from str.
 
bool cp_seconds (const String &str, double *result)
 Parse an amount of time from str.
 
bool cp_time (const String &str, Timestamp *result, bool allow_negative=false)
 Parse a timestamp from str.
 
bool cp_time (const String &str, struct timeval *result)
 
bool cp_bandwidth (const String &str, uint64_t *result)
 Parse a bandwidth value from str.
 
bool cp_ip_address (const String &str, IPAddress *result, const Element *context=0)
 Parse an IP address from str.
 
bool cp_ip_address (const String &str, struct in_addr *result, const Element *context=0)
 
bool cp_ip_address (const String &str, unsigned char *result, const Element *context=0)
 
bool cp_ip_prefix (const String &str, IPAddress *result_addr, IPAddress *result_mask, bool allow_bare_address, const Element *context=0)
 Parse an IP address or prefix from str.
 
bool cp_ip_prefix (const String &str, unsigned char *result_addr, unsigned char *result_mask, bool allow_bare_address, const Element *context=0)
 
bool cp_ip_prefix (const String &str, IPAddress *result_addr, IPAddress *result_mask, const Element *context=0)
 
bool cp_ip_prefix (const String &str, unsigned char *result_addr, unsigned char *result_mask, const Element *context=0)
 
bool cp_ip_address_list (const String &str, Vector< IPAddress > *result, const Element *context=0)
 Parse a space-separated list of IP addresses from str.
 
bool cp_ip6_address (const String &str, IP6Address *result, const Element *context=0)
 Parse an IPv6 address from str.
 
bool cp_ip6_address (const String &str, struct in6_addr *result, const Element *context=0)
 
bool cp_ip6_address (const String &str, unsigned char *result, const Element *context=0)
 
bool cp_ip6_prefix (const String &str, IP6Address *result_addr, int *result_prefix, bool allow_bare_address, const Element *context=0)
 Parse an IPv6 address or prefix from str.
 
bool cp_ip6_prefix (const String &str, unsigned char *result_addr, int *result_prefix, bool allow_bare_address, const Element *context=0)
 
bool cp_ip6_prefix (const String &str, unsigned char *result_addr, unsigned char *result_mask, bool allow_bare_address, const Element *context=0)
 
bool cp_ip6_prefix (const String &str, IP6Address *result_addr, IP6Address *result_mask, bool allow_bare_address, const Element *context=0)
 
bool cp_ethernet_address (const String &str, EtherAddress *result, const Element *context=0)
 Parse an Ethernet address from str.
 
bool cp_ethernet_address (const String &str, unsigned char *result, const Element *context=0)
 
bool cp_tcpudp_port (const String &str, int proto, uint16_t *result, const Element *context=0)
 Parse a TCP, UDP, etc. port number from str.
 
Element * cp_element (const String &str, const Element *context, ErrorHandler *errh=0, const char *argname=0)
 Parse an element reference from str.
 
Element * cp_element (const String &str, Router *router, ErrorHandler *errh=0, const char *argname=0)
 Parse an element reference from str.
 
bool cp_handler_name (const String &str, Element **result_element, String *result_hname, const Element *context, ErrorHandler *errh=0)
 Parse a handler name from str.
 
bool cp_handler (const String &str, int flags, Element **result_element, const Handler **result_handler, const Element *context, ErrorHandler *errh=0)
 Parse a handler reference from str.
 
bool cp_filename (const String &str, String *result)
 Parse a filename string from str.
 
bool cp_file_offset (const String &str, off_t *result)
 Parse a file offset from str.
 
bool cp_anno (const String &str, int size, int *result, const Element *context=0)
 Parse a packet annotation value from str.
 

cp_va_kparse

enum  CpKparseFlags {
  cpkN = 0 , cpkM = 1 , cpkP = 2 , cpkC = 4 ,
  cpkD = 8 , cpkNormal = cpkN , cpkMandatory = cpkM , cpkPositional = cpkP ,
  cpkConfirm = cpkC , cpkDeprecated = cpkD
}
 Type of flags for cp_va_kparse() items. More...
 
typedef const char * CpVaParseCmd
 Type of argument type names for cp_va_kparse() items.
 
const CpVaParseCmd cpEnd
 Use as argument name. Ends cp_va argument list.
 
const CpVaParseCmd cpIgnoreRest
 Use as argument name. No result storage; causes cp_va_kparse() to ignore unparsed arguments and any remaining items.
 
const CpVaParseCmd cpIgnore
 No result storage, ignores this argument.
 
const CpVaParseCmd cpArgument
 Result storage String*, accepts any argument.
 
const CpVaParseCmd cpArguments
 Result storage Vector<String>*, accepts any number of arguments with the same keyword.
 
const CpVaParseCmd cpString
 Result storage String*, parsed by cp_string().
 
const CpVaParseCmd cpWord
 Result storage String*, parsed by cp_word().
 
const CpVaParseCmd cpKeyword
 Result storage String*, parsed by cp_keyword().
 
const CpVaParseCmd cpBool
 Result storage bool*, parsed by cp_bool().
 
const CpVaParseCmd cpByte
 Result storage unsigned char*, parsed by cp_integer().
 
const CpVaParseCmd cpShort
 Result storage short*, parsed by cp_integer().
 
const CpVaParseCmd cpUnsignedShort
 Result storage unsigned short*, parsed by cp_integer().
 
const CpVaParseCmd cpInteger
 Result storage int32_t*, parsed by cp_integer().
 
const CpVaParseCmd cpUnsigned
 Result storage uint32_t*, parsed by cp_integer().
 
const CpVaParseCmd cpSize
 Result storage size_t*, parsed by cp_integer().
 
const CpVaParseCmd cpNamedInteger
 Parse parameter uint32_t nameinfo_type, result storage int32_t*, parsed by NameInfo::query_int.
 
const CpVaParseCmd cpInteger64
 Result storage int64_t*, parsed by cp_integer().
 
const CpVaParseCmd cpUnsigned64
 Result storage uint64_t*, parsed by cp_integer().
 
const CpVaParseCmd cpUnsignedReal2
 Parse parameter int frac_bits, result storage uint32_t*, parsed by cp_real2().
 
const CpVaParseCmd cpReal10
 Parse parameter int frac_digits, result storage int32_t*, parsed by cp_real10().
 
const CpVaParseCmd cpUnsignedReal10
 Parse parameter int frac_digits, result storage uint32_t*, parsed by cp_real10().
 
const CpVaParseCmd cpDouble
 Result storage double*, parsed by cp_double().
 
const CpVaParseCmd cpSeconds
 Result storage uint32_t*, parsed by cp_seconds_as() with frac_digits 0.
 
const CpVaParseCmd cpSecondsAsMilli
 Result storage uint32_t*, parsed by cp_seconds_as_milli().
 
const CpVaParseCmd cpSecondsAsMicro
 Result storage uint32_t*, parsed by cp_seconds_as_micro().
 
const CpVaParseCmd cpTimestamp
 Result storage Timestamp*, parsed by cp_time().
 
const CpVaParseCmd cpTimestampSigned
 Result storage Timestamp*, parsed by cp_time().
 
const CpVaParseCmd cpTimeval
 Result storage struct timeval*, parsed by cp_time().
 
const CpVaParseCmd cpBandwidth
 Result storage uint32_t*, parsed by cp_bandwidth().
 
const CpVaParseCmd cpIPAddress
 Result storage IPAddress* or equivalent, parsed by cp_ip_address().
 
const CpVaParseCmd cpIPPrefix
 Result storage IPAddress* addr and IPAddress *mask, parsed by cp_ip_prefix().
 
const CpVaParseCmd cpIPAddressOrPrefix
 Result storage IPAddress* addr and IPAddress *mask, parsed by cp_ip_prefix().
 
const CpVaParseCmd cpIPAddressList
 Result storage Vector<IPAddress>*, parsed by cp_ip_address_list().
 
const CpVaParseCmd cpEtherAddress
 Result storage EtherAddress*, parsed by cp_ethernet_address().
 
const CpVaParseCmd cpEthernetAddress
 Result storage EtherAddress*, parsed by cp_ethernet_address(). Synonym for cpEtherAddress.
 
const CpVaParseCmd cpTCPPort
 Result storage uint16_t*, parsed by cp_tcpudp_port().
 
const CpVaParseCmd cpUDPPort
 Result storage uint16_t*, parsed by cp_tcpudp_port().
 
const CpVaParseCmd cpElement
 Result storage Element**, parsed by cp_element().
 
const CpVaParseCmd cpElementCast
 Parse parameter const char*, result storage void**, parsed by cp_element() and Element::cast().
 
const CpVaParseCmd cpHandlerName
 Result storage Element** and String*, parsed by cp_handler_name().
 
const CpVaParseCmd cpHandlerCallRead
 Result storage HandlerCall*, parsed by HandlerCall.
 
const CpVaParseCmd cpHandlerCallWrite
 Result storage HandlerCall*, parsed by HandlerCall.
 
const CpVaParseCmd cpHandlerCallPtrRead
 Result storage HandlerCall**, parsed by HandlerCall::reset_read.
 
const CpVaParseCmd cpHandlerCallPtrWrite
 Result storage HandlerCall**, parsed by HandlerCall::reset_write.
 
const CpVaParseCmd cpIP6Address
 Result storage IP6Address* or equivalent, parsed by cp_ip6_address().
 
const CpVaParseCmd cpIP6Prefix
 Result storage IP6Address* addr and IP6Address* mask, parsed by cp_ip6_prefix().
 
const CpVaParseCmd cpIP6PrefixLen
 Result storage IP6Address* addr and int* prefix_len, parsed by cp_ip6_prefix().
 
const CpVaParseCmd cpIP6AddressOrPrefix
 Result storage IP6Address* addr and IP6Address* mask, parsed by cp_ip6_prefix().
 
const CpVaParseCmd cpFilename
 Result storage String*, parsed by cp_filename().
 
const CpVaParseCmd cpFileOffset
 Result storage off_t*, parsed by cp_integer().
 
const CpVaParseCmd cpAnno
 Parse parameter int annotation_size, result storage int*, parsed by cp_anno().
 
const CpVaParseCmd cpOptional
 cp_va_parse only: Following arguments are optional.
 
const CpVaParseCmd cpKeywords
 cp_va_parse only: Following arguments are keywords.
 
const CpVaParseCmd cpConfirmKeywords
 cp_va_parse only: Following arguments are confirmed keywords.
 
const CpVaParseCmd cpMandatoryKeywords
 cp_va_parse only: Following arguments are mandatory keywords.
 
const CpVaParseCmd cpInterval CLICK_CONFPARSE_DEPRECATED
 
int cp_va_kparse (const Vector< String > &conf, const Element *context, ErrorHandler *errh,...) CP_SENTINEL
 Parse a list of arguments.
 
int cp_va_kparse (const String &str, const Element *context, ErrorHandler *errh,...) CP_SENTINEL
 Parse a comma-separated argument string.
 
int cp_va_space_kparse (const String &str, const Element *context, ErrorHandler *errh,...) CP_SENTINEL
 Parse a space-separated argument string.
 
int cp_va_kparse_keyword (const String &str, const Element *context, ErrorHandler *errh,...) CP_SENTINEL
 Parse a single argument.
 
int cp_va_kparse_remove_keywords (Vector< String > &conf, const Element *context, ErrorHandler *errh,...) CP_SENTINEL
 Parse and remove matching arguments from conf.
 
int cp_assign_arguments (const Vector< String > &argv, const String *param_begin, const String *param_end, Vector< String > *values=0)
 Assign arguments from argv to values.
 
void cp_va_static_initialize ()
 Initialize the cp_va_kparse() implementation.
 
void cp_va_static_cleanup ()
 Clean up the cp_va_kparse() implementation.
 

Argument Types for cp_va_kparse()

enum  {
  cpArgNormal = 0 , cpArgStore2 = 1 , cpArgExtraInt = 2 , cpArgExtraCStr = 4 ,
  cpArgAllowNumbers = 8
}
 
typedef void(* cp_parsefunc) (cp_value *value, const String &arg, ErrorHandler *errh, const char *argdesc, const Element *context)
 
typedef void(* cp_storefunc) (cp_value *value, const Element *context)
 
int cp_register_argtype (const char *name, const char *description, int flags, cp_parsefunc parsefunc, cp_storefunc storefunc, void *user_data=0)
 
void cp_unregister_argtype (const char *name)
 
int cp_register_stringlist_argtype (const char *name, const char *description, int flags)
 
int cp_extend_stringlist_argtype (const char *name,...)
 

Detailed Description

Support for parsing configuration strings.

Defines functions and helpers for parsing configuration strings into numbers, IP addresses, and other useful types.

cp_va_kparse Introduction

Most elements that take configuration strings parse them using the cp_va_kparse() function and friends. These functions take a variable argument list describing the desired arguments and result slots. They parse the configuration, store the results in the slots, report any errors, and return the number of arguments successfully assigned on success or a negative value on failure.

Note
Previous versions of Click used cp_va_parse() and friends instead of cp_va_kparse(). A guide for transitioning from cp_va_parse() to cp_va_kparse() is given in the documentation for cp_va_parse().

Here are some cp_va_kparse() examples.

int MyElement::configure(Vector<String> &conf, ErrorHandler *errh) {
String data; uint32_t limit = 0; bool stop = false;
if (cp_va_kparse(conf, this, errh,
"DATA", cpkP+cpkM, cpString, &data,
"LIMIT", cpkP, cpUnsigned, &limit,
"STOP", 0, cpBool, &stop,
cpEnd) < 0) // argument list always terminated by cpEnd
return -1;
... }
Error reporting class.
Definition error.hh:90
A string of characters.
Definition string.hh:22
Vector template.
Definition vector.hh:111
const CpVaParseCmd cpUnsigned
Result storage uint32_t*, parsed by cp_integer().
Definition confparse.hh:266
const CpVaParseCmd cpEnd
Use as argument name. Ends cp_va argument list.
Definition confparse.cc:2197
@ cpkP
Argument may be specified positionally.
Definition confparse.hh:239
@ cpkM
Argument is mandatory.
Definition confparse.hh:238
const CpVaParseCmd cpBool
Result storage bool*, parsed by cp_bool().
Definition confparse.hh:261
const CpVaParseCmd cpString
Result storage String*, parsed by cp_string().
Definition confparse.hh:258
int cp_va_kparse(const Vector< String > &conf, const Element *context, ErrorHandler *errh,...) CP_SENTINEL
Parse a list of arguments.
Definition confparse.cc:3779

This element supports three arguments, DATA (a string), LIMIT (an unsigned integer), and STOP (a boolean). Here are some example element definitions:

MyElement(DATA "blah blah blah", LIMIT 10);
/* OK, sets data = "blah blah blah", limit = 10; leaves stop unchanged */
MyElement(LIMIT 10, DATA "blah blah blah");
/* OK, has the same effect */
MyElement(LIMIT 10);
/* error "missing mandatory DATA argument" */
/* (the cpkM flag marks an argument as mandatory) */
MyElement(DATA "blah blah blah");
/* OK, sets data = "blah blah blah" and leaves limit unchanged */
/* (LIMIT lacks the cpkM flag, so it can be left off) */
MyElement(DATA "blah blah blah", STOP true);
/* OK, sets data = "blah blah blah" and stop = true */
/* (LIMIT lacks the cpkM flag, so it can be left off) */
MyElement(DATA "blah blah blah", LIMIT 10, DATA "blah");
/* OK, sets data = "blah" (later arguments take precedence) */
MyElement(DATA "blah blah blah", LIMIT 10, BOGUS "bogus");
/* error "too many arguments" */
MyElement("blah blah blah", 10);
/* OK, same as MyElement(DATA "blah blah blah", LIMIT 10) */
/* (the cpkP flag allows positional arguments) */
MyElement("blah blah blah", 10, true);
/* error "too many arguments" */
/* (STOP lacks the cpkP flag and must be given by name) */

cp_va_kparse Items

An item in a cp_va_kparse() argument list consists of:

  1. Argument name (type: const char *). Example: "DATA".
  2. Parse flags (type: int). Zero or more of cpkP, cpkM, and cpkC.
  3. If the parse flags contain cpkC, then a confirmation flag comes next (type: bool *). This flag is set to true if an argument successfully matched the item and false if not.
  4. Argument type (type: CpVaParseCmd). Defines the type of argument read from the configuration string. Example: cpString.
  5. Optional parse parameters (determined by the argument type). For example, cpUnsignedReal2 takes a parse parameter that defines how many bits of fraction are needed.
  6. Result storage (determined by the argument type).

This example uses more of these features.

int MyElement2::configure(Vector<String> &conf, ErrorHandler *errh) {
bool p_given; uint32_t p = 0x10000; IPAddress addr, mask;
if (cp_va_kparse(conf, this, errh,
"P", cpkC, &p_given, cpUnsignedReal2, 16, &p,
"NETWORK", 0, cpIPPrefix, &addr, &mask,
cpEnd) < 0)
return -1;
... }
An IPv4 address.
Definition ipaddress.hh:16
const CpVaParseCmd cpIPPrefix
Result storage IPAddress* addr and IPAddress *mask, parsed by cp_ip_prefix().
Definition confparse.hh:287
const CpVaParseCmd cpUnsignedReal2
Parse parameter int frac_bits, result storage uint32_t*, parsed by cp_real2().
Definition confparse.hh:273
@ cpkC
Argument presence should be confirmed.
Definition confparse.hh:240

This element supports two arguments, P (a fixed-point number with 16 bits of fraction) and NETWORK (an IP prefix, defined by address and mask). Here are some example element definitions:

MyElement2();
/* OK, since neither argument is mandatory; sets p_given = false */
MyElement2(P 0.5, PREFIX 10/8);
/* OK, sets p_given = true, p = 0x8000, addr = 10.0.0.0, and mask = 255.0.0.0 */

cp_va_kparse Argument Types

cp_va_kparse() argument types are defined by CpVaParseCmd constants. For example, the cpInteger argument type parses a 32-bit signed integer. See CpVaParseCmd for more. Elements may also define their own argument types with cp_register_argtype().

Direct Parsing Functions

You may also call parsing functions directly if cp_va_kparse() doesn't match your needs. These functions have names like cp_bool(), cp_string(), cp_integer(), cp_ip_address(), and so forth, and share a basic interface:

Argument Manipulation

Finally, functions like cp_uncomment(), cp_unquote(), cp_quote(), cp_argvec(), and cp_is_space() manipulate arguments as strings. cp_uncomment() removes comments and simplifies white space; cp_unquote() removes quotation marks and expands backslash escapes; cp_argvec() splits a configuration string at commas; and so forth.

Typedef Documentation

◆ CpVaParseCmd

typedef const char* CpVaParseCmd

Type of argument type names for cp_va_kparse() items.

Enumeration Type Documentation

◆ CpKparseFlags

Type of flags for cp_va_kparse() items.

Enumerator
cpkN 

Default flags.

cpkM 

Argument is mandatory.

cpkP 

Argument may be specified positionally.

cpkC 

Argument presence should be confirmed.

cpkD 

Argument is deprecated.

Function Documentation

◆ cp_skip_space()

const char * cp_skip_space ( const char *  begin,
const char *  end 
)

Find the first nonspace character in the string [begin, end).

Parameters
beginbeginning of string
endone past end of string
Returns
Pointer to first non-space character in [begin, end), or end if the string is all spaces.

Space characters are defined as by isspace() in the "C" locale, and consist of the characters in [ \f\n\r\t\v].

◆ cp_skip_comment_space()

const char * cp_skip_comment_space ( const char *  begin,
const char *  end 
)

Find the first nonspace, noncomment character in the string [begin, end).

Parameters
beginbeginning of string
endone past end of string
Returns
Pointer to first nonspace and noncomment character in [begin, end), or end if the string is all spaces and comments.

This function recognizes C-style and C++-style comments:

/* C style */ // C++ style (runs until newline)

In C++-style comments, the character sequences "\n", "\r", and "\r\n" are recognized as newlines. The newline is considered part of the comment.

◆ cp_skip_double_quote()

const char * cp_skip_double_quote ( const char *  begin,
const char *  end 
)

Return the first character after a double-quoted string starting at begin.

Parameters
beginbeginning of double-quoted string
endone past end of string
Returns
Pointer to first character in [begin, end) after the double-quoted string, or end if the double-quoted portion is not correctly terminated.
Precondition
begin < end and *begin == '"'

cp_skip_double_quote() understands all the backslash escapes processed by cp_process_backslash().

◆ cp_eat_space()

bool cp_eat_space ( String &  str)

Remove spaces from the beginning of str.

Parameters
[in,out]strstring
Returns
True if the resulting string is nonempty, false otherwise.

◆ cp_is_space()

bool cp_is_space ( const String &  str)
inline

Test if str is all spaces.

Returns
True when every character in str is a space.

◆ cp_is_word()

bool cp_is_word ( const String &  str)

Test whether str is a valid "word".

A "word" in Click consists of one or more characters in the ASCII range '!' through '~', inclusive, except for the quote characters '"' and ''', the backslash '\', and the comma ','.

◆ cp_is_click_id()

bool cp_is_click_id ( const String &  str)

Test if str is a valid Click identifier.

A Click identifier consists of one or more characters in the set [A-Za-z0-9/_@], with restrictions on where / may appear (it cannot be the first character or the last character, and two adjacent slashes aren't allowed either).

◆ cp_uncomment()

String cp_uncomment ( const String &  str)

Simplify str's whitespace and replace comments by spaces, returning the result.

Returns
A version of str with all initial space removed, all final space removed, and all comments and space-comment sequences replaced by a single space character.

Adjacent space characters are preserved in the output unless they appear next to a comment. For example:

cp_uncomment(" a b ") == "a b", but:
cp_uncomment(" a /* Comment */ b ") == "a b"
String cp_uncomment(const String &str)
Simplify str's whitespace and replace comments by spaces, returning the result.
Definition confparse.cc:442

Comment characters inside double or single quotes are ignored:

cp_uncomment(" \" /*??? */ \" ") == "\" /*??? */ \""

◆ cp_unquote()

String cp_unquote ( const String &  str)

Remove one level of quoting from str, returning the result.

This function acts as cp_uncomment, plus removing one level of quoting. "..." and '...' sequences are replaced by their contents. Backslash escapes are expanded inside double quotes (see cp_process_backslash). Additionally, "\<...>" sequences are expanded outside of any quotes. For example:

cp_unquote("\"\\n\" abc /* 123 */ '/* def */'") == "\n abc /* def */"
String cp_unquote(const String &str)
Remove one level of quoting from str, returning the result.
Definition confparse.cc:571

◆ cp_process_backslash()

const char * cp_process_backslash ( const char *  begin,
const char *  end,
StringAccum &  sa 
)

Process a backslash escape, appending results to sa.

Parameters
beginbeginning of string
endend of string
sastring accumulator
Precondition
begin < end, and begin points to a backslash character.
Returns
A pointer to the first character in [begin, end) following the backslash escape.

This function understands the following backslash escapes.

  • "\[newline]" is ignored (it adds no characters to sa), where [newline] is one of the sequences "\n", "\r", or "\r\n".
  • "\[C escape]" is processed as in C, where [C escape] is one of the characters in [abfnrtv].
  • "\\"</tt> expands to a single backslash. Similarly, <tt>"$"</tt>, <tt>"\'"</tt>, <tt>"\"", and "\," expand to the escaped character.
  • "\[1-3 octal digits]" expands to the given character.
  • "\x[hex digits]" expands to the given character.
  • "\<[hex digits, spaces, and comments]>" expands to the binary string indicated by the hex digits. Spaces and comments are removed. For example,
    "<48656c6C 6f 2 /* And finally */ 1>" expands to "Hello!"
    (This example should begin with "\<"; it may not because of Doxygen problems.)
  • A backslash at the end of the string expands to a backslash.

◆ cp_quote()

String cp_quote ( const String &  str,
bool  allow_newlines 
)

Return a quoted version of str.

Parameters
strstring
allow_newlinesIf true, then newline sequences are allowed in in the result. If false, then newline sequences should be translated to their backslash escape equivalents. Default is false.

Returns a double-quoted string that, when unquoted by cp_unquote(), will equal str. The returned string consists of a single double-quoted string, and in particular is never empty.

Invariant
cp_quote(str) != "" && cp_unquote(cp_quote(str)) == str

◆ cp_argvec()

void cp_argvec ( const String &  str,
Vector< String > &  conf 
)

Separate a configuration string into arguments at commas.

Parameters
strconfiguration string
[out]confarguments

The configuration string is broken into arguments at unquoted commas. Each argument is passed through cp_uncomment(), then appended to conf. If the final argument is empty, it is ignored. For example:

cp_argvec("a, b, c", v) appends "a", "b", "c"
cp_argvec(" a /*?*/ b, c, ", v) appends "a b", "c"
cp_argvec("\"x, y\" // ?", v) appends "\"x, y\""
void cp_argvec(const String &str, Vector< String > &conf)
Separate a configuration string into arguments at commas.
Definition confparse.cc:697

◆ cp_unargvec()

String cp_unargvec ( const Vector< String > &  conf)

Join the strings of conf with commas and return the result.

This function does not quote or otherwise protect the strings in conf. The caller should do that if necessary.

◆ cp_spacevec()

void cp_spacevec ( const String &  str,
Vector< String > &  conf 
)

Separate a configuration string into arguments at unquoted spaces.

Parameters
strconfiguration string
[out]confarguments

The configuration string is broken into arguments at unquoted spaces. Each argument is passed through cp_uncomment(), then appended to conf. If the final argument is empty, it is ignored. For example:

cp_spacevec("a b, c", v) appends "a", "b,", "c"
cp_spacevec(" 'a /*?*/ b'c", v) appends "'a /*?*/ b'c"
void cp_spacevec(const String &str, Vector< String > &conf)
Separate a configuration string into arguments at unquoted spaces.
Definition confparse.cc:768

◆ cp_shift_spacevec()

String cp_shift_spacevec ( String &  str)

Remove and return the first space-separated argument from str.

Parameters
[in,out]strspace-separated configuration string

The first space-separated argument in the configuration string is removed and returned. The returned argument is passed through cp_uncomment(). str is set to the remaining portion of the string, with any preceding spaces and comments removed. If the input string is all spaces and comments, then both the returned string and str will be empty.

◆ cp_unspacevec() [1/2]

String cp_unspacevec ( const String *  begin,
const String *  end 
)

Join the strings in [begin, end) with spaces and return the result.

Parameters
beginfirst string in range
endone past last string in range

This function does not quote or otherwise protect the strings in [begin, end). The caller should do that if necessary.

See also
cp_unspacevec(const Vector<String> &)

◆ cp_unspacevec() [2/2]

String cp_unspacevec ( const Vector< String > &  conf)
inline

Join the strings in conf with spaces and return the result.

This function does not quote or otherwise protect the strings in conf. The caller should do that if necessary.

See also
cp_unspacevec(const String *, const String *)

◆ cp_shift_delimiter()

String cp_shift_delimiter ( String &  str,
char  delim 
)

Remove and return the first delimiter-separated argument from str.

Parameters
[in,out]strdelimiter-separated string
[in]delimdelimiter

All characters up to the first delimiter character are removed and returned. str is set to the remaining portion of the string, with up to one delimiter character removed.

◆ cp_string()

bool cp_string ( const String &  str,
String *  result,
String *  rest 
)

Parse a string from str.

Parameters
strstring
[out]resultstores parsed result
[out]rest(optional) stores unparsed portion of str
Returns
True if str parsed correctly, false otherwise.

Parses a string from str. The first unquoted space encountered ends the string, but spaces are allowed within single or double quotes. Unquoted empty strings are not accepted. If the string fully parses, then the result is unquoted by cp_unquote() and stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false.

If rest is nonnull, then the string doesn't need to fully parse; the part of the string starting with the first unquoted space is stored in *rest and the function returns true.

◆ cp_word()

bool cp_word ( const String &  str,
String *  result,
String *  rest 
)

Parse a word from str.

Parameters
strstring
[out]resultstores parsed result
[out]rest(optional) stores unparsed portion of str
Returns
True if str parsed correctly, false otherwise.

Parses a word from str. The first unquoted space encountered ends the word. Single and double quotes are removed as by cp_unquote, but the unquoted string must satisfy cp_is_word. If the string fully parses, then the resulting value is stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false.

If rest is nonnull, then the string doesn't need to fully parse; the part of the string starting with the first unquoted space is stored in *rest and the function returns true (assuming cp_is_word succeeds on the initial portion).

◆ cp_keyword()

bool cp_keyword ( const String &  str,
String *  result,
String *  rest 
)

Parse a keyword from str.

Parameters
strstring
[out]resultstores parsed result
[out]rest(optional) stores unparsed portion of str
Returns
True if str parsed correctly, false otherwise.

Parses a keyword from str. Keywords consist of characters in [A-Za-z0-9_.:?!]. Quotes and spaces are not allowed; neither is the empty string. If the string fully parses as a keyword, then the resulting value is stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false.

If rest is nonnull, then the string doesn't need to fully parse; the part of the string starting with the first unquoted space is stored in *rest and the function returns true (assuming the initial portion is a valid keyword).

◆ cp_bool()

bool cp_bool ( const String &  str,
bool *  result 
)

Parse a boolean from str.

Parameters
strstring
[out]resultstores parsed result
Returns
True if str parsed correctly, false otherwise.

Parses a boolean from str. The following strings are the valid representations for booleans:

0, false, no, f, n
Means false
1, true, yes, t, y
Means true

If the string fully parses, then the resulting value is stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false.

◆ cp_integer() [1/3]

const char * cp_integer ( const char *  begin,
const char *  end,
int  base,
int *  result 
)
inline

Parse an integer from [begin, end) in base base.

Parameters
beginfirst character in string
endone past last character in string
basebase of integer: 0 or 2-36
[out]resultstores parsed result
Returns
pointer to first unparsed character in string; equals begin if the string didn't start with a valid integer

This function parses an integer from the initial characters of a string. The resulting integer is stored in *result.

The integer format consists of an optional initial sign +/-, followed by one or more digits. A negative sign is only accepted if result has a signed type. Digits may be separated by underscores (to make numbers easier to read), but the first and last characters in the integer cannot be underscores, and two underscores can't appear in a row. Some examples:

0
0x100
-1_000_023

Digits are numbered from 0-9, then A-Z/a-z. base determines which digits are legal. If base is 0, then a leading 0x or 0X may precede the digits, indicating base 16; a leading 0 indicates base 8; anything else is base 10.

Returns the first character that can't be parsed as part of the integer. If there is no valid integer at the beginning of the string, then returns begin; *result is unchanged.

This function checks for overflow. If an integer is too large for result, then the maximum possible value is stored in result and the cp_errno variable is set to CPE_OVERFLOW. Otherwise, cp_errno is set to CPE_FORMAT (for no valid integer) or CPE_OK (if all was well).

Overloaded versions of this function are available for int, unsigned int, long, unsigned long, and (depending on configuration) long long and unsigned long long result values.

◆ cp_integer() [2/3]

bool cp_integer ( const String &  str,
int  base,
int *  result 
)
inline

Parse an integer from str in base base.

Parameters
strstring
basebase of integer: 0 or 2-36
[out]resultstores parsed result
Returns
True if str parsed correctly, false otherwise.

Parses an integer from an input string. If the string correctly parses as an integer, then the resulting value is stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false.

Overloaded versions are available for int, unsigned int, long, unsigned long, and (depending on configuration) long long and unsigned long long result values.

See also
cp_integer(const char *, const char *, int, int *) for the rules on parsing integers.

◆ cp_integer() [3/3]

bool cp_integer ( const String &  str,
int *  result 
)
inline

Parse an integer from str in base 0.

Same as cp_integer(str, 0, result).

◆ cp_real2()

bool cp_real2 ( const String &  str,
int  frac_bits,
int32_t *  result 
)

Parse a fixed-point number from str.

Parameters
strstring
frac_bitsnumber of bits of fraction, 0-CP_REAL2_MAX_FRAC_BITS
[out]resultstores parsed result
Returns
True if str parsed correctly, false otherwise.

Parses a real number from an input string. The result is represented as a fixed-point number with frac_bits bits of fraction. For example, the number 0.5 would be represented as 0x1 if frac_bits == 1, or 0x8000 if frac_bits == 16. If the string fully parses, then the resulting value is stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false.

The real number format is the familiar decimal format parsed by, for example, C's strtod() function. It consists of, in order:

  • An optional + or - sign.
  • An optional sequence of decimal digits representing the integer part.
  • An optional fraction point, followed by an optional sequence of decimal digits representing the fraction part.
  • An optional exponent (either E<digits>, E+<digits>, or E-<digits>).

There must be at least one digit in either the integer part or the fraction part. As with cp_integer, digits can be separated by underscores to make large numbers easier to read. Some examples:

0
-100_000_000
1e8
+10.
.1
0.000_000_01e10

This function checks for overflow. If a number is too large for result, then the maximum possible value is stored in result and the cp_errno variable is set to CPE_OVERFLOW. Otherwise, cp_errno is set to CPE_FORMAT (unparsable input) or CPE_OK (if all was well). Underflow is handled by rounding the result to the nearest representable number.

The following invariant always holds for all values x and fraction bits frac_bits:

check_invariant(int32_t x, int frac_bits) {
int32_t y;
assert(cp_real2(cp_unparse_real2(x, frac_bits), frac_bits, &y) == true
&& y == x);
}
bool cp_real2(const String &str, int frac_bits, int32_t *result)
Parse a fixed-point number from str.
Definition confparse.cc:1304

An overloaded version of this function is available for uint32_t result values; it doesn't accept negative numbers.

See also
The cp_real10() functions behave like cp_real2(), but the fractional part is expressed in decimal digits rather than bits.

◆ cp_real10() [1/2]

bool cp_real10 ( const String &  str,
int  frac_digits,
int32_t *  result 
)

Parse a real number from str, representing the result as an integer with frac_digits decimal digits of fraction.

Parameters
strstring
frac_digitsnumber of decimal digits of fraction, 0-9
[out]resultstores parsed result
Returns
True if str parsed correctly, false otherwise.

Parses a real number from an input string. The result is represented as an integer with frac_digits decimal digits of fraction. For example, the number 0.5 would be represented as 5 if frac_digits == 1, or 5000 if frac_digits == 4. If the string fully parses, then the resulting value is stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false.

The real number format and error conditions are the same as for cp_real2().

An overloaded version of this function is available for uint32_t result values; it doesn't accept negative numbers.

◆ cp_real10() [2/2]

bool cp_real10 ( const String &  str,
int  frac_digits,
uint32_t *  result_int_part,
uint32_t *  result_frac_part 
)

Parse a real number from str, representing the result as an integer with frac_digits decimal digits of fraction.

Parameters
strstring
frac_digitsnumber of decimal digits of fraction, 0-9
[out]result_int_partstores integer portion of parsed result
[out]result_frac_partstores fractional portion of parsed result
Returns
True if str parsed correctly, false otherwise.

Parses an unsigned real number from an input string. The result is represented with frac_digits decimal digits of fraction. The integer and fraction parts of the result are stored in two separate integers, result_int_part and result_frac_part. For example, the number 10.5 would be represented as 10 and 5 if frac_digits == 1, or 10 and 5000 if frac_digits == 4. If the string fully parses, then the resulting value is stored in the result variables and the function returns true. Otherwise, the result variables remains unchanged and the function returns false.

The real number format and error conditions are the same as for cp_real2(). (Negative numbers are not allowed.)

◆ cp_double()

bool cp_double ( const String &  str,
double *  result 
)

Parse a real number from str.

Parameters
strstring
[out]resultstores parsed result
Returns
True if str parsed correctly, false otherwise.

Parses a real number from an input string in double format. It is basically equivalent to C's strtod(), but follows Click's configuration parsing conventions: If the string fully parses, then the resulting value is stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false. If a number is too large for result, then the maximum possible value is stored in result and the cp_errno variable is set to CPE_OVERFLOW; otherwise, cp_errno is set to CPE_FORMAT (unparsable) or CPE_OK (if all was well).

This function is not available in the kernel, since double objects cannot be used there.

◆ cp_seconds_as()

bool cp_seconds_as ( const String &  str,
int  frac_digits,
uint32_t *  result 
)

Parse an amount of time from str.

Parameters
strstring
frac_digitsnumber of decimal digits of fraction, 0-9
[out]resultstores parsed result
Returns
True if str parsed correctly, false otherwise.

Parses an amount of time, measured in seconds, from str. frac_digits is the number of decimal digits of fraction returned in the result. For example, to measure the result in milliseconds, set frac_digits == 3; for microseconds, set frac_digits == 6. Does not handle negative amounts of time.

The input string is a real number (as in cp_real2) followed by an optional unit suffix. Units are:

ns, nsec
nanoseconds
us, usec
microseconds
ms, msec
milliseconds
s, sec
seconds
m, min
minutes
h, hr
hours
d, day
days

The default unit suffix is seconds. Thus, "3600", "3600s", "3.6e6 msec", "60m", and "1 hr" all parse to the same result, 3600 seconds.

If the string fully parses, then the resulting value is stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false.

If a number is too large for result, then the maximum possible value is stored in result and the cp_errno variable is set to CPE_OVERFLOW; otherwise, cp_errno is set to CPE_FORMAT (unparsable) or CPE_OK (if all was well).

◆ cp_seconds_as_milli()

bool cp_seconds_as_milli ( const String &  str,
uint32_t *  result 
)

Parse an amount of time in milliseconds from str.

Parameters
strstring
[out]resultstores parsed result
Returns
True if str parsed correctly, false otherwise.

Parses an amount of time, measured in milliseconds, from str. Equivalent to cp_seconds_as(str, 3, result).

◆ cp_seconds_as_micro()

bool cp_seconds_as_micro ( const String &  str,
uint32_t *  result 
)

Parse an amount of time in microseconds from str.

Parameters
strstring
[out]resultstores parsed result
Returns
True if str parsed correctly, false otherwise.

Parses an amount of time, measured in microseconds, from str. Equivalent to cp_seconds_as(str, 6, result).

◆ cp_seconds()

bool cp_seconds ( const String &  str,
double *  result 
)

Parse an amount of time from str.

Parameters
strstring
[out]resultstores parsed result
Returns
True if str parsed correctly, false otherwise.

Parses an amount of time, measured in seconds, from str. As in cp_seconds_as(), the input string is a real number followed by an optional unit suffix which defaults to seconds.

If the string fully parses, then the resulting value is stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false.

◆ cp_time()

bool cp_time ( const String &  str,
Timestamp *  result,
bool  allow_negative 
)

Parse a timestamp from str.

Parameters
strstring
[out]resultstores parsed result
allow_negativeallow negative timestamps if true
Returns
True if str parsed correctly, false otherwise.

Parses a timestamp from str. Timestamps are expressed as fractional amounts of seconds, usually measured in Unix time, such as "1189383079.180265331". The input format accepts the unit suffixes described at cp_seconds_as. If the string fully parses, then the resulting value is stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false.

If a number is too large for result, then the maximum possible value is stored in result and the cp_errno variable is set to CPE_OVERFLOW; otherwise, cp_errno is set to CPE_FORMAT (unparsable) or CPE_OK (if all was well).

An overloaded version of this function is available for struct timeval result values.

◆ cp_bandwidth()

bool cp_bandwidth ( const String &  str,
uint64_t *  result 
)

Parse a bandwidth value from str.

Parameters
strstring
[out]resultstores parsed result
Returns
True if str parsed correctly, false otherwise.

Parses a bandwidth value from str. The input format is a real number followed by an optional unit suffix. Units are:

baud, bps, b/s
bits per second
Bps, B/s
bytes per second
e.g. kbaud, Mbps, GBps
kilo, mega, giga are supported (they mean 10^3, 10^6, and 10^9)

The default unit suffix is bytes per second.

If a number is too large for result, then the maximum possible value is stored in result and the cp_errno variable is set to CPE_OVERFLOW; otherwise, cp_errno is set to CPE_FORMAT (unparsable) or CPE_OK (if all was well).

◆ cp_ip_address()

bool cp_ip_address ( const String &  str,
IPAddress *  result,
const Element *  context 
)

Parse an IP address from str.

Parameters
strstring
[out]resultstores parsed result
contextoptional context for AddressInfo
Returns
True if str parsed correctly, false otherwise.

Parses an IP address from str. The input format is the usual dotted-quad format, as in "18.26.4.9", where each number is a decimal number from 0-255. The AddressInfo element can be used to register shorthand names for other IP addresses. If the string fully parses, then the resulting value is stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false.

Overloaded versions of this function are available for unsigned char[4] and struct in_addr * result types.

◆ cp_ip_prefix()

bool cp_ip_prefix ( const String &  str,
IPAddress *  result_addr,
IPAddress *  result_mask,
bool  allow_bare_address,
const Element *  context 
)

Parse an IP address or prefix from str.

Parameters
strstring
[out]result_addrstores parsed address result
[out]result_maskstores parsed address mask result
allow_bare_addressoptional: if true, allow raw IP addresses; defaults to false
contextoptional context for AddressInfo
Returns
True if str parsed correctly, false otherwise.

Parses an IP prefix description from str. The input format is the usual CIDR format with some additions. Allowed examples:

  • "18.26.4.0/24": the default CIDR format. The prefix length, here 24, is a number between 0 and 32. This stores the equivalents of 18.26.4.0 in *result_addr and 255.255.255.0 in *result_mask.
  • "18.26.4/24": it is OK to leave off irrelevant parts of the address. However, "18.26/24" will not parse.
  • "18.26.4.0/255.255.255.0": the mask may be specified directly. This is the only way to define a non-prefix mask.
  • Additionally, AddressInfo names may be used to specify the address part or the whole prefix: given AddressInfo(a 18.26.4.9), "a/24" is parseable as an IP prefix.

The address part need not fit entirely within the prefix. "18.26.4.9/24" will parse into address 18.26.4.9 and mask 255.255.255.0.

If allow_bare_address is true, then a raw IP address is also acceptable input. The resulting mask will equal 255.255.255.255. Raw IP addresses take precedence over networks, so given AddressInfo(a 18.26.4.9/24), "a" will parse as 18.26.4.9/32, not 18.26.4/24. allow_bare_address defaults to false.

If the string fully parses, then the resulting address is stored in *result_addr, the resulting mask is stored in *result_mask, and the function returns true. Otherwise, the results remain unchanged and the function returns false.

Overloaded versions of this function are available for unsigned char[4] result types.

◆ cp_ip_address_list()

bool cp_ip_address_list ( const String &  str,
Vector< IPAddress > *  result,
const Element *  context 
)

Parse a space-separated list of IP addresses from str.

Parameters
strstring
[out]resultstores parsed result
contextoptional context for AddressInfo
Returns
True if str parsed correctly, false otherwise.

Parses a space-separated list of IP addresses from str. Each individual IP address is parsed as by cp_ip_address(). If the string fully parses, then *result is set to the resulting values in order. Otherwise, *result remains unchanged and the function returns false.

In addition to errors from cp_ip_address(), this function might run out of memory for *result, which produces a CPE_MEMORY error.

◆ cp_ip6_address()

bool cp_ip6_address ( const String &  str,
IP6Address *  result,
const Element *  context 
)

Parse an IPv6 address from str.

Parameters
strstring
[out]resultstores parsed result
contextoptional context for AddressInfo
Returns
True if str parsed correctly, false otherwise.

Parses an IPv6 address from str. The input format may be any of the forms allowed by RFC2373:

  • A nonabbreviated address consists of eight colon-separated 16-bit hexadecimal numbers, as in "1080:0:0:0:8:800:200C:417a".
  • Groups of zeros may be abbrivated with two colons, as in the equivalent "1080::8:800:200C:417A".
  • An address may end with an embedded IPv4 address, as in "::13.1.68.3", "::FFFF:129.144.52.38", and (assuming the appropriate AddressInfo information) "0::ip4_addr".

The AddressInfo element can be used to register shorthand names for other IPv6 addresses. If the string fully parses, then the resulting value is stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false.

An overloaded version of this function is available for unsigned char[16] result type.

◆ cp_ip6_prefix()

bool cp_ip6_prefix ( const String &  str,
IP6Address *  result_addr,
int *  result_prefix,
bool  allow_bare_address,
const Element *  context 
)

Parse an IPv6 address or prefix from str.

Parameters
strstring
[out]result_addrstores parsed address result
[out]result_prefixstores parsed prefix length result
allow_bare_addressif true, allow raw IPv6 addresses
contextoptional context for AddressInfo
Returns
True if str parsed correctly, false otherwise.

Parses an IPv6 prefix description from str. The input format is the usual CIDR format: an IPv6 address, followed by "/prefixlen", where prefixlen is a number between 0 and 128. As an extension, the format "addr/mask" is supported, where both addr and mask are valid IPv6 addresses. However, unlike cp_ip_prefix(), mask must correspond to a valid prefix length – some number of one bits, followed by all zero bits. For example, "::/::1" will not parse. Finally, AddressInfo names may be used to specify the address part or the whole prefix.

The address part need not fit entirely within the prefix. "::1/32" will parse into address ::1 and prefix length 32.

If allow_bare_address is true, then a raw IPv6 address is also acceptable input. The resulting prefix will equal 128.

If the string fully parses, then the resulting address is stored in *result_addr, the resulting prefix length is stored in *result_prefix, and the function returns true. Otherwise, the results remain unchanged and the function returns false.

Overloaded versions of this function are available for unsigned char[16] result address type, and for IP6Address or unsigned char[16] result masks (instead of result prefix lengths).

◆ cp_ethernet_address()

bool cp_ethernet_address ( const String &  str,
EtherAddress *  result,
const Element *  context 
)

Parse an Ethernet address from str.

Parameters
strstring
[out]resultstores parsed result
contextoptional context for AddressInfo
Returns
True if str parsed correctly, false otherwise.

Parses an Ethernet address from str. The input format is the IEEE standard format, as in "00-15-58-2D-FB-8F": six dash-separated 8-bit hexadecimal numbers in transmission order. Colons are also accepted as separators. The AddressInfo element can be used to register shorthand names for other Ethernet addresses. If the string fully parses, then the resulting value is stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false.

An overloaded version of this function is available for unsigned char[6] result type.

◆ cp_tcpudp_port()

bool cp_tcpudp_port ( const String &  str,
int  proto,
uint16_t *  result,
const Element *  context 
)

Parse a TCP, UDP, etc. port number from str.

Parameters
strstring
protoprotocol number, e.g. IP_PROTO_TCP == 6
[out]resultstores parsed result
contextoptional context for IPNameInfo
Returns
True if str parsed correctly, false otherwise.

Parses a port number for IP protocol proto from str. The input may be a 16-bit number parsable by cp_integer(), as in "80". It may also be a port name, such as "www". Several port names are defined by default, including auth, chargen, echo, finger, ftp, https, ntp, and www. The PortInfo element can be used to define additional names, and at user level, cp_tcpudp_port() will consult the /etc/services database using getservbyname() as a last resort. If the string fully parses, then the resulting value is stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false.

◆ cp_element() [1/2]

Element * cp_element ( const String &  str,
const Element *  context,
ErrorHandler *  errh,
const char *  argname 
)

Parse an element reference from str.

Parameters
strstring
contextelement context
errhoptional error handler
argnameoptional argument name (used for error messages)
Returns
Element pointer, or null if no such element is found.

Parses an element reference from str. The input must be a single (possibly quoted) string acceptable to cp_string(). The unquoted value should be an element name. The name may be relative to a compound element; for instance, if context is an element named a/b/c/xxx, and str was "yyy", then cp_element() would search for elements named a/b/c/yyy, a/b/yyy, a/yyy, and finally yyy, returning the first one found. (See Router::find().) If no element is found, reports an error to errh and returns null. If errh is null, no error is reported.

See also
This function differs from Router::find() in that it unquotes its argument.

◆ cp_element() [2/2]

Element * cp_element ( const String &  str,
Router *  router,
ErrorHandler *  errh,
const char *  argname 
)

Parse an element reference from str.

Parameters
strstring
routerrouter
errhoptional error handler
argnameoptional argument name (used for error messages)
Returns
Element pointer, or null if no such element is found.

Parses an element reference from str. The input must be a single (possibly quoted) string acceptable to cp_string(). The unquoted value should be a fully qualified element name corresponding to an element in router. If no element is found, reports an error to errh and returns null. If errh is null, no error is reported.

See also
This function differs from Router::find() in that it unquotes its argument.

◆ cp_handler_name()

bool cp_handler_name ( const String &  str,
Element **  result_element,
String *  result_hname,
const Element *  context,
ErrorHandler *  errh 
)

Parse a handler name from str.

Parameters
strstring
[out]result_elementstores parsed element result
[out]result_hnamestores parsed handler name result
contextelement context
errhoptional error handler
Returns
True if str parsed correctly, false otherwise.

Parses a handler name from str. Three formats are supported:

  • "elementname.handlername", for a handler on a named element. The named element must exist; it is looked up as by cp_element() in the compound element context specified by context.
  • ".handlername", for a global handler on context's router.
  • "handlername", for a handler on the context element (if such a handler exists), or a global handler on context's router.

The handler name must contain at least one character. Although the named element must exist, this function does not check whether the named handler exists. The input string may contain quotes; it is unquoted by cp_string().

If the string fully parses, then the resulting element is stored in *result_element, the resulting handler name is stored in *result_hname, and the function returns true. For global handlers, *result_element is set to Router::root_element(). If the string does not fully parse, the results remain unchanged and the function returns false.

◆ cp_handler()

bool cp_handler ( const String &  str,
int  flags,
Element **  result_element,
const Handler **  result_handler,
const Element *  context,
ErrorHandler *  errh 
)

Parse a handler reference from str.

Parameters
strstring
flagszero or more of Handler::f_read, Handler::f_write, and HandlerCall::f_preinitialize
[out]result_elementstores parsed element result
[out]result_handlerstores parsed handler result
contextelement context
errhoptional error handler
Returns
True if str parsed correctly, false otherwise.

Parses a handler reference from str. The input format is as in cp_handler_name(), but the named handler must actually exist. The flags argument lets the caller check for read and/or write handlers; its values are as for HandlerCall::initialize(). If the string fully parses, then the resulting element is stored in *result_element, the resulting handler is stored in *result_handler, and the function returns true. For global handlers, *result_element is set to Router::root_element(). If the string does not fully parse, the results remain unchanged and the function returns false.

◆ cp_filename()

bool cp_filename ( const String &  str,
String *  result 
)

Parse a filename string from str.

Parameters
strstring
[out]resultstores parsed result
Returns
True if str parsed correctly, false otherwise.

Parses a filename from str. This behaves like cp_string() plus shell-style tilde expansion. Thus, ~/ at the beginning of a string is replaced with the value of the HOME environment variable (if it exists), and ~username/ is replaced with the given user's home directory as returned by getpwnam() (if the given user exists). Additionally, double slashes are replaced by single slashes. Thus, "~//myfile.txt~" might parse to "/home/kohler/myfile.txt~". Empty strings are not accepted. If the string fully parses, then the result is stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false.

This function is only available at user level.

◆ cp_file_offset()

bool cp_file_offset ( const String &  str,
off_t *  result 
)

Parse a file offset from str.

Parameters
strstring
[out]resultstores parsed result
Returns
True if str parsed correctly, false otherwise.

Parses an unsigned integer from str, similarly to cp_integer(str, result).

◆ cp_anno()

bool cp_anno ( const String &  str,
int  size,
int *  result,
const Element *  context 
)

Parse a packet annotation value from str.

Parameters
strstring
sizeannotation size, or <= 0 to not check size
[out]resultstores parsed result
contextelement context
Returns
True if str parsed correctly, false otherwise.

Parses a packet annotation value from str. This is either a predefined annotation name, such as PAINT or ICMP_PARAM_PROB (all names from <click/packet_anno.hh> are defined by default); a user-defined name (see the AnnotationInfo element); or an integer indicating the byte offset into the annotation area.

If size <= 0, then the annotation value is returned as is. Use the ANNOTATIONINFO_OFFSET and ANNOTATIONINFO_SIZE macros to extract the offset and size portions. If size > 0, then the annotation value is checked to ensure that the sizes are compatible. For instance, if size == 1, then the "DST_IP" annotation is rejected since it has the wrong size. In this case, the value stored in *result equals the annotation offset – the size is masked off.

Values that extend past the end of the annotation area are rejected.

If the string fully parses, then the result is stored in *result and the function returns true. Otherwise, *result remains unchanged and the function returns false.

◆ cp_va_kparse() [1/2]

int cp_va_kparse ( const Vector< String > &  conf,
const Element *  context,
ErrorHandler *  errh,
  ... 
)

Parse a list of arguments.

Parameters
confargument list
contextelement context
errherror handler
...zero or more parameter items, terminated by cpEnd
Returns
The number of parameters successfully assigned, or negative on error.

The arguments in conf are parsed according to the items. Each supplied argument must match one of the items, and at least one argument must match each mandatory item. Any errors are reported to errh. If no error occurs, then the item results are assigned appropriately, and the function returns the number of assigned items, which might be 0. If any error occurs, then the item results are left unchanged and the function returns a negative error code.

The context argument is passed to any parsing functions that require element context. See above for more information on cp_va_kparse() items.

The item list must be terminated with cpEnd. An error message such as "warning: missing sentinel in function call" indicates that you terminated the list with 0 instead. Fix it by replacing the 0 with cpEnd.

◆ cp_va_kparse() [2/2]

int cp_va_kparse ( const String &  str,
const Element *  context,
ErrorHandler *  errh,
  ... 
)

Parse a comma-separated argument string.

Parameters
strcomma-separated argument string
contextelement context
errherror handler
...zero or more parameter items, terminated by cpEnd
Returns
The number of parameters successfully assigned, or negative on error.

The argument string is separated into an argument list by cp_argvec(), after which the function behaves like cp_va_kparse(const Vector<String>&, Element *, ErrorHandler *, ...).

◆ cp_va_space_kparse()

int cp_va_space_kparse ( const String &  str,
const Element *  context,
ErrorHandler *  errh,
  ... 
)

Parse a space-separated argument string.

Parameters
strspace-separated argument string
contextelement context
errherror handler
...zero or more parameter items, terminated by cpEnd
Returns
The number of parameters successfully assigned, or negative on error.

The argument string is separated into an argument list by cp_spacevec(), after which the function behaves like cp_va_kparse(const Vector<String>&, Element *, ErrorHandler *, ...).

◆ cp_va_kparse_keyword()

int cp_va_kparse_keyword ( const String &  str,
const Element *  context,
ErrorHandler *  errh,
  ... 
)

Parse a single argument.

Parameters
strargument
contextelement context
errherror handler
...zero or more parameter items, terminated by cpEnd
Returns
The number of parameters successfully assigned (0 or 1), or negative on error.

An argument list consisting of the single argument str is formed, after which this function behaves like cp_va_kparse(const Vector<String>&, Element *, ErrorHandler *, ...).

◆ cp_va_kparse_remove_keywords()

int cp_va_kparse_remove_keywords ( Vector< String > &  conf,
const Element *  context,
ErrorHandler *  errh,
  ... 
)

Parse and remove matching arguments from conf.

Parameters
confargument list
contextelement context
errherror handler
...zero or more parameter items, terminated by cpEnd
Returns
The number of parameters successfully assigned, or negative on error.

The arguments in conf are parsed according to the items. At least one argument must correspond to each mandatory item, but extra arguments are not errors. If no error occurs, then the item results are assigned appropriately; any arguments that successfully matched are removed from conf; and the function returns the number of assigned items, which might be 0. If any error occurs, then conf and the item results are left unchanged and the function returns a negative error code. Errors are reported to errh.

The context argument is passed to any parsing functions that require element context.

◆ cp_assign_arguments()

int cp_assign_arguments ( const Vector< String > &  argv,
const String *  param_begin,
const String *  param_end,
Vector< String > *  values 
)

Assign arguments from argv to values.

Parameters
argvargument array
param_beginstart iterator for parameter list
param_endend iterator for parameter list
valuesvalue storage (may equal null or &argv)
Returns
>= 0 on success, negative on failure

This function is used to resolve an argument array. The range [param_begin, param_end) defines the parameter names. This range begins with zero or more empty strings, which define mandatory positional arguments. It continues with zero or more nonempty strings, which define optional keyword arguments with the corresponding names. It may optionally conclude with "__REST__", which says that the last value should collect all unassigned arguments.

cp_assign_arguments attempts to assign the arguments in argv to the corresponding parameters. This succeeds if all mandatory positional arguments are present and all other arguments are accounted for, either by keywords or by "__REST__". On success, returns >= 0. On failure because the argument list is invalid, returns -EINVAL. On other failure cases, such as out of memory, returns another negative error code.

On success, cp_assign_arguments also optionally assigns *values to the resulting value list. *values is resized to size (param_end - param_begin), and *values[i] is set to the argument corresponding to param_begin[i]. If values is null this step is skipped and the function has no side effects. It is safe to set values to &argv.

◆ cp_va_static_initialize()

void cp_va_static_initialize ( )

Initialize the cp_va_kparse() implementation.

This function must be called before any cp_va function is called. It is safe to call it multiple times.

Note
Elements don't need to worry about cp_va_static_initialize(); Click drivers have already called it for you.

◆ cp_va_static_cleanup()

void cp_va_static_cleanup ( )

Clean up the cp_va_kparse() implementation.

Call this function to release any memory allocated by the cp_va implementation. As a side effect, this function unregisters all argument types registered by cp_register_argtype().

◆ cp_va_parse() [1/2]

int cp_va_parse ( const Vector< String > &  conf,
const Element *  context,
ErrorHandler *  errh,
  ... 
)

Legacy function for parsing a list of arguments.

never

Parameters
confargument list
contextelement context
errherror handler
...zero or more parameter descriptions, terminated by cpEnd
Deprecated:
Use cp_va_kparse() instead.

Older versions of Click used cp_va_parse() instead of the current cp_va_kparse(). This guide shows how to transition cp_va_parse() calls into cp_va_kparse().

There are two major differences between the variants. First, every argument to cp_va_kparse() must have a keyword name, including arguments that are normally specified by position. Second, each cp_va_parse() argument includes an "argument description string" used to improve error messages. cp_va_kparse() arguments do not take such a string; the keyword generates better, more concise messages.

The following examples, taken from Click elements, show how to change concrete cp_va_parse() calls into cp_va_kparse() calls.

// 1. Paint: Mandatory arguments are marked with cpkP+cpkM.
// Element documentation and other analogous elements are
// good places to look for keywords.
... cp_va_parse(conf, this, errh,
cpByte, "color", &_color, // "color" is the description string
cpEnd) ...
/* => */
... cp_va_kparse(conf, this, errh,
"COLOR", cpkP+cpkM, cpByte, &_color,
cpEnd) ...
// 2. Switch: Optional arguments are marked with cpkP (no cpkM).
... cp_va_parse(conf, this, errh,
cpInteger, "active output", &_output,
cpEnd) ...
/* => */
... cp_va_kparse(conf, this, errh,
"OUTPUT", cpkP, cpInteger, &_output,
cpEnd) ...
// 3. Counter: Keywords are marked with cpkN (or, equivalently, 0).
... cp_va_parse(conf, this, errh,
"COUNT_CALL", cpArgument, "handler to call after a count", &count_call,
"BYTE_COUNT_CALL", cpArgument, "handler to call after a byte count", &byte_count_call,
cpEnd) ...
/* => */
... cp_va_kparse(conf, this, errh,
"COUNT_CALL", cpkN, cpArgument, &count_call,
"BYTE_COUNT_CALL", cpkN, cpArgument, &byte_count_call,
cpEnd) ...
// 4. IPFragmenter: Combining all of the above.
... cp_va_parse(conf, this, errh,
cpUnsigned, "MTU", &_mtu,
cpBool, "HONOR_DF", &_honor_df,
"HONOR_DF", cpBool, "honor DF bit?", &_honor_df,
"VERBOSE", cpBool, "be verbose?", &_verbose,
cpEnd) ...
/* => */
... cp_va_kparse(conf, this, errh,
"MTU", cpkP+cpkM, cpUnsigned, &_mtu,
"HONOR_DF", cpkP, cpBool, &_honor_df, // NB only one HONOR_DF
"VERBOSE", cpkN, cpBool, &_verbose,
cpEnd) ...
// 5. AggregateIPFlows: Confirmed keywords are marked with cpkC.
... cp_va_parse(conf, this, errh,
"TCP_TIMEOUT", cpSeconds, "timeout for active TCP connections", &_tcp_timeout, ...,
"FRAGMENTS", cpBool, "handle fragmented packets?", &gave_fragments, &fragments,
cpEnd) ...
/* => */
... cp_va_kparse(conf, this, errh,
"TCP_TIMEOUT", cpkN, cpSeconds, &_tcp_timeout, ...,
"FRAGMENTS", cpkC, &gave_fragments, cpBool, &fragments, // Note different order
cpEnd) ...
const CpVaParseCmd cpConfirmKeywords
cp_va_parse only: Following arguments are confirmed keywords.
Definition confparse.hh:314
const CpVaParseCmd cpArgument
Result storage String*, accepts any argument.
Definition confparse.hh:256
@ cpkN
Default flags.
Definition confparse.hh:237
const CpVaParseCmd cpByte
Result storage unsigned char*, parsed by cp_integer().
Definition confparse.hh:262
const CpVaParseCmd cpOptional
cp_va_parse only: Following arguments are optional.
Definition confparse.hh:312
const CpVaParseCmd cpKeywords
cp_va_parse only: Following arguments are keywords.
Definition confparse.hh:313
const CpVaParseCmd cpSeconds
Result storage uint32_t*, parsed by cp_seconds_as() with frac_digits 0.
Definition confparse.hh:279
int cp_va_parse(const Vector< String > &conf, const Element *context, ErrorHandler *errh,...)
Legacy function for parsing a list of arguments.
Definition confparse.cc:3601
const CpVaParseCmd cpInteger
Result storage int32_t*, parsed by cp_integer().
Definition confparse.hh:265

◆ cp_va_parse() [2/2]

int cp_va_parse ( const String &  str,
const Element *  context,
ErrorHandler *  errh,
  ... 
)

Legacy function for parsing a comma-separated argument string.

Parameters
strcomma-separated argument string
contextelement context
errherror handler
...zero or more parameter descriptions, terminated by cpEnd
Deprecated:
Use cp_va_kparse() instead. See cp_va_parse(const Vector<String> &, Element *, ErrorHandler *, ...) for a transition guide.

◆ cp_va_space_parse()

int cp_va_space_parse ( const String &  str,
const Element *  context,
ErrorHandler *  errh,
  ... 
)

Legacy function for parsing a space-separated argument string.

Parameters
strspace-separated argument string
contextelement context
errherror handler
...zero or more parameter descriptions, terminated by cpEnd
Deprecated:
Use cp_va_space_kparse() instead. See cp_va_parse(const Vector<String> &, Element *, ErrorHandler *, ...) for a transition guide.

◆ cp_va_parse_keyword()

int cp_va_parse_keyword ( const String &  str,
const Element *  context,
ErrorHandler *  errh,
  ... 
)

Legacy function for parsing a single argument.

Parameters
strargument
contextelement context
errherror handler
...zero or more parameter descriptions, terminated by cpEnd
Deprecated:
Use cp_va_kparse_keyword() instead. See cp_va_parse(const Vector<String> &, Element *, ErrorHandler *, ...) for a transition guide.

◆ cp_va_parse_remove_keywords()

int cp_va_parse_remove_keywords ( Vector< String > &  conf,
int  first,
const Element *  context,
ErrorHandler *  errh,
  ... 
)

Legacy function for parsing and removing matching arguments from conf.

Parameters
confargument list
firstindex of first non-mandatory argument
contextelement context
errherror handler
...zero or more parameter descriptions, terminated by cpEnd
Deprecated:
Use cp_va_kparse_remove_keywords() instead. See cp_va_parse(const Vector<String> &, Element *, ErrorHandler *, ...) for a transition guide. Note that cp_va_kparse_remove_keywords() does not take the first argument; simply leave it off.

Variable Documentation

◆ cpEnd

const CpVaParseCmd cpEnd
extern

Use as argument name. Ends cp_va argument list.

◆ cpIgnoreRest

const CpVaParseCmd cpIgnoreRest

Use as argument name. No result storage; causes cp_va_kparse() to ignore unparsed arguments and any remaining items.

◆ cpIgnore

const CpVaParseCmd cpIgnore

No result storage, ignores this argument.

◆ cpArgument

const CpVaParseCmd cpArgument

Result storage String*, accepts any argument.

◆ cpArguments

const CpVaParseCmd cpArguments

Result storage Vector<String>*, accepts any number of arguments with the same keyword.

◆ cpString

const CpVaParseCmd cpString

Result storage String*, parsed by cp_string().

◆ cpWord

const CpVaParseCmd cpWord

Result storage String*, parsed by cp_word().

◆ cpKeyword

const CpVaParseCmd cpKeyword

Result storage String*, parsed by cp_keyword().

◆ cpBool

const CpVaParseCmd cpBool

Result storage bool*, parsed by cp_bool().

◆ cpByte

const CpVaParseCmd cpByte

Result storage unsigned char*, parsed by cp_integer().

◆ cpShort

const CpVaParseCmd cpShort

Result storage short*, parsed by cp_integer().

◆ cpUnsignedShort

const CpVaParseCmd cpUnsignedShort

Result storage unsigned short*, parsed by cp_integer().

◆ cpInteger

const CpVaParseCmd cpInteger

Result storage int32_t*, parsed by cp_integer().

◆ cpUnsigned

const CpVaParseCmd cpUnsigned

Result storage uint32_t*, parsed by cp_integer().

◆ cpSize

const CpVaParseCmd cpSize

Result storage size_t*, parsed by cp_integer().

◆ cpNamedInteger

const CpVaParseCmd cpNamedInteger

Parse parameter uint32_t nameinfo_type, result storage int32_t*, parsed by NameInfo::query_int.

◆ cpInteger64

const CpVaParseCmd cpInteger64

Result storage int64_t*, parsed by cp_integer().

◆ cpUnsigned64

const CpVaParseCmd cpUnsigned64

Result storage uint64_t*, parsed by cp_integer().

◆ cpUnsignedReal2

const CpVaParseCmd cpUnsignedReal2

Parse parameter int frac_bits, result storage uint32_t*, parsed by cp_real2().

◆ cpReal10

const CpVaParseCmd cpReal10

Parse parameter int frac_digits, result storage int32_t*, parsed by cp_real10().

◆ cpUnsignedReal10

const CpVaParseCmd cpUnsignedReal10

Parse parameter int frac_digits, result storage uint32_t*, parsed by cp_real10().

◆ cpDouble

const CpVaParseCmd cpDouble

Result storage double*, parsed by cp_double().

◆ cpSeconds

const CpVaParseCmd cpSeconds

Result storage uint32_t*, parsed by cp_seconds_as() with frac_digits 0.

◆ cpSecondsAsMilli

const CpVaParseCmd cpSecondsAsMilli

Result storage uint32_t*, parsed by cp_seconds_as_milli().

◆ cpSecondsAsMicro

const CpVaParseCmd cpSecondsAsMicro

Result storage uint32_t*, parsed by cp_seconds_as_micro().

◆ cpTimestamp

const CpVaParseCmd cpTimestamp

Result storage Timestamp*, parsed by cp_time().

◆ cpTimestampSigned

const CpVaParseCmd cpTimestampSigned

Result storage Timestamp*, parsed by cp_time().

◆ cpTimeval

const CpVaParseCmd cpTimeval

Result storage struct timeval*, parsed by cp_time().

◆ cpBandwidth

const CpVaParseCmd cpBandwidth

Result storage uint32_t*, parsed by cp_bandwidth().

◆ cpIPAddress

const CpVaParseCmd cpIPAddress

Result storage IPAddress* or equivalent, parsed by cp_ip_address().

◆ cpIPPrefix

const CpVaParseCmd cpIPPrefix

Result storage IPAddress* addr and IPAddress *mask, parsed by cp_ip_prefix().

◆ cpIPAddressOrPrefix

const CpVaParseCmd cpIPAddressOrPrefix

Result storage IPAddress* addr and IPAddress *mask, parsed by cp_ip_prefix().

◆ cpIPAddressList

const CpVaParseCmd cpIPAddressList

Result storage Vector<IPAddress>*, parsed by cp_ip_address_list().

◆ cpEtherAddress

const CpVaParseCmd cpEtherAddress

Result storage EtherAddress*, parsed by cp_ethernet_address().

◆ cpEthernetAddress

const CpVaParseCmd cpEthernetAddress

Result storage EtherAddress*, parsed by cp_ethernet_address(). Synonym for cpEtherAddress.

◆ cpTCPPort

const CpVaParseCmd cpTCPPort

Result storage uint16_t*, parsed by cp_tcpudp_port().

◆ cpUDPPort

const CpVaParseCmd cpUDPPort

Result storage uint16_t*, parsed by cp_tcpudp_port().

◆ cpElement

const CpVaParseCmd cpElement

Result storage Element**, parsed by cp_element().

◆ cpElementCast

const CpVaParseCmd cpElementCast

Parse parameter const char*, result storage void**, parsed by cp_element() and Element::cast().

◆ cpHandlerName

const CpVaParseCmd cpHandlerName

Result storage Element** and String*, parsed by cp_handler_name().

◆ cpHandlerCallRead

const CpVaParseCmd cpHandlerCallRead

Result storage HandlerCall*, parsed by HandlerCall.

◆ cpHandlerCallWrite

const CpVaParseCmd cpHandlerCallWrite

Result storage HandlerCall*, parsed by HandlerCall.

◆ cpHandlerCallPtrRead

const CpVaParseCmd cpHandlerCallPtrRead

Result storage HandlerCall**, parsed by HandlerCall::reset_read.

◆ cpHandlerCallPtrWrite

const CpVaParseCmd cpHandlerCallPtrWrite

Result storage HandlerCall**, parsed by HandlerCall::reset_write.

◆ cpIP6Address

const CpVaParseCmd cpIP6Address

Result storage IP6Address* or equivalent, parsed by cp_ip6_address().

◆ cpIP6Prefix

const CpVaParseCmd cpIP6Prefix

Result storage IP6Address* addr and IP6Address* mask, parsed by cp_ip6_prefix().

◆ cpIP6PrefixLen

const CpVaParseCmd cpIP6PrefixLen

Result storage IP6Address* addr and int* prefix_len, parsed by cp_ip6_prefix().

◆ cpIP6AddressOrPrefix

const CpVaParseCmd cpIP6AddressOrPrefix

Result storage IP6Address* addr and IP6Address* mask, parsed by cp_ip6_prefix().

◆ cpFilename

const CpVaParseCmd cpFilename

Result storage String*, parsed by cp_filename().

◆ cpFileOffset

const CpVaParseCmd cpFileOffset

Result storage off_t*, parsed by cp_integer().

◆ cpAnno

const CpVaParseCmd cpAnno

Parse parameter int annotation_size, result storage int*, parsed by cp_anno().

◆ cpOptional

const CpVaParseCmd cpOptional

cp_va_parse only: Following arguments are optional.

◆ cpKeywords

const CpVaParseCmd cpKeywords

cp_va_parse only: Following arguments are keywords.

◆ cpConfirmKeywords

const CpVaParseCmd cpConfirmKeywords

cp_va_parse only: Following arguments are confirmed keywords.

◆ cpMandatoryKeywords

const CpVaParseCmd cpMandatoryKeywords

cp_va_parse only: Following arguments are mandatory keywords.