Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

idep_adep.cxx File Reference

#include "idep_aliasdep.h"
#include "idep_namearray.h"
#include "idep_nameindexmap.h"
#include "idep_filedepiter.h"
#include "idep_tokeniter.h"
#include "idep_aliastable.h"
#include "idep_aliasutil.h"
#include <ctype.h>
#include <cstring>
#include <fstream>
#include <memory>
#include <iostream>
#include <cassert>

Go to the source code of this file.

Classes

class  idep_AliasDepIntArray
class  idep_AliasDepString
struct  idep_AliasDep_i

Typedefs

typedef void(idep_AliasDep::* Func )(const char *)

Functions

std::ostream & warn (std::ostream &ing)
std::ostream & err (std::ostream &orr)
const char * stripDir (const char *s)
int isAsciiFile (const char *fileName)
void loadFromStream (std::istream &in, idep_AliasDep *dep, Func add)
int loadFromFile (const char *file, idep_AliasDep *dep, Func add)
char * newStrCpy (const char *name)
char * removeSuffix (char *dirPath)
void zero (idep_AliasDepIntArray *a)
const char * th (int n)


Typedef Documentation

typedef void(idep_AliasDep::* Func)(const char *)
 

Definition at line 68 of file idep_adep.cxx.


Function Documentation

std::ostream& err std::ostream &  orr  )  [static]
 

Definition at line 24 of file idep_adep.cxx.

00025 {
00026   return orr << "Error: ";
00027 }

int isAsciiFile const char *  fileName  )  [static]
 

Definition at line 50 of file idep_adep.cxx.

00051 {
00052     enum { NO = 0, YES = 1 };
00053     std::ifstream in(fileName);
00054     if (!in) {
00055         return NO;
00056     }
00057 
00058     // check for non-ascii characters
00059     char c;
00060     while (in && !in.get(c).eof()) {
00061        if (!isascii(c)) {
00062           return NO;
00063        }
00064     }
00065     return YES;
00066 }

int loadFromFile const char *  file,
idep_AliasDep dep,
Func  add
[static]
 

Definition at line 85 of file idep_adep.cxx.

References BAD, GOOD, isAsciiFile(), and loadFromStream().

00086 {
00087     enum { BAD = -1, GOOD = 0 };
00088     if (!isAsciiFile(file)) {
00089         return BAD;
00090     }
00091     std::ifstream in(file);
00092     assert(in);
00093     loadFromStream(in, dep, add); 
00094     return GOOD;
00095 }

void loadFromStream std::istream &  in,
idep_AliasDep dep,
Func  add
[static]
 

Definition at line 69 of file idep_adep.cxx.

00070 { 
00071     assert(in);
00072     for (idep_TokenIter it(in); it; ++it) {
00073         if ('#' == *it()) {                     // strip comment if any
00074              while (it && '\n' != *it()) {
00075                 ++it;
00076             }
00077             continue;                           // either !it or '\n'
00078         }
00079         if ('\n' != *it()) {
00080             (dep->*add)(it());
00081         }
00082     }
00083 }

char* newStrCpy const char *  name  )  [static]
 

Definition at line 97 of file idep_adep.cxx.

Referenced by idep_AliasDepString::idep_AliasDepString().

00098 {
00099     int size = strlen(name) + 1;
00100     char *buf = new char[size];
00101     memcpy(buf, name, size);
00102     return buf;
00103 }

char* removeSuffix char *  dirPath  )  [static]
 

Definition at line 105 of file idep_adep.cxx.

00106 {
00107     char *dot = strrchr(dirPath, '.');
00108     if (dot && !strchr(dot, '/')) {     // if '.' found in final path segment
00109         dot[0] = '\0';                  // eliminate suffix ("a/.b" -> "a/") 
00110     }
00111     return dirPath;
00112 }

const char* stripDir const char *  s  )  [static]
 

Definition at line 41 of file idep_adep.cxx.

References s().

Referenced by idep_AliasDep::extract(), and idep_AliasDep::verify().

00042 {
00043     if (s) {
00044         const char *slash = strrchr(s, '/');
00045         return slash ? slash + 1 : s; 
00046     }
00047     return s;   // input was null
00048 }

const char* th int  n  )  [static]
 

Definition at line 305 of file idep_adep.cxx.

Referenced by idep_AliasDep::verify().

00306 {
00307     return 1 == n ? "st" : 2 == n ? "nd" : 3 == n ? "rd" : "th";
00308 }

std::ostream& warn std::ostream &  ing  )  [static]
 

Definition at line 19 of file idep_adep.cxx.

00020 {
00021   return ing << "Warning: ";
00022 }

void zero idep_AliasDepIntArray a  )  [static]
 

Definition at line 129 of file idep_adep.cxx.

References idep_AliasDepIntArray::length().

Referenced by idep_AliasDep::extract(), and idep_AliasDep::unpaired().

00130 { 
00131     for (int i = 0; i < a->length(); ++i) { 
00132         (*a)[i] = 0; 
00133     }
00134 }


Generated on Mon Feb 15 11:07:59 2010 for loon by  doxygen 1.3.9.1