summaryrefslogtreecommitdiff
path: root/generic/String.cpp
diff options
context:
space:
mode:
authorPixel <Pixel>2002-09-27 12:17:57 +0000
committerPixel <Pixel>2002-09-27 12:17:57 +0000
commitbfa5de7eccf4604ff8217f619e9685a09e80d545 (patch)
treea5be5de750ac611145f459a09bda902c3dbc1a70 /generic/String.cpp
parent60c1003845035ad4cd0e9ea50862bad7626faf0e (diff)
The week-without-the-network changes
Diffstat (limited to 'generic/String.cpp')
-rw-r--r--generic/String.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/generic/String.cpp b/generic/String.cpp
index 24961c5..d879308 100644
--- a/generic/String.cpp
+++ b/generic/String.cpp
@@ -1,6 +1,7 @@
#include <iostream>
#include <string.h>
#include <stdarg.h>
+#include <ctype.h>
#include "String.h"
#include "Exceptions.h"
#ifdef HAVE_CONFIG_H
@@ -27,14 +28,13 @@ String::String(char c) : siz(1) {
str = t;
}
-#if 0
String::String(const char * s) : str(Base::strdup(s)), siz(::strlen(str)) {
#ifdef DEBUG
fprintf(stderr, "Creating a string with `%s' at %p\n", str, str);
#endif
}
-#endif
+#if 0
String::String(const char * s, ...) {
va_list ap;
@@ -42,14 +42,13 @@ String::String(const char * s, ...) {
fprintf(stderr, "Creating a String with s = '%s'\n", s);
#endif
-/* This causes a warning: cannot pass objects of type `const String' through `...'
- but it is not really a problem. */
va_start(ap, s);
vsnprintf(t, BUFSIZ, s, ap);
str = Base::strdup(t);
va_end(ap);
siz = ::strlen(str);
}
+#endif
String::String(int hs, const char * s) : str(s ? Base::strdup(s) : Base::strdup("")), siz(hs) { }
@@ -389,3 +388,19 @@ bool String::is_time(void) const {
String operator+(const char * a, const String & b) {
return String(a) + b;
}
+
+String & String::toupper() {
+ for (int i = 0; i < strlen(); i++) {
+ str[i] = ::toupper(str[i]);
+ }
+
+ return *this;
+}
+
+String & String::tolower() {
+ for (int i = 0; i < strlen(); i++) {
+ str[i] = ::tolower(str[i]);
+ }
+
+ return *this;
+}