nlib
CsvReader.h
[詳解]
1 
2 /*--------------------------------------------------------------------------------*
3  Project: CrossRoad
4  Copyright (C)Nintendo All rights reserved.
5 
6  These coded instructions, statements, and computer programs contain proprietary
7  information of Nintendo and/or its licensed developers and are protected by
8  national and international copyright laws. They may not be disclosed to third
9  parties or copied or duplicated in any form, in whole or in part, without the
10  prior written consent of Nintendo.
11 
12  The content herein is highly confidential and should be handled accordingly.
13  *--------------------------------------------------------------------------------*/
14 
15 #pragma once
16 #ifndef INCLUDE_NN_NLIB_MSGPACK_CSVREADER_H_
17 #define INCLUDE_NN_NLIB_MSGPACK_CSVREADER_H_
18 
20 #include "nn/nlib/Swap.h"
21 
22 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS)
23 #undef NLIB_VIS_PUBLIC
24 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT
25 #endif
26 
27 NLIB_NAMESPACE_BEGIN
28 class InputStream;
29 namespace msgpack {
30 
32  public:
33  // In Conformance with RFC4180(https://www.ietf.org/rfc/rfc4180.txt).
34  // except that
35  // pass UTF-8, the UTF-8 string is checked validity.
36  // pass CR, LF, CRLF as a new line.
37  CsvReader() NLIB_NOEXCEPT : prv_(NULL), error_(0) {}
39  NLIB_MOVE_MEMBER_HELPER_1(CsvReader, prv_);
40  errno_t Init() NLIB_NOEXCEPT;
41  errno_t Open(InputStream* stream) NLIB_NOEXCEPT;
42  bool Close() NLIB_NOEXCEPT;
43  errno_t GetErrorValue() const NLIB_NOEXCEPT { return error_; }
44  void swap(CsvReader& rhs) NLIB_NOEXCEPT {
45  using std::swap;
46  swap(prv_, rhs.prv_);
47  }
48 
49  public:
50  static bool Read(MpObject* obj, const nlib_utf8_t* csvtext) NLIB_NOEXCEPT NLIB_NONNULL;
51  bool Read(MpObject* obj) NLIB_NOEXCEPT NLIB_NONNULL;
52  InputStream* GetStream() NLIB_NOEXCEPT;
53  NLIB_SAFE_BOOL(CsvReader, error_ == 0)
54 
55  private:
56  void SetError(errno_t e) NLIB_NOEXCEPT {
57  if (error_ == 0) error_ = e;
58  }
59 
60  private:
61  struct CsvReaderPrivate;
62  CsvReaderPrivate* prv_;
63  errno_t error_;
65 };
66 
67 } // namespace msgpack
68 NLIB_NAMESPACE_END
69 NLIB_DEFINE_STD_SWAP(::nlib_ns::msgpack::CsvReader)
70 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS)
71 #undef NLIB_VIS_PUBLIC
72 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT
73 #endif
74 
75 #endif // INCLUDE_NN_NLIB_MSGPACK_CSVREADER_H_
CSVパーサーです。ストリームからCSV文字列を読み込んでパースします。
Definition: CsvReader.h:31
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
TypeName で指定されたクラスのコピーコンストラクタと代入演算子を禁止します。
Definition: Config.h:163
#define NLIB_SAFE_BOOL(class_name, exp)
クラス内に安全なoperator bool()を定義します。 可能であればC++11のexplicit boolを利用します。 ...
Definition: Config.h:178
#define NLIB_VIS_PUBLIC
関数やクラス等のシンボルをライブラリの外部に公開します。
Definition: Platform_unix.h:89
MessagePack又はJSONを読み込むことで作成されるオブジェクトです。
Definition: MpObject.h:95
MessagePack, JSON及びCSVを読み込むと作成されるオブジェクトです。
入力ストリームの基底クラスです。このクラスを実体化することはできません。
Definition: InputStream.h:29
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
Definition: Config.h:99
CsvReader() noexcept
デフォルトコンストラクタです。
Definition: CsvReader.h:37
#define NLIB_FINAL
利用可能であればfinalが定義されます。そうでない場合は空文字列です。
Definition: Config.h:229
bool Read(BinaryReader *r, T *x)
この関数テンプレートを特殊化することで、ユーザー定義クラスに読み込むことができます。 ...
Definition: BinaryReader.h:172
errno_t GetErrorValue() const noexcept
発生したエラーを取得します。
Definition: CsvReader.h:43
#define NLIB_NONNULL
全ての引数にNULLを指定することができないことを示します。
char nlib_utf8_t
charのtypedefです。文字列がUTF-8であることを示します。
Definition: Platform.h:300
int errno_t
intのtypedefで、戻り値としてPOSIXのエラー値を返すことを示します。
Definition: NMalloc.h:37