v-16

Committer:
DuyLionTran
Date:
Tue Dec 12 15:58:23 2017 +0000
Revision:
0:89e2c8a57572
version 1.6

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DuyLionTran 0:89e2c8a57572 1 /**
DuyLionTran 0:89e2c8a57572 2 ******************************************************************************
DuyLionTran 0:89e2c8a57572 3 * @file EmptyRecord.h
DuyLionTran 0:89e2c8a57572 4 * @author ST / Central Labs
DuyLionTran 0:89e2c8a57572 5 * @version V2.0.0
DuyLionTran 0:89e2c8a57572 6 * @date 28 Apr 2017
DuyLionTran 0:89e2c8a57572 7 * @brief Implement an Empyt Record.
DuyLionTran 0:89e2c8a57572 8 ******************************************************************************
DuyLionTran 0:89e2c8a57572 9 * @attention
DuyLionTran 0:89e2c8a57572 10 *
DuyLionTran 0:89e2c8a57572 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
DuyLionTran 0:89e2c8a57572 12 *
DuyLionTran 0:89e2c8a57572 13 * Redistribution and use in source and binary forms, with or without modification,
DuyLionTran 0:89e2c8a57572 14 * are permitted provided that the following conditions are met:
DuyLionTran 0:89e2c8a57572 15 * 1. Redistributions of source code must retain the above copyright notice,
DuyLionTran 0:89e2c8a57572 16 * this list of conditions and the following disclaimer.
DuyLionTran 0:89e2c8a57572 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
DuyLionTran 0:89e2c8a57572 18 * this list of conditions and the following disclaimer in the documentation
DuyLionTran 0:89e2c8a57572 19 * and/or other materials provided with the distribution.
DuyLionTran 0:89e2c8a57572 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
DuyLionTran 0:89e2c8a57572 21 * may be used to endorse or promote products derived from this software
DuyLionTran 0:89e2c8a57572 22 * without specific prior written permission.
DuyLionTran 0:89e2c8a57572 23 *
DuyLionTran 0:89e2c8a57572 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
DuyLionTran 0:89e2c8a57572 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
DuyLionTran 0:89e2c8a57572 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DuyLionTran 0:89e2c8a57572 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
DuyLionTran 0:89e2c8a57572 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DuyLionTran 0:89e2c8a57572 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
DuyLionTran 0:89e2c8a57572 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
DuyLionTran 0:89e2c8a57572 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
DuyLionTran 0:89e2c8a57572 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
DuyLionTran 0:89e2c8a57572 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
DuyLionTran 0:89e2c8a57572 34 *
DuyLionTran 0:89e2c8a57572 35 ******************************************************************************
DuyLionTran 0:89e2c8a57572 36 */
DuyLionTran 0:89e2c8a57572 37
DuyLionTran 0:89e2c8a57572 38 #ifndef NDEFLIB_RECORDTYPE_EMPTYRECORD_H_
DuyLionTran 0:89e2c8a57572 39 #define NDEFLIB_RECORDTYPE_EMPTYRECORD_H_
DuyLionTran 0:89e2c8a57572 40
DuyLionTran 0:89e2c8a57572 41 #include "NDefLib/Record.h"
DuyLionTran 0:89e2c8a57572 42
DuyLionTran 0:89e2c8a57572 43 namespace NDefLib {
DuyLionTran 0:89e2c8a57572 44
DuyLionTran 0:89e2c8a57572 45 /**
DuyLionTran 0:89e2c8a57572 46 * Define an empty Record.
DuyLionTran 0:89e2c8a57572 47 */
DuyLionTran 0:89e2c8a57572 48 class EmptyRecord: public Record {
DuyLionTran 0:89e2c8a57572 49 public:
DuyLionTran 0:89e2c8a57572 50
DuyLionTran 0:89e2c8a57572 51 EmptyRecord() {
DuyLionTran 0:89e2c8a57572 52 mRecordHeader.set_FNT(RecordHeader::Empty);
DuyLionTran 0:89e2c8a57572 53 mRecordHeader.set_MB(true);
DuyLionTran 0:89e2c8a57572 54 mRecordHeader.set_ME(true);
DuyLionTran 0:89e2c8a57572 55 mRecordHeader.set_type_length(0);
DuyLionTran 0:89e2c8a57572 56 mRecordHeader.set_payload_length(0);
DuyLionTran 0:89e2c8a57572 57 }
DuyLionTran 0:89e2c8a57572 58
DuyLionTran 0:89e2c8a57572 59 /**
DuyLionTran 0:89e2c8a57572 60 * Write the 3 bytes used to define an empty record.
DuyLionTran 0:89e2c8a57572 61 * @param[out] buffer Buffer to write the record into.
DuyLionTran 0:89e2c8a57572 62 * @return number of write bytes
DuyLionTran 0:89e2c8a57572 63 */
DuyLionTran 0:89e2c8a57572 64 virtual uint16_t write(uint8_t *buffer) {
DuyLionTran 0:89e2c8a57572 65 return mRecordHeader.write_header(buffer);
DuyLionTran 0:89e2c8a57572 66 } //write
DuyLionTran 0:89e2c8a57572 67
DuyLionTran 0:89e2c8a57572 68 virtual ~EmptyRecord() { }
DuyLionTran 0:89e2c8a57572 69 };
DuyLionTran 0:89e2c8a57572 70
DuyLionTran 0:89e2c8a57572 71 } /* namespace NDefLib */
DuyLionTran 0:89e2c8a57572 72
DuyLionTran 0:89e2c8a57572 73 #endif /* NDEFLIB_RECORDTYPE_EMPTYRECORD_H_ */