TDMS
Time Domain Maxwell Solver
All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
utils.h File Reference

Useful miscellaneous utility functions. More...

#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
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.

Namespaces

namespace  tdms_vector_utils
 A collection of utility functions that we will be applying to std::vectors multiple times throughout the codebase.
 

Functions

void assert_can_open_file (const char *filename, const char *mode)
 Throws a runtime error if a file is not found.
 
bool are_equal (const char *a, const char *b)
 Check two strings are equal.
 
template<typename T >
tdms_vector_utils::max (const std::vector< T > &v)
 Return the maximum value stored in the vector.
 
template<typename T >
bool tdms_vector_utils::has_elements (const std::vector< T > &v)
 Return true if the vector has non-zero size.
 
template<typename T >
int tdms_vector_utils::index (const std::vector< T > &v, const T &value)
 
std::vector< int > tdms_vector_utils::to_vector_int (const std::vector< double > &ints_that_are_doubles)
 Static_casts an array of doubles to ints. ONLY INTENDED FOR CASES WHERE WE KNOW THAT THE VALUES STORED AS DOUBLES ARE INTS.
 

Detailed Description

Useful miscellaneous utility functions.

Function Documentation

◆ are_equal()

bool are_equal ( const char *  a,
const char *  b 
)

Check two strings are equal.

Parameters
aThe first string
bThe second string
Returns
true if the strings are the same
false otherwise

◆ assert_can_open_file()

void assert_can_open_file ( const char *  filename,
const char *  mode 
)

Throws a runtime error if a file is not found.

Parameters
filenameThe name of the file to check.
modeThe mode to try and open with.