This method is unused and requires the risky c_str() API to operate.
Code wanting to parse an SBuf should use a Tokenizer or Parser instead.
return npos;
}
-/*
- * TODO: borrow a sscanf implementation from Linux or similar?
- * we'd really need a vsnscanf(3)... ? As an alternative, a
- * light-regexp-like domain-specific syntax might be an idea.
- */
-int
-SBuf::scanf(const char *format, ...)
-{
- // with the format or an arg might be a dangerous char*
- // that gets invalidated by c_str()
- const Locker blobKeeper(this, buf());
-
- va_list arg;
- int rv;
- ++stats.scanf;
- va_start(arg, format);
- rv = vsscanf(c_str(), format, arg);
- va_end(arg);
- return rv;
-}
-
void
SBuf::toLower()
{
*/
size_type findLastNotOf(const CharacterSet &set, size_type endPos = npos) const;
- /** sscanf-alike
- *
- * sscanf re-implementation. Non-const, and not \0-clean.
- * \return same as sscanf
- * \see man sscanf(3)
- */
- int scanf(const char *format, ...);
-
/// converts all characters to lower case; \see man tolower(3)
void toLower();
: alloc(0), allocCopy(0), allocFromCString(0),
assignFast(0), clear(0), append(0), moves(0), toStream(0), setChar(0),
getChar(0), compareSlow(0), compareFast(0), copyOut(0),
- rawAccess(0), nulTerminate(0), chop(0), trim(0), find(0), scanf(0),
+ rawAccess(0), nulTerminate(0), chop(0), trim(0), find(0),
caseChange(0), cowFast(0), cowSlow(0), live(0)
{}
chop += ss.chop;
trim += ss.trim;
find += ss.find;
- scanf += ss.scanf;
caseChange += ss.caseChange;
cowFast += ss.cowFast;
cowSlow += ss.cowSlow;
"\nchop operations: " << chop <<
"\ntrim operations: " << trim <<
"\nfind: " << find <<
- "\nscanf: " << scanf <<
"\ncase-change ops: " << caseChange <<
"\nCOW not actually requiring a copy: " << cowFast <<
"\nCOW: " << cowSlow <<
uint64_t chop; ///<number of chop operations
uint64_t trim; ///<number of trim operations
uint64_t find; ///<number of find operations
- uint64_t scanf; ///<number of scanf operations
uint64_t caseChange; ///<number of toUpper and toLower operations
uint64_t cowFast; ///<number of cow operations not actually requiring a copy
uint64_t cowSlow; ///<number of cow operations requiring a copy
SBuf::size_type SBuf::rfind(const SBuf &str, size_type endPos) const STUB_RETVAL(SBuf::npos)
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)
void SBuf::toLower() STUB
void SBuf::toUpper() STUB
CPPUNIT_ASSERT_EQUAL(strlen(fox),(size_t)s.length());
}
-void
-testSBuf::testScanf()
-{
- SBuf s1;
- char s[128];
- int i;
- float f;
- int rv;
- s1.assign("string , 123 , 123.50");
- rv=s1.scanf("%s , %d , %f",s,&i,&f);
- CPPUNIT_ASSERT_EQUAL(3,rv);
- CPPUNIT_ASSERT_EQUAL(0,strcmp(s,"string"));
- CPPUNIT_ASSERT_EQUAL(123,i);
- CPPUNIT_ASSERT_EQUAL(static_cast<float>(123.5),f);
-}
-
void
testSBuf::testCopy()
{
CPPUNIT_TEST( testFindFirstOf );
CPPUNIT_TEST( testFindFirstNotOf );
CPPUNIT_TEST( testPrintf );
- CPPUNIT_TEST( testScanf );
CPPUNIT_TEST( testCopy );
CPPUNIT_TEST( testStringOps );
CPPUNIT_TEST( testGrow );
void testAppendStdString();
void testAppendf();
void testPrintf();
- void testScanf();
void testSubscriptOp();
void testSubscriptOpFail();
void testDumpStats();