From c8f5d847e530083a7aa658dad9a37af7b4647615 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 18 Aug 2011 14:20:10 +0000 Subject: step one of removing Glib::ustring from ardour2 git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@10003 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/pbd/basename.cc | 9 ++++----- libs/pbd/convert.cc | 46 ---------------------------------------------- libs/pbd/copyfile.cc | 2 +- libs/pbd/pbd/basename.h | 4 ++-- libs/pbd/pbd/convert.h | 2 -- libs/pbd/pbd/copyfile.h | 4 ++-- libs/pbd/pbd/shortpath.h | 4 ++-- libs/pbd/pbd/strsplit.h | 2 -- libs/pbd/pbd/whitespace.h | 5 ----- libs/pbd/shortpath.cc | 21 ++++++++++----------- libs/pbd/strsplit.cc | 38 -------------------------------------- libs/pbd/whitespace.cc | 9 --------- 12 files changed, 21 insertions(+), 125 deletions(-) (limited to 'libs') diff --git a/libs/pbd/basename.cc b/libs/pbd/basename.cc index 0b631f4249..702f711eb4 100644 --- a/libs/pbd/basename.cc +++ b/libs/pbd/basename.cc @@ -20,13 +20,12 @@ #include #include -using Glib::ustring; +using std::string; -ustring -PBD::basename_nosuffix (ustring str) +string +PBD::basename_nosuffix (const string& str) { - ustring base = Glib::path_get_basename (str); - + string base = Glib::path_get_basename (str); return base.substr (0, base.find_last_of ('.')); } diff --git a/libs/pbd/convert.cc b/libs/pbd/convert.cc index 598473c244..622e1dfdd4 100644 --- a/libs/pbd/convert.cc +++ b/libs/pbd/convert.cc @@ -31,7 +31,6 @@ using std::string; using std::vector; -using Glib::ustring; namespace PBD { @@ -196,51 +195,6 @@ url_decode (string& url) } } -void -url_decode (ustring& url) -{ - ustring::iterator last; - ustring::iterator next; - - for (ustring::iterator i = url.begin(); i != url.end(); ++i) { - if ((*i) == '+') { - next = i; - ++next; - url.replace (i, next, 1, ' '); - } - } - - if (url.length() <= 3) { - return; - } - - last = url.end(); - - --last; /* points at last char */ - --last; /* points at last char - 1 */ - - for (ustring::iterator i = url.begin(); i != last; ) { - - if (*i == '%') { - - next = i; - - url.erase (i); - - i = next; - ++next; - - if (isxdigit (*i) && isxdigit (*next)) { - /* replace first digit with char */ - url.replace (i, next, 1, (gunichar) int_from_hex (*i,*next)); - ++i; /* points at 2nd of 2 digits */ - url.erase (i); - } - } else { - ++i; - } - } -} #if 0 string diff --git a/libs/pbd/copyfile.cc b/libs/pbd/copyfile.cc index 2284a6b26d..a6177fe8bc 100644 --- a/libs/pbd/copyfile.cc +++ b/libs/pbd/copyfile.cc @@ -30,7 +30,7 @@ using namespace PBD; using namespace std; int -PBD::copy_file (Glib::ustring from, Glib::ustring to) +PBD::copy_file (const string& from, const string& to) { ifstream in (from.c_str()); ofstream out (to.c_str()); diff --git a/libs/pbd/pbd/basename.h b/libs/pbd/pbd/basename.h index f13c3840dc..42b6295713 100644 --- a/libs/pbd/pbd/basename.h +++ b/libs/pbd/pbd/basename.h @@ -20,12 +20,12 @@ #ifndef __stupid_basename_h__ #define __stupid_basename_h__ -#include +#include namespace PBD { -Glib::ustring basename_nosuffix (Glib::ustring); +std::string basename_nosuffix (const std::string&); } diff --git a/libs/pbd/pbd/convert.h b/libs/pbd/pbd/convert.h index f8358e8801..7270265cb2 100644 --- a/libs/pbd/pbd/convert.h +++ b/libs/pbd/pbd/convert.h @@ -25,7 +25,6 @@ #include #include #include -#include namespace PBD { @@ -34,7 +33,6 @@ std::string short_version (std::string, std::string::size_type target_length); int atoi (const std::string&); double atof (const std::string&); void url_decode (std::string&); -void url_decode (Glib::ustring&); // std::string length2string (const int32_t frames, const float sample_rate); std::string length2string (const int64_t frames, const double sample_rate); diff --git a/libs/pbd/pbd/copyfile.h b/libs/pbd/pbd/copyfile.h index 1e8c5c2a42..74bdf4516c 100644 --- a/libs/pbd/pbd/copyfile.h +++ b/libs/pbd/pbd/copyfile.h @@ -17,9 +17,9 @@ */ -#include +#include namespace PBD { - int copy_file (Glib::ustring from, Glib::ustring to); + int copy_file (const std::string& from, const std::string& to); } diff --git a/libs/pbd/pbd/shortpath.h b/libs/pbd/pbd/shortpath.h index 55431bf34e..dacd1ebbfe 100644 --- a/libs/pbd/pbd/shortpath.h +++ b/libs/pbd/pbd/shortpath.h @@ -20,8 +20,8 @@ #ifndef __pbd_shortpath_h__ #define __pbd_shortpath_h__ -#include +#include -Glib::ustring short_path (const Glib::ustring& path, Glib::ustring::size_type target_characters); +std::string short_path (const std::string& path, std::string::size_type target_characters); #endif /* __pbd_shortpath_h__ */ diff --git a/libs/pbd/pbd/strsplit.h b/libs/pbd/pbd/strsplit.h index 25c4526b6a..f235448b31 100644 --- a/libs/pbd/pbd/strsplit.h +++ b/libs/pbd/pbd/strsplit.h @@ -22,9 +22,7 @@ #include #include -#include extern void split (std::string, std::vector&, char); -extern void split (Glib::ustring, std::vector&, char); #endif // __pbd_strplit_h__ diff --git a/libs/pbd/pbd/whitespace.h b/libs/pbd/pbd/whitespace.h index dcdb4e5f27..444be112b0 100644 --- a/libs/pbd/pbd/whitespace.h +++ b/libs/pbd/pbd/whitespace.h @@ -22,16 +22,11 @@ #include -namespace Glib { - class ustring; -} - namespace PBD { // returns the empty string if the entire string is whitespace // so check length after calling. extern void strip_whitespace_edges (std::string& str); -extern void strip_whitespace_edges (Glib::ustring& str); } // namespace PBD diff --git a/libs/pbd/shortpath.cc b/libs/pbd/shortpath.cc index f5a6f696a7..069fed32c2 100644 --- a/libs/pbd/shortpath.cc +++ b/libs/pbd/shortpath.cc @@ -22,26 +22,25 @@ #include -using namespace Glib; -using namespace std; +using std::string; -ustring -short_path (const Glib::ustring& path, ustring::size_type target_characters) +string +short_path (const std::string& path, string::size_type target_characters) { - ustring::size_type last_sep; - ustring::size_type len = path.length(); + string::size_type last_sep; + string::size_type len = path.length(); const char separator = '/'; if (len <= target_characters) { return path; } - if ((last_sep = path.find_last_of (separator)) == ustring::npos) { + if ((last_sep = path.find_last_of (separator)) == string::npos) { /* just a filename, but its too long anyway */ if (target_characters > 3) { - return path.substr (0, target_characters - 3) + ustring ("..."); + return path.substr (0, target_characters - 3) + string ("..."); } else { /* stupid caller, just hand back the whole thing */ return path; @@ -53,7 +52,7 @@ short_path (const Glib::ustring& path, ustring::size_type target_characters) /* even the filename itself is too long */ if (target_characters > 3) { - return path.substr (last_sep+1, target_characters - 3) + ustring ("..."); + return path.substr (last_sep+1, target_characters - 3) + string ("..."); } else { /* stupid caller, just hand back the whole thing */ return path; @@ -64,12 +63,12 @@ short_path (const Glib::ustring& path, ustring::size_type target_characters) uint32_t space_for = target_characters - so_far; if (space_for >= 3) { - ustring res = "..."; + string res = "..."; res += path.substr (last_sep - space_for); return res; } else { /* remove part of the end */ - ustring res = "..."; + string res = "..."; res += path.substr (last_sep - space_for, len - last_sep + space_for - 3); res += "..."; return res; diff --git a/libs/pbd/strsplit.cc b/libs/pbd/strsplit.cc index 342daadaa2..74c4a9b3ef 100644 --- a/libs/pbd/strsplit.cc +++ b/libs/pbd/strsplit.cc @@ -20,7 +20,6 @@ #include using namespace std; -using namespace Glib; void split (string str, vector& result, char splitchar) @@ -60,40 +59,3 @@ split (string str, vector& result, char splitchar) } } -void -split (ustring str, vector& result, char splitchar) -{ - ustring::size_type pos; - ustring remaining; - ustring::size_type len = str.length(); - int cnt; - - cnt = 0; - - if (str.empty()) { - return; - } - - for (ustring::size_type n = 0; n < len; ++n) { - if (str[n] == gunichar(splitchar)) { - cnt++; - } - } - - if (cnt == 0) { - result.push_back (str); - return; - } - - remaining = str; - - while ((pos = remaining.find_first_of (splitchar)) != ustring::npos) { - result.push_back (remaining.substr (0, pos)); - remaining = remaining.substr (pos+1); - } - - if (remaining.length()) { - - result.push_back (remaining); - } -} diff --git a/libs/pbd/whitespace.cc b/libs/pbd/whitespace.cc index 126039842e..808b990edd 100644 --- a/libs/pbd/whitespace.cc +++ b/libs/pbd/whitespace.cc @@ -78,13 +78,4 @@ strip_whitespace_edges (string& str) } } -void -strip_whitespace_edges (Glib::ustring& str) -{ - string copy (str.raw()); - strip_whitespace_edges (copy); - str = copy; -} - - } // namespace PBD -- cgit v1.2.3