• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

LogFieldAliasMap.cc

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 /***************************************************************************
00025  LogFieldAliasMap.cc
00026 
00027 
00028  ***************************************************************************/
00029 
00030 #include "ink_config.h"
00031 #include "LogFieldAliasMap.h"
00032 #include "ink_assert.h"
00033 
00034 void
00035 LogFieldAliasTable::init(size_t numPairs, ...)
00036 {
00037 
00038   ink_assert(numPairs > 0);
00039 
00040   if (m_table) {
00041     delete[]m_table;
00042   }
00043 
00044   size_t n;
00045   va_list ap;
00046   va_start(ap, numPairs);
00047   char *name;
00048 
00049   /* A note on the varargs -
00050      Although IntType is used internally the compiler doesn't know that
00051      at the call site of this method. Because the numeric values aren't
00052      explicitly cast, they will come through as "int" sized values.
00053   */
00054   m_min = m_max = va_arg(ap, int);
00055   va_arg(ap, char *);    // ignore next arg. for now
00056 
00057   for (n = 1; n < numPairs; n++) {
00058     IntType val = va_arg(ap, int);
00059     if (val < m_min) {
00060       m_min = val;
00061     } else if (val > m_max) {
00062       m_max = val;
00063     }
00064     va_arg(ap, char *);  // ignore next arg. for now
00065   }
00066 
00067   va_end(ap);
00068   va_start(ap, numPairs);
00069 
00070   m_entries = m_max - m_min + 1;
00071   m_table = new LogFieldAliasTableEntry[m_entries];
00072 
00073   for (n = 0; n < numPairs; n++) {
00074     IntType val = va_arg(ap, int);
00075     size_t i = val - m_min;
00076     name = va_arg(ap, char *);
00077 
00078     m_table[i].name = ats_strdup(name);
00079     m_table[i].length = strlen(name);
00080     m_table[i].valid = true;
00081   }
00082 
00083   va_end(ap);
00084 }

Generated by  doxygen 1.7.1