teditor  1.8.0@@fee5e94
Terminal based editor written in C++
Classes | Namespaces | Macros | Typedefs | Functions
utils.h File Reference
#include <algorithm>
#include <string>
#include <stdexcept>
#include <vector>
#include <stdarg.h>
#include <unordered_map>

Go to the source code of this file.

Classes

struct  teditor::CmdStatus
 
class  teditor::History
 Container to store history (files-visited or command-history, etc) More...
 

Namespaces

 teditor
 

Macros

#define THROW(fmt, ...)
 Macro to throw runtime_error exception. More...
 
#define ASSERT(check, fmt, ...)
 Macro to assert with runtime_error exception if the check fails. More...
 

Typedefs

typedef std::vector< std::string > teditor::Strings
 

Functions

std::string teditor::format (const char *fmt,...)
 
std::string teditor::format (const char *fmt, va_list &vl)
 
bool teditor::allStringsEmpty (const Strings &strs)
 
template<typename T >
bool teditor::same (const std::vector< T > &s1, const std::vector< T > &s2)
 
std::string teditor::env (const std::string &s)
 
std::string teditor::expandEnvVars (const std::string &str)
 
bool teditor::startsWith (const char *s1, int len1, const char *s2)
 
Strings teditor::split (const std::string &str, char delim)
 
std::string teditor::join (const Strings &s, char delim, int start, int end)
 
std::string teditor::num2str (int num)
 
int teditor::str2num (const std::string &str)
 
float teditor::str2real (const std::string &str)
 
double teditor::str2double (const std::string &str)
 
bool teditor::isUnderGit (const std::string &dir)
 
std::string teditor::gitBranchName (const std::string &dir)
 
CmdStatus teditor::check_output (const std::string &cmd)
 
CmdStatus teditor::check_output (const std::string &cmd, const std::string &host)
 
std::string teditor::urlHexify (const std::string &url)
 Hexify the input url. More...
 
void teditor::downloadUrl (const std::string &url, const std::string &file, const std::string &dnldProg="curl", const std::string &dnldProgOpts="-s")
 Download the content of input url into the given file. More...
 
std::string teditor::downloadUrlToString (const std::string &url, const std::string &dnldProg="curl", const std::string &dnldProgOpts="-s")
 Download the content of input url into a string. More...
 
bool teditor::isOpenParen (char c)
 
bool teditor::isCloseParen (char c)
 
bool teditor::isParen (char c)
 
char teditor::getMatchingParen (char c)
 
bool teditor::strFind (const std::string &line, const std::string &str)
 
bool teditor::iStrFind (const std::string &line, const std::string &str)
 
void teditor::dos2unix (std::string &in)
 
std::string teditor::dos2unix (const std::string &in)
 
unsigned teditor::numThreads ()
 
template<typename K , typename V >
std::vector< K > teditor::sortedKeys (const std::unordered_map< K, V > &map)
 

Macro Definition Documentation

◆ ASSERT

#define ASSERT (   check,
  fmt,
  ... 
)
Value:
do { \
if(!(check)) THROW(fmt, ##__VA_ARGS__); \
} while(0)

Macro to assert with runtime_error exception if the check fails.

Parameters
checkthe boolean check to be performed
fmtC-string format containing error message

◆ THROW

#define THROW (   fmt,
  ... 
)
Value:
do { \
std::string msg = format("Exception occured! file=%s line=%d: " \
fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
throw std::runtime_error(msg); \
} while(0)

Macro to throw runtime_error exception.

Parameters
fmtC-string format containing error message
THROW
#define THROW(fmt,...)
Macro to throw runtime_error exception.
Definition: utils.h:22
teditor::format
std::string format(const char *fmt, va_list &vl)
Definition: utils.cpp:22