2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 /* standard library header */
24 /* SLP library header */
27 #include "ByteArray.h"
29 namespace smartcard_service_api
34 TLVHelper *currentTLV;
42 unsigned int currentT;
43 unsigned int currentL;
46 void initialize(TLVHelper *parent = NULL);
47 TLVHelper(TLVHelper *parent);
48 TLVHelper(const ByteArray &array, TLVHelper *parent);
50 virtual int decodeTag(unsigned char *buffer) = 0;
51 virtual int decodeLength(unsigned char *buffer) = 0;
52 virtual int decodeValue(unsigned char *buffer) = 0;
54 virtual TLVHelper *getChildTLV(ByteArray data) = 0;
55 TLVHelper *getParentTLV();
57 bool setTLVBuffer(const ByteArray &array, TLVHelper *parent);
58 bool setTLVBuffer(unsigned char *buffer, unsigned int length, TLVHelper *parent);
60 bool _isEndOfBuffer() { return offset >= tlvBuffer.getLength(); }
63 unsigned int _getTag() { return currentT; }
64 unsigned int _getLength() { return currentL; }
65 ByteArray _getValue() { return currentV; }
69 TLVHelper(const ByteArray &array);
72 bool setTLVBuffer(const ByteArray &array) { return setTLVBuffer(array, NULL); }
73 bool setTLVBuffer(unsigned char *buffer, unsigned int length) { return setTLVBuffer(buffer, length, NULL); }
75 bool isEndOfBuffer() { return currentTLV->_isEndOfBuffer(); }
76 bool decodeTLV() { return currentTLV->_decodeTLV(); }
78 unsigned int getTag() { return currentTLV->_getTag(); }
79 unsigned int getLength() { return currentTLV->_getLength(); }
80 ByteArray getValue() { return currentTLV->_getValue(); }
82 const char *toString();
84 bool enterToValueTLV();
85 bool returnToParentTLV();
88 } /* namespace smartcard_service_api */
89 #endif /* TLVHELPER_H_ */