CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
HTML.h File Reference

HTML/URL helper utilities: entity encoding/decoding, MIME type lookup and URL component parsing. More...

#include "Utils.h"
Include dependency graph for HTML.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  cmlabs
namespace  cmlabs::html

Functions

std::string cmlabs::html::DecodeHTML (std::string str)
 Decode HTML entities in a string (e.g.
std::string cmlabs::html::EncodeHTML (std::string str)
 Encode a plain string for safe embedding in HTML (e.g.
unsigned char cmlabs::html::HTML2Char (const char *str)
 Convert a single HTML entity (e.g.
bool cmlabs::html::GetMimeType (char *dest, const char *filename, uint32 maxsize)
 Look up the MIME type for a filename based on its extension.
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.
bool cmlabs::html::IsMimeBinary (const char *type)
 Determine whether a MIME type denotes binary content.
std::string cmlabs::html::GetUsernameFromURL (std::string url)
 Extract the username from a URL of the form scheme://user:pass@host/...
std::string cmlabs::html::GetPasswordFromURL (std::string url)
 Extract the password from a URL of the form scheme://user:pass@host/...
std::string cmlabs::html::GetAuthenticationFromURL (std::string url)
 Extract the full "user:pass" authentication section from a URL.
std::string cmlabs::html::GetHostFromURL (std::string url)
 Extract the host name (or IP literal) from a URL.
uint16 cmlabs::html::GetPortFromURL (std::string url)
 Extract the port number from a URL.
std::string cmlabs::html::GetProtocolFromURL (std::string url)
 Extract the protocol/scheme from a URL.
std::string cmlabs::html::GetURIFromURL (std::string url)
 Extract the URI (path plus query) from a URL.
bool cmlabs::html::HTML_UnitTest ()
 Self-contained unit test of the HTML/URL helpers.

Detailed Description

HTML/URL helper utilities: entity encoding/decoding, MIME type lookup and URL component parsing.

Small, dependency-light helpers used throughout the networking stack (NetworkProtocols, NetworkManager's built-in HTTP server, RequestGateway web serving). Two families of functions live here:

  • HTML text handling: entity encode/decode (e.g. "&" ↔ "&") and MIME type resolution from file extensions, used when serving files over HTTP.
  • URL parsing: extraction of protocol, host, port, URI path and embedded basic-auth credentials from URL strings such as "https://user:pass@host:8080/path?x=1".

All functions are stateless and thread-safe (no shared mutable state); std::string arguments are taken by value and results returned by value.

Definition in file HTML.h.