Nemiver  0.3
nmv-ustring.h
Go to the documentation of this file.
1 /* -*- Mode: C++; indent-tabs-mode:nil; c-basic-offset: 4-*- */
2 
3 /*Copyright (c) 2005-2009 Dodji Seketeli
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of this
6  * software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute,
9  * sublicense, and/or sell copies of the Software, and to permit
10  * persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies
14  * or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS",
17  * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18  * INCLUDING BUT NOT LIMITED TO THE
19  * WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE
21  * AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23  * HOLDERS BE LIABLE FOR ANY CLAIM,
24  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
25  * CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
27  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28  *
29  */
30 #ifndef __NMV_USTRING_H__
31 #define __NMV_USTRING_H__
32 
33 #include <vector>
34 #include <string>
35 #include <glibmm.h>
36 #include "nmv-namespace.h"
37 #include "nmv-api-macros.h"
38 
39 using namespace std;
40 
41 NEMIVER_BEGIN_NAMESPACE (nemiver)
42 NEMIVER_BEGIN_NAMESPACE (common)
43 
44 class WString;
45 class NEMIVER_API UString: public Glib::ustring {
46 
47 public:
48  UString ();
49  UString (const char *a_cstr, long a_len=-1);
50  UString (const unsigned char *a_cstr, long a_len=-1);
51  UString (const Glib::ustring &an_other_string);
52  UString (const string &an_other_string);
53  UString (UString const &an_other_string);
54  virtual ~UString ();
55  UString& set (const gchar* a_buf, gulong a_len);
56  static UString from_int (long long an_int);
57  static size_t hexa_to_int (const string &a_hexa_str);
58  bool is_integer () const;
59  UString& append_int (long long an_int);
60  UString& assign_int (long long);
61  UString& operator= (const char *a_cstr);
62  UString& operator= (const unsigned char *a_cstr);
63  UString& operator= (UString const &a_cstr);
64  bool operator! () const;
65  vector<UString> split (const UString &a_delim) const;
66  list<UString> split_to_list (const UString &a_delim) const;
67  vector<UString> split_set (const UString &a_delim_set) const;
68  static UString join (const vector<UString> &a_elements,
69  const UString &a_delim=" ");
70  static UString join (vector<UString>::const_iterator &a_from,
71  vector<UString>::const_iterator &a_to,
72  const UString &a_delim=" ");
73  void chomp ();
74 
75  UString::size_type get_number_of_lines () const;
76 
77  UString::size_type get_number_of_words () const;
78 
79  UString& printf (const UString &a_format, ...);
80 
81  UString& vprintf (const UString &a_format, va_list a_args);
82 };//end class UString
83 
84 class NEMIVER_API WString : public basic_string<gunichar> {
85 
86 typedef basic_string<gunichar> super_type;
87 
88 public:
89 
90  WString ();
91 
92  ~WString ();
93 
94  WString (const super_type &a_str);
95 
96  WString (const char* a_str, unsigned int a_len=-1);
97 
98  WString (const super_type::allocator_type &a);
99 
100  WString (const WString &str);
101 
102  WString (const WString &str,
103  size_type position,
104  size_type n = npos);
105 
106  WString (const WString &str, size_type position,
107  size_type n,
108  const super_type::allocator_type &a);
109 
110  WString (const gunichar *s,
111  super_type::size_type n,
112  const super_type::allocator_type &a=super_type::allocator_type());
113 
114  WString (const gunichar *s,
115  const super_type::allocator_type &a=super_type::allocator_type());
116 
117  WString (size_type n,
118  gunichar c,
119  const super_type::allocator_type &a=super_type::allocator_type());
120 
121  WString& assign (const char *a_str, long a_len=-1);
122 
123  WString& assign (const WString &a_str);
124 
125  WString& assign (const WString &a_str, size_type a_position,
126  super_type::size_type a_n);
127 
128  WString& assign (const gunichar *a_str,
129  super_type::size_type a_n);
130 
131  WString& assign (const gunichar *a_str);
132 
133  WString& assign (super_type::size_type a_n, gunichar a_c);
134 };//end WString
135 
136 bool NEMIVER_API wstring_to_ustring (const WString &a_wstr,
137  UString &a_ustr);
138 bool NEMIVER_API ustring_to_wstring (const UString &a_ustr,
139  WString &a_wstr);
140 
141 NEMIVER_END_NAMESPACE (common)
142 NEMIVER_END_NAMESPACE (nemiver)
143 
144 #endif
145 
nemiver::str_utils::get_number_of_words
UString::size_type get_number_of_words(const UString &a_string)
nemiver::common::wstring_to_ustring
bool wstring_to_ustring(const WString &a_wstr, UString &a_ustr)
nemiver
Definition: nmv-address.h:31
NEMIVER_API
#define NEMIVER_API
Definition: nmv-api-macros.h:53
nmv-api-macros.h
nemiver::str_utils::split
vector< UString > split(const UString &a_string, const UString &a_delim)
nemiver::common::ustring_to_wstring
bool ustring_to_wstring(const UString &a_ustr, WString &a_wstr)
nemiver::common::UString
Definition: nmv-ustring.h:45
nemiver::str_utils::chomp
void chomp(S &a_string)
Definition: nmv-str-utils.h:57
nemiver::str_utils::hexa_to_int
size_t hexa_to_int(const string &a_hexa_str)
nemiver::str_utils::vprintf
UString vprintf(const UString &a_format, va_list a_args)
nemiver::common::WString
Definition: nmv-ustring.h:84
nemiver::str_utils::printf
UString printf(const UString &a_format,...)
nemiver::str_utils::get_number_of_lines
UString::size_type get_number_of_lines(const UString &a_string)
nemiver::str_utils::join
UString join(const vector< UString > &a_elements, const UString &a_delim=" ")
nmv-namespace.h
nemiver::str_utils::split_set
vector< UString > split_set(const UString &a_string, const UString &a_delim_set)
common
Definition: nmv-proc-list-dialog.h:32