Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for libplaton/platon/str/strplus.h between version 1.18 and 1.19

version 1.18, 2002/09/19 15:28:36 version 1.19, 2002/10/02 20:01:57
Line 14 
Line 14 
  *                                                                        *   *                                                                        *
  **************************************************************************/   **************************************************************************/
   
   /**
    * Advanced string locate, counting, removing, inserting
    * and comparing functions
    *
    * @file        platon/str/strplus.h
    * @author      Ondrej Jombik <nepto@pobox.sk>
    * @version     \$Id$
    * @date        1997-2002
    */
   
 #ifndef _PLATON_STR_STRPLUS_H  #ifndef _PLATON_STR_STRPLUS_H
 #define _PLATON_STR_STRPLUS_H  #define _PLATON_STR_STRPLUS_H
   
 /* TODO: macros should not be in extern "C" { } */  
   
 #ifndef PLATON_FUNC  #ifndef PLATON_FUNC
 # define PLATON_FUNC(_name) _name  # define PLATON_FUNC(_name) _name
 #endif  #endif
Line 30 
Line 38 
 extern "C" {  extern "C" {
 #endif  #endif
   
 /*          /**
  * Locate functions           * @name Locate functions
  *           */
  * strendstr() - macro that locates end of substring (use only if you are sure,          /**@{*/
  *               that substring is located in string)  
  * strestr() - locate a end of substring          /**
  * strcasestr(), stristr() - locate a substring ignoring case           * Macro that locates end of substring
  * str_white_str() - search substr in str; every white char in substr can be           *
  *                   substitued with one or more white chars in str; in size,           * @param               __s1    where to search (haystack)
  *                   if not NULL, will be the length of matched patern;           * @param               __s2    what to search (needle)
  *                   author: Rastislav 'Crasher' Barlik <rbarlik@yahoo.com>           * @return              pointer to character after __s2
  *                   patched by: Ondrej Jombik <nepto@pobox.sk> [28/2/2002]           * @warning             use only if you are sure, that substring is located in string;
  * strwstr() - the same as function above but without size parameter           *                              otherwise use strestr() function
  */           */
   
 #define strendstr(__s1,__s2) (strstr(__s1,__s2) + strlen(__s2))  #define strendstr(__s1,__s2) (strstr(__s1,__s2) + strlen(__s2))
   
           /**
            * Locates a end of substring
            *
            * @param               s1              where to search (haystack)
            * @param               s2              what to search (needle)
            * @return              pointer to character after s2 or NULL if not found
            */
         char *PLATON_FUNC(strestr)(const char *s1, const char *s2);          char *PLATON_FUNC(strestr)(const char *s1, const char *s2);
   
           /**
            * Locates a substring case-insensitive
            *
            * @param               s1              where to search (haystack)
            * @param               s2              what to search (needle)
            * @return              pointer to s2 in s1 or NULL if not found
            */
         char *PLATON_FUNC(stristr)(const char *s1, const char *s2);          char *PLATON_FUNC(stristr)(const char *s1, const char *s2);
   
 #define strcasestr(__s1, __s2) stristr(__s1, __s2)  #define strcasestr(__s1, __s2) stristr(__s1, __s2) /**< alias to stristr() */
   
           /**
            * Searches substr in str with special whitespaces handling
            *
            * @param       str             where to search (haystack)
            * @param       substr  what to search (needle)
            * @retval      size    size of matched patern if found, undefined if not found
            * @return      pointer to substr in str on NULL if not found
            * @author      Rastislav 'Crasher' Barlik <rbarlik@yahoo.com>
            *                      patched by: Ondrej Jombik <nepto@pobox.sk> [28/2/2002]
            *
            * This function works just like classical strstr() call, with following
            * advanced feature. Every white char in substr can be substitued with one
            * or more white chars in str. In size, if not NULL was passed, will be the
            * length of matched patern.
            */
         char *PLATON_FUNC(str_white_str)(char *str, char *substr, int *size);          char *PLATON_FUNC(str_white_str)(char *str, char *substr, int *size);
   
           /* TODO: remove this (???) */
           /** alias to str_white_str() */
 #define strwhitestr(str, substr, size) str_white_str(str, substr, size)  #define strwhitestr(str, substr, size) str_white_str(str, substr, size)
 #define strwstr(str, substr) str_white_str(str, substr, NULL)  
   
 /*          /**
  * Counting functions           * Function str_white_str() without usage of matched pattern size.
  *           *
  * strcnt() - count number of characters in string           * This function works just like str_white_str(), but third return value
  * strcnt_str() - count number of substrings in string           * parameter (pattern length) is unused.
  * strcnt_sepstr() - count number of separate substrings in string           */
  */  #define strwstr(str, substr) str_white_str(str, substr, NULL)
   
           /**@}*/
           /**
            * @name Counting functions
            */
           /**@{*/
   
           /**
            * Counts number of characters in string
            *
            * @param       str             input string
            * @param       c               character to count
            * @return      number of c occurences in str
            */
         int PLATON_FUNC(strcnt)(const char *str, const int c);          int PLATON_FUNC(strcnt)(const char *str, const int c);
   
           /**
            * Counts number of substrings in string
            *
            * @param       str             input string
            * @param       substr  substring to count
            * @return      number of substr occurences in str
            *
            * Note that in this function strings may overlay. For separate strings
            * counting use strcnt_sepstr() function.
            */
         int PLATON_FUNC(strcnt_str)(const char *str, const char *substr);          int PLATON_FUNC(strcnt_str)(const char *str, const char *substr);
         int PLATON_FUNC(strcnt_sepstr)(const char *str, const char *substr);  
   
 /*          /**
  * Removing functions           * Count number of separate substrings in string
  *           *
  * strdel() - deletes a one character at position of s           * @param       str             input string
  * strrmlf() - removes all occurences of LF (Line Feed) in string           * @param       substr  substring to count
  * strrmcr() - removes all occurences of CR (Carriage Return) in string.           * @return      number of separate substr occurences in str
  * strrmeol(), strrmcrlf(), strrmlfcr() - macros that removes all occurences           *
  *                                        of CR and LF in string           * Note that in this function will be only not overlayed strings counted.
  * str_left_trim(), ltrim() - removes white characters from beginning of string           * For counting overlayed strings use strcnt_str() function. Also note,
  * str_right_trim(), rtrim() - removes white characters from end of string           * that counting is performed from beginning of string. Result count may,
  * str_trim(),strtrim(), trim() - removes white characters from beginning and           * but MUST NOT be the highest number of separate substr substrings in str.
  *                                end of string           */
  * str_trim_whitechars() - substitute every group of white characters in string by          int PLATON_FUNC(strcnt_sepstr)(const char *str, const char *substr);
  *                         one space character  
  */  
   
           /**@}*/
           /**
            * @name Removing functions
            */
           /**@{*/
   
           /**
            * Deletes a one character
            *
            * @param       s       where to delete one character
            * @return      modified string
            */
         char *PLATON_FUNC(strdel)(char *s);          char *PLATON_FUNC(strdel)(char *s);
   
           /**
            * Removes all occurences of LF (Line Feed)
            *
            * @param       s       string where to remove all LF (\n) characters
            * @return      modified string
            */
         char *PLATON_FUNC(strrmlf)(char *s);          char *PLATON_FUNC(strrmlf)(char *s);
   
           /**
            * Removes all occurences of CR (Carriage Return)
            *
            * @param       s       string where to remove all CR (\r) characters
            * @return      modified string
            */
         char *PLATON_FUNC(strrmcr)(char *s);          char *PLATON_FUNC(strrmcr)(char *s);
   
           /** alias that removes all occurences of LF and CR characters */
 #define strrmeol(__s)   strrmcr(strrmlf(__s))  #define strrmeol(__s)   strrmcr(strrmlf(__s))
 #define strrmcrlf(__s)  strrmeol(__s)  #define strrmcrlf(__s)  strrmeol(__s)   /**< alias to strrmeol() */
 #define strrmlfcr(__s)  strrmeol(__s)  #define strrmlfcr(__s)  strrmeol(__s)   /**< alias to strrmeol() */
   
           /**
            * Removes white characters from the beginning of string
            *
            * @param       s       string
            * @param       modified string
            */
         char *PLATON_FUNC(str_left_trim)(char *s);          char *PLATON_FUNC(str_left_trim)(char *s);
   
           /**
            * Removes white characters from the end of string
            *
            * @param       s       string
            * @param       modified string
            */
         char *PLATON_FUNC(str_right_trim)(char *s);          char *PLATON_FUNC(str_right_trim)(char *s);
         char *PLATON_FUNC(str_trim_whitechars)(char *s);  
 #  define ltrim(s)      PLATON_FUNC(str_left_trim)(s)  
 #  define rtrim(s)      PLATON_FUNC(str_right_trim)(s)  
   
 #define trim(s)         rtrim(ltrim(s))  #define ltrim(s) PLATON_FUNC(str_left_trim)(s) /**< alias to str_left_trim() */
 #define strtrim(s)      trim(s)  #define rtrim(s) PLATON_FUNC(str_right_trim)(s)/**< alias to str_right_trim()*/
 #define str_trim(s)     trim(s)  
   
 /*          /**
  * Inserting functions           * Removes white characters from beginning and end of string
  *           *
  * strins() - function inserts string ins at position str;           * @param       s       string
  *            there MUST be enough memory allocated in str           * @return      modified string
  */           */
         char *PLATON_FUNC(strins)(char *str, char *ins);  #define trim(s) rtrim(ltrim(s))
   
   #define strtrim(s)      trim(s) /**< alias to trim() */
   #define str_trim(s)     trim(s) /**< alias to trim() */
   
           /**
            * Substitute every group of whitespaces for one space
            *
            * @param       s       string
            * @return      modified string
            */
           char *PLATON_FUNC(str_trim_whitechars)(char *s);
   
 /*          /**@}*/
  * Comparing functions          /**
  *           * @name Inserting functions
  * strrcmp() - compares two string in reverse order           */
  */          /**@{*/
   
           /**
            * Inserts string into string
            *
            * @param       str             where to insert
            * @param       ins             what to insert
            * @return      modified string.
            *
            * This function inserts string ins at position str. Note that there MUST
            * be enough memory allocated in str to avoid memory ovelaping after str.
            */
           char *PLATON_FUNC(strins)(char *str, char *ins);
   
           /**@}*/
           /**
            * @name Comparing functions
            */
           /**@{*/
   
           /**
            * Compares two string in reverse order
            *
            * @param       s1      first string to compare
            * @param       s2      second string to compare
            * @return      0 if strings are indetical, strcmp() difference of the shortest
            *                      different substrings otherwise
            */
         int PLATON_FUNC(strrcmp)(const char *s1, const char *s2);          int PLATON_FUNC(strrcmp)(const char *s1, const char *s2);
   
           /**@}*/
   
 #ifdef __cplusplus  #ifdef __cplusplus
 }  }
 #endif  #endif

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top