📄 wy.3wy
字号:
.\".\" Edited by I.J.Wang, 2004.\".TH Wy 3wy "libwy v0.31".SH NAMEWy \- namespace of miscellaneous functions and objects.SH SYNOPSIS.PP.B #include <wynum.h>.PP int \fBWy::_charnum\fP(int) throw() NumType \fBWy::_sqrt\fP(NumType n) WyRet \fBWy::_strnum\fP(NumType&, const char**, WyCSeg, const int&) WyRet \fBWy::_strnum\fP(NumType&, const char**, WyCSeg, int&) WyRet \fBWy::_strnum\fP(NumType&, const char**, WyCSeg) WyRet \fBWy::_scanum\fP(NumType&, size_t&, const WyCSeg&, const int&) WyRet \fBWy::_scanum\fP(NumType&, size_t&, const WyCSeg&).PP.B #include <wymath.h>.PP WyRet \fBWy::_strnum\fP(NumType&, const char**, WyCSeg, const int&) WyRet \fBWy::_strnum\fP(NumType&, const char**, WyCSeg, int&) WyRet \fBWy::_strnum\fP(NumType&, const char**, WyCSeg).PP.B #include <wytimespec.h>.PP WyRet \fBWy::sleep\fP(WyTimeSpec) WyRet \fBWy::sleep\fP(WyTimeSpec, WyTimeSpec&) WyRet \fBWy::sleep_till\fP(WyTimeSpec) WyTimeSpec \fBWy::now\fP(void) WyRet \fBWy::set_systime\fP(const WyTimeSpec&) WyStr \fBWy::wrd\fP(const WyTimeSpec&) WyStr \fBWy::wrd\fP(const WyTimeSpec&, int, size_t) WyRet \fBWy::_mkstr\fP(WyStr&, const WyTimeSpec&, int, size_t) WyRet \fBWy::_strnum\fP(WyTimeSpec&, const char**, WyCSeg) WyRet \fBWy::_strnum\fP(WyTimeSpec&, const char**, WyCSeg, const int&) WyRet \fBWy::_strnum\fP(WyTimeSpec&, const char**, WyCSeg, int&).PP.B #include <wydate.h>.PP WyRet \fBWy::_strftime\fP(WyStr&, const char*, const WyDate&) WyStr \fBWy::wrd\fP(const WyDate&) WyStr \fBWy::local_tzname\fP(void).PP.B #include <wyfilehandle.h>.PP WyRet \fBWy::unlink\fP(const WyStr&) WyRet \fBWy::unlink\fP(const char*) WyRet \fBWy::access\fP(const WyStr&, int) WyRet \fBWy::access\fP(const char*, int) WyRet \fBWy::chdir\fP(const WyStr&) WyRet \fBWy::chdir\fP(const char*) WyRet \fBWy::getcwd\fP(WyStr&) WyRet \fBWy::chown\fP(const WyStr&, uid_t, gid_t) WyRet \fBWy::chown\fP(const char*, uid_t, gid_t) WyRet \fBWy::chmod\fP(const WyStr&, mode_t) WyRet \fBWy::chmod\fP(const char*, mode_t) WyRet \fBWy::link\fP(const WyStr&, const WyStr&) WyRet \fBWy::link\fP(const char*, const char*).PP.B #include <wystr.h>.PP WyRet \fBWy::_mkstr\fP(WyStr&, NumType, int=10) WyRet \fBWy::_mkstr\fP(WyStr&, NumType, int, size_t) WyRet \fBWy::_catstr\fP(WyStr&, NumType, int=10) WyRet \fBWy::_catstr\fP(WyStr&,NumType, int, size_t) int \fBWy::_strcmp\fP(const WyStr&, const WyStr&) throw() int \fBWy::_strcmp\fP(const WyStr&, const WyCSeg&) throw() int \fBWy::_strcmp\fP(const WyStr&, const char*) int \fBWy::_strcmp\fP(const WyCSeg&, const WyStr&) throw() int \fBWy::_strcmp\fP(const char*, const WyStr&) WyStr \fBWy::wrd\fP(const WyReply&) throw(WyStr::Reply) WyStr \fBWy::wrd\fP(const WyRet&) throw(WyStr::Reply) WyStr \fBWy::wrd\fP(const Wy_SrcLoc&) throw(WyStr::Reply) WyStr \fBWy::wrd\fP(NumType, int=10) WyStr \fBWy::wrd\fP(NumType, int, size_t) WyStr& \fBWy::_toupper\fP(WyStr&) throw() WyStr& \fBWy::_tolower\fP(WyStr&) throw().PP.B #include <wybyteflow.h>.PP WyByteFlow& \fBWy::cerr\fP WyByteFlow& \fBWy::cin\fP WyByteFlow& \fBWy::cout\fP.PP.B #include <wyfilestat.h>.PP WyRet \fBWy::stat\fP(const char*, WyFileStat&) WyRet \fBWy::stat\fP(const WyStr&, WyFileStat&) WyRet \fBWy::lstat\fP(const char*, WyFileStat&) WyRet \fBWy::lstat\fP(const WyStr&, WyFileStat&).PP.B #include <wy_thread.h>.PP WyStr \fBWy::wrd\fP(const Wy_ThreadID&).PP.B #include <wyselect.h>.PP WyRet \fBWy::select\fP(Wy_FdSet*, Wy_FdSet*, Wy_FdSet*) WyRet \fBWy::select\fP(Wy_FdSet*, Wy_FdSet*, Wy_FdSet*, const WyTimeSpec&) WyRet \fBWy::select\fP(Wy_FdSet*, Wy_FdSet*, Wy_FdSet*, WyTimeSpec&).PP.B #include <wycseg.h>.PP int \fBWy::_strcmp\fP(const WyCSeg&, const WyCSeg&) throw() int \fBWy::_strcmp\fP(const WyCSeg&, const char*) int \fBWy::_strcmp\fP(const char*, const WyCSeg&) int \fBWy::_strcmp\fP(const char*, const char*) void \fBWy::_strcpy\fP(char*, WyCSeg) void \fBWy::_strmove\fP(char*, char*, size_t) const char* \fBWy::_strchr\fP(const WyCSeg&, char) throw() const char* \fBWy::_strrchr\fP(const WyCSeg&, char) throw() const char* \fBWy::_strstr\fP(const WyCSeg&, const WyCSeg&) throw().PP.B #include <wy_atdestroy.h> template<typename T> void \fBWy::_delete_one\fP(T*) template<typename T> void \fBWy::_delete_array\fP(T*).PP.B #include <wysockaddrlocal.h> WyStr \fBWy::wrd\fP(const WySockAddrLocal&) throw(WyStr::Reply).PP.B #include <wysockaddrinet4.h> WyStr \fBWy::wrd\fP(const WySockAddrINet4&) WyStr \fBWy::wrd\fP(const WySockAddrINet4::IPAddr&).PP.B #include <wysockaddrinet6.h> WyStr \fBWy::wrd\fP(const WySockAddrINet6&) WyStr \fBWy::wrd\fP(const WySockAddrINet6::IPAddr&).SH "DESCRIPTION".\"--------------------------------------------.PP.BI "WyRet Wy::_mkstr(WyStr& " "str" ", NumType " "num" ", int " "radix" "=10)".PP Convert \fInum\fP to text string in \fIradix\fP notation and reset \fIstr\fP with the result. \fBNumtype\fP is implemented for the built-in arithmetic types except long double, e.g. int, float... If the conversion uses digit greater than 9, digit from 10 to 35 are represented by 'A' to 'Z' respectively. For integer type T, the converted string is in the form [-]ddd For float type T, The converted string is in the form [-]ddd.ddd ,\fIradix\fP has to be 10. Or if \fIradix\fP is 0, scientific notation [-]d.ddde(+-)ddd results instead. (The number of digits for fraction is six for this version).PP [\fBRet\fP] Ok Succeed Wym_EINVAL \fIradix\fP not in valid range [0,2-36] Wym_ENOMEM Not enough memory.\"--------------------------------------------.PP.BI "WyRet Wy::_mkstr(WyStr& " "str" ", NumType " "num" ", int " "radix" ", size_t " "frdig" ")".PP Convert \fInum\fP to text string in \fIradix\fP notation and reset \fIstr\fP with the result. \fBNumtype\fP is implemented for the built-in arithmetic types except long double, e.g. int, float... If the conversion uses digit greater than 9, digit from 10 to 35 are represented by 'A' to 'Z' respectively. For integer type T, the converted string is in the form [-]ddd ,\fIfrdig\fP has to be 0. For float type T, the converted string is in the form [-]ddd.ddd ,\fIradix\fP has to be 10. Or if \fIradix\fP is 0, scientific notation [-]d.ddde(+-)ddd results instead. \fIfrdig\fP specifies the digits of fraction. .PP [\fBRet\fP] Ok Succeed Wym_EINVAL \fIradix\fP not in valid range [0,2-36] or \fIfrdig\fP not 0 (NumType is integer type) Wym_ENOMEM Not enough memory.\"--------------------------------------------.PP.BI "WyRet _mkstr(WyStr& " "str" ",const WyTimeSpec& " "num" ", int " "radix" ", size_t " "frdig" ")".PP Convert \fInum\fP to text string in \fIradix\fP notation and reset \fIstr\fP with the result. If the conversion uses digit greater than 9, digit from 10 to 35 are represented by 'A' to 'Z' respectively. The converted string is in the form [-]ddd.ddd, \fIradix\fP has to be 10. Or if \fIradix\fP is 0, scientific notation [-]d.ddde(+-)ddd results instead. \fIfrdig\fP specifies the digits of fraction. .PP [\fBRet\fP] Ok Succeed Wym_EINVAL \fIradix\fP not in valid range Wym_EFBIG \fIstr\fP size exceeds the maximum Wym_ENOMEM Not enough memory.\"--------------------------------------------.PP.BI "WyRet _catstr(WyStr& " "str" ", NumType " "num" ", int " "radix" "=10)".PP Convert \fInum\fP to text string in \fIradix\fP notation and append \fIstr\fP with the result. Function of conversion is the same as \fBWyRet Wy::_mkstr(WyStr&, NumType, int)\fP, except the resultant string is appended to \fIstr\fP..\"--------------------------------------------.PP.BI "WyRet _catstr(WyStr& " "str" ", NumType " "num" ", int " "radix" ", size_t " "frdig" ")".PP Convert \fInum\fP to text string in \fIradix\fP notation and append \fIstr\fP with the result. Function of conversion is the same as \fBWyRet Wy::_mkstr(WyStr&, NumType, int, size_t)\fP, except the resultant string is appended to \fIstr\fP..\"--------------------------------------------.PP.BI "WyRet _strnum(NumType& " "n" ", const char** " "endptr" ", WyCSeg " "cs" ", const int& " "radix" ")".PP Convert string pointed by \fIcs\fP as a number in \fIradix\fP string representation and reset \fIn\fP with the converted result. The string representation begins with optional '+' or '-' followed by optional "0x" and then by digit characters '0'-'9' ,'A'-'Z' or 'a'-'z'. If \fBNumType\fP is float type, the accepted string is in the form: [+-]ddd.ddd[(eE)[+-]ddd] If \fIradix\fP is zero, the radix in effect depends on the prefix of the string: "0x" for radix 16, '0' for radix 8, otherwise radix 10 is assumed. Upon return, \fIn\fP is stored with the longest recognized number notation scanned and converted. If \fIendptr\fP is not NULL, *\fIendptr\fP is written with the value so that [\fIcs\fP.begin(),*\fIendptr\fP) represents the converted number. Note: For float types, \fIradix\fP is implemented for 0 and 10 Error ratio for tested samples (double) is within 1e-14 Error ratio for tested samples (float) is within 1e-7 Note: Long digits in may cause conversion failure.PP [\fBRet\fP] Ok Succeed (fully converted) Wym_EINVAL \fIradix\fP not in range [0,2-36] Wym_ENOENT No number representation recognized Wym_EBADMSG Invalid character encountered (partially converted) Wym_ERANGE Result would be unrepresentable (partially converted).\"--------------------------------------------.PP.BI "WyRet _strnum(NumType& " "n" ", const char** " "endptr" ", WyCSeg " "cs" ", int& " "radix" ")".PP Convert string pointed by \fIcs\fP as a number in \fIradix\fP string representation and reset \fIn\fP with the converted result. The string representation begins with optional '+' or '-' followed by optional "0x" and then by digit characters '0'-'9' ,'A'-'Z' or 'a'-'z'. If \fBNumType\fP is float type, the accepted string is in the form: [+-]ddd.ddd[(eE)[+-]ddd] If \fIradix\fP is zero, the radix in effect depends on the prefix of the string: "0x" for radix 16, '0' for radix 8, otherwise radix 10 is assumed. And \fBthe effective radix in the conversion is written back\fP to \fIradix\fP ("0" is recognized as the zero in radix 10). Upon return, \fIn\fP is stored with the longest recognized number notation scanned and converted. If \fIendptr\fP is not NULL, *\fIendptr\fP is written with the value so that [\fIcs\fP.begin(),*\fIendptr\fP) represents the converted number. Note: For float type \fIradix\fP is implemented for 0 and 10 Error ratio for tested samples (double) is within 1e-14 Error ratio for tested samples (float) is within 1e-7 Note: Long digits in may cause conversion failure.PP [\fBRet\fP] Ok Succeed (fully converted) Wym_EINVAL \fIradix\fP not in range [0,2-36] Wym_ENOENT No number representation recognized Wym_EBADMSG Invalid character encountered (partially converted) Wym_ERANGE Result would be unrepresentable (partially converted).\"--------------------------------------------.PP.BI "WyRet _strnum(NumType& " "n" ", const char** " "endptr" ", WyCSeg " "cs" ")".PP Convert string pointed by \fIcs\fP as a number in radix 10 string representation and reset \fIn\fP with the converted result. Functionality is the same as _strnum(\fIn\fP,\fIendptr\fP,\fIcs\fP,10).\"--------------------------------------------.PP.BI "WyRet _scanum(NumType& " "n" ", size_t& " "idx" ", const WyCSeg& " "text" ", const int& " "radix" ")".PP Scan for the first non-blank string from &\fItext\fP[\fIidx\fP], converted as number representation in \fIradix\fP notation. On successful return, \fIn\fP is reset with the converted result and \fIidx\fP is reset to the one-past-the-last position of the converted string representation. If \fIradix\fP is zero, the radix in effect depends on the prefix of the string: "0x" for radix 16, '0' for radix 8, otherwise radix 10 is assumed..PP [\fBRet\fP] Ok Succeed Wym_EINVAL \fIradix\fP not in range [0,2-36] Wym_ENOENT No number representation recognized Wym_ERANGE Result would be unrepresentable .\"--------------------------------------------.PP.BI "WyRet _scanum(NumType& " "n" ", size_t& " "idx" ", const WyCSeg& " "text" ")".PP Scan for the first non-blank string from &\fItext\fP[\fIidx\fP], converted as number representation in radix 10 notation. On successful return, \fIn\fP is reset with the converted result and \fIidx\fP is reset to the one-past-the-last position of the converted string representation..PP [\fBRet\fP] Ok Succeed Wym_ENOENT No number representation recognized Wym_ERANGE Result would be unrepresentable .\"--------------------------------------------.PP.BI "int _charnum(int " "ch" ") throw()".PP Convert the character \fIch\fP number representation to number The characters for number are '0'-'9' for 0 to 9, 'A'-'Z' and 'a'-'z' for 10 to 35. This function defines the digit characters used by _strnum.PP [\fBRet\fP] The number represented by character \fIch\fP, [0-35]. Or -1, if \fIch\fP does not represent a number.\"--------------------------------------------.PP.BI "NumType _sqrt(NumType " "n" ")".PP Compute the square root of \fIn\fP Note: NumType is implemented for unsigned integer types.PP [\fBRet\fP] Floor of square root of \fIn\fP.\"--------------------------------------------.PP.BI "WyRet Wy::_strnum(WyTimeSpec& " "n" ", const char** " "endptr" ", WyCSeg " "cs" ")".PP.BI "WyRet Wy::_strnum(WyTimeSpec& " "n" ", const char** " "endptr" ", WyCSeg " "cs" ", const int& " "index" ")".PP.BI "WyRet Wy::_strnum(WyTimeSpec& " "n" ", const char** " "endptr" ", WyCSeg " "cs" ", int& " "index" ")".PP These are _strnum function overloads for WyTimeSpec. Definition is the same as that for type float. Note: Digits representing numbers less than 1/billion are ignored \fBWarning\fP: Non-Ok postcondition is not reliable (implementation)!.\"--------------------------------------------.PP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -