![]() |
![]() |
|
00001 /* ///////////////////////////////////////////////////////////////////////////// 00002 * File: src/pattern.hpp 00003 * 00004 * Purpose: C string object for shwild implementation 00005 * 00006 * Created: 17th June 2005 00007 * Updated: 2nd May 2008 00008 * 00009 * Home: http://shwild.org/ 00010 * 00011 * Copyright (c) 2005-2008, Sean Kelly and Matthew Wilson 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 00041 #ifndef SHWILD_INCL_HPP_PATTERN 00042 #define SHWILD_INCL_HPP_PATTERN 00043 00044 /* ///////////////////////////////////////////////////////////////////////////// 00045 * Version information 00046 */ 00047 00048 #ifndef SHWILD_DOCUMENTATION_SKIP_SECTION 00049 # define SHWILD_VER_PATTERN_MAJOR 1 00050 # define SHWILD_VER_PATTERN_MINOR 1 00051 # define SHWILD_VER_PATTERN_REVISION 5 00052 # define SHWILD_VER_PATTERN_EDIT 12 00053 #endif /* !SHWILD_DOCUMENTATION_SKIP_SECTION */ 00054 00055 /* ///////////////////////////////////////////////////////////////////////////// 00056 * Includes 00057 */ 00058 00059 /* shwild Header Files */ 00060 #include <shwild/shwild.h> 00061 00062 /* STLSoft Header Files */ 00063 #include <stlsoft/stlsoft.h> 00064 00065 #if defined(STLSOFT_COMPILER_IS_MSVC) && \ 00066 _MSC_VER >= 1400 00067 /* For some weird reason, when used with VC++ 8, pattern.cpp ends up with a 00068 * definition of std::allocator<>::allocate() and 00069 * std::allocator<>::deallocate(), which breaks the linker with LNK2005 00070 * (multiple definitions). 00071 * 00072 * So we disable the use of std::allocator, and tell it to use 00073 * stlsoft::malloc_allocator instead. 00074 */ 00075 # define STLSOFT_ALLOCATOR_SELECTOR_USE_STLSOFT_MALLOC_ALLOCATOR 00076 # define STLSOFT_ALLOCATOR_SELECTOR_NO_USE_STD_ALLOCATOR 00077 #endif /* compiler */ 00078 00079 #include <stlsoft/memory/auto_buffer.hpp> 00080 00081 /* Standard C Header Files */ 00082 #include <limits.h> 00083 00084 /* ///////////////////////////////////////////////////////////////////////////// 00085 * Typedefs 00086 */ 00087 00089 enum token_type 00090 { 00091 TOK_INVALID = CHAR_MIN - 1 00092 , TOK_END = 0 00093 , TOK_WILD_1 = CHAR_MAX + 1 00094 , TOK_WILD_N = CHAR_MAX + 2 00095 , TOK_RANGE_BEG = CHAR_MAX + 3 00096 , TOK_RANGE_END = CHAR_MAX + 4 00097 , TOK_ENOMEM = CHAR_MAX + 5 00098 }; 00099 00101 enum node_type 00102 { 00103 NODE_NOTHING 00104 , NODE_WILD_1 00105 , NODE_WILD_N 00106 , NODE_RANGE 00107 , NODE_NOT_RANGE 00108 , NODE_LITERAL 00109 , NODE_END 00110 }; 00111 00113 struct node_t 00114 { 00115 node_type type; 00116 shwild_slice_t data; 00117 }; 00118 00120 typedef stlsoft::auto_buffer< char 00121 , 1024 00122 // , ss_typename_type_def_k allocator_selector<T>::allocator_type 00123 > node_buffer_t; 00124 00125 /* ///////////////////////////////////////////////////////////////////////////// 00126 * API 00127 */ 00128 00130 void node_init( node_t* node ); 00131 00133 void node_reset( node_t* node ); 00134 00136 int get_node( node_t* node, node_buffer_t &buffer, char const* buf, size_t* len, unsigned flags ); 00137 00138 /* ////////////////////////////////////////////////////////////////////////// */ 00139 00140 #endif /* !SHWILD_INCL_HPP_PATTERN */ 00141 00142 /* ////////////////////////////////////////////////////////////////////////// */
|
b64 Library documentation © Synesis Software Pty Ltd, 2004-2007 |