From 2186d5f3f95cd74a070a490d899291648d58667a Mon Sep 17 00:00:00 2001 From: Steven Fuller Date: Sun, 1 Jul 2001 00:55:22 +0000 Subject: Initial revision --- 3dc/win95/STRING.CPP | 305 --------------------------------------------------- 1 file changed, 305 deletions(-) delete mode 100644 3dc/win95/STRING.CPP (limited to '3dc/win95/STRING.CPP') diff --git a/3dc/win95/STRING.CPP b/3dc/win95/STRING.CPP deleted file mode 100644 index 4ea96b5..0000000 --- a/3dc/win95/STRING.CPP +++ /dev/null @@ -1,305 +0,0 @@ -#include -#include -#include -#include "string.hpp" - -String::String() -: rep(0) -, len(0) -, cstring(0) -{ -} - -String::String(char const * str, size_t maxlen) -: rep(0) -, len(strlen(str)) -, cstring(0) -{ - if (len > maxlen) len = maxlen; - if (!len) return; - rep = (char *)malloc(len*sizeof(char)); - memcpy(rep,str,len*sizeof(char)); -} - -String::String(String const & str, size_t start, size_t leng) -: rep(0) -, len(leng) -, cstring(0) -{ - if (start>str.len) return; - if (start+len>str.len) len=str.len-start; - if (!len) return; - rep = (char *)malloc(len*sizeof(char)); - memcpy(rep,&str.rep[start],len*sizeof(char)); -} - -String::String(char c, size_t n) -: rep(0) -, len(n) -, cstring(0) -{ - if (len) - { - rep = (char *)malloc(len*sizeof(char)); - for (size_t p=0; p=) -STRING_COMPARES(<) -STRING_COMPARES(>) - -void String::put_at(size_t pos, char c) -{ - if (pos=len || pos>=str.len || rep[pos] != str.rep[pos]) return (int)pos; - } - return -1; -} - -int String::match(char const * str) const -{ - for (size_t pos = 0; pos=len || !*str || rep[pos] != *str) return (int)pos; - } - return -1; -} - -int String::index(String const & str, size_t pos) const -{ - if (!str.len) return (int)pos; - for (size_t spos = 0, rpos = pos; pos= str.len) return (int)rpos; - } - else spos = 0; - } - return -1; -} - -int String::index(char const * str, size_t pos) const -{ - if (!*str) return (int)pos; - char const * strP = str; - for (size_t rpos = pos; pos