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: 19th December 2011
00008  *
00009  * Home:    http://shwild.org/
00010  *
00011  * Copyright (c) 2005-2011, 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
00016  * met:
00017  *
00018  * - Redistributions of source code must retain the above copyright notice,
00019  *   this list of conditions and the following disclaimer.
00020  * - Redistributions in binary form must reproduce the above copyright
00021  *   notice, this list of conditions and the following disclaimer in the
00022  *   documentation and/or other materials provided with the distribution.
00023  * - Neither the names of Matthew Wilson and Sean Kelly nor the names of
00024  *   any contributors may be used to endorse or promote products derived
00025  *   from this software without specific prior written permission.
00026  *
00027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00028  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00029  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00030  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00031  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00032  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00033  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00034  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00035  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00036  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00037  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038  *
00039  * ////////////////////////////////////////////////////////////////////// */
00040 
00041 
00045 #ifndef SHWILD_INCL_SHWILD_H_SHWILD
00046 #define SHWILD_INCL_SHWILD_H_SHWILD
00047 
00048 /* /////////////////////////////////////////////////////////////////////////
00049  * Version information
00050  */
00051 
00052 #ifndef SHWILD_DOCUMENTATION_SKIP_SECTION
00053 # define SHWILD_VER_SHWILD_H_SHWILD_MAJOR       1
00054 # define SHWILD_VER_SHWILD_H_SHWILD_MINOR       2
00055 # define SHWILD_VER_SHWILD_H_SHWILD_REVISION    20
00056 # define SHWILD_VER_SHWILD_H_SHWILD_EDIT        30
00057 #endif /* !SHWILD_DOCUMENTATION_SKIP_SECTION */
00058 
00075 #ifndef SHWILD_DOCUMENTATION_SKIP_SECTION
00076 # define SHWILD_VER_0_9_1       0x00090100
00077 # define SHWILD_VER_0_9_2       0x00090200
00078 # define SHWILD_VER_0_9_3       0x00090300
00079 # define SHWILD_VER_0_9_4       0x00090400
00080 # define SHWILD_VER_0_9_5       0x00090500
00081 # define SHWILD_VER_0_9_6       0x00090600
00082 # define SHWILD_VER_0_9_7       0x00090700
00083 # define SHWILD_VER_0_9_8       0x00090800
00084 # define SHWILD_VER_0_9_9       0x00090900
00085 # define SHWILD_VER_0_9_10      0x00090a00
00086 # define SHWILD_VER_0_9_11      0x00090b00
00087 # define SHWILD_VER_0_9_12      0x00090cff
00088 # define SHWILD_VER_0_9_13      0x00090dff
00089 # define SHWILD_VER_0_9_14      0x00090eff
00090 # define SHWILD_VER_0_9_15      0x00090fff
00091 # define SHWILD_VER_0_9_16      0x000910ff
00092 # define SHWILD_VER_0_9_17      0x000911ff
00093 # define SHWILD_VER_0_9_18      0x000912ff
00094 # define SHWILD_VER_0_9_19      0x000913ff
00095 # define SHWILD_VER_0_9_20      0x000914ff
00096 #endif /* !SHWILD_DOCUMENTATION_SKIP_SECTION */
00097 
00098 #define SHWILD_VER_MAJOR        0
00099 #define SHWILD_VER_MINOR        9
00100 #define SHWILD_VER_REVISION     20
00101 
00102 #define SHWILD_VER              SHWILD_VER_0_9_20
00103 
00104 /* /////////////////////////////////////////////////////////////////////////
00105  * Includes
00106  */
00107 
00108 #include <stddef.h>     /* for size_t */
00109 
00110 /* /////////////////////////////////////////////////////////////////////////
00111  * Documentation
00112  */
00113 
00127 /* /////////////////////////////////////////////////////////////////////////
00128  * Typedefs
00129  */
00130 
00134 struct shwild_handle_t_;
00135 
00141 typedef struct shwild_handle_t_* shwild_handle_t;
00142 
00151 struct shwild_slice_t
00152 {
00153     size_t      len;    
00154     char const* ptr;    
00156 #ifdef __cplusplus
00157 public:
00159     shwild_slice_t();
00161     shwild_slice_t(shwild_slice_t const& rhs);
00167     shwild_slice_t(size_t n, char const* s);
00168 #endif /* __cplusplus */
00169 };
00170 #ifndef SHWILD_DOCUMENTATION_SKIP_SECTION
00171 typedef struct shwild_slice_t   shwild_slice_t;
00172 #endif /* !SHWILD_DOCUMENTATION_SKIP_SECTION */
00173 
00174 /* /////////////////////////////////////////////////////////////////////////
00175  * Constants and definitions
00176  */
00177 
00202 #define SHWILD_F_SUPPRESS_RANGE_SUPPORT                             (0x0001)    
00203 #define SHWILD_F_SUPPRESS_BACKSLASH_ESCAPE                          (0x0002)    
00204 #define SHWILD_F_SUPPRESS_RANGE_CONTINUUM_SUPPORT                   (0x0004)    
00205 #define SHWILD_F_SUPPRESS_RANGE_CONTINUUM_HIGHLOW_SUPPORT           (0x0008)    
00206 #define SHWILD_F_SUPPRESS_RANGE_CONTINUUM_CROSSCASE_SUPPORT         (0x0010)    
00207 #define SHWILD_F_SUPPRESS_RANGE_LITERAL_WILDCARD_SUPPORT            (0x0020)    
00208 #define SHWILD_F_SUPPRESS_RANGE_LEADTRAIL_LITERAL_HYPHEN_SUPPORT    (0x0040)    
00209 #define SHWILD_F_SUPPRESS_RANGE_NOT_SUPPORT                         (0x0400)    
00210 #define SHWILD_F_IGNORE_CASE                                        (0x0200)    
00212 #if 0
00213 /* Not currently supported. */
00214 #define SHWILD_F_ALLOW_RANGE_LITERAL_BRACKET_SUPPORT                (0x0080)    
00215 #define SHWILD_F_ALLOW_RANGE_QUANTIFICATION_SUPPORT                 (0x0100)    
00216 #define SHWILD_F_FNM_PATHNAME_SEMANTICS                             (0x0800)    
00217 #endif /* 0 */
00218 
00228 #define SHWILD_RC_SUCCESS               (0)                             
00229 #define SHWILD_RC_ERROR_BASE_           (-2000)
00230 #define SHWILD_RC_ALLOC_ERROR           (SHWILD_RC_ERROR_BASE_ - 1)     
00231 #define SHWILD_RC_PARSE_ERROR           (SHWILD_RC_ERROR_BASE_ - 2)     
00232 #define SHWILD_RC_UNSPECIFIED           (SHWILD_RC_ERROR_BASE_ - 3)     
00236 /* /////////////////////////////////////////////////////////////////////////
00237  * C API
00238  */
00239 
00240 #ifdef __cplusplus
00241 extern "C"
00242 {
00243 #endif /* __cplusplus */
00244 
00251 int shwild_init(void);
00252 
00257 void shwild_uninit(void);
00258 
00271 int shwild_match(char const* pattern, char const* string, unsigned flags);
00272 
00276 int shwild_match_s(shwild_slice_t const* pattern, shwild_slice_t const* string, unsigned flags);
00277 
00292 int shwild_compile_pattern(char const* pattern, unsigned flags, shwild_handle_t* phCompiledPattern);
00293 
00297 int shwild_compile_pattern_s(shwild_slice_t const* pattern, unsigned flags, shwild_handle_t* phCompiledPattern);
00298 
00309 int shwild_match_pattern(shwild_handle_t hCompiledPattern, char const* string);
00310 
00314 int shwild_match_pattern_s(shwild_handle_t hCompiledPattern, shwild_slice_t const* string);
00315 
00321 void shwild_destroy_pattern(shwild_handle_t hCompiledPattern);
00322 
00323 #ifdef __cplusplus
00324 } /* extern "C" */
00325 #endif /* __cplusplus */
00326 
00327 /* /////////////////////////////////////////////////////////////////////////
00328  * Namespace
00329  */
00330 
00331 #if !defined(__cplusplus) && \
00332     !defined(SHWILD_DOCUMENTATION_SKIP_SECTION) && \
00333     !defined(SHWILD_NO_NAMESPACE)
00334 # define SHWILD_NO_NAMESPACE
00335 #endif /* __cplusplus, etc. */
00336 
00337 #if !defined(SHWILD_NO_NAMESPACE)
00338 
00340 namespace shwild
00341 {
00342 #endif /* !SHWILD_NO_NAMESPACE */
00343 
00344 /* /////////////////////////////////////////////////////////////////////////
00345  * C++ functions
00346  */
00347 
00348 #ifdef __cplusplus
00349 
00361 typedef shwild_slice_t  slice_t;
00362 
00366 inline int match(char const* pattern, char const* string, unsigned flags = 0)
00367 {
00368     return shwild_match(pattern, string, flags);
00369 }
00373 inline int compile_pattern(char const* pattern, unsigned flags, shwild_handle_t* phCompiledPattern)
00374 {
00375     return shwild_compile_pattern(pattern, flags, phCompiledPattern);
00376 }
00380 inline int match_pattern(shwild_handle_t hCompiledPattern, char const* string)
00381 {
00382     return shwild_match_pattern(hCompiledPattern, string);
00383 }
00387 inline void destroy_pattern(shwild_handle_t hCompiledPattern)
00388 {
00389     shwild_destroy_pattern(hCompiledPattern);
00390 }
00391 
00394 #endif /* __cplusplus */
00395 
00396 /* /////////////////////////////////////////////////////////////////////////
00397  * Namespace
00398  */
00399 
00400 #if !defined(SHWILD_NO_NAMESPACE)
00401 } /* namespace shwild */
00402 #endif /* !SHWILD_NO_NAMESPACE */
00403 
00404 /* /////////////////////////////////////////////////////////////////////////
00405  * Implementation
00406  */
00407 
00408 #ifndef SHWILD_DOCUMENTATION_SKIP_SECTION
00409 
00410 # ifdef __cplusplus
00411 
00412 #  if defined(__BORLANDC__) && \
00413       __BORLANDC__ >= 0x0582
00414 #   pragma warn -8026
00415 #  endif /* compiler */
00416 
00417 
00418 inline shwild_slice_t::shwild_slice_t()
00419     : len(0)
00420     , ptr(NULL)
00421 {}
00422 inline shwild_slice_t::shwild_slice_t(shwild_slice_t const& rhs)
00423     : len(rhs.len)
00424     , ptr(rhs.ptr)
00425 {}
00426 inline shwild_slice_t::shwild_slice_t(size_t n, char const* s)
00427     : len(n)
00428     , ptr(s)
00429 {}
00430 
00431 #  if defined(__BORLANDC__) && \
00432       __BORLANDC__ >= 0x0582
00433 #   pragma warn .8026
00434 #  endif /* compiler */
00435 
00436 # endif /* __cplusplus */
00437 
00438 #endif /* !SHWILD_DOCUMENTATION_SKIP_SECTION */
00439 
00440 /* ////////////////////////////////////////////////////////////////////// */
00441 
00442 #endif /* !SHWILD_INCL_SHWILD_H_SHWILD */
00443 
00444 /* ///////////////////////////// end of file //////////////////////////// */

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