FACT++  1.0
string Tools::Trim ( const std::string &  str)

This is a static helper to remove leading and trailing whitespaces.

Parameters
bufa pointer to the char array from which the whitespaces should be removed
Returns
a std::string with the whitespaces removed from buf

Definition at line 68 of file tools.cc.

References end, and start().

Referenced by StateMachineFAD< T >::AddAddress(), RemoteControl< Shell >::Completion(), StateMachineTimeCheck::Execute(), Readline::Execute(), FactGui::FactGui(), Converter::GetStringEol(), SkypeClient::HandleDBusMessage(), CompressedFitsFile::HeaderEntry::HeaderEntry(), PointingModel::Load(), fits::Table::ParseBlock(), LocalControl< ConsoleStream >::Process(), RemoteControl< Shell >::Process(), Readline::Prompt(), Readline::PromptEOF(), StateMachineDimControl::SendDimCommand(), DimServiceInfoList::SendDimCommand(), Description::SplitDescription(), Readline::StaticPrompt(), and TrimQuotes().

69 {
70  // Trim Both leading and trailing spaces
71  const size_t start = str.find_first_not_of(' '); // Find the first character position after excluding leading blank spaces
72  const size_t end = str.find_last_not_of(' '); // Find the first character position from reverse af
73 
74  // if all spaces or empty return an empty string
75  if (string::npos==start || string::npos==end)
76  return string();
77 
78  return str.substr(start, end-start+1);
79 }
int start(int initState)
Definition: feeserver.c:1740
char str[80]
Definition: test_client.c:7
double end

+ Here is the call graph for this function:

+ Here is the caller graph for this function: