aboutsummaryrefslogtreecommitdiff
path: root/libbutl/utility.ixx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-10-01 11:51:38 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-10-01 11:51:38 +0200
commit177d187a8e1eb01d18f4541726467bf6eef114fd (patch)
treeca807d5961b1cf2408d7691145fae5d46e85f8b5 /libbutl/utility.ixx
parentfbfd4eed353baf6577f7a09b8a7c15e89d33bda7 (diff)
Add position and size arguments to lcase()/ucase() functions
Diffstat (limited to 'libbutl/utility.ixx')
-rw-r--r--libbutl/utility.ixx26
1 files changed, 16 insertions, 10 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