update the latest source
[platform/core/connectivity/smartcard-service.git] / common / include / ISO7816BERTLV.h
1 /*
2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18 #ifndef ISO7816BERTLV_H_
19 #define ISO7816BERTLV_H_
20
21 /* standard library header */
22
23 /* SLP library header */
24
25 /* local header */
26 #include "ByteArray.h"
27 #include "TLVHelper.h"
28
29 namespace smartcard_service_api
30 {
31         class ISO7816BERTLV: public TLVHelper
32         {
33         private:
34 //              ISO7816BERTLV child;
35
36                 unsigned char firstByte;
37                 unsigned int tagClass;
38                 unsigned int encoding;
39
40                 ISO7816BERTLV(TLVHelper *parent);
41                 ISO7816BERTLV(const ByteArray &array, TLVHelper *parent);
42
43                 int decodeTag(unsigned char *buffer);
44                 int decodeLength(unsigned char *buffer);
45                 int decodeValue(unsigned char *buffer);
46
47                 TLVHelper *getChildTLV(ByteArray data);
48
49         public:
50                 ISO7816BERTLV();
51                 ISO7816BERTLV(const ByteArray &array);
52                 ~ISO7816BERTLV();
53
54                 unsigned int getClass();
55                 unsigned int getEncoding();
56
57                 static ByteArray encode(unsigned int tagClass, unsigned int encoding, unsigned int tag, ByteArray buffer);
58                 static ByteArray encode(unsigned int tagClass, unsigned int encoding, unsigned int tag, unsigned char *buffer, unsigned int length);
59         };
60
61 } /* namespace smartcard_service_api */
62 #endif /* ISO7816BERTLV_H_ */