# HG changeset patch # User John W. Eaton # Date 1313417128 14400 # Node ID 8ec12d6867961d0b70f5908127e47daf533c22a1 # Parent 27e5f0e79f19f5d4ca3962f1f6335fa11b5b3712 new string_vector::join method * str-vec.cc, str-vec.h (string_vector::join): New method. diff --git a/liboctave/str-vec.cc b/liboctave/str-vec.cc --- a/liboctave/str-vec.cc +++ b/liboctave/str-vec.cc @@ -163,6 +163,26 @@ return *this; } +std::string +string_vector::join (const std::string& sep) const +{ + std::string retval; + + octave_idx_type len = length (); + + if (len > 0) + { + octave_idx_type i; + + for (i = 0; i < len - 1; i++) + retval += elem(i) + sep; + + retval += elem(i); + } + + return retval; +} + char ** string_vector::c_str_vec (void) const { diff --git a/liboctave/str-vec.h b/liboctave/str-vec.h --- a/liboctave/str-vec.h +++ b/liboctave/str-vec.h @@ -105,6 +105,8 @@ string_vector& append (const string_vector& sv); + std::string join (const std::string& sep = std::string ()) const; + char **c_str_vec (void) const; static void delete_c_str_vec (const char * const*);