summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <Pixel>2001-11-28 19:24:09 +0000
committerPixel <Pixel>2001-11-28 19:24:09 +0000
commit9f2ad93e4dd13446a9df2304f1f74c4272739bea (patch)
treecc6437645abc05ecb8e21d3f5efdefbc5a89da18
parent0ddaa5127bf155ffb93f9da13381ad176b43a295 (diff)
String enhance...
-rw-r--r--include/String.h3
-rw-r--r--lib/String.cc14
2 files changed, 15 insertions, 2 deletions
diff --git a/include/String.h b/include/String.h
index b614d8d..fbeb9fc 100644
--- a/include/String.h
+++ b/include/String.h
@@ -50,7 +50,8 @@ class String : public Base {
String(unsigned long long);
String(double);
~String();
- const char * set(char *, ...);
+ const char * set(const char *, ...);
+ const char * set(const String &, ...);
const char * to_charp(size_t = 0, ssize_t = -1) const;
String extract(size_t = 0, ssize_t = -1) const;
char * strdup(size_t = 0, ssize_t = -1) const;
diff --git a/lib/String.cc b/lib/String.cc
index fa1db50..83adad7 100644
--- a/lib/String.cc
+++ b/lib/String.cc
@@ -71,7 +71,7 @@ String::~String() {
free(str);
}
-const char * String::set(char * s, ...) {
+const char * String::set(const char * s, ...) {
va_list ap;
va_start(ap, s);
@@ -83,6 +83,18 @@ const char * String::set(char * s, ...) {
return t;
}
+const char * String::set(const String & s, ...) {
+ va_list ap;
+
+ va_start(ap, s);
+ vsnprintf(t, BUFSIZ, s.str, ap);
+ free(str);
+ str = Base::strdup(t);
+ va_end(ap);
+ siz = ::strlen(str);
+ return t;
+}
+
const char * String::to_charp(size_t from, ssize_t to) const {
if (to < 0) {
strncpy(t, &(str[from]), BUFSIZ);