[220] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 | //
|
---|
| 3 | // $Id: utils.h,v 1.1.1.1 1999-04-09 17:57:56 ansari Exp $
|
---|
| 4 | //
|
---|
| 5 |
|
---|
| 6 | #ifndef UTILS_EA
|
---|
| 7 | #define UTILS_EA
|
---|
| 8 |
|
---|
| 9 | #include "defs.h"
|
---|
| 10 | #include <string.h>
|
---|
| 11 | #include <string>
|
---|
| 12 | #include <stdlib.h>
|
---|
| 13 | #include <stdio.h>
|
---|
| 14 |
|
---|
| 15 | #if defined(__KCC__)
|
---|
| 16 | using std::string ;
|
---|
| 17 | #endif
|
---|
| 18 |
|
---|
| 19 | // MemCpy marche meme en cas de recouvrement.
|
---|
| 20 | // #define memcpy MemCpy
|
---|
| 21 |
|
---|
| 22 | void* MemCpy(void* dest, const void* source, size_t n);
|
---|
| 23 |
|
---|
| 24 | char const* PeidaWorkPath();
|
---|
| 25 | void buildPath(char* dst, const char* dir, const char* file);
|
---|
| 26 | void buildPath(string& dst, const string& dir, const string& file);
|
---|
| 27 | void changeSuffix(char* file, const char* suffix);
|
---|
| 28 | void changeSuffix(string& file, const string& suffix);
|
---|
| 29 | string itos(int);
|
---|
| 30 | string ftos(double);
|
---|
| 31 |
|
---|
| 32 | inline void GetIntEnv(char const* s, int& v)
|
---|
| 33 | {
|
---|
| 34 | char* pdeb = getenv(s);
|
---|
| 35 | if (pdeb) v = atoi(pdeb);
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | /* if defined(__DECCXX) || defined(__xlC) */
|
---|
| 39 | #if defined(__xlC) || defined(__DECCXX)
|
---|
| 40 | #define STRUCTCOMP(s) \
|
---|
| 41 | bool operator==(s const& b) const \
|
---|
| 42 | { return memcmp(this, &b, sizeof(s)) == 0; } \
|
---|
| 43 | bool operator<(s const& b) const \
|
---|
| 44 | { return memcmp(this, &b, sizeof(s)) < 0; }
|
---|
| 45 |
|
---|
| 46 | #define STRUCTCOMPF(s,f) \
|
---|
| 47 | bool operator==(s const& b) const \
|
---|
| 48 | { return f == b.f; } \
|
---|
| 49 | bool operator<(s const& b) const \
|
---|
| 50 | { return f < b.f; }
|
---|
| 51 | #else
|
---|
| 52 | #define STRUCTCOMP(s)
|
---|
| 53 | #define STRUCTCOMPF(s,f)
|
---|
| 54 | #endif
|
---|
| 55 |
|
---|
| 56 | #endif // UTILS_EA
|
---|