| 1 |
#ifndef CVD_INCLUDE_INTERNAL_IO_TEXT_H |
| 2 |
#define CVD_INCLUDE_INTERNAL_IO_TEXT_H |
| 3 |
|
| 4 |
#include <cvd/image.h> |
| 5 |
#include <cvd/internal/load_and_save.h> |
| 6 |
#include <iostream> |
| 7 |
#include <memory> |
| 8 |
#include <string> |
| 9 |
#include <vector> |
| 10 |
|
| 11 |
namespace CVD |
| 12 |
{ |
| 13 |
namespace TEXT |
| 14 |
{ |
| 15 |
|
| 16 |
using CVD::Internal::Head; |
| 17 |
using CVD::Internal::TypeList; |
| 18 |
|
| 19 |
class ReadPimpl; |
| 20 |
class Reader |
| 21 |
{ |
| 22 |
public: |
| 23 |
Reader(std::istream&); |
| 24 |
~Reader(); |
| 25 |
|
| 26 |
ImageRef size(); |
| 27 |
bool top_row_first(); |
| 28 |
|
| 29 |
void get_raw_pixel_line(double*); |
| 30 |
|
| 31 |
std::string datatype(); |
| 32 |
std::string name(); |
| 33 |
|
| 34 |
typedef TypeList<double, Head> Types; |
| 35 |
|
| 36 |
static bool first_byte_matches(const int c) |
| 37 |
{ |
| 38 |
return c == ' ' || c == '\t' || isdigit(c) || c == '-' || c == '+'; |
| 39 |
} |
| 40 |
|
| 41 |
private: |
| 42 |
std::unique_ptr<ReadPimpl> t; |
| 43 |
}; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
class WritePimpl; |
| 50 |
|
| 51 |
class writer |
| 52 |
{ |
| 53 |
public: |
| 54 |
writer(std::ostream&, ImageRef size, const std::string& type, const std::map<std::string, Parameter<>>& p); |
| 55 |
~writer(); |
| 56 |
|
| 57 |
void write_raw_pixel_line(const double*); |
| 58 |
void write_raw_pixel_line(const float*); |
| 59 |
|
| 60 |
template <class Incoming> |
| 61 |
struct Outgoing |
| 62 |
{ |
| 63 |
typedef double type; |
| 64 |
}; |
| 65 |
|
| 66 |
static const int top_row_first = 1; |
| 67 |
|
| 68 |
private: |
| 69 |
std::unique_ptr<WritePimpl> t; |
| 70 |
}; |
| 71 |
|
| 72 |
} |
| 73 |
} |
| 74 |
#endif |