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