Home / Open source / Terimber 2.0
00001 /* 00002 * The Software License 00003 * ================================================================================= 00004 * Copyright (c) 2003-.The Terimber Corporation. All rights reserved. 00005 * ================================================================================= 00006 * Redistributions of source code must retain the above copyright notice, 00007 * this list of conditions and the following disclaimer. 00008 * Redistributions in binary form must reproduce the above copyright notice, 00009 * this list of conditions and the following disclaimer in the documentation 00010 * and/or other materials provided with the distribution. 00011 * The end-user documentation included with the redistribution, if any, 00012 * must include the following acknowledgment: 00013 * "This product includes software developed by the Terimber Corporation." 00014 * ================================================================================= 00015 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, 00016 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00017 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00018 * IN NO EVENT SHALL THE TERIMBER CORPORATION OR ITS CONTRIBUTORS BE LIABLE FOR 00019 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00020 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00021 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00022 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00023 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00024 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 * ================================================================================ 00026 */ 00027 00028 #ifndef _terimber_storexml_hpp_ 00029 #define _terimber_storexml_hpp_ 00030 00031 #include "xml/storexml.h" 00032 00033 BEGIN_TERIMBER_NAMESPACE 00034 #pragma pack(4) 00035 00037 inline 00038 size_t 00039 byte_source::get_standalone() const 00040 { 00041 return _standalone; 00042 } 00043 00044 inline 00045 bool 00046 byte_source::get_subset() const 00047 { 00048 return _subset; 00049 } 00050 00051 inline 00052 size_t 00053 byte_source::get_version() const 00054 { 00055 return _version; 00056 } 00057 00058 inline 00059 size_t 00060 byte_source::get_xml_size() const 00061 { 00062 return _xml_size; 00063 } 00064 00065 xml_forceinline 00066 ub1_t 00067 byte_source::pick() 00068 { 00069 return _buffer_pos == _xml_size ? go_shopping() : _symbol; 00070 } 00071 00072 00073 xml_forceinline 00074 ub1_t 00075 byte_source::pop() 00076 { 00077 ++_pos_counter; 00078 ++_char_counter; 00079 ub1_t symbol = _buffer_pos >= _xml_size - 1 ? go_shopping() : (_symbol = _buffer[++_buffer_pos]); 00080 switch (symbol) 00081 { 00082 case ch_lf: 00083 ++_line_counter; 00084 case ch_cr: 00085 _char_counter = 0; 00086 break; 00087 } 00088 00089 return symbol; 00090 } 00091 00092 xml_forceinline 00093 ub1_t 00094 byte_source::pip() 00095 { 00096 ub1_t symbol = pick(); 00097 pop(); 00098 return symbol; 00099 } 00100 00101 xml_forceinline 00102 void 00103 byte_source::skip_white_space(bool mustPresent, const char* message) 00104 { 00105 ub1_t fsymbol = pick(); 00106 ub1_t symbol = fsymbol; 00107 00108 while (symbol) 00109 { 00110 switch (symbol) 00111 { 00112 case ch_lf: 00113 case ch_cr: 00114 case ch_hor_tab: 00115 case ch_space: 00116 break; 00117 default: 00118 if (mustPresent && fsymbol == symbol) 00119 throw_exception(message); 00120 return; 00121 } // switch 00122 00123 symbol = pop(); 00124 } 00125 } 00126 00127 xml_forceinline 00128 size_t 00129 byte_source::current_pos() const 00130 { 00131 return _pos_counter; 00132 } 00133 00134 xml_forceinline 00135 void 00136 byte_source::push(ub1_t x) 00137 { 00138 push(&x, 1); 00139 } 00140 00141 inline 00142 encodingSchema 00143 byte_source::get_encoding() const 00144 { 00145 return _encodingSchema; 00146 } 00147 00148 inline 00149 void 00150 byte_source::set_encoding(encodingSchema schema) 00151 { 00152 _encodingSchema = schema; 00153 } 00154 00155 inline 00156 const char* 00157 byte_source::get_location() const 00158 { 00159 return _url; 00160 } 00161 00163 inline 00164 void 00165 byte_consumer::push(ub1_t x) 00166 { 00167 push(&x, 1); 00168 } 00169 00170 inline 00171 void 00172 byte_consumer::push(const char* x) 00173 { 00174 if (x) 00175 { 00176 push((ub1_t*)x, strlen(x)); 00177 } 00178 } 00179 00180 inline 00181 size_t 00182 byte_consumer::get_xml_size() const 00183 { 00184 return _xml_size; 00185 } 00186 00187 inline 00188 size_t 00189 byte_consumer::get_buffer_pos() const 00190 { 00191 return _buffer_pos; 00192 } 00193 00194 #pragma pack() 00195 END_TERIMBER_NAMESPACE 00196 00197 #endif // _terimber_storexml_hpp_