1 /*
2   This is io.h
3 
4   Coxeter version 3.0  Copyright (C) 2002 Fokko du Cloux
5   See file main.cpp for full copyright notice
6 */
7 
8 #ifndef IO_H  /* guarantee single inclusion */
9 #define IO_H
10 
11 #include "globals.h"
12 #include "list.h"
13 #include "memory.h"
14 
15 namespace io {
16   using namespace coxeter;
17   using namespace list;
18   using namespace memory;
19 
20 /******** type definitions **************************************************/
21 
22   class String;
23 
24   /* style tags for i/o */
25 
26   struct Default{};
27   struct GAP {};
28   struct LaTeX {};
29   struct Pretty {};
30   struct Terse {};
31   struct TeX {};
32 
33 /******** constants **********************************************************/
34 
35   const Ulong LINESIZE = 79;
36   const Ulong HALFLINESIZE = 39;
37 
38 /******** function declarations **********************************************/
39 
40   int alphabeticDigits(Ulong c, Ulong b);
41   String& append(String& l, const char c);
42   String& append(String& l, const char *s);
43   String& append(String& l1, const String& l2);
44   String& append(String& l, const Ulong& n);
45   String& append(String& l, const long& m);
46   String& append(String& l, const int& n);
47   String& append(String& l, const unsigned& n);
48   String& append(String& l, const int *v, const Ulong& n);
49   int digits(Ulong c, Ulong b);
50   String& erase(String& l, const Ulong& n);
51   void foldLine(FILE* file, const String& str, const Ulong& ls,
52 		const Ulong& h, const char* hyphens);
53   char* getInput(FILE *inputfile, String& buf, Ulong len = 0);
54   String& pad(String& l, const Ulong& n);
55   void print(FILE* file, const char * str);                      /* inlined */
56   void print(FILE* file, const String& str);                     /* inlined */
57   void print(FILE* file, const int *const& v, const Ulong& n);
58   void printFile(FILE* file, const char *name);
59   void printFile(FILE* file, const char *name, const char *dir_name);
60   String& reset(String& l);
61   String& setString(String& l, const String& s, const Ulong &first,
62 		       const Ulong& r);
63   Ulong skipSpaces(const String& l, Ulong p);
64 
65 /******** type definitions **************************************************/
66 
67 class String:public List<char>
68 {
69   private:
70   public:
71 /* constructors and destructors */
String()72     String():List<char>() {};
String(const Ulong & n)73     String(const Ulong& n):List<char>(n+1) {setSizeValue(1);}
String(const int & n)74     String(const int& n):List<char>(n+1) {setSizeValue(1);}
String(const char * const str)75     String(const char* const str):List<char>(strlen(str)+1)
76       {setData(str,strlen(str)+1);}
77     ~String();
78 /* modifiers */
79     void setLength(const Ulong& n);                        /* inlined */
80 /* accessors */
81     bool isDefined() const;                                  /* inlined */
82     Ulong length() const;                                  /* inlined */
83 /* static member function */
84     static const String& undefined();
85   };
86 
87 /******** Inline definitions ***********************************************/
88 
print(FILE * file,const char * str)89 inline void print(FILE *file, const char* str) {fprintf(file,"%s",str);}
print(FILE * file,const String & str)90 inline void print(FILE *file, const String& str)
91   {fprintf(file,"%s",str.ptr());}
92 
setLength(const Ulong & n)93 inline void String::setLength(const Ulong& n) {setSize(n+1);}
isDefined()94 inline bool String::isDefined() const {return size();}
length()95 inline Ulong String::length() const {return size()-1;}
96 
97 }
98 
99 #endif
100