/usr/include/ipebase.h is in libipe-dev 7.1.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | // -*- C++ -*-
// --------------------------------------------------------------------
// Base header file --- must be included by all Ipe components.
// --------------------------------------------------------------------
/*
This file is part of the extensible drawing editor Ipe.
Copyright (C) 1993-2013 Otfried Cheong
Ipe is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
As a special exception, you have permission to link Ipe with the
CGAL library and distribute executables, as long as you follow the
requirements of the Gnu General Public License in regard to all of
the software in the executable aside from CGAL.
Ipe is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with Ipe; if not, you can find it at
"http://www.gnu.org/copyleft/gpl.html", or write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef IPEBASE_H
#define IPEBASE_H
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
// --------------------------------------------------------------------
typedef unsigned char uchar;
#if defined(__MINGW32__) || defined(__APPLE__)
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long int ulong;
#endif
#undef assert
#define assert(e) ((e) ? (void)0 : ipeAssertionFailed(__FILE__, __LINE__, #e))
extern void ipeAssertionFailed(const char *, int, const char *);
// --------------------------------------------------------------------
extern void ipeDebug(const char *msg, ...);
template<class T>
class IpeAutoPtr {
public:
IpeAutoPtr(T *ptr) : iPtr(ptr) { /* nothing */ }
~IpeAutoPtr() { delete iPtr; }
T *operator->() { return iPtr; }
T &operator*() { return *iPtr; }
T *ptr() { return iPtr; }
T *take() { T *p = iPtr; iPtr = 0; return p; }
private:
T *iPtr;
};
namespace ipe {
//! Ipelib version.
/*! \ingroup base */
const int IPELIB_VERSION = 70104;
//! Oldest readable file format version.
/*! \ingroup base */
const int OLDEST_FILE_FORMAT = 70000;
//! Current file format version.
/*! \ingroup base */
const int FILE_FORMAT = 70005;
// --------------------------------------------------------------------
class Stream;
class String {
public:
String();
String(const char *str);
String(const String &rhs);
String(const String &rhs, int index, int len);
String &operator=(const String &rhs);
~String();
//! Return character at index i.
inline char operator[](int i) const { return iImp->iData[i]; }
//! Is the string empty?
inline bool empty() const { return (size() == 0); }
//! Is the string empty?
inline bool isEmpty() const { return (size() == 0); }
//! Return read-only pointer to the data.
const char *data() const { return iImp->iData; }
//! Return number of bytes in the string.
inline int size() const { return iImp->iSize; }
//! Operator syntax for append.
inline void operator+=(const String &rhs) { append(rhs); }
//! Operator syntax for append.
void operator+=(char ch) { append(ch); }
//! Create substring.
inline String substr(int i, int len = -1) const {
return String(*this, i, len); }
//! Create substring at the left.
inline String left(int i) const {
return String(*this, 0, i); }
String right(int i) const;
//! Operator !=.
inline bool operator!=(const String &rhs) const {
return !(*this == rhs); }
int find(char ch) const;
int rfind(char ch) const;
int find(const char *rhs) const;
void erase();
void append(const String &rhs);
void append(char ch);
bool operator==(const String &rhs) const;
bool operator<(const String &rhs) const;
String operator+(const String &rhs) const;
int unicode(int &index) const;
const char *z() const;
private:
void detach(int n);
private:
struct Imp {
int iRefCount;
int iSize;
int iCapacity;
char *iData;
};
Imp *iImp;
};
// --------------------------------------------------------------------
class Fixed {
public:
explicit Fixed(int val) : iValue(val * 1000) { /* nothing */ }
explicit Fixed() { /* nothing */ }
inline static Fixed fromInternal(int val);
static Fixed fromDouble(double val);
inline int toInt() const { return iValue / 1000; }
inline double toDouble() const { return iValue / 1000.0; }
inline int internal() const { return iValue; }
Fixed mult(int a, int b) const;
inline bool operator==(const Fixed &rhs) const;
inline bool operator!=(const Fixed &rhs) const;
inline bool operator<(const Fixed &rhs) const;
private:
int iValue;
friend Stream &operator<<(Stream &stream, const Fixed &f);
};
// --------------------------------------------------------------------
class Lex {
public:
explicit Lex(String str);
String token();
String nextToken();
int getInt();
int getHexByte();
Fixed getFixed();
unsigned long int getHexNumber();
double getDouble();
//! Extract next character (not skipping anything).
inline char getChar() {
return iString[iPos++]; }
void skipWhitespace();
//! Operator syntax for getInt().
inline Lex &operator>>(int &i) {
i = getInt(); return *this; }
//! Operator syntax for getDouble().
inline Lex &operator>>(double &d) {
d = getDouble(); return *this; }
//! Operator syntax for getFixed().
inline Lex &operator>>(Fixed &d) {
d = getFixed(); return *this; }
//! Mark the current position.
inline void mark() {
iMark = iPos; }
//! Reset reader to the marked position.
inline void fromMark() {
iPos = iMark; }
//! Return true if at end of string (not even whitespace left).
inline bool eos() const {
return (iPos == iString.size()); }
private:
String iString;
int iPos;
int iMark;
};
// --------------------------------------------------------------------
class Buffer {
public:
Buffer();
~Buffer();
Buffer(const Buffer &rhs);
Buffer &operator=(const Buffer &rhs);
explicit Buffer(int size);
explicit Buffer(const char *data, int size);
//! Character access.
inline char &operator[](int index) { return iImp->iData[index]; }
//! Character access (const version).
inline const char &operator[](int index) const
{ return iImp->iData[index]; }
//! Return size of buffer;
inline int size() const { return iImp->iSize; }
//! Return pointer to buffer data.
inline char *data() { return iImp->iData; }
//! Return pointer to buffer data (const version).
inline const char *data() const { return iImp->iData; }
private:
struct Imp {
int iRefCount;
char *iData;
int iSize;
};
Imp *iImp;
};
// --------------------------------------------------------------------
class Stream {
public:
//! Virtual destructor.
virtual ~Stream();
//! Output character.
virtual void putChar(char ch) = 0;
//! Close the stream. No more writing allowed!
virtual void close();
//! Output string.
virtual void putString(String s);
//! Output C string.
virtual void putCString(const char *s);
//! Output raw character data.
virtual void putRaw(const char *data, int size);
//! Output character.
inline Stream &operator<<(char ch) { putChar(ch); return *this; }
//! Output string.
inline Stream &operator<<(const String &s) { putString(s); return *this; }
//! Output C string.
inline Stream &operator<<(const char *s) { putCString(s); return *this; }
Stream &operator<<(int i);
Stream &operator<<(double d);
void putHexByte(char b);
void putXmlString(String s);
};
/*! \class ipe::TellStream
\ingroup base
\brief Adds position feedback to IpeStream.
*/
class TellStream : public Stream {
public:
virtual long tell() const = 0;
};
class StringStream : public TellStream {
public:
StringStream(String &string);
virtual void putChar(char ch);
virtual void putString(String s);
virtual void putCString(const char *s);
virtual void putRaw(const char *data, int size);
virtual long tell() const;
private:
String &iString;
};
class FileStream : public TellStream {
public:
FileStream(std::FILE *file);
virtual void putChar(char ch);
virtual void putString(String s);
virtual void putCString(const char *s);
virtual void putRaw(const char *data, int size);
virtual long tell() const;
private:
std::FILE *iFile;
};
// --------------------------------------------------------------------
class DataSource {
public:
virtual ~DataSource() = 0;
//! Get one more character, or EOF.
virtual int getChar() = 0;
};
class FileSource : public DataSource {
public:
FileSource(std::FILE *file);
virtual int getChar();
private:
std::FILE *iFile;
};
class BufferSource : public DataSource {
public:
BufferSource(const Buffer &buffer);
virtual int getChar();
private:
const Buffer &iBuffer;
int iPos;
};
// --------------------------------------------------------------------
class Platform {
public:
typedef void (*DebugHandler)(const char *);
#ifdef WIN32
static String ipeDir(const char *suffix);
#endif
static int libVersion();
static void initLib(int version);
static void setDebug(bool debug);
static char pathSeparator();
static String currentDirectory();
static String latexDirectory();
static String fontmapFile();
static bool fileExists(String fname);
static String readFile(String fname);
static int runPdfLatex(String dir);
};
// --------------------------------------------------------------------
inline bool Fixed::operator==(const Fixed &rhs) const
{
return iValue == rhs.iValue;
}
inline bool Fixed::operator!=(const Fixed &rhs) const
{
return iValue != rhs.iValue;
}
inline bool Fixed::operator<(const Fixed &rhs) const
{
return iValue < rhs.iValue;
}
inline Fixed Fixed::fromInternal(int val)
{
Fixed f;
f.iValue = val;
return f;
}
} // namespace
// --------------------------------------------------------------------
#endif
|