⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 confparse.hh

📁 Click is a modular router toolkit. To use it you ll need to know how to compile and install the sof
💻 HH
📖 第 1 页 / 共 2 页
字号:
    cp_argtype* next;    cp_parsefunc parse;    cp_storefunc store;    void* user_data;    int flags;    const char* description;    int internal;    int use_count;};struct cp_value {    // set by cp_va_parse:    const cp_argtype* argtype;    const char* keyword;    const char* description CLICK_CONFPARSE_DEPRECATED;    union {	int i;	const char *c_str;	void *p;    } extra;    void* store;    void* store2;    bool* store_confirm;    // set by parsefunc, used by storefunc:    union {	bool b;	int32_t i;	uint32_t u;#if HAVE_INT64_TYPES	int64_t i64;	uint64_t u64;#endif	size_t size;#if HAVE_FLOAT_TYPES	double d;#endif	unsigned char address[16];	int is[4];#ifndef CLICK_TOOL	Element *element;#endif	void *p;    } v, v2;    String v_string;    String v2_string;};enum {    cpArgNormal = 0, cpArgStore2 = 1, cpArgExtraInt = 2,    cpArgExtraCStr = 4, cpArgAllowNumbers = 8};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, ...);// Takes: const char* name, int value, ...., const char* ender = (const char*)0//@}/// @cond neverbool cp_seconds_as(int want_power, const String& str, uint32_t* result) CLICK_DEPRECATED;#define cp_integer64 cp_integer#define cp_unsigned64 cp_integer#define cp_unsigned cp_integer#define cp_unsigned_real10 cp_real10#define cp_unsigned_real2 cp_real2/// @endcond/** @brief  Join the strings in @a conf with spaces and return the result. * *  This function does not quote or otherwise protect the strings in @a conf. *  The caller should do that if necessary. *  @sa cp_unspacevec(const String *, const String *) */inline String cp_unspacevec(const Vector<String>& conf){    return cp_unspacevec(conf.begin(), conf.end());}/** @brief  Test if @a str is all spaces. *  @return True when every character in @a str is a space. */inline bool cp_is_space(const String& str){    return cp_skip_space(str.begin(), str.end()) == str.end();}/** @brief  Parse an integer from [@a begin, @a end) in base @a base. * @param  begin  first character in string * @param  end    one past last character in string * @param  base   base of integer: 0 or 2-36 * @param[out]  result  stores parsed result * @return  pointer to first unparsed character in string; equals @a 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 *@a result. * * The integer format consists of an optional initial sign <tt>+/-</tt>, * followed by one or more digits.  A negative sign is only accepted if @a * 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: * * @code * 0 * 0x100 * -1_000_023 * @endcode * * Digits are numbered from 0-9, then A-Z/a-z.  @a base determines which * digits are legal.  If @a base is 0, then a leading <tt>0x</tt> or * <tt>0X</tt> may precede the digits, indicating base 16; a leading * <tt>0</tt> 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 * @a begin; *@a result is unchanged. * * This function checks for overflow.  If an integer is too large for @a * result, then the maximum possible value is stored in @a 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 @a result values. */inline const char *cp_integer(const char *begin, const char *end, int base, int *result){    return cp_basic_integer(begin, end, base, -(int) sizeof(*result), result);}/** @brief  Parse an integer from @a str in base @a base. * @param  str   string * @param  base  base of integer: 0 or 2-36 * @param[out]  result  stores parsed result * @return  True if @a 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 *@a result and the * function returns true.  Otherwise, *@a 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 @a * result values. * * @sa cp_integer(const char *, const char *, int, int *) for the rules on * parsing integers. */inline bool cp_integer(const String &str, int base, int *result){    return cp_basic_integer(str.begin(), str.end(), base + cp_basic_integer_whole, -(int) sizeof(*result), result) != str.begin();}inline const char *cp_integer(const char *begin, const char *end, int base, unsigned *result){    return cp_basic_integer(begin, end, base, (int) sizeof(*result), result);}/// @cond neverinline const unsigned char *cp_integer(const unsigned char *begin, const unsigned char *end, int base, unsigned *result){    return reinterpret_cast<const unsigned char *>(cp_integer(reinterpret_cast<const char *>(begin), reinterpret_cast<const char *>(end), base, result));}/// @endcondinline const char *cp_integer(const char *begin, const char *end, int base, long *result){    return cp_basic_integer(begin, end, base, -(int) sizeof(*result), result);}inline const char *cp_integer(const char *begin, const char *end, int base, unsigned long *result){    return cp_basic_integer(begin, end, base, (int) sizeof(*result), result);}/// @cond neverinline const unsigned char *cp_integer(const unsigned char *begin, const unsigned char *end, int base, unsigned long *result){    return reinterpret_cast<const unsigned char *>(cp_integer(reinterpret_cast<const char *>(begin), reinterpret_cast<const char *>(end), base, result));}/// @endcond#if HAVE_LONG_LONGinline const char *cp_integer(const char *begin, const char *end, int base, long long *result){    return cp_basic_integer(begin, end, base, -(int) sizeof(*result), result);}inline const char *cp_integer(const char *begin, const char *end, int base, unsigned long long *result){    return cp_basic_integer(begin, end, base, (int) sizeof(*result), result);}/// @cond neverinline const unsigned char *cp_integer(const unsigned char *begin, const unsigned char *end, int base, unsigned long long *result){    return reinterpret_cast<const unsigned char *>(cp_integer(reinterpret_cast<const char *>(begin), reinterpret_cast<const char *>(end), base, result));}/// @endcond#elif HAVE_INT64_TYPES && !HAVE_INT64_IS_LONGinline const char *cp_integer(const char *begin, const char *end, int base, int64_t *result){    return cp_basic_integer(begin, end, base, -(int) sizeof(*result), result);}inline const char *cp_integer(const char *begin, const char *end, int base, uint64_t *result){    return cp_basic_integer(begin, end, base, (int) sizeof(*result), result);}/// @cond neverinline const unsigned char *cp_integer(const unsigned char *begin, const unsigned char *end, int base, uint64_t *result){    return reinterpret_cast<const unsigned char *>(cp_integer(reinterpret_cast<const char *>(begin), reinterpret_cast<const char *>(end), base, result));}/// @endcond#endifinline bool cp_integer(const String &str, int base, int *result);inline bool cp_integer(const String &str, int base, unsigned int *result){    return cp_basic_integer(str.begin(), str.end(), base + cp_basic_integer_whole, (int) sizeof(*result), result) != str.begin();}inline bool cp_integer(const String &str, int base, long *result){    return cp_basic_integer(str.begin(), str.end(), base + cp_basic_integer_whole, -(int) sizeof(*result), result) != str.begin();}inline bool cp_integer(const String &str, int base, unsigned long *result){    return cp_basic_integer(str.begin(), str.end(), base + cp_basic_integer_whole, (int) sizeof(*result), result) != str.begin();}#if HAVE_LONG_LONGinline bool cp_integer(const String &str, int base, long long *result){    return cp_basic_integer(str.begin(), str.end(), base + cp_basic_integer_whole, -(int) sizeof(*result), result) != str.begin();}inline bool cp_integer(const String &str, int base, unsigned long long *result){    return cp_basic_integer(str.begin(), str.end(), base + cp_basic_integer_whole, (int) sizeof(*result), result) != str.begin();}#elif HAVE_INT64_TYPES && !HAVE_INT64_IS_LONGinline bool cp_integer(const String &str, int base, int64_t *result){    return cp_basic_integer(str.begin(), str.end(), base + cp_basic_integer_whole, -(int) sizeof(*result), result) != str.begin();}inline bool cp_integer(const String &str, int base, uint64_t *result){    return cp_basic_integer(str.begin(), str.end(), base + cp_basic_integer_whole, (int) sizeof(*result), result) != str.begin();}#endif/** @brief  Parse an integer from @a str in base 0. * *  Same as cp_integer(str, 0, result). */inline bool cp_integer(const String &str, int *result){    return cp_basic_integer(str.begin(), str.end(), cp_basic_integer_whole, -(int) sizeof(*result), result) != str.begin();}inline bool cp_integer(const String &str, unsigned int *result){    return cp_basic_integer(str.begin(), str.end(), cp_basic_integer_whole, (int) sizeof(*result), result) != str.begin();}inline bool cp_integer(const String &str, long *result){    return cp_basic_integer(str.begin(), str.end(), cp_basic_integer_whole, -(int) sizeof(*result), result) != str.begin();}inline bool cp_integer(const String &str, unsigned long *result){    return cp_basic_integer(str.begin(), str.end(), cp_basic_integer_whole, (int) sizeof(*result), result) != str.begin();}#if HAVE_LONG_LONGinline bool cp_integer(const String &str, long long *result){    return cp_basic_integer(str.begin(), str.end(), cp_basic_integer_whole, -(int) sizeof(*result), result) != str.begin();}inline bool cp_integer(const String &str, unsigned long long *result){    return cp_basic_integer(str.begin(), str.end(), cp_basic_integer_whole, (int) sizeof(*result), result) != str.begin();}#elif HAVE_INT64_TYPES && !HAVE_INT64_IS_LONGinline bool cp_integer(const String &str, int64_t *result){    return cp_basic_integer(str.begin(), str.end(), cp_basic_integer_whole, -(int) sizeof(*result), result) != str.begin();}inline bool cp_integer(const String &str, uint64_t *result){    return cp_basic_integer(str.begin(), str.end(), cp_basic_integer_whole, (int) sizeof(*result), result) != str.begin();}#endifinline bool cp_ip_address(const String& str, struct in_addr* ina  CP_CONTEXT){    return cp_ip_address(str, reinterpret_cast<IPAddress*>(ina)  CP_PASS_CONTEXT);}/// @cond neverinline bool cp_seconds_as(int want_power, const String &str, uint32_t *result){    return cp_seconds_as(str, want_power, result);}#if !CLICK_TOOLinline int cp_register_argtype(const char* name, const char* description, int flags,			       void (*parsefunc)(cp_value *, const String &, ErrorHandler *, const char *, Element *),			       void (*storefunc)(cp_value *, Element *),			       void *user_data = 0) {    return cp_register_argtype(name, description, flags,			       (cp_parsefunc) parsefunc,			       (cp_storefunc) storefunc,			       user_data);}#endifinline String cp_pop_spacevec(String &str) CLICK_DEPRECATED;/// @brief  Remove and return the first space-separated argument from @a str./// @param[in,out]  str  space-separated configuration string/// @deprecated This is a deprecated synonym for cp_shift_spacevec().inline String cp_pop_spacevec(String &str) {    return cp_shift_spacevec(str);}#undef CP_VA_ARGS_REST#undef CP_OPT_CONTEXT#undef CP_CONTEXT#undef CP_PASS_CONTEXT#undef CLICK_CONFPARSE_DEPRECATED#undef CP_SENTINEL#define cpEnd ((CpVaParseCmd) 0)/// @endcondCLICK_ENDDECLS#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -