How to use TString::Strip() ??

From: Tom Roberts <tjrob_at_fnal.gov>
Date: Mon, 16 Mar 2009 12:56:42 -0500

   ROOT 5.22/00 (trunk_at_26997, Mar 10 2009, 22:56:00 on macosx)    CINT/ROOT C/C++ Interpreter version 5.16.29, Jan 08, 2008    Type ? for help. Commands must be C++ statements.    Enclose multiple statements between { }.    root [0] TString y(" y ")
   root [1] y.Strip().String()
(class TString)" y "

   root [2] y.Strip(TString::kTrailing,' ').String()
(class TString)" y "

I expected the trailing spaces to be removed.

   root [3] y.Strip(TString::kBoth,' ').String()
(class TString)" y "

I expected all spaces to be removed.

Am I missing something?

OK, I'm guessing that TSubString::String() just returns the TString of which the substring is a part. If so, please document that in the reference manual (I certainly expect String() to return a string representing the object, not some ancestor object).

How do I use this to remove the initial and trailing spaces from the string (NOT a sub-string)? I sure expected this to work:

   root [0] TString y("  y  ")
   root [1] TString z(y.Strip(TString::kTrailing,' ').Data())
   root [2] z

(class TString)" y "

   root [3]

And this:

   root [0] TString y("  y  ")
   root [1] TString z(y.Strip(TString::kBoth,' ').Data())
   root [2] z

(class TString)"y "

So I think there is a bug here.... Looks like I just have to write the obvious but rather inefficient loops....

Tom Roberts Received on Mon Mar 16 2009 - 18:56:46 CET

This archive was generated by hypermail 2.2.0 : Mon Mar 16 2009 - 23:50:02 CET