Bsoft 2.1.4
Bernard's software package
string_util.h File Reference
#include <vector>
#include <sstream>
#include <fstream>
#include <iterator>
#include <algorithm>
#include <chrono>
#include <complex>

Macros

#define _STRINGUTIL_
 

Functions

string command_line (int argc, char **argv)
 
string base (string &filename)
 
string extension (string filename)
 
string replace_extension (string &filename, string ext)
 
string insert (string &filename, string ins)
 
string insert (string &filename, int i, int n)
 
void remove_spaces (string &s)
 
string remove_spaces2 (string &s)
 
string parameter_file_path (string &filename)
 Finds the parameter file path. More...
 
string quote_or_not (const string &s)
 
vector< string > split (const string &s)
 Splits a string on whitespace. More...
 
vector< string > splitn (const string &s, long n)
 Splits a string on whitespace. More...
 
vector< string > split (const string &s, char delim)
 Splits a string using a given delimiter. More...
 
string concatenate (const vector< string > &vs)
 Concatenates a vector of strings. More...
 
string concatenate (const vector< long > &v)
 Concatenates a vector of integers into a comma-separated array. More...
 
string concatenate (const vector< double > &v)
 Concatenates a vector of real values into a comma-separated array. More...
 
vector< long > parse_integer_vector (string vecstr)
 Parses a comma-separated array of integers into a vector. More...
 
vector< double > parse_real_vector (string vecstr)
 Parses a comma-separated array of real values into a vector. More...
 
string local_time ()
 
string get_clean_line (ifstream &fstar)
 
long to_integer (string s)
 
double to_real (string s)
 
bool check_for_number (string &s)
 
int check_for_type (string &s)
 

Detailed Description

Author
Bernard Heymann
Date
20160911 - 20220101

Macro Definition Documentation

◆ _STRINGUTIL_

#define _STRINGUTIL_

Function Documentation

◆ base()

string base ( string &  filename)

◆ check_for_number()

bool check_for_number ( string &  s)

◆ check_for_type()

int check_for_type ( string &  s)

◆ command_line()

string command_line ( int  argc,
char **  argv 
)

◆ concatenate() [1/3]

string concatenate ( const vector< double > &  v)

Concatenates a vector of real values into a comma-separated array.

Parameters
&vvector of real values.
Returns
string concatenated strings.

◆ concatenate() [2/3]

string concatenate ( const vector< long > &  v)

Concatenates a vector of integers into a comma-separated array.

Parameters
&vvector of integers.
Returns
string concatenated strings.

◆ concatenate() [3/3]

string concatenate ( const vector< string > &  vs)

Concatenates a vector of strings.

Parameters
&vsvector of strings.
Returns
string concatenated strings.

◆ extension()

string extension ( string  filename)

◆ get_clean_line()

string get_clean_line ( ifstream &  fstar)

◆ insert() [1/2]

string insert ( string &  filename,
int  i,
int  n 
)

◆ insert() [2/2]

string insert ( string &  filename,
string  ins 
)

◆ local_time()

string local_time ( )

◆ parameter_file_path()

string parameter_file_path ( string &  filename)

Finds the parameter file path.

Parameters
&filenamethe parameter filename.
Returns
Bstring the full path and file name.
The parameter file path should primarily be defined in the environmental
variable "BPARAM".
Otherwise a default is used which may or may not be valid.
The string returned has a length containing the path plus one byte.

◆ parse_integer_vector()

vector< long > parse_integer_vector ( string  vecstr)

Parses a comma-separated array of integers into a vector.

Parameters
vecstrstring.
Returns
vector<long> vector of integers.

◆ parse_real_vector()

vector< double > parse_real_vector ( string  vecstr)

Parses a comma-separated array of real values into a vector.

Parameters
vecstrstring.
Returns
vector<double> vector of real values.

◆ quote_or_not()

string quote_or_not ( const string &  s)

◆ remove_spaces()

void remove_spaces ( string &  s)

◆ remove_spaces2()

string remove_spaces2 ( string &  s)

◆ replace_extension()

string replace_extension ( string &  filename,
string  ext 
)

◆ split() [1/2]

vector< string > split ( const string &  s)

Splits a string on whitespace.

Parameters
&sstring to be split.
Returns
vector<string> vector of strings.

◆ split() [2/2]

vector< string > split ( const string &  s,
char  delim 
)

Splits a string using a given delimiter.

Parameters
&sstring to be split.
delimdelimiter.
Returns
vector<string> vector of strings.

◆ splitn()

vector< string > splitn ( const string &  s,
long  n 
)

Splits a string on whitespace.

Parameters
&sstring to be split.
nnumber of strings to expect.
Returns
vector<string> vector of strings.
Keeps whitespace within quoted strings intact.
Excess beyond n strings is discarded.

◆ to_integer()

long to_integer ( string  s)

◆ to_real()

double to_real ( string  s)