1*ac3d0c65SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ac3d0c65SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ac3d0c65SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ac3d0c65SAndrew Rist * distributed with this work for additional information 6*ac3d0c65SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ac3d0c65SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ac3d0c65SAndrew Rist * "License"); you may not use this file except in compliance 9*ac3d0c65SAndrew Rist * with the License. You may obtain a copy of the License at 10*ac3d0c65SAndrew Rist * 11*ac3d0c65SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ac3d0c65SAndrew Rist * 13*ac3d0c65SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ac3d0c65SAndrew Rist * software distributed under the License is distributed on an 15*ac3d0c65SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ac3d0c65SAndrew Rist * KIND, either express or implied. See the License for the 17*ac3d0c65SAndrew Rist * specific language governing permissions and limitations 18*ac3d0c65SAndrew Rist * under the License. 19*ac3d0c65SAndrew Rist * 20*ac3d0c65SAndrew Rist *************************************************************/ 21*ac3d0c65SAndrew Rist 22*ac3d0c65SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef COSV_STR_TYPES_HXX 25cdf0e10cSrcweir #define COSV_STR_TYPES_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir namespace csv 29cdf0e10cSrcweir { 30cdf0e10cSrcweir 31cdf0e10cSrcweir /** Provides some generally used constants. 32cdf0e10cSrcweir */ 33cdf0e10cSrcweir struct str 34cdf0e10cSrcweir { 35cdf0e10cSrcweir public: 36cdf0e10cSrcweir typedef ::size_t position; 37cdf0e10cSrcweir typedef ::size_t size; 38cdf0e10cSrcweir 39cdf0e10cSrcweir enum constants 40cdf0e10cSrcweir { 41cdf0e10cSrcweir npos = position(-1), 42cdf0e10cSrcweir maxsize = size(-1) 43cdf0e10cSrcweir }; 44cdf0e10cSrcweir 45cdf0e10cSrcweir enum insert_mode 46cdf0e10cSrcweir { 47cdf0e10cSrcweir overwrite = 0, 48cdf0e10cSrcweir insert = 1 49cdf0e10cSrcweir }; 50cdf0e10cSrcweir }; 51cdf0e10cSrcweir 52cdf0e10cSrcweir 53cdf0e10cSrcweir /** Is used for string comparisons. 54cdf0e10cSrcweir 55cdf0e10cSrcweir @collab String 56cdf0e10cSrcweir @collab various csv::compare(...) functions 57cdf0e10cSrcweir */ 58cdf0e10cSrcweir class CharOrder_Table 59cdf0e10cSrcweir { 60cdf0e10cSrcweir public: 61cdf0e10cSrcweir /** @precond 62cdf0e10cSrcweir Parameter i_pCharWeightsArray 63cdf0e10cSrcweir must have size of 256. 64cdf0e10cSrcweir */ 65cdf0e10cSrcweir CharOrder_Table( 66cdf0e10cSrcweir const int * i_pCharWeightsArray ); 67cdf0e10cSrcweir 68cdf0e10cSrcweir /** @return the weight of the char i_c. 69cdf0e10cSrcweir @precond 70cdf0e10cSrcweir Even with unusual implementations, where char has more than 8 bit, 71cdf0e10cSrcweir there must be true: 0 <= i_c < 256. 72cdf0e10cSrcweir */ 73cdf0e10cSrcweir int operator()( 74cdf0e10cSrcweir char i_c ) const; 75cdf0e10cSrcweir private: 76cdf0e10cSrcweir int cWeights[256]; 77cdf0e10cSrcweir }; 78cdf0e10cSrcweir 79cdf0e10cSrcweir 80cdf0e10cSrcweir // IMPLEMENTATION 81cdf0e10cSrcweir 82cdf0e10cSrcweir inline int operator ()(char i_c) const83cdf0e10cSrcweirCharOrder_Table::operator()( char i_c ) const 84cdf0e10cSrcweir { return cWeights[ UINT8(i_c) ]; } 85cdf0e10cSrcweir 86cdf0e10cSrcweir 87cdf0e10cSrcweir 88cdf0e10cSrcweir } // namespace csv 89cdf0e10cSrcweir 90cdf0e10cSrcweir #endif 91