Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/Deprecated/old_18mar_diff/Str14dec/StrFind.cpp

Go to the documentation of this file.
00001 #ifndef __J2K__JString_Find_CPP__
00002 #define __J2K__JString_Find_CPP__
00003 
00004 #include <j2k/Fred/String/String.hpp>
00005 #include <string.h>
00006 #include <time.h>
00007 
00008 // Does NOT use external JString function
00009 
00010 // Instr missing (FindAt)
00011 
00012 long JString::Find( const char* s, ULONG offset ) const {
00013   if ( s == NULL ) return (-1);  // If null then -1
00014   if ( offset >= pData->length ) return (-1);
00015   char* p  = pData->data + offset;
00016   char* s2 = strstr(p, s);
00017   return ( (s2 == NULL) ? (long)(-1) : (long)(s2 - p) );
00018 }
00019 
00020 JString  JString::getFind( const char* s, ULONG offset ) {
00021   // On error return Null String
00022   if ( s == NULL ) return JString();
00023   if ( offset >= pData->length ) return JString();
00024   char* p  = pData->data + offset;
00025   char* s2 = strstr(p, s);
00026   if ( s2 == NULL ) {
00027     return JString();
00028   }
00029 
00030   ULONG sz = pData->length - (ULONG)(s2 - p);
00031   return JString( (char*)(s2 - p), sz );
00032 }
00033 
00034 #endif

Generated on Sun Oct 14 18:46:28 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001