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

static std::ostream & warn (std::ostream &ing)
static std::ostream & err (std::ostream &orr)
static const char * stripDir (const char *s)
static int isAsciiFile (const char *fileName)
static void loadFromStream (std::istream &in, idep_AliasDep *dep, Func add)
static int loadFromFile (const char *file, idep_AliasDep *dep, Func add)
static char * newStrCpy (const char *name)
static char * removeSuffix (char *dirPath)
static void zero (idep_AliasDepIntArray *a)
static 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

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

Definition at line 24 of file idep_adep.cxx.

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

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

static int isAsciiFile ( const char *  fileName  )  [static]

Definition at line 50 of file idep_adep.cxx.

Referenced by loadFromFile().

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 }

static 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().

Referenced by idep_AliasDep::readFileNames(), and idep_AliasDep::readIgnoreNames().

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 }

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

Definition at line 69 of file idep_adep.cxx.

References it.

Referenced by idep_AliasDep::inputFileNames(), and loadFromFile().

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 }

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

Definition at line 97 of file idep_adep.cxx.

References size.

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

static char* removeSuffix ( char *  dirPath  )  [static]

Definition at line 105 of file idep_adep.cxx.

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

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 }

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

Definition at line 41 of file idep_adep.cxx.

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 }

static const char* th ( int  n  )  [static]
static std::ostream& warn ( std::ostream &  ing  )  [static]
static void zero ( idep_AliasDepIntArray a  )  [static]

Definition at line 129 of file idep_adep.cxx.

References idep_AliasDepIntArray::length().

Referenced by CalLinearity::CalLinearity(), idep_AliasDep::extract(), JBComparator::GetSummary(), Comparator::GetSummary(), SWIG_ConvertPtr(), and idep_AliasDep::unpaired().

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


Generated on 19 Jan 2018 for loon by  doxygen 1.6.1