Agents 1.4.0
Edge AI Agents SDK
Loading...
Searching...
No Matches
agents::Utils Class Reference

Utility class providing static helper functions. More...

#include <utils.h>

Static Public Member Functions

static void changeKey (JsonObject &object, const std::string &old_key, const std::string &new_key)
 Change a key in a JSON object.
static std::string toLower (const std::string &s)
 Convert a string to lowercase.
static std::string toUpper (const std::string &s)
 Convert a string to uppercase.
static std::vector< std::string > splitByNewline (const std::string &text)
 Split a string by newlines.
static void trim (std::string &s)
 String trim helper.
static std::string getBaseUrl (const std::string &url)
 Extract the path (including leading '/') from a full URL.
static std::string getPathFromUrl (const std::string &url)
 Extract the path (including leading '/') from a full URL.
static std::string getHostFromUrl (const std::string &url)
 Get the hostname From Url object.
static int getPortFromUrl (const std::string &url)
 Get the port from a URL string.

Detailed Description

Utility class providing static helper functions.

Member Function Documentation

◆ changeKey()

void agents::Utils::changeKey ( JsonObject & object,
const std::string & old_key,
const std::string & new_key )
inlinestatic

Change a key in a JSON object.

Parameters
objectThe JSON object
old_keyThe old key name
new_keyThe new key name

◆ getBaseUrl()

std::string agents::Utils::getBaseUrl ( const std::string & url)
inlinestatic

Extract the path (including leading '/') from a full URL.

Example: https://example.com/api/search?q=x -> /api/search?q=x

Parameters
urlFull URL
Returns
std::string Path and query portion

◆ getHostFromUrl()

std::string agents::Utils::getHostFromUrl ( const std::string & url)
inlinestatic

Get the hostname From Url object.

(e.g., "127.0.0.1") stripping "http://" and ":8080"

Parameters
urlThe URL string
Returns
std::string The hostname portion of the URL

◆ getPathFromUrl()

std::string agents::Utils::getPathFromUrl ( const std::string & url)
inlinestatic

Extract the path (including leading '/') from a full URL.

Example: https://example.com/api/search?q=x -> /api/search?q=x

Parameters
urlFull URL
Returns
std::string Path and query portion

◆ getPortFromUrl()

int agents::Utils::getPortFromUrl ( const std::string & url)
inlinestatic

Get the port from a URL string.

Returns the port as an integer (defaulting to 80 or 443 if not found)

Parameters
urlThe URL string
Returns
int The port number

◆ splitByNewline()

std::vector< std::string > agents::Utils::splitByNewline ( const std::string & text)
inlinestatic

Split a string by newlines.

Parameters
textThe text to split
Returns
The lines

◆ toLower()

std::string agents::Utils::toLower ( const std::string & s)
inlinestatic

Convert a string to lowercase.

Parameters
sThe input string
Returns
The lowercase string

◆ toUpper()

std::string agents::Utils::toUpper ( const std::string & s)
inlinestatic

Convert a string to uppercase.

Parameters
sThe input string
Returns
std::string

◆ trim()

void agents::Utils::trim ( std::string & s)
inlinestatic

String trim helper.

Parameters
sthe input string