WPOCT Software Developer's Kit (SDK)
SDK For using Wasatch Photonics OCT Spectrometers
Macros | Functions
Helper.h File Reference

Utility template functions. More...

#include <fstream>
#include <sstream>
#include <vector>
Include dependency graph for Helper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool ParseBool (const char *str)
 
int ParseNumberInt (const char *str)
 
double ParseNumberDouble (const char *str)
 
void Waitms (int val)
 
std::string GetUserProfile ()
 
void GetFullPathName (const char *rpstr, char *&ret_buff, int buffLen)
 
void GetFullPathName (const char *relativePathName, const char *initPath, char *&ret_buff, int buffLen)
 
std::string GetFullPathName (std::string relativePathName, std::string initPath)
 
std::string GetFilledDigits (int number, size_t totalDigits)
 Gets the string prefixed with zeros so the string is a certain length. More...
 
void StringToLower (std::string &str)
 
void StringToUpper (std::string &str)
 
template<class T >
void __declspec(dllexport) smessage(std void SafeDelete (T *&pVal)
 messaging More...
 
template<class T >
void SafeDeleteArray (T *&pVal)
 Safely delete memory that was allocated with new[]. More...
 
template<class T >
void ResizeContainer (std::vector< T > &vec, size_t size, bool zeroIfNotResized=false)
 
template<typename T >
Round (T num)
 round value More...
 
template<typename DstType , typename SrcType >
bool IsType (const SrcType *src)
 
template<typename T >
bool Contains (std::vector< T, std::allocator< T > > vec, T item)
 
template<typename T >
std::string NumToString (T val)
 
template<typename T >
bool FromString (T &t, const std::string &s, std::ios_base &(*f)(std::ios_base &)=std::dec)
 save the array to file More...
 

Detailed Description

Utility template functions.

Function Documentation

◆ Contains()

template<typename T >
bool Contains ( std::vector< T, std::allocator< T > >  vec,
item 
)
inline
Returns
true if item is contained in vec

◆ FromString()

template<typename T >
bool FromString ( T &  t,
const std::string &  s,
std::ios_base &(*)(std::ios_base &)  f = std::dec 
)
inline

save the array to file

Parameters
lenlength of array
line_dataarray
fnamename of file to save. ".txt" is appended to filename

◆ GetFilledDigits()

std::string GetFilledDigits ( int  number,
size_t  totalDigits 
)

Gets the string prefixed with zeros so the string is a certain length.

Gets the string prefixed with zeros so the string is a certain length.

Parameters
numberThe number to convert to a string.
totalDigitsThe total length to make the string.
Returns

◆ IsType()

template<typename DstType , typename SrcType >
bool IsType ( const SrcType *  src)
inline
Returns
true if source is type of DstType

◆ NumToString()

template<typename T >
std::string NumToString ( val)
inline
Returns
string of value

◆ Round()

template<typename T >
T Round ( num)
inline

round value

Parameters
numnumber to round
Returns
rounded value

◆ SafeDelete()

template<class T >
void __declspec (dllexport) smessage(std void SafeDelete ( T *&  pVal)

messaging

Safely delete memory that was allocated with new.

Parameters
pValThe pointer to memory.

◆ SafeDeleteArray()

template<class T >
void SafeDeleteArray ( T *&  pVal)

Safely delete memory that was allocated with new[].

Parameters
pValThe pointer to memory.