aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbutl/utility.ixx26
-rw-r--r--libbutl/utility.mxx21
2 files changed, 30 insertions, 17 deletions
diff --git a/libbutl/utility.ixx b/libbutl/utility.ixx
index 72fbc5b..fa37a14 100644
--- a/libbutl/utility.ixx
+++ b/libbutl/utility.ixx
@@ -25,12 +25,15 @@ namespace butl
}
inline std::string&
- ucase (std::string& s)
+ ucase (std::string& s, std::size_t p, std::size_t n)
{
- if (size_t n = s.size ())
+ if (n == std::string::npos)
+ n = s.size () - p;
+
+ if (n != 0)
{
s.front () = s.front (); // Force copy in CoW.
- ucase (const_cast<char*> (s.data ()), n);
+ ucase (const_cast<char*> (s.data ()) + p, n);
}
return s;
}
@@ -43,9 +46,9 @@ namespace butl
}
inline std::string
- ucase (const std::string& s)
+ ucase (const std::string& s, std::size_t p, std::size_t n)
{
- return ucase (s.c_str (), s.size ());
+ return ucase (s.c_str () + p, n != std::string::npos ? n : s.size () - p);
}
inline char
@@ -62,12 +65,15 @@ namespace butl
}
inline std::string&
- lcase (std::string& s)
+ lcase (std::string& s, std::size_t p, std::size_t n)
{
- if (size_t n = s.size ())
+ if (n == std::string::npos)
+ n = s.size () - p;
+
+ if (n != 0)
{
s.front () = s.front (); // Force copy in CoW.
- lcase (const_cast<char*> (s.data ()), n);
+ lcase (const_cast<char*> (s.data ()) + p, n);
}
return s;
}
@@ -80,9 +86,9 @@ namespace butl
}
inline std::string
- lcase (const std::string& s)
+ lcase (const std::string& s, std::size_t p, std::size_t n)
{
- return lcase (s.c_str (), s.size ());
+ return lcase (s.c_str () + p, n != std::string::npos ? n : s.size () - p);
}
inline int
diff --git a/libbutl/utility.mxx b/libbutl/utility.mxx
index 78c9355..a59686b 100644
--- a/libbutl/utility.mxx
+++ b/libbutl/utility.mxx
@@ -86,16 +86,23 @@ LIBBUTL_MODEXPORT namespace butl
// http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap07.html#tag_07_02)
//
char ucase (char);
- std::string ucase (const char*, std::size_t = std::string::npos);
-
- std::string ucase (const std::string&);
- std::string& ucase (std::string&);
+ std::string ucase (const char*, std::size_t n = std::string::npos);
+ std::string ucase (const std::string&,
+ std::size_t p = 0,
+ std::size_t n = std::string::npos);
+ std::string& ucase (std::string&,
+ std::size_t p = 0,
+ std::size_t n = std::string::npos);
void ucase (char*, std::size_t);
char lcase (char);
- std::string lcase (const char*, std::size_t = std::string::npos);
- std::string lcase (const std::string&);
- std::string& lcase (std::string&);
+ std::string lcase (const char*, std::size_t n = std::string::npos);
+ std::string lcase (const std::string&,
+ std::size_t p = 0,
+ std::size_t n = std::string::npos);
+ std::string& lcase (std::string&,
+ std::size_t p = 0,
+ std::size_t n = std::string::npos);
void lcase (char*, std::size_t);
// Compare ASCII characters/strings ignoring case. Behave as if characters