nlib
CsvReader.h
Go to the documentation of this file.
1 
2 #pragma once
3 #ifndef INCLUDE_NN_NLIB_MSGPACK_CSVREADER_H_
4 #define INCLUDE_NN_NLIB_MSGPACK_CSVREADER_H_
5 
7 
8 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS)
9 #undef NLIB_VIS_PUBLIC
10 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT
11 #endif
12 
13 NLIB_NAMESPACE_BEGIN
14 class InputStream;
15 namespace msgpack {
16 
18  public:
19  // In Conformance with RFC4180(https://www.ietf.org/rfc/rfc4180.txt).
20  // except that
21  // pass UTF-8, the UTF-8 string is checked validity.
22  // pass CR, LF, CRLF as a new line.
23  CsvReader() NLIB_NOEXCEPT : prv_(NULL), error_(0) {}
25  errno_t Init() NLIB_NOEXCEPT;
26  errno_t Open(InputStream* stream) NLIB_NOEXCEPT;
27  bool Close() NLIB_NOEXCEPT;
28  errno_t GetErrorValue() const NLIB_NOEXCEPT { return error_; }
29 
30  public:
31  static bool Read(MpObject* obj, const char* csvtext) NLIB_NOEXCEPT NLIB_NONNULL;
32  bool Read(MpObject* obj) NLIB_NOEXCEPT NLIB_NONNULL;
33  InputStream* GetStream() NLIB_NOEXCEPT;
34  NLIB_SAFE_BOOL(CsvReader, error_ == 0)
35 
36  private:
37  void SetError(errno_t e) NLIB_NOEXCEPT {
38  if (error_ == 0) error_ = e;
39  }
40 
41  private:
42  struct CsvReaderPrivate;
43  CsvReaderPrivate* prv_;
44  errno_t error_;
46 };
47 
48 } // namespace msgpack
49 NLIB_NAMESPACE_END
50 
51 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS)
52 #undef NLIB_VIS_PUBLIC
53 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT
54 #endif
55 
56 #endif // INCLUDE_NN_NLIB_MSGPACK_CSVREADER_H_
CSV parser. Reads and parses the CSV string from the stream.
Definition: CsvReader.h:17
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
Prohibits use of the copy constructor and assignment operator for the class specified by TypeName...
Definition: Config.h:145
#define NLIB_SAFE_BOOL(class_name, exp)
Defines a safe operator bool function in the class. Uses the C++11 explicit bool if it is available f...
Definition: Config.h:160
#define NLIB_VIS_PUBLIC
Symbols for functions and classes are made available outside of the library.
Definition: Platform_unix.h:61
Object created when MessagePack or JSON is read.
Definition: MpObject.h:82
Object created when MessagePack, JSON, or CSV is read.
The base class for input streams. This class cannot be instantiated.
Definition: InputStream.h:16
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
Definition: Config.h:86
CsvReader() noexcept
Instantiates the object with default parameters (default constructor).
Definition: CsvReader.h:23
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
Definition: Config.h:211
bool Read(BinaryReader *r, T *x)
You can read to user-defined class objects by specializing this function template.
Definition: BinaryReader.h:152
errno_t GetErrorValue() const noexcept
Gets the error that occurred.
Definition: CsvReader.h:28
#define NLIB_NONNULL
Indicates that you cannot specify NULL for all arguments.
Definition: Platform_unix.h:76
int errno_t
Indicates with an int-type typedef that a POSIX error value is returned as the return value...
Definition: NMalloc.h:24