This namespace covers some useful functions, which are used in several other classes. More...


Functions

int replaceStr (std::string &str, char *val, char *newval, bool all=false)
 Replace the occurence of an old-value with the new-value.
void replaceStr (std::string &str, uint from, uint to, char *newval)
 Replace the characters starting at position-1 until position-2.
template<class Ch> std::string toString (Ch arg)
 Convert any object to a string.
char * newStrCpy (char *from, uint length=0)
 Create a copy of the specified string with a specified length of characters.
char * getHostname ()
 Get name of current host.
char * formatTime (ulong msecs)
 Convert time in milliseconds to the time-format: HH:MM:SS.
char * formatTimeSecs (ulong secs)
 Convert time in seconds to the time-format: HH:MM:SS.
char * convertToString (ulong msecs)
 Convert milliseconds to a string.
string createSDPFile (string name, string url, string relpath, string abspath)
 Create a SDP file.

Detailed Description

This namespace covers some useful functions, which are used in several other classes.

Author:
Klaus Schoeffmann


Function Documentation

string createSDPFile string  name,
string  url,
string  relpath,
string  abspath
[inline]
 

Create a SDP file.

Parameters:
name name of SDP file (without '.sdp')
url Rtsp-URI to use in this file
relpath relative path (used to store SDPs)
abspath absolute path (used to store SDPs)
Returns:
web-path for that file
Definition at line 286 of file SemiGlobals.hpp.

Referenced by Movie::getHTMLRepresentation(), and SessionList::writeHTMLRepresentation().

00287 { 00288 string fname (abspath + name + ".sdp"); 00289 00290 ofstream ofile (fname.c_str(), ios::out | ios::trunc); 00291 if (ofile) 00292 { 00293 ofile << "v=0" << "\r\n"; 00294 ofile << "s=" << name << "\r\n"; 00295 ofile << "a=control:" << url <<"\r\n"; 00296 ofile.close(); 00297 } else { 00298 cerr << "no success!!!" << endl; 00299 } 00300 00301 return relpath + name + ".sdp"; 00302 }

void replaceStr std::string &  str,
uint  from,
uint  to,
char *  newval
[inline]
 

Replace the characters starting at position-1 until position-2.

Parameters:
str string to scan
from position-1
to position-2
newval string to insert
Definition at line 173 of file SemiGlobals.hpp.
00174 { 00175 //TODO: use replace() function !!! 00176 str.replace(from, to-from, newval, strlen(newval)); 00177 }

int replaceStr std::string &  str,
char *  val,
char *  newval,
bool  all = false
[inline]
 

Replace the occurence of an old-value with the new-value.

Parameters:
str string to scan
val old-value
newval new value
all controls, if all occurrences of substring1 will be replaced.
Definition at line 153 of file SemiGlobals.hpp.

Referenced by SemiProxySession::forwardToClient(), and SemiDebug::operator<<().

00154 { 00155 //TODO: use replace() function !!! 00156 uint pos = str.find(val); 00157 uint lengthDiff = 0; 00158 while (pos != std::string::npos) { 00159 str.replace(pos, strlen(val), newval); 00160 lengthDiff += (strlen(val)-strlen(newval)); 00161 pos = str.find(val); 00162 if (!all) break; 00163 } 00164 return lengthDiff; 00165 };