liblcf
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
writer_lcf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 liblcf authors
3  * This file is released under the MIT License
4  * http://opensource.org/licenses/MIT
5  */
6 
7 #ifndef LCF_WRITER_LCF_H
8 #define LCF_WRITER_LCF_H
9 
10 #include <string>
11 #include <vector>
12 #include <iosfwd>
13 #include <cstring>
14 #include <cstdio>
15 #include <cassert>
16 #include "reader_types.h"
17 #include "reader_options.h"
18 #include "reader_util.h"
19 
23 class LcfWriter {
24 
25 public:
32  LcfWriter(const char* filename, std::string encoding = "");
33 
40  LcfWriter(const std::string& filename, std::string encoding = "");
41 
45  ~LcfWriter();
46 
50  void Close();
51 
59  void Write(const void *ptr, size_t size, size_t nmemb);
60 
66  template <class T>
67  void Write(T val);
68 
75  void Write(const std::string& str);
76 
82  void WriteInt(int val);
83 
89  template <class T>
90  void Write(const std::vector<T>& buffer);
91 
97  bool IsOk() const;
98 
106  std::string Decode(const std::string& str_to_encode);
107 
108 private:
110  std::string filename;
112  std::string encoding;
114  FILE* stream;
115 
121  static void SwapByteOrder(int16_t &us);
122 
128  static void SwapByteOrder(uint16_t &us);
129 
135  static void SwapByteOrder(uint32_t &ui);
136 
142  static void SwapByteOrder(double &d);
143 
144 };
145 
146 #endif
std::string Decode(const std::string &str_to_encode)
Definition: writer_lcf.cpp:121
void WriteInt(int val)
Definition: writer_lcf.cpp:58
std::string encoding
Definition: writer_lcf.h:112
bool IsOk() const
Definition: writer_lcf.cpp:117
void Write(const void *ptr, size_t size, size_t nmemb)
Definition: writer_lcf.cpp:33
LcfWriter(const char *filename, std::string encoding="")
Definition: writer_lcf.cpp:9
void Close()
Definition: writer_lcf.cpp:27
static void SwapByteOrder(int16_t &us)
Definition: writer_lcf.cpp:155
FILE * stream
Definition: writer_lcf.h:114
std::string filename
Definition: writer_lcf.h:110