Login Languish
Functions
utils.h File Reference

handles generic tasks More...

#include <iostream>
#include <fstream>
#include <vector>
#include "rapidjson/document.h"
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::string loadStringFromFile (std::string filepath)
 loads content from specified file to a string More...
 
std::string JSEncode (const std::string &message)
 encodes a string in base 64 More...
 
std::string JSEncode (const std::vector< std::string > &message)
 encodes strings in a vector to base 64 More...
 
std::string JSONToString (const rapidjson::Document &doc)
 converts RapidJSON documents to a string representation More...
 
std::string url_encode (const std::string &value)
 encodes a string into a url More...
 
std::string base64Decode (const std::string &value)
 decodes a base 64 message More...
 
bool caseInsensitiveEquals (const std::string &a, const std::string &b)
 

Detailed Description

handles generic tasks

Author
Jeb Nicholson

Function Documentation

◆ base64Decode()

std::string base64Decode ( const std::string &  value)

decodes a base 64 message

Parameters
valuemessage to be decoded
Returns
the decoded message

◆ JSEncode() [1/2]

std::string JSEncode ( const std::string &  message)

encodes a string in base 64

Parameters
messagestring to be encoded
Returns
the encoded base 64 string

◆ JSEncode() [2/2]

std::string JSEncode ( const std::vector< std::string > &  message)

encodes strings in a vector to base 64

Parameters
messagevector of strings to be encoded
Returns
string representation of an array of base 64 encoded messages

◆ JSONToString()

std::string JSONToString ( const rapidjson::Document &  doc)

converts RapidJSON documents to a string representation

Parameters
docthe RapidJSON document to be converted
Returns
string representation JSON

◆ loadStringFromFile()

std::string loadStringFromFile ( std::string  filepath)

loads content from specified file to a string

Parameters
pathto file
Returns
file content
Parameters
pathstring representation of file path
Returns
file content

◆ url_encode()

std::string url_encode ( const std::string &  value)

encodes a string into a url

from https://stackoverflow.com/a/17708801 (xperroni)

Parameters
valuethe string to be encoded
Returns
string representation of the encoded url