|
CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
|
Functions | |
| std::string | DecodeHTML (std::string str) |
| Decode HTML entities in a string (e.g. | |
| std::string | EncodeHTML (std::string str) |
| Encode a plain string for safe embedding in HTML (e.g. | |
| unsigned char | HTML2Char (const char *str) |
| Convert a single HTML entity (e.g. | |
| bool | GetMimeType (char *dest, const char *filename, uint32 maxsize) |
| Look up the MIME type for a filename based on its extension. | |
| bool | GetMimeType (char *dest, const char *filename, uint32 maxsize, bool &isBinary) |
| Look up the MIME type for a filename and report whether it is binary. | |
| bool | IsMimeBinary (const char *type) |
| Determine whether a MIME type denotes binary content. | |
| std::string | GetUsernameFromURL (std::string url) |
| Extract the username from a URL of the form scheme://user:pass@host/... | |
| std::string | GetPasswordFromURL (std::string url) |
| Extract the password from a URL of the form scheme://user:pass@host/... | |
| std::string | GetAuthenticationFromURL (std::string url) |
| Extract the full "user:pass" authentication section from a URL. | |
| std::string | GetHostFromURL (std::string url) |
| Extract the host name (or IP literal) from a URL. | |
| uint16 | GetPortFromURL (std::string url) |
| Extract the port number from a URL. | |
| std::string | GetProtocolFromURL (std::string url) |
| Extract the protocol/scheme from a URL. | |
| std::string | GetURIFromURL (std::string url) |
| Extract the URI (path plus query) from a URL. | |
| bool | HTML_UnitTest () |
| Self-contained unit test of the HTML/URL helpers. | |
| std::string cmlabs::html::DecodeHTML | ( | std::string | str | ) |
Decode HTML entities in a string (e.g.
"&lt;" to "<", "&#65;" to "A").
| str | Input string possibly containing HTML entities. |
Definition at line 12 of file HTML.cpp.
References HTML2Char().
Referenced by cmlabs::PostSpec::contentFromXML(), HTML_UnitTest(), cmlabs::RESTParser::parseRequest(), cmlabs::HTTPRequest::parseURIParameters(), and cmlabs::RESTRequest::RESTRequest().
| std::string cmlabs::html::EncodeHTML | ( | std::string | str | ) |
Encode a plain string for safe embedding in HTML (e.g.
"<" to "&lt;").
| str | Input plain-text string. |
Definition at line 51 of file HTML.cpp.
Referenced by cmlabs::RESTRequest::getStorageMessageCopy(), HTML_UnitTest(), cmlabs::utils::TextJoinXML(), cmlabs::LogEntry::toXML(), cmlabs::PostSpec::toXML(), and cmlabs::ProcessInfoStruct::toXML().
| std::string cmlabs::html::GetAuthenticationFromURL | ( | std::string | url | ) |
Extract the full "user:pass" authentication section from a URL.
| url | Full URL string. |
Definition at line 279 of file HTML.cpp.
Referenced by GetPasswordFromURL(), and GetUsernameFromURL().
| std::string cmlabs::html::GetHostFromURL | ( | std::string | url | ) |
Extract the host name (or IP literal) from a URL.
| url | Full URL string. |
Definition at line 291 of file HTML.cpp.
Referenced by cmlabs::NetworkChannel::createWebsocketConnection(), cmlabs::RESTHTTPCall::generateHTTPRequest(), HTML_UnitTest(), cmlabs::NetworkManager::makeHTTPRequest(), cmlabs::NetworkManager::makeHTTPRequest(), and cmlabs::NetworkManager::makeHTTPRequest().
| bool cmlabs::html::GetMimeType | ( | char * | dest, |
| const char * | filename, | ||
| uint32 | maxsize ) |
Look up the MIME type for a filename based on its extension.
| dest | Caller-provided buffer receiving the MIME type string (e.g. "text/html"). |
| filename | File name or path whose extension determines the type. |
| maxsize | Capacity of dest in bytes (output is truncated to fit). |
Definition at line 137 of file HTML.cpp.
References GetMimeType().
Referenced by cmlabs::HTTPReply::createFromFile(), GetMimeType(), and HTML_UnitTest().
| bool cmlabs::html::GetMimeType | ( | char * | dest, |
| const char * | filename, | ||
| uint32 | maxsize, | ||
| bool & | isBinary ) |
Look up the MIME type for a filename and report whether it is binary.
| dest | Caller-provided buffer receiving the MIME type string. |
| filename | File name or path whose extension determines the type. |
| maxsize | Capacity of dest in bytes. |
| isBinary | Set to true when the content should be treated as binary (no text transformations, Content-Length required), false for text types. |
Definition at line 142 of file HTML.cpp.
References cmlabs::utils::strcpyavail(), and cmlabs::utils::TextEndsWith().
| std::string cmlabs::html::GetPasswordFromURL | ( | std::string | url | ) |
Extract the password from a URL of the form scheme://user:pass@host/...
| url | Full URL string. |
Definition at line 267 of file HTML.cpp.
References GetAuthenticationFromURL().
| uint16 cmlabs::html::GetPortFromURL | ( | std::string | url | ) |
Extract the port number from a URL.
| url | Full URL string. |
Definition at line 314 of file HTML.cpp.
References cmlabs::utils::Ascii2Uint32().
Referenced by cmlabs::NetworkChannel::createWebsocketConnection(), HTML_UnitTest(), cmlabs::NetworkManager::makeHTTPRequest(), cmlabs::NetworkManager::makeHTTPRequest(), and cmlabs::NetworkManager::makeHTTPRequest().
| std::string cmlabs::html::GetProtocolFromURL | ( | std::string | url | ) |
Extract the protocol/scheme from a URL.
| url | Full URL string. |
Definition at line 333 of file HTML.cpp.
Referenced by cmlabs::NetworkChannel::createWebsocketConnection(), HTML_UnitTest(), cmlabs::NetworkManager::makeHTTPRequest(), cmlabs::NetworkManager::makeHTTPRequest(), and cmlabs::NetworkManager::makeHTTPRequest().
| std::string cmlabs::html::GetURIFromURL | ( | std::string | url | ) |
Extract the URI (path plus query) from a URL.
| url | Full URL string. |
Definition at line 348 of file HTML.cpp.
Referenced by cmlabs::NetworkChannel::createWebsocketConnection(), cmlabs::RESTHTTPCall::generateHTTPRequest(), HTML_UnitTest(), cmlabs::NetworkManager::makeHTTPRequest(), cmlabs::NetworkManager::makeHTTPRequest(), and cmlabs::NetworkManager::makeHTTPRequest().
| std::string cmlabs::html::GetUsernameFromURL | ( | std::string | url | ) |
Extract the username from a URL of the form scheme://user:pass@host/...
| url | Full URL string. |
Definition at line 255 of file HTML.cpp.
References GetAuthenticationFromURL().
| unsigned char cmlabs::html::HTML2Char | ( | const char * | str | ) |
Convert a single HTML entity (e.g.
"&amp;" or "&#38;") to its character.
| str | Pointer to the entity text (starting at or after '&'). |
Definition at line 90 of file HTML.cpp.
Referenced by DecodeHTML(), and HTML_UnitTest().
| bool cmlabs::html::HTML_UnitTest | ( | ) |
Self-contained unit test of the HTML/URL helpers.
Definition at line 362 of file HTML.cpp.
References DecodeHTML(), cmlabs::unittest::detail(), EncodeHTML(), cmlabs::unittest::fail(), GetHostFromURL(), GetMimeType(), GetPortFromURL(), GetProtocolFromURL(), cmlabs::GetTimeNow(), GetURIFromURL(), HTML2Char(), IsMimeBinary(), cmlabs::unittest::metric(), and cmlabs::unittest::progress().
Referenced by cmlabs::Register_HTML_Tests().
| bool cmlabs::html::IsMimeBinary | ( | const char * | type | ) |
Determine whether a MIME type denotes binary content.
| type | MIME type string, e.g. "image/png". |
Definition at line 130 of file HTML.cpp.
References cmlabs::utils::stristr().
Referenced by cmlabs::HTTPRequest::createMultipartRequest(), cmlabs::RESTHTTPCall::generateHTTPRequest(), and HTML_UnitTest().