return os;
}
-SBuf
-SBuf::toLower() const
+void
+SBuf::toLower()
{
debugs(24, 8, "\"" << *this << "\"");
- SBuf rv(*this);
for (size_type j = 0; j < length(); ++j) {
const int c = (*this)[j];
if (isupper(c))
- rv.setAt(j, tolower(c)); //will cow() if needed
+ setAt(j, tolower(c));
}
- debugs(24, 8, "result: \"" << rv << "\"");
+ debugs(24, 8, "result: \"" << *this << "\"");
++stats.caseChange;
- return rv;
}
-SBuf
-SBuf::toUpper() const
+void
+SBuf::toUpper()
{
debugs(24, 8, "\"" << *this << "\"");
- SBuf rv(*this);
for (size_type j = 0; j < length(); ++j) {
const int c = (*this)[j];
if (islower(c))
- rv.setAt(j, toupper(c)); //will cow() if needed
+ setAt(j, toupper(c));
}
- debugs(24, 8, "result: \"" << rv << "\"");
+ debugs(24, 8, "result: \"" << *this << "\"");
++stats.caseChange;
- return rv;
}
/**
*/
int scanf(const char *format, ...);
- /** Lower-case SBuf
- *
- * Returns a lower-cased COPY of the SBuf
- * \see man tolower(3)
- */
- SBuf toLower() const;
+ /// converts all characters to lower case; \see man tolower(3)
+ void toLower();
- /** Upper-case SBuf
- *
- * Returns an upper-cased COPY of the SBuf
- * \see man toupper(3)
- */
- SBuf toUpper() const;
+ /// converts all characters to upper case; \see man toupper(3)
+ void toUpper();
/** String export function
* converts the SBuf to a legacy String, by copy.
return S.print(os);
}
+/// Returns a lower-cased copy of its parameter.
+inline SBuf
+ToUpper(SBuf buf)
+{
+ buf.toUpper();
+ return buf;
+}
+
+/// Returns an upper-cased copy of its parameter.
+inline SBuf
+ToLower(SBuf buf)
+{
+ buf.toLower();
+ return buf;
+}
+
#endif /* SQUID_SBUF_H */
SBuf::size_type SBuf::findFirstOf(const CharacterSet &set, size_type startPos) const STUB_RETVAL(SBuf::npos)
SBuf::size_type SBuf::findFirstNotOf(const CharacterSet &set, size_type startPos) const STUB_RETVAL(SBuf::npos)
int SBuf::scanf(const char *format, ...) STUB_RETVAL(-1)
-SBuf SBuf::toLower() const STUB_RETVAL(*this)
-SBuf SBuf::toUpper() const STUB_RETVAL(*this)
+void SBuf::toLower() STUB
+void SBuf::toUpper() STUB
String SBuf::toString() const STUB_RETVAL(String(""))
void
testSBuf::testStringOps()
{
- SBuf sng(literal.toLower()),
+ SBuf sng(ToLower(literal)),
ref("the quick brown fox jumped over the lazy dog");
CPPUNIT_ASSERT_EQUAL(ref,sng);
sng=literal;
// case-insensitive checks
CPPUNIT_ASSERT(literal.startsWith(casebuf,caseInsensitive));
- casebuf=SBuf(fox1).toUpper();
+ casebuf=ToUpper(SBuf(fox1));
CPPUNIT_ASSERT(literal.startsWith(casebuf,caseInsensitive));
CPPUNIT_ASSERT(literal.startsWith(SBuf(fox1),caseInsensitive));
casebuf = "tha quick";