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

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: 2nd June 2008
00008  *
00009  * Home:    http://shwild.org/
00010  *
00011  * Copyright (c) 2005-2008, 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       2
00054 # define SHWILD_VER_SHWILD_H_SHWILD_REVISION    18
00055 # define SHWILD_VER_SHWILD_H_SHWILD_EDIT        28
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 # define SHWILD_VER_0_9_3       0x00090300
00078 # define SHWILD_VER_0_9_4       0x00090400
00079 # define SHWILD_VER_0_9_5       0x00090500
00080 # define SHWILD_VER_0_9_6       0x00090600
00081 # define SHWILD_VER_0_9_7       0x00090700
00082 # define SHWILD_VER_0_9_8       0x00090800
00083 # define SHWILD_VER_0_9_9       0x00090900
00084 # define SHWILD_VER_0_9_10      0x00090a00
00085 # define SHWILD_VER_0_9_11      0x00090b00
00086 # define SHWILD_VER_0_9_12      0x00090cff
00087 # define SHWILD_VER_0_9_13      0x00090dff
00088 # define SHWILD_VER_0_9_14      0x00090eff
00089 # define SHWILD_VER_0_9_15      0x00090fff
00090 # define SHWILD_VER_0_9_16      0x000910ff
00091 # define SHWILD_VER_0_9_17      0x000911ff
00092 # define SHWILD_VER_0_9_18      0x000912ff
00093 #endif /* !SHWILD_DOCUMENTATION_SKIP_SECTION */
00094 
00095 #define SHWILD_VER_MAJOR        0
00096 #define SHWILD_VER_MINOR        9
00097 #define SHWILD_VER_REVISION     18
00098 
00099 #define SHWILD_VER              SHWILD_VER_0_9_18
00100 
00101 /* /////////////////////////////////////////////////////////////////////////////
00102  * Includes
00103  */
00104 
00105 #include <stddef.h>     /* for size_t */
00106 
00107 /* /////////////////////////////////////////////////////////////////////////////
00108  * Documentation
00109  */
00110 
00124 /* /////////////////////////////////////////////////////////////////////////////
00125  * Typedefs
00126  */
00127 
00131 struct shwild_handle_t_;
00132 
00138 typedef struct shwild_handle_t_ *shwild_handle_t;
00139 
00148 struct shwild_slice_t
00149 {
00150     size_t      len;    
00151     char const* ptr;    
00153 #ifdef __cplusplus
00154 public:
00156     shwild_slice_t();
00158     shwild_slice_t(shwild_slice_t const& rhs);
00164     shwild_slice_t(size_t n, char const* s);
00165 #endif /* __cplusplus */
00166 };
00167 #ifndef SHWILD_DOCUMENTATION_SKIP_SECTION
00168 typedef struct shwild_slice_t   shwild_slice_t;
00169 #endif /* !SHWILD_DOCUMENTATION_SKIP_SECTION */
00170 
00171 /* /////////////////////////////////////////////////////////////////////////////
00172  * Constants and definitions
00173  */
00174 
00199 #define SHWILD_F_SUPPRESS_RANGE_SUPPORT                             (0x0001)    
00200 #define SHWILD_F_SUPPRESS_BACKSLASH_ESCAPE                          (0x0002)    
00201 #define SHWILD_F_SUPPRESS_RANGE_CONTINUUM_SUPPORT                   (0x0004)    
00202 #define SHWILD_F_SUPPRESS_RANGE_CONTINUUM_HIGHLOW_SUPPORT           (0x0008)    
00203 #define SHWILD_F_SUPPRESS_RANGE_CONTINUUM_CROSSCASE_SUPPORT         (0x0010)    
00204 #define SHWILD_F_SUPPRESS_RANGE_LITERAL_WILDCARD_SUPPORT            (0x0020)    
00205 #define SHWILD_F_SUPPRESS_RANGE_LEADTRAIL_LITERAL_HYPHEN_SUPPORT    (0x0040)    
00206 #define SHWILD_F_SUPPRESS_RANGE_NOT_SUPPORT                         (0x0400)    
00207 #define SHWILD_F_IGNORE_CASE                                        (0x0200)    
00209 #if 0
00210 /* Not currently supported. */
00211 #define SHWILD_F_ALLOW_RANGE_LITERAL_BRACKET_SUPPORT                (0x0080)    
00212 #define SHWILD_F_ALLOW_RANGE_QUANTIFICATION_SUPPORT                 (0x0100)    
00213 #define SHWILD_F_FNM_PATHNAME_SEMANTICS                             (0x0800)    
00214 #endif /* 0 */
00215 
00225 #define SHWILD_RC_SUCCESS               (0)                             
00226 #define SHWILD_RC_ERROR_BASE_           (-2000)
00227 #define SHWILD_RC_ALLOC_ERROR           (SHWILD_RC_ERROR_BASE_ - 1)     
00228 #define SHWILD_RC_PARSE_ERROR           (SHWILD_RC_ERROR_BASE_ - 2)     
00229 #define SHWILD_RC_UNSPECIFIED           (SHWILD_RC_ERROR_BASE_ - 3)     
00233 /* /////////////////////////////////////////////////////////////////////////////
00234  * C API
00235  */
00236 
00237 #ifdef __cplusplus
00238 extern "C"
00239 {
00240 #endif /* __cplusplus */
00241 
00248 int shwild_init(void);
00249 
00254 void shwild_uninit(void);
00255 
00268 int shwild_match(char const* pattern, char const* string, unsigned flags);
00269 
00273 int shwild_match_s(shwild_slice_t const* pattern, shwild_slice_t const* string, unsigned flags);
00274 
00289 int shwild_compile_pattern(char const* pattern, unsigned flags, shwild_handle_t* phCompiledPattern);
00290 
00294 int shwild_compile_pattern_s(shwild_slice_t const* pattern, unsigned flags, shwild_handle_t* phCompiledPattern);
00295 
00306 int shwild_match_pattern(shwild_handle_t hCompiledPattern, char const* string);
00307 
00311 int shwild_match_pattern_s(shwild_handle_t hCompiledPattern, shwild_slice_t const* string);
00312 
00318 void shwild_destroy_pattern(shwild_handle_t hCompiledPattern);
00319 
00320 #ifdef __cplusplus
00321 } /* extern "C" */
00322 #endif /* __cplusplus */
00323 
00324 /* /////////////////////////////////////////////////////////////////////////////
00325  * Namespace
00326  */
00327 
00328 #if !defined(__cplusplus) && \
00329     !defined(SHWILD_DOCUMENTATION_SKIP_SECTION) && \
00330     !defined(SHWILD_NO_NAMESPACE)
00331 # define SHWILD_NO_NAMESPACE
00332 #endif /* __cplusplus, etc. */
00333 
00334 #if !defined(SHWILD_NO_NAMESPACE)
00335 
00337 namespace shwild
00338 {
00339 #endif /* !SHWILD_NO_NAMESPACE */
00340 
00341 /* /////////////////////////////////////////////////////////////////////////////
00342  * C++ functions
00343  */
00344 
00345 #ifdef __cplusplus
00346 
00358 typedef shwild_slice_t  slice_t;
00359 
00363 inline int match(char const* pattern, char const* string, unsigned flags = 0)
00364 {
00365     return shwild_match(pattern, string, flags);
00366 }
00370 inline int compile_pattern(char const* pattern, unsigned flags, shwild_handle_t* phCompiledPattern)
00371 {
00372     return shwild_compile_pattern(pattern, flags, phCompiledPattern);
00373 }
00377 inline int match_pattern(shwild_handle_t hCompiledPattern, char const* string)
00378 {
00379     return shwild_match_pattern(hCompiledPattern, string);
00380 }
00384 inline void destroy_pattern(shwild_handle_t hCompiledPattern)
00385 {
00386     shwild_destroy_pattern(hCompiledPattern);
00387 }
00388 
00391 #endif /* __cplusplus */
00392 
00393 /* /////////////////////////////////////////////////////////////////////////////
00394  * Namespace
00395  */
00396 
00397 #if !defined(SHWILD_NO_NAMESPACE)
00398 } /* namespace shwild */
00399 #endif /* !SHWILD_NO_NAMESPACE */
00400 
00401 /* /////////////////////////////////////////////////////////////////////////////
00402  * Implementation
00403  */
00404 
00405 #ifndef SHWILD_DOCUMENTATION_SKIP_SECTION
00406 
00407 # ifdef __cplusplus
00408 
00409 #  if defined(__BORLANDC__) && \
00410       __BORLANDC__ >= 0x0582
00411 #   pragma warn -8026
00412 #  endif /* compiler */
00413 
00414 
00415 inline shwild_slice_t::shwild_slice_t()
00416     : len(0)
00417     , ptr(NULL)
00418 {}
00419 inline shwild_slice_t::shwild_slice_t(shwild_slice_t const& rhs)
00420     : len(rhs.len)
00421     , ptr(rhs.ptr)
00422 {}
00423 inline shwild_slice_t::shwild_slice_t(size_t n, char const* s)
00424     : len(n)
00425     , ptr(s)
00426 {}
00427 
00428 #  if defined(__BORLANDC__) && \
00429       __BORLANDC__ >= 0x0582
00430 #   pragma warn .8026
00431 #  endif /* compiler */
00432 
00433 # endif /* __cplusplus */
00434 
00435 #endif /* !SHWILD_DOCUMENTATION_SKIP_SECTION */
00436 
00437 /* ////////////////////////////////////////////////////////////////////////// */
00438 
00439 #endif /* !SHWILD_INCL_SHWILD_H_SHWILD */
00440 
00441 /* ////////////////////////////////////////////////////////////////////////// */

b64 Library documentation © Synesis Software Pty Ltd, 2004-2007