nlib
CsvReader.h
[詳解]
1 
2 /*---------------------------------------------------------------------------*
3 
4  Project: CrossRoad
5  Copyright (C)2012-2016 Nintendo. All rights reserved.
6 
7  These coded instructions, statements, and computer programs contain
8  proprietary information of Nintendo of America Inc. and/or Nintendo
9  Company Ltd., and are protected by Federal copyright law. They may
10  not be disclosed to third parties or copied or duplicated in any form,
11  in whole or in part, without the prior written consent of Nintendo.
12 
13  *---------------------------------------------------------------------------*/
14 
15 #pragma once
16 #ifndef INCLUDE_NN_NLIB_MSGPACK_CSVREADER_H_
17 #define INCLUDE_NN_NLIB_MSGPACK_CSVREADER_H_
18 
20 
21 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS)
22 #undef NLIB_VIS_PUBLIC
23 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT
24 #endif
25 
26 NLIB_NAMESPACE_BEGIN
27 class InputStream;
28 namespace msgpack {
29 
31  public:
32  // In Conformance with RFC4180(https://www.ietf.org/rfc/rfc4180.txt).
33  // except that
34  // pass UTF-8, the UTF-8 string is checked validity.
35  // pass CR, LF, CRLF as a new line.
36  CsvReader() NLIB_NOEXCEPT : prv_(NULL), error_(0) {}
38  errno_t Init() NLIB_NOEXCEPT;
39  errno_t Open(InputStream* stream) NLIB_NOEXCEPT;
40  bool Close() NLIB_NOEXCEPT;
41  errno_t GetErrorValue() const NLIB_NOEXCEPT { return error_; }
42 
43  public:
44  static bool Read(MpObject* obj, const char* csvtext) NLIB_NOEXCEPT NLIB_NONNULL;
45  bool Read(MpObject* obj) NLIB_NOEXCEPT NLIB_NONNULL;
46  InputStream* GetStream() NLIB_NOEXCEPT;
47  NLIB_SAFE_BOOL(CsvReader, error_ == 0)
48 
49  private:
50  void SetError(errno_t e) NLIB_NOEXCEPT {
51  if (error_ == 0) error_ = e;
52  }
53 
54  private:
55  struct CsvReaderPrivate;
56  CsvReaderPrivate* prv_;
57  errno_t error_;
59 };
60 
61 } // namespace msgpack
62 NLIB_NAMESPACE_END
63 
64 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS)
65 #undef NLIB_VIS_PUBLIC
66 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT
67 #endif
68 
69 #endif // INCLUDE_NN_NLIB_MSGPACK_CSVREADER_H_
CSVパーサーです。ストリームからCSV文字列を読み込んでパースします。
Definition: CsvReader.h:30
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
TypeName で指定されたクラスのコピーコンストラクタと代入演算子を禁止します。
Definition: Config.h:158
#define NLIB_SAFE_BOOL(class_name, exp)
クラス内に安全なoperator bool()を定義します。 可能であればC++11のexplicit boolを利用します。 ...
Definition: Config.h:173
#define NLIB_VIS_PUBLIC
関数やクラス等のシンボルをライブラリの外部に公開します。
Definition: Platform_unix.h:87
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:36
#define NLIB_FINAL
利用可能であればfinalが定義されます。そうでない場合は空文字列です。
Definition: Config.h:224
bool Read(BinaryReader *r, T *x)
この関数テンプレートを特殊化することで、ユーザー定義クラスに読み込むことができます。 ...
Definition: BinaryReader.h:165
errno_t GetErrorValue() const noexcept
発生したエラーを取得します。
Definition: CsvReader.h:41
#define NLIB_NONNULL
全ての引数にNULLを指定することができないことを示します。
int errno_t
intのtypedefで、戻り値としてPOSIXのエラー値を返すことを示します。
Definition: NMalloc.h:37