?? myhttpclient.h
字號(hào):
PCSZ GetKey (DWORD nIdx) throw () ;
MapValue Get (DWORD nIdx) throw (Exception &) ;
PCSZ GetValue (DWORD nIdx) throw () ;
DWORD GetFlag (DWORD nIdx) throw () ;
MapValue Get (PCSZ szName, DWORD nIdx = 0) throw () ;
PCSZ GetValue (PCSZ szName, DWORD nIdx = 0) throw () ;
DWORD GetFlag (PCSZ szName, DWORD nIdx = 0) throw () ;
void AddPointerDirectly (PSZ szName, PSZ szValue = NULL, BOOL dwFlag = 0) throw (Exception &) ;
void Add (PCSZ szName, PCSZ szValue = NULL, BOOL dwFlag = 0) throw (Exception &) ;
void Set (PCSZ szName, PCSZ szValue = NULL, BOOL dwFlag = 0, DWORD nIdx = 0) throw (Exception &) ;
ConstMapIter Begin () const throw () ;
ConstMapIter End () const throw () ;
private:
// Type definitions for map ===================================================
typedef typename std::multimap<PCSZ, MapValue, HttpTool> Map ;
typedef typename std::multimap<PCSZ, MapValue, HttpTool>::iterator MapIter ;
typedef typename std::multimap<PCSZ, MapValue, HttpTool>::size_type MapSizeType ;
typedef std::pair<PCSZ, MapValue> MapItem ;
Map m_map ;
} ;
typedef CHttpClientMapT<CHttpToolA> CHttpClientMapA ;
typedef CHttpClientMapT<CHttpToolW> CHttpClientMapW ;
#ifdef UNICODE
typedef CHttpClientMapW CHttpClientMap ;
#else
typedef CHttpClientMapA CHttpClientMap ;
#endif
///////////////////////////////////////// CHttpClientMapT /////////////////////////////////////////
///////////////////////////////////////// CHttpEncoderT /////////////////////////////////////////
/*!
* \brief This class encodes or decodes a string to use in HTTP operation. (Ansi version)
*
* This class supports various encoding and decoding methods which can be used in various HTTP operations.
*/
class CHttpEncoderA
{
public:
typedef httpclientexceptionA Exception ; //!< typedef of httpclientexceptionA
/*! \brief Returns the number of bytes required to make an Ansi string from a string. */
static DWORD AnsiEncodeLen (PCSTR szStr, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Encodes a string using Ansi character set. */
static PSTR AnsiEncode (PSTR szBuff, PCSTR szStr, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Returns the number of bytes required to make a string from an Ansi string. */
static DWORD AnsiDecodeLen (PCSTR szEncoded, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Decodes an Ansi string to make a string. */
static PSTR AnsiDecode (PSTR szBuff, PCSTR szEncoded, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Returns the number of bytes required to encode a string in UTF-8. */
static DWORD Utf8EncodeLen (PCSTR szStr, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Encodes a string in UTF-8. */
static PSTR Utf8Encode (PSTR szBuff, PCSTR szStr, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Returns the number of bytes required to decode a UTF-8 string. */
static DWORD Utf8DecodeLen (PCSTR szEncoded, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Decodes an UTF-8 string to make a string. */
static PSTR Utf8Decode (PSTR szBuff, PCSTR szEncoded, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Returns the number of bytes required to encode an Ansi string using URL encoding. */
static DWORD UrlEncodeLenA (PCSTR szStr, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &) ;
/*!
* \brief Returns the number of unicode characters required to encode an Ansi string using URL encoding.
*
* This method returns the number of unicode characters required to make a URL-encoded string
* (in Unicode character set) from an Ansi string.
* The URL-encoded string is a string that is safe to transmit from the Web server to a client.
* The returned value does not include a terminating NULL character.
* For more infomation about the Code-Page Identifiers, see the MSDN documentation.
*
* \param szStr [in] A string which is encoded.
* \param bUtf8Encoding [in] If this is TRUE, the string is encoded using UTF-8 encoding
* and that string is used to make a URL-encoded string.
* \param CodePage [in] A code page of the szStr parameter.
* \return The number of unicode characters required. (Not including a terminating NULL character)
* \throw Throws a httpclientexception if an error occurred.
*/
static inline DWORD UrlEncodeLenW (PCSTR szStr, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &)
{return UrlEncodeLenA (szStr, bUtf8Encoding, CodePage) ;}
/*!
* \brief Returns the number of bytes required to encode an Ansi string using URL encoding.
*
* This method returns the number of bytes required to make a URL-encoded string
* (in Ansi character set) from an Ansi string.
* The URL-encoded string is a string that is safe to transmit from the Web server to a client.
* The returned value does not include a terminating NULL character.
* For more infomation about the Code-Page Identifiers, see the MSDN documentation.
*
* \param szStr [in] A string which is encoded.
* \param bUtf8Encoding [in] If this is TRUE, the string is encoded using UTF-8 encoding
* and that string is used to make a URL-encoded string.
* \param CodePage [in] A code page of the szStr parameter.
* \return The number of bytes required. (Not including a terminating NULL character)
* \throw Throws a httpclientexception if an error occurred.
*/
static inline DWORD UrlEncodeLen (PCSTR szStr, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &)
{
return UrlEncodeLenA (szStr, bUtf8Encoding, CodePage) ;
}
/*! \brief Encodes a string using URL encoding. */
static PSTR UrlEncodeA (PSTR szBuff, PCSTR szStr, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Encodes a string using URL encoding. */
static PWSTR UrlEncodeW (PWSTR szBuff, PCSTR szStr, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &) ;
/*!
* \brief Encodes a string using URL encoding.
*
* This method encodes a Ansi string using URL encoding.
* For more infomation about the Code-Page Identifiers, see the MSDN documentation.
*
* \param szBuff [out] A buffer to save the encoded string. The buffer can not be NULL.
* \param szStr [in] A string which is encoded.
* \param bUtf8Encoding [in] If this is TRUE, the string is encoded using UTF-8 encoding
* and that string is used to make a URL-encoded string.
* \param CodePage [in] A code page of the szStr parameter.
* \return An encoded string.
* \throw Throws a httpclientexception if an error occurred.
*/
static inline PSTR UrlEncode (PSTR szBuff, PCSTR szStr, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &)
{
return UrlEncodeA (szBuff, szStr, bUtf8Encoding, CodePage) ;
}
/*! \brief Returns the number of bytes required to decode an URL-encoded string. */
static DWORD UrlDecodeLenA (PCSTR szEncoded, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Returns the number of unicode characters required to decode an URL-encoded string. */
static DWORD UrlDecodeLenW (PCSTR szEncoded, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &) ;
/*!
* \brief Returns the number of bytes required to decode an URL-encoded string.
*
* This method returns the number of bytes required to decode an URL-encoded string. (Ansi version)
* The returned value does not include a terminating NULL character.
* This method does not support the URL-encoded string which contains a unicode character by using the %u or %x prefix.
* For more infomation about the Code-Page Identifiers, see the MSDN documentation.
*
* \param szEncoded [in] A string to decode.
* \param bUtf8Encoding [in] If this is TRUE, the decoded string is assumed an UTF-8 string.
* So the decoded string is converted into an Ansi string.
* \param CodePage [in] A code page of the decoded string.
* \return The number of bytes required. (Not including a terminating NULL character)
* \throw Throws a httpclientexception if an error occurred.
*/
static inline DWORD UrlDecodeLen (PCSTR szEncoded, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &)
{
return UrlDecodeLenA (szEncoded, bUtf8Encoding, CodePage) ;
}
/*! \brief Decodes an URL-encoded string. */
static PSTR UrlDecodeA (PSTR szBuff, PCSTR szEncoded, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Decodes an URL-encoded string. */
static PWSTR UrlDecodeW (PWSTR szBuff, PCSTR szEncoded, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &) ;
/*!
* \brief Decodes an URL-encoded string.
*
* This method decodes an URL-encoded string.
* This method does not support the URL-encoded string which contains a unicode character by using the %u or %x prefix.
* For more infomation about the Code-Page Identifiers, see the MSDN documentation.
*
* \param szBuff [out] A buffer to save the decoded string. The buffer can not be NULL.
* \param szEncoded [in] A string to decode.
* \param bUtf8Encoding [in] If this is TRUE, the decoded string is assumed an UTF-8 string.
* So the decoded string is converted into an Ansi string.
* \param CodePage [in] A code page of the decoded string.
* \return A decoded string.
* \throw Throws a httpclientexception if an error occurred.
*/
static inline PSTR UrlDecode (PSTR szBuff, PCSTR szEncoded, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &)
{
return UrlDecodeA (szBuff, szEncoded, bUtf8Encoding, CodePage) ;
}
private:
/*! \internal \brief Converts an Ansi character into an UTF-8 character. */
static void _AnsiCharToUtf8Char (PSTR szUtf8Char, PCSTR szAnsiChar, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \internal \brief Converts an UTF-8 character into an Ansi character. */
static void _Utf8CharToAnsiChar (PSTR szAnsiChar, PCSTR szUtf8Char, UINT CodePage = CP_ACP) throw (Exception &) ;
} ;
/*!
* \brief This class encodes or decodes a string to use in HTTP operation. (Unicode version)
*
* This class supports various encoding and decoding methods to use in various HTTP operations.
*/
class CHttpEncoderW
{
public:
typedef httpclientexceptionW Exception ; //!< typedef of httpclientexceptionW
/*! \brief Returns the number of bytes required to make an Ansi string from a string. */
static DWORD AnsiEncodeLen (PCWSTR szStr, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Encodes a string using Ansi character set. */
static PSTR AnsiEncode (PSTR szBuff, PCWSTR szStr, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Returns the number of unicode characters required to make a string from an Ansi string. */
static DWORD AnsiDecodeLen (PCSTR szEncoded, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Decodes an Ansi string to make a string. */
static PWSTR AnsiDecode (PWSTR szBuff, PCSTR szEncoded, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Returns the number of characters required to encode a string in UTF-8. */
static DWORD Utf8EncodeLen (PCWSTR szStr, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Encodes a string using UTF-8 encoding. */
static PSTR Utf8Encode (PSTR szBuff, PCWSTR szStr, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Returns the number of characters required to decode an UTF-8 string. */
static DWORD Utf8DecodeLen (PCSTR szEncoded, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Decodes an UTF-8 string. */
static PWSTR Utf8Decode (PWSTR szBuff, PCSTR szEncoded, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Returns the number of bytes required to encode an Unicode string using URL encoding. */
static DWORD UrlEncodeLenA (PCWSTR szStr, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &) ;
/*!
* \brief Returns the number of unicode characters required to encode an Unicode string using URL encoding.
*
* This method returns the number of unicode characters required to make a URL-encoded string
* (in Unicode character set) from an Unicode string.
* The URL-encoded string is a string that is safe to transmit from the Web server to a client.
* The returned value does not include a terminating NULL character.
* For more infomation about the Code-Page Identifiers, see the MSDN documentation.
*
* \param szStr [in] A string which is encoded.
* \param bUtf8Encoding [in] If this is TRUE, the string is encoded using UTF-8 encoding
* and that string is used to make a URL-encoded string.
* \param CodePage [in] A code page of the encoded string.
* \return The number of unicode characters required. (Not including a terminating NULL character)
* \throw Throws a httpclientexception if an error occurred.
*/
static inline DWORD UrlEncodeLenW (PCWSTR szStr, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &)
{return UrlEncodeLenA (szStr, bUtf8Encoding, CodePage) ;}
/*!
* \brief Returns the number of unicode characters required to encode an Unicode string using URL encoding.
*
* This method returns the number of unicode characters required to make a URL-encoded string
* (in Unicode character set) from an Unicode string.
* The URL-encoded string is a string that is safe to transmit from the Web server to a client.
* The returned value does not include a terminating NULL character.
* For more infomation about the Code-Page Identifiers, see the MSDN documentation.
*
* \param szStr [in] A string which is encoded.
* \param bUtf8Encoding [in] If this is TRUE, the string is encoded using UTF-8 encoding
* and that string is used to make a URL-encoded string.
* \param CodePage [in] A code page of the encoded string.
* \return The number of unicode characters required. (Not including a terminating NULL character)
* \throw Throws a httpclientexception if an error occurred.
*/
static inline DWORD UrlEncodeLen (PCWSTR szStr, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &)
{
return UrlEncodeLenW (szStr, bUtf8Encoding, CodePage) ;
}
/*! \brief Encodes a string using URL encoding. */
static PSTR UrlEncodeA (PSTR szBuff, PCWSTR szStr, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Encodes a string using URL encoding. */
static PWSTR UrlEncodeW (PWSTR szBuff, PCWSTR szStr, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &) ;
/*!
* \brief Encodes a string using URL encoding.
*
* This method encodes a Unicode string using URL encoding.
* For more infomation about the Code-Page Identifiers, see the MSDN documentation.
*
* \param szBuff [out] A buffer to save the encoded string. The buffer can not be NULL.
* \param szStr [in] A string which is encoded.
* \param bUtf8Encoding [in] If this is TRUE, the string is encoded using UTF-8 encoding
* and that string is used to make a URL-encoded string.
* \param CodePage [in] A code page of the encoded string.
* \return An encoded string.
* \throw Throws a httpclientexception if an error occurred.
*/
static inline PWSTR UrlEncode (PWSTR szBuff, PCWSTR szStr, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &)
{
return UrlEncodeW (szBuff, szStr, bUtf8Encoding, CodePage) ;
}
/*! \brief Returns the number of bytes required to decode an URL-encoded string. */
static DWORD UrlDecodeLenA (PCWSTR szEncoded, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &) ;
/*! \brief Returns the number of unicode characters required to decode an URL-encoded string. */
static DWORD UrlDecodeLenW (PCWSTR szEncoded, BOOL bUtf8Encoding = FALSE, UINT CodePage = CP_ACP) throw (Exception &) ;
/*!
* \brief Returns the number of unicode characters required to decode an URL-encoded string.
*
* This method returns the number of unicode characters required to decode an URL-encoded string.
* The returned value does not include a terminating NULL character.
* This method does not support the URL-encoded string which contains a unicode character by using the %u or %x prefix.
* For more infomation about the Code-Page Identifiers, see the MSDN documentation.
*
* \param szEncoded [in] A string to decode.
* \param bUtf8Encoding [in] If this is TRUE, the decoded string is assumed an UTF-8 string.
* So the decoded string is converted into an Unicode string.
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -