LCG Project | LCG Applications Area | |
$Date: 2004/07/05 14:19:55 $ |
The StringOps class contains methods to manipulate a String, such as join,
split, find, rfind, remove, replace.
Detailed information can be found consulting the reference
documentation.
This example shows how to use StringOps for splitting the PATH string in the different elements and replace the "/" with "\" and the ":" with ";"
#include "SealBase/StringOps.h"
#include "SealBase/ShellEnvironment.h" #include <iostream> int main ( )
{ // get environment variable std::string value = seal::ShellEnvironment().get("PATH"); // split seal::StringList items = seal::StringOps::split (value, ":");
// replace each item from seal::StringList newItems; for (unsigned int i = 0; i < items.size() ; ++i) { // get directoy items seal::StringList subItems = seal::StringOps::split (items[i], "/"); // join them back but with "\" newItems.push_back( seal::StringOps::join( subItems, "\\") ); } // rebuild the PATH std::string newValue = seal::StringOps::join( newItems, ";"); std::cout "new PATH : \n" << newValue << std::endl; }