idep_namea.cxx File Reference

#include "idep_namearray.h"
#include <memory.h>
#include <string.h>
#include <iostream>
#include <cassert>

Go to the source code of this file.

Enumerations

enum  { START_SIZE = 1, GROW_FACTOR = 2 }

Functions

static char * newStrCpy (const char *oldStr)
std::ostream & operator<< (std::ostream &out, const idep_NameArray &array)

Enumeration Type Documentation

anonymous enum
Enumerator:
START_SIZE 
GROW_FACTOR 

Definition at line 11 of file idep_namea.cxx.

00011 { START_SIZE = 1, GROW_FACTOR = 2 };


Function Documentation

static char* newStrCpy ( const char *  oldStr  )  [static]

Definition at line 13 of file idep_namea.cxx.

References size.

Referenced by idep_NameArray::append().

00014 {
00015     int size = strlen(oldStr) + 1;
00016     char *newStr = new char[size];
00017     assert(newStr);
00018     memcpy(newStr, oldStr, size);
00019     return newStr;
00020 }

std::ostream& operator<< ( std::ostream &  out,
const idep_NameArray array 
)

Definition at line 65 of file idep_namea.cxx.

References idep_NameArray::length().

00066 {
00067     int fieldWidth = 10;
00068     int maxIndex = array.length() - 1;
00069     assert (sizeof (long int) >= 4);
00070     long int x = 1000 * 1000 * 1000;    // requires 4-byte integer.
00071     while (fieldWidth > 1 && 0 == maxIndex / x) {
00072         --fieldWidth;  
00073         x /= 10;
00074     }
00075 
00076     for (int i = 0; i < array.length(); ++i) {
00077         out.width(fieldWidth);
00078         out << i << ". " << array[i] << std::endl;
00079     }
00080 
00081     return out;
00082 }


Generated on 25 Apr 2018 for loon by  doxygen 1.6.1