step one of removing Glib::ustring from ardour2
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@10003 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
bc9d6f66c1
commit
c8f5d847e5
|
@ -20,13 +20,12 @@
|
|||
#include <pbd/basename.h>
|
||||
#include <glibmm/miscutils.h>
|
||||
|
||||
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 ('.'));
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
#ifndef __stupid_basename_h__
|
||||
#define __stupid_basename_h__
|
||||
|
||||
#include <glibmm/ustring.h>
|
||||
#include <string>
|
||||
|
||||
namespace PBD
|
||||
{
|
||||
|
||||
Glib::ustring basename_nosuffix (Glib::ustring);
|
||||
std::string basename_nosuffix (const std::string&);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
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);
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
*/
|
||||
|
||||
#include <glibmm/ustring.h>
|
||||
#include <string>
|
||||
|
||||
namespace PBD {
|
||||
|
||||
int copy_file (Glib::ustring from, Glib::ustring to);
|
||||
int copy_file (const std::string& from, const std::string& to);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
#ifndef __pbd_shortpath_h__
|
||||
#define __pbd_shortpath_h__
|
||||
|
||||
#include <glibmm/ustring.h>
|
||||
#include <string>
|
||||
|
||||
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__ */
|
||||
|
|
|
@ -22,9 +22,7 @@
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
extern void split (std::string, std::vector<std::string>&, char);
|
||||
extern void split (Glib::ustring, std::vector<Glib::ustring>&, char);
|
||||
|
||||
#endif // __pbd_strplit_h__
|
||||
|
|
|
@ -22,16 +22,11 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -22,26 +22,25 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
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;
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include <pbd/strsplit.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Glib;
|
||||
|
||||
void
|
||||
split (string str, vector<string>& result, char splitchar)
|
||||
|
@ -60,40 +59,3 @@ split (string str, vector<string>& result, char splitchar)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
split (ustring str, vector<ustring>& 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue