utility.h File Reference

Utility functions. More...

#include <string>

Functions

bool valid_tag_strict (std::string s)
 true if first carachter is alphabetic and all others are alphanumeric or space or ,-_{ }<>[] More...
 
bool valid_tag (std::string s)
 
bool valid_description (std::string s)
 true if all characters are alphanumeric or space or .:,-_{ }<>[] More...
 
double pos (double x)
 return x if x > 0 else 0 More...
 
double neg (double x)
 return x if x < 0 else 0 More...
 
std::string escapeXml (const std::string &in)
 
void escapeFileName (std::string &buf)
 remove < > for compliance with file naming conventions More...
 
std::string itoalpha (int value)
 converts an int value between 0 to 16 to a alphabetic string composed of a single character, 'A' for 0 to 'Q' for 16 More...
 
void ltrim (std::string &str)
 in-place trim all spaces to the right, modified from: http://idlebox.net/2007/0530-StdString-Trim.blog More...
 
void rtrim (std::string &str)
 in-place trim all spaces to the left More...
 
void trim (std::string &str)
 in-place trim all spaces to the right and to the left More...
 
bool replace (std::string &str, const std::string &from, const std::string &to)
 
double steamSaturatedLiquidTemperature (double p)
 
double steamSaturatedLiquidPressure (double t)
 

Detailed Description

Utility functions.

This file is part of LIBPF All rights reserved; do not distribute without permission.

Author
(C) Copyright 2004-2023 Paolo Greppi simevo s.r.l.

Function Documentation

◆ escapeFileName()

void escapeFileName ( std::string &  buf)

remove < > for compliance with file naming conventions

◆ escapeXml()

std::string escapeXml ( const std::string &  in)

utility function for smoothly clipping the pressure to a positive value Ppositive(2*Pmin) = 2*Pmin Ppositive(-Inf) = Pmin+ dPact(P)/dP @ (P=2*Pmin) = 1 remove < > for xml compliance

Returns
an string you can put in an xml file

◆ itoalpha()

std::string itoalpha ( int  value)

converts an int value between 0 to 16 to a alphabetic string composed of a single character, 'A' for 0 to 'Q' for 16

◆ ltrim()

void ltrim ( std::string &  str)

in-place trim all spaces to the right, modified from: http://idlebox.net/2007/0530-StdString-Trim.blog

◆ neg()

double neg ( double  x)

return x if x < 0 else 0

◆ pos()

double pos ( double  x)

return x if x > 0 else 0

◆ replace()

bool replace ( std::string &  str,
const std::string &  from,
const std::string &  to 
)

find the first occurrence of substring from within the string str and replace it with the string to

Parameters
[in,out]strthe string to manipulate
[in]fromthe string to be replaced
[in]tothe string to replace

◆ rtrim()

void rtrim ( std::string &  str)

in-place trim all spaces to the left

◆ steamSaturatedLiquidPressure()

double steamSaturatedLiquidPressure ( double  t)

◆ steamSaturatedLiquidTemperature()

double steamSaturatedLiquidTemperature ( double  p)

◆ trim()

void trim ( std::string &  str)

in-place trim all spaces to the right and to the left

◆ valid_description()

bool valid_description ( std::string  s)

true if all characters are alphanumeric or space or .:,-_{ }<>[]

◆ valid_tag()

bool valid_tag ( std::string  s)

true if first carachter is alphabetic and all others are alphanumeric or space or .:,-_{ }<>[] as valid_tag_strict, but also allows for .:

◆ valid_tag_strict()

bool valid_tag_strict ( std::string  s)

true if first carachter is alphabetic and all others are alphanumeric or space or ,-_{ }<>[]