Changeset 10429


Ignore:
Timestamp:
Apr 20, 2011, 4:58:05 PM (9 years ago)
Author:
tbretz
Message:
Moved the tools function into their own namespace to get rid of problems whenlinking with root.
Location:
trunk/FACT++/src
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/Console.cc

    r10305 r10429  
    134134    const string siz = fLogO.GetSizeStr();
    135135    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());
    137138}
    138139
  • trunk/FACT++/src/Description.cc

    r10408 r10429  
    4646
    4747using namespace std;
     48using namespace Tools;
    4849
    4950// --------------------------------------------------------------------------
  • trunk/FACT++/src/DimServiceInfoList.cc

    r10391 r10429  
    638638void DimServiceInfoList::SendDimCommand(const string &server, string str, ostream &lout) const
    639639{
    640     str = Trim(str);
     640    str = Tools::Trim(str);
    641641
    642642    // Find the delimiter between the command name and the data
  • trunk/FACT++/src/LocalControl.cc

    r10266 r10429  
    11#include "LocalControl.h"
    2 
    3 #include "tools.h"
    42
    53string LocalConsole::GetUpdatePrompt() const
    64{
    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> ";
    158}
    16 
    17 //#include <boost/regex.hpp>
    189
    1910string LocalShell::GetUpdatePrompt() const
    2011{
    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()+"> ";
    2913}
  • trunk/FACT++/src/MessageImp.cc

    r10383 r10429  
    151151    va_list ap;
    152152    va_start(ap, fmt);
    153     string str = Format(fmt, ap);
     153    string str = Tools::Format(fmt, ap);
    154154    va_end(ap);
    155155    return Update(str, severity);
  • trunk/FACT++/src/Readline.cc

    r10343 r10429  
    536536string Readline::GetLinePrompt() const
    537537{
    538     return Form("[%d]", fLine);
     538    return Tools::Form("[%d]", fLine);
    539539}
    540540
     
    996996        return false;
    997997
    998     str = Trim(buf);
     998    str = Tools::Trim(buf);
    999999
    10001000    free(buf);
     
    10241024    Shutdown(buf ? buf : "");
    10251025
    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);
    10271028
    10281029    free(buf);
  • trunk/FACT++/src/ReadlineWindow.cc

    r10183 r10429  
    290290
    291291    // Compile a proper format string
    292     const string fmt = Form("%%-%ds", max);
     292    const string fmt = Tools::Form("%%-%ds", max);
    293293
    294294    // loop over all entries and display them
  • trunk/FACT++/src/RemoteControl.cc

    r10390 r10429  
    4646    // If we are continously flushing the buffer omit the buffer size
    4747    // If we are buffering show the buffer size
    48     const string beg = "\n" + GetLinePrompt();
     48    const string beg = '\n' + GetLinePrompt();
    4949
    5050    // If we have not cd'ed to a server show only the line start
     
    5555    const ClientList::const_iterator l = fClientList.find(fCurrentServer);
    5656    if (l==fClientList.end())
    57         return beg + "> ";//Form("\n[%d] \033[34m\033[1m%s\033[0m> ", GetLine(), fCurrentServer.c_str());
     57        return beg + "> ";
    5858
    5959    const State state = GetState(fCurrentServer, l->second->GetState());
    6060
    6161    // 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";
    6363
    6464    // If no match found or something wrong found just output the server
  • trunk/FACT++/src/RemoteControl.h

    r10390 r10429  
    7474        const string b = string(T::GetBuffer());
    7575        const string s = b.substr(0, start);
    76         const string l = Trim(s.c_str());
     76        const string l = Tools::Trim(s.c_str());
    7777        if (l.empty())
    7878        {
  • trunk/FACT++/src/ServiceList.cc

    r10355 r10429  
    697697        out << kBold << " " << server << endl;
    698698
    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*>(""));
    700700
    701701        string buffer2;
  • trunk/FACT++/src/State.cc

    r10395 r10429  
    2525
    2626using namespace std;
     27using namespace Tools;
    2728
    2829// --------------------------------------------------------------------------
  • trunk/FACT++/src/StateMachineDim.cc

    r10386 r10429  
    6868StateMachineDim::StateMachineDim(ostream &out, const std::string &name)
    6969: 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*>(""))
    7373{
    7474    // WARNING: This exit handler is GLOBAL!
  • trunk/FACT++/src/StateMachineImp.cc

    r10424 r10429  
    554554EventImp &StateMachineImp::AddTransition(int targetstate, const char *name, int s1, int s2, int s3, int s4, int s5)
    555555{
    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(), "");
    557558}
    558559
     
    586587EventImp &StateMachineImp::AddTransition(int targetstate, const char *name, const char *fmt, int s1, int s2, int s3, int s4, int s5)
    587588{
    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);
    589591}
    590592
     
    701703{
    702704    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;
    704706}
    705707
     
    737739{
    738740    const string &str = GetStateName(state);
    739     if (str==Form("%d", state))
     741    if (str==Tools::Form("%d", state))
    740742        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));
    742744}
    743745
  • trunk/FACT++/src/WindowLog.cc

    r10183 r10429  
    273273        u = 'M';
    274274    }
    275     return Form("%d%c", s, u);
     275    return Tools::Form("%d%c", s, u);
    276276}
    277277
  • trunk/FACT++/src/tools.cc

    r10338 r10429  
    1414using namespace std;
    1515
    16 string Format(const char *fmt, va_list &ap)
     16string Tools::Format(const char *fmt, va_list &ap)
    1717{
    1818    int n=256;
     
    3838}
    3939
    40 string Form(const char *fmt, ...)
     40string Tools::Form(const char *fmt, ...)
    4141{
    4242    va_list ap;
     
    6161//!    a std::string with the whitespaces removed from buf
    6262//
    63 string Trim(const string &str)
     63string Tools::Trim(const string &str)
    6464{
    6565    // Trim Both leading and trailing spaces
  • trunk/FACT++/src/tools.h

    r10338 r10429  
    11#include <string>
    22
    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);
     3namespace 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.