GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
str-vec.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2013 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_str_vec_h)
24 #define octave_str_vec_h 1
25 
26 #include <iosfwd>
27 #include <list>
28 #include <set>
29 #include <string>
30 
31 #include "Array.h"
32 
33 class
34 OCTAVE_API
36 {
37 public:
38 
39  string_vector (void) : Array<std::string> () { }
40 
42  : Array<std::string> (dim_vector (n, 1)) { }
43 
44  string_vector (const char *s)
45  : Array<std::string> (dim_vector (1, 1), s) { }
46 
47  string_vector (const std::string& s)
48  : Array<std::string> (dim_vector (1, 1), s) { }
49 
50  string_vector (const string_vector& s) : Array<std::string> (s) { }
51 
52  string_vector (const std::list<std::string>& lst);
53 
54  string_vector (const std::set<std::string>& lst);
55 
57  : Array<std::string> (s.as_column ()) { }
58 
59  string_vector (const char * const *s);
60 
61  string_vector (const char * const *s, octave_idx_type n);
62 
63  string_vector& operator = (const string_vector& s)
64  {
65  if (this != &s)
67 
68  return *this;
69  }
70 
71  ~string_vector (void) { }
72 
73  bool empty (void) const { return length () == 0; }
74 
75  octave_idx_type max_length (void) const
76  {
77  octave_idx_type n = length ();
78  octave_idx_type longest = 0;
79 
80  for (octave_idx_type i = 0; i < n; i++)
81  {
82  octave_idx_type tmp = elem (i).length ();
83 
84  if (tmp > longest)
85  longest = tmp;
86  }
87 
88  return longest;
89  }
90 
91  void resize (octave_idx_type n, const std::string& rfv = std::string ())
92  {
94  }
95 
96  std::string& operator[] (octave_idx_type i)
97  { return Array<std::string>::elem (i); }
98 
99  std::string operator[] (octave_idx_type i) const
100  { return Array<std::string>::elem (i); }
101 
102  string_vector& sort (bool make_uniq = false);
103 
104  string_vector& uniq (void);
105 
106  string_vector& append (const std::string& s);
107 
108  string_vector& append (const string_vector& sv);
109 
110  std::string join (const std::string& sep = std::string ()) const;
111 
112  char **c_str_vec (void) const;
113 
114  static void delete_c_str_vec (const char * const*);
115 
116  std::ostream&
117  list_in_columns (std::ostream&, int width = 0,
118  const std::string& prefix = std::string ()) const;
119 };
120 
121 #endif