LCOV - code coverage report
Current view: top level - shared - stream.h (source / functions) Hit Total Coverage
Test: Libprimis Test Coverage Lines: 5 15 33.3 %
Date: 2024-11-22 05:07:59 Functions: 4 12 33.3 %

          Line data    Source code
       1             : 
       2             : #ifndef STREAM_H_
       3             : #define STREAM_H_
       4             : 
       5             : template<class T>
       6             : struct streambuf
       7             : {
       8             :     stream *s;
       9             : 
      10           0 :     streambuf(stream *s) : s(s) {}
      11             : 
      12           0 :     T get() { return s->get<T>(); }
      13           0 :     size_t get(T *vals, size_t numvals) { return s->get(vals, numvals); }
      14           0 :     void put(const T &val) { s->put(&val, 1); }
      15             :     void put(const T *vals, size_t numvals) { s->put(vals, numvals); }
      16           0 :     void push_back(const T &val) { put(val); }
      17             :     size_t length() { return s->size(); }
      18             : };
      19             : 
      20             : enum
      21             : {
      22             :     CubeType_Print   = 1 << 0,
      23             :     CubeType_Space   = 1 << 1,
      24             :     CubeType_Digit   = 1 << 2,
      25             :     CubeType_Alpha   = 1 << 3,
      26             :     CubeType_Lower   = 1 << 4,
      27             :     CubeType_Upper   = 1 << 5,
      28             :     CubeType_Unicode = 1 << 6
      29             : };
      30             : 
      31             : extern const uchar cubectype[256];
      32          30 : inline int iscubeprint(uchar c) { return cubectype[c] & CubeType_Print; }
      33          23 : inline int iscubespace(uchar c) { return cubectype[c] & CubeType_Space; }
      34             : inline int iscubealpha(uchar c) { return cubectype[c] & CubeType_Alpha; }
      35           1 : inline int iscubealnum(uchar c) { return cubectype[c]&(CubeType_Alpha | CubeType_Digit); }
      36           0 : inline int iscubepunct(uchar c) { return cubectype[c] == CubeType_Print; }
      37       13139 : inline int cube2uni(uchar c)
      38             : {
      39       13139 :     return c;
      40             : }
      41             : 
      42           0 : inline uchar cubelower(uchar c)
      43             : {
      44           0 :     return c;
      45             : }
      46           0 : inline uchar cubeupper(uchar c)
      47             : {
      48           0 :     return c;
      49             : }
      50             : extern size_t encodeutf8(uchar *dstbuf, size_t dstlen, const uchar *srcbuf, size_t srclen, size_t *carry = nullptr);
      51             : 
      52             : extern char *loadfile(const char *fn, size_t *size, bool utf8 = true);
      53             : extern int listfiles(const char *dir, const char *ext, std::vector<char *> &files);
      54             : extern int listzipfiles(const char *dir, const char *ext, std::vector<char *> &files);
      55             : extern bool findzipfile(const char *filename);
      56             : extern const char *addpackagedir(const char *dir);
      57             : extern const char *parentdir(const char *directory);
      58             : extern bool fileexists(const char *path, const char *mode);
      59             : extern bool createdir(const char *path);
      60             : extern size_t fixpackagedir(char *dir);
      61             : extern char *makerelpath(const char *dir, const char *file, const char *prefix = nullptr, const char *cmd = nullptr);
      62             : 
      63             : extern void sendstring(const char *t, std::vector<uchar> &p);
      64             : 
      65             : extern void putint(std::vector<uchar> &p, int n);
      66             : extern int getint(std::vector<uchar> &p);
      67             : extern void putfloat(std::vector<uchar> &p, float n);
      68             : extern float getfloat(std::vector<uchar> &p);
      69             : #endif

Generated by: LCOV version 1.14