Changeset 10429
- Timestamp:
- 04/20/11 16:58:05 (14 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Console.cc
r10305 r10429 134 134 const string siz = fLogO.GetSizeStr(); 135 135 return fContinous ? 136 Form("[%d]", GetLine()) : Form("[%d:%s]", GetLine(), siz.c_str()); 136 Tools::Form("[%d]", GetLine()) : 137 Tools::Form("[%d:%s]", GetLine(), siz.c_str()); 137 138 } 138 139 -
trunk/FACT++/src/Description.cc
r10408 r10429 46 46 47 47 using namespace std; 48 using namespace Tools; 48 49 49 50 // -------------------------------------------------------------------------- -
trunk/FACT++/src/DimServiceInfoList.cc
r10391 r10429 638 638 void DimServiceInfoList::SendDimCommand(const string &server, string str, ostream &lout) const 639 639 { 640 str = T rim(str);640 str = Tools::Trim(str); 641 641 642 642 // Find the delimiter between the command name and the data -
trunk/FACT++/src/LocalControl.cc
r10266 r10429 1 1 #include "LocalControl.h" 2 3 #include "tools.h"4 2 5 3 string LocalConsole::GetUpdatePrompt() const 6 4 { 7 // Compile a string like "server:state> " 8 const string end = 9 Form("\033[34m\033[1m%s\033[0m:\033[32m\033[1m%s\033[0m> ", 10 fName.c_str(), fStateMachine->GetStateName().c_str()); 11 12 // If we are continously flushing the buffer omit the buffer size 13 // If we are buffering show the buffer size 14 return GetLinePrompt() + " " + end; 5 return GetLinePrompt()+" " 6 "\033[34m\033[1m"+fName+"\033[0m:" 7 "\033[32m\033[1m"+fStateMachine->GetStateName()+"\033[0m> "; 15 8 } 16 17 //#include <boost/regex.hpp>18 9 19 10 string LocalShell::GetUpdatePrompt() const 20 11 { 21 //const string s = (beg[0]=='\n'?beg.substr(1):beg) + " " + end; 22 //return boost::regex_replace(s, boost::regex("\033[[0-9]+m"), ""); 23 24 const string end = 25 Form("%s:%s> ", fName.c_str(), 26 fStateMachine->GetStateName().c_str()); 27 28 return GetLinePrompt() + " " + end; 12 return GetLinePrompt()+' '+fName+':'+fStateMachine->GetStateName()+"> "; 29 13 } -
trunk/FACT++/src/MessageImp.cc
r10383 r10429 151 151 va_list ap; 152 152 va_start(ap, fmt); 153 string str = Format(fmt, ap);153 string str = Tools::Format(fmt, ap); 154 154 va_end(ap); 155 155 return Update(str, severity); -
trunk/FACT++/src/Readline.cc
r10343 r10429 536 536 string Readline::GetLinePrompt() const 537 537 { 538 return Form("[%d]", fLine);538 return Tools::Form("[%d]", fLine); 539 539 } 540 540 … … 996 996 return false; 997 997 998 str = T rim(buf);998 str = Tools::Trim(buf); 999 999 1000 1000 free(buf); … … 1024 1024 Shutdown(buf ? buf : ""); 1025 1025 1026 const string str = !buf || (rl_done && rl_pending_input==4) ? ".q" : Trim(buf); 1026 const string str = !buf || (rl_done && rl_pending_input==4) 1027 ? ".q" : Tools::Trim(buf); 1027 1028 1028 1029 free(buf); -
trunk/FACT++/src/ReadlineWindow.cc
r10183 r10429 290 290 291 291 // Compile a proper format string 292 const string fmt = Form("%%-%ds", max);292 const string fmt = Tools::Form("%%-%ds", max); 293 293 294 294 // loop over all entries and display them -
trunk/FACT++/src/RemoteControl.cc
r10390 r10429 46 46 // If we are continously flushing the buffer omit the buffer size 47 47 // If we are buffering show the buffer size 48 const string beg = "\n"+ GetLinePrompt();48 const string beg = '\n' + GetLinePrompt(); 49 49 50 50 // If we have not cd'ed to a server show only the line start … … 55 55 const ClientList::const_iterator l = fClientList.find(fCurrentServer); 56 56 if (l==fClientList.end()) 57 return beg + "> "; //Form("\n[%d] \033[34m\033[1m%s\033[0m> ", GetLine(), fCurrentServer.c_str());57 return beg + "> "; 58 58 59 59 const State state = GetState(fCurrentServer, l->second->GetState()); 60 60 61 61 // The server 62 const string serv = Form("\033[34m\033[1m%s\033[0m", fCurrentServer.c_str());62 const string serv = "\033[34m\033[1m"+fCurrentServer+"\033[0m"; 63 63 64 64 // If no match found or something wrong found just output the server -
trunk/FACT++/src/RemoteControl.h
r10390 r10429 74 74 const string b = string(T::GetBuffer()); 75 75 const string s = b.substr(0, start); 76 const string l = T rim(s.c_str());76 const string l = Tools::Trim(s.c_str()); 77 77 if (l.empty()) 78 78 { -
trunk/FACT++/src/ServiceList.cc
r10355 r10429 697 697 out << kBold << " " << server << endl; 698 698 699 DimCurrentInfo info2( Form("%s/SERVICE_LIST", server.c_str()).c_str(), const_cast<char*>(""));699 DimCurrentInfo info2((server+"/SERVICE_LIST").c_str(), const_cast<char*>("")); 700 700 701 701 string buffer2; -
trunk/FACT++/src/State.cc
r10395 r10429 25 25 26 26 using namespace std; 27 using namespace Tools; 27 28 28 29 // -------------------------------------------------------------------------- -
trunk/FACT++/src/StateMachineDim.cc
r10386 r10429 68 68 StateMachineDim::StateMachineDim(ostream &out, const std::string &name) 69 69 : StateMachine(out, name), DimStart(name, *this), fLog(name, out), 70 fSrvState( Form("%s/STATE", name.c_str()).c_str(), const_cast<char*>("")),71 fSrvVersion( Form("%s/VERSION", name.c_str()).c_str(), const_cast<int&>(fVersion)),72 fDescriptionStates( Form("%s/STATE_LIST", name.c_str()).c_str(), const_cast<char*>(""))70 fSrvState((name+"/STATE").c_str(), const_cast<char*>("")), 71 fSrvVersion((name+"/VERSION").c_str(), const_cast<int&>(fVersion)), 72 fDescriptionStates((name+"/STATE_LIST").c_str(), const_cast<char*>("")) 73 73 { 74 74 // WARNING: This exit handler is GLOBAL! -
trunk/FACT++/src/StateMachineImp.cc
r10424 r10429 554 554 EventImp &StateMachineImp::AddTransition(int targetstate, const char *name, int s1, int s2, int s3, int s4, int s5) 555 555 { 556 return AddTransition(targetstate, name, Form("%d %d %d %d %d", s1, s2, s3, s4, s5).c_str(), ""); 556 return AddTransition(targetstate, name, 557 Tools::Form("%d %d %d %d %d", s1, s2, s3, s4, s5).c_str(), ""); 557 558 } 558 559 … … 586 587 EventImp &StateMachineImp::AddTransition(int targetstate, const char *name, const char *fmt, int s1, int s2, int s3, int s4, int s5) 587 588 { 588 return AddTransition(targetstate, name, Form("%d %d %d %d %d", s1, s2, s3, s4, s5).c_str(), fmt); 589 return AddTransition(targetstate, name, 590 Tools::Form("%d %d %d %d %d", s1, s2, s3, s4, s5).c_str(), fmt); 589 591 } 590 592 … … 701 703 { 702 704 const StateNames::const_iterator i = fStateNames.find(state); 703 return i==fStateNames.end() || i->second.first.empty() ? Form("%d", state) : i->second.first;705 return i==fStateNames.end() || i->second.first.empty() ? Tools::Form("%d", state) : i->second.first; 704 706 } 705 707 … … 737 739 { 738 740 const string &str = GetStateName(state); 739 if (str== Form("%d", state))741 if (str==Tools::Form("%d", state)) 740 742 return str; 741 return str.empty() ? Form("%d", state) : (str+Form("[%d]", state));743 return str.empty() ? Tools::Form("%d", state) : (str+Tools::Form("[%d]", state)); 742 744 } 743 745 -
trunk/FACT++/src/WindowLog.cc
r10183 r10429 273 273 u = 'M'; 274 274 } 275 return Form("%d%c", s, u);275 return Tools::Form("%d%c", s, u); 276 276 } 277 277 -
trunk/FACT++/src/tools.cc
r10338 r10429 14 14 using namespace std; 15 15 16 string Format(const char *fmt, va_list &ap)16 string Tools::Format(const char *fmt, va_list &ap) 17 17 { 18 18 int n=256; … … 38 38 } 39 39 40 string Form(const char *fmt, ...)40 string Tools::Form(const char *fmt, ...) 41 41 { 42 42 va_list ap; … … 61 61 //! a std::string with the whitespaces removed from buf 62 62 // 63 string T rim(const string &str)63 string Tools::Trim(const string &str) 64 64 { 65 65 // Trim Both leading and trailing spaces -
trunk/FACT++/src/tools.h
r10338 r10429 1 1 #include <string> 2 2 3 std::string Format(const char *fmt, va_list &ap); 4 std::string Form(const char *fmt, ...); 5 std::string Trim(const std::string &str); 3 namespace Tools 4 { 5 std::string Format(const char *fmt, va_list &ap); 6 std::string Form(const char *fmt, ...); 7 std::string Trim(const std::string &str); 8 }
Note:
See TracChangeset
for help on using the changeset viewer.