Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

include/shwild/shwild.h

Go to the documentation of this file.
00001 /* /////////////////////////////////////////////////////////////////////////////
00002  * File:    shwild/shwild.h
00003  *
00004  * Purpose: Root header file for the shwild library
00005  *
00006  * Created: 17th June 2005
00007  * Updated: 15th May 2006
00008  *
00009  * Home:    http://shwild.org/
00010  *
00011  * Copyright (c) 2005-2006, Matthew Wilson and Sean Kelly
00012  * All rights reserved.
00013  *
00014  * Redistribution and use in source and binary forms, with or without
00015  * modification, are permitted provided that the following conditions are met:
00016  *
00017  * - Redistributions of source code must retain the above copyright notice, this
00018  *   list of conditions and the following disclaimer.
00019  * - Redistributions in binary form must reproduce the above copyright notice,
00020  *   this list of conditions and the following disclaimer in the documentation
00021  *   and/or other materials provided with the distribution.
00022  * - Neither the names of Matthew Wilson and Sean Kelly nor the names of
00023  *   any contributors may be used to endorse or promote products derived from
00024  *   this software without specific prior written permission.
00025  *
00026  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00027  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00029  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00030  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00031  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00032  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00033  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00034  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00035  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00036  * POSSIBILITY OF SUCH DAMAGE.
00037  *
00038  * ////////////////////////////////////////////////////////////////////////// */
00039 
00040 
00044 #ifndef SHWILD_INCL_SHWILD_H_SHWILD
00045 #define SHWILD_INCL_SHWILD_H_SHWILD
00046 
00047 /* /////////////////////////////////////////////////////////////////////////////
00048  * Version information
00049  */
00050 
00051 #ifndef SHWILD_DOCUMENTATION_SKIP_SECTION
00052 # define SHWILD_VER_SHWILD_H_SHWILD_MAJOR       1
00053 # define SHWILD_VER_SHWILD_H_SHWILD_MINOR       1
00054 # define SHWILD_VER_SHWILD_H_SHWILD_REVISION    1
00055 # define SHWILD_VER_SHWILD_H_SHWILD_EDIT        5
00056 #endif /* !SHWILD_DOCUMENTATION_SKIP_SECTION */
00057 
00074 #ifndef SHWILD_DOCUMENTATION_SKIP_SECTION
00075 # define SHWILD_VER_0_9_1       0x00090100
00076 # define SHWILD_VER_0_9_2       0x00090200
00077 #endif /* !SHWILD_DOCUMENTATION_SKIP_SECTION */
00078 
00079 #define SHWILD_VER_MAJOR    0
00080 #define SHWILD_VER_MINOR    9
00081 #define SHWILD_VER_REVISION 2
00082 
00083 #define SHWILD_VER  SHWILD_VER_0_9_2
00084 
00085 /* /////////////////////////////////////////////////////////////////////////////
00086  * Includes
00087  */
00088 
00089 #include <stddef.h>     /* for size_t */
00090 
00091 /* /////////////////////////////////////////////////////////////////////////////
00092  * Documentation
00093  */
00094 
00108 /* /////////////////////////////////////////////////////////////////////////////
00109  * Typedefs
00110  */
00111 
00115 struct shwild_handle_t_;
00116 
00122 typedef struct shwild_handle_t_ *shwild_handle_t;
00123 
00132 struct shwild_slice_t
00133 {
00134     size_t      len;    
00135     char const  *ptr;   
00137 #ifdef __cplusplus
00138 public:
00140     shwild_slice_t();
00142     shwild_slice_t(shwild_slice_t const &rhs);
00148     shwild_slice_t(size_t n, char const *s);
00149 #endif /* __cplusplus */
00150 };
00151 #ifndef SHWILD_DOCUMENTATION_SKIP_SECTION
00152 typedef struct shwild_slice_t   shwild_slice_t;
00153 #endif /* !SHWILD_DOCUMENTATION_SKIP_SECTION */
00154 
00155 /* /////////////////////////////////////////////////////////////////////////////
00156  * Constants and definitions
00157  */
00158 
00183 #define SHWILD_F_SUPPRESS_RANGE_SUPPORT                             (0x0001)    
00184 #define SHWILD_F_SUPPRESS_BACKSLASH_ESCAPE                          (0x0002)    
00185 #define SHWILD_F_SUPPRESS_RANGE_CONTINUUM_SUPPORT                   (0x0004)    
00186 #define SHWILD_F_SUPPRESS_RANGE_CONTINUUM_HIGHLOW_SUPPORT           (0x0008)    
00187 #define SHWILD_F_SUPPRESS_RANGE_CONTINUUM_CROSSCASE_SUPPORT         (0x0010)    
00188 #define SHWILD_F_SUPPRESS_RANGE_LITERAL_WILDCARD_SUPPORT            (0x0020)    
00189 #define SHWILD_F_SUPPRESS_RANGE_LEADTRAIL_LITERAL_HYPHEN_SUPPORT    (0x0040)    
00190 #define SHWILD_F_SUPPRESS_RANGE_NOT_SUPPORT                                                     (0x0400)    
00191 #if 0
00192 #define SHWILD_F_ALLOW_RANGE_LITERAL_BRACKET_SUPPORT                (0x0080)    
00193 #define SHWILD_F_ALLOW_RANGE_QUANTIFICATION_SUPPORT                 (0x0100)    
00194 #endif /* 0 */
00195 #define SHWILD_F_IGNORE_CASE                                        (0x0200)    
00197 #if 0
00198 /* Not currently supported. */
00199 #define SHWILD_F_FNM_PATHNAME_SEMANTICS                             (0x0800)    
00200 #endif /* 0 */
00201 
00211 #define SHWILD_RC_SUCCESS               (0)                             
00212 #define SHWILD_RC_ERROR_BASE_           (-2000)
00213 #define SHWILD_RC_ALLOC_ERROR           (SHWILD_RC_ERROR_BASE_ - 1)     
00214 #define SHWILD_RC_PARSE_ERROR           (SHWILD_RC_ERROR_BASE_ - 2)     
00218 /* /////////////////////////////////////////////////////////////////////////////
00219  * C API
00220  */
00221 
00222 #ifdef __cplusplus
00223 extern "C"
00224 {
00225 #endif /* __cplusplus */
00226 
00239 int shwild_match(char const *pattern, char const *string, unsigned flags);
00240 
00244 int shwild_match_s(shwild_slice_t const *pattern, shwild_slice_t const *string, unsigned flags);
00245 
00260 int shwild_compile_pattern(char const *pattern, unsigned flags, shwild_handle_t *phCompiledPattern);
00261 
00265 int shwild_compile_pattern_s(shwild_slice_t const *pattern, unsigned flags, shwild_handle_t *phCompiledPattern);
00266 
00277 int shwild_match_pattern(shwild_handle_t hCompiledPattern, char const *string);
00278 
00282 int shwild_match_pattern_s(shwild_handle_t hCompiledPattern, shwild_slice_t const *string);
00283 
00289 void shwild_destroy_pattern(shwild_handle_t hCompiledPattern);
00290 
00291 #ifdef __cplusplus
00292 } /* extern "C" */
00293 #endif /* __cplusplus */
00294 
00295 /* /////////////////////////////////////////////////////////////////////////////
00296  * Namespace
00297  */
00298 
00299 #if !defined(__cplusplus) && \
00300     !defined(SHWILD_DOCUMENTATION_SKIP_SECTION) && \
00301     !defined(SHWILD_NO_NAMESPACE)
00302 # define SHWILD_NO_NAMESPACE
00303 #endif /* __cplusplus, etc. */
00304 
00305 #if !defined(SHWILD_NO_NAMESPACE)
00306 
00308 namespace shwild
00309 {
00310 #endif /* !SHWILD_NO_NAMESPACE */
00311 
00312 /* /////////////////////////////////////////////////////////////////////////////
00313  * C++ functions
00314  */
00315 
00316 #ifdef __cplusplus
00317 
00329 typedef shwild_slice_t  slice_t;
00330 
00334 inline int match(char const *pattern, char const *string, unsigned flags = 0)
00335 {
00336     return shwild_match(pattern, string, flags);
00337 }
00341 inline int compile_pattern(char const *pattern, unsigned flags, shwild_handle_t *phCompiledPattern)
00342 {
00343     return shwild_compile_pattern(pattern, flags, phCompiledPattern);
00344 }
00348 inline int match_pattern(shwild_handle_t hCompiledPattern, char const *string)
00349 {
00350     return shwild_match_pattern(hCompiledPattern, string);
00351 }
00355 inline void destroy_pattern(shwild_handle_t hCompiledPattern)
00356 {
00357     shwild_destroy_pattern(hCompiledPattern);
00358 }
00359 
00362 #endif /* __cplusplus */
00363 
00364 /* /////////////////////////////////////////////////////////////////////////////
00365  * Namespace
00366  */
00367 
00368 #if !defined(SHWILD_NO_NAMESPACE)
00369 } /* namespace shwild */
00370 
00371 #endif /* !SHWILD_NO_NAMESPACE */
00372 
00373 /* /////////////////////////////////////////////////////////////////////////////
00374  * Implementation
00375  */
00376 
00377 #ifndef SHWILD_DOCUMENTATION_SKIP_SECTION
00378 
00379 # ifdef __cplusplus
00380 inline shwild_slice_t::shwild_slice_t()
00381     : len(0)
00382     , ptr(NULL)
00383 {}
00384 inline shwild_slice_t::shwild_slice_t(shwild_slice_t const &rhs)
00385     : len(rhs.len)
00386     , ptr(rhs.ptr)
00387 {}
00388 inline shwild_slice_t::shwild_slice_t(size_t n, char const *s)
00389     : len(n)
00390     , ptr(s)
00391 {}
00392 # endif /* __cplusplus */
00393 
00394 #endif /* !SHWILD_DOCUMENTATION_SKIP_SECTION */
00395 
00396 /* ////////////////////////////////////////////////////////////////////////// */
00397 
00398 #endif /* !SHWILD_INCL_SHWILD_H_SHWILD */
00399 
00400 /* ////////////////////////////////////////////////////////////////////////// */

shwild Library documentation © Matthew Wilson and Sean Kelly, 2004-2006 SourceForge.net Logo