Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: NFC M2M_2016_STM32 MyongjiElec_capstone1 IDW01M1_Cloud_IBM ... more
Fork of NDefLib by
RecordAAR.h
00001 /** 00002 ****************************************************************************** 00003 * @file RecordAAR.h 00004 * @author ST / Central Labs 00005 * @version V2.0.0 00006 * @date 28 Apr 2017 00007 * @brief Create a Record that can start an application in an Android mobile. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 00038 #ifndef NDEFLIB_RECORDTYPE_RECORDAAR_H_ 00039 #define NDEFLIB_RECORDTYPE_RECORDAAR_H_ 00040 00041 #include <string> 00042 00043 #include "NDefLib/Record.h" 00044 00045 namespace NDefLib { 00046 00047 /** 00048 * Create a Record that can start an application in an Android mobile. 00049 * @par The package data are copied inside the class. 00050 */ 00051 class RecordAAR: public Record { 00052 public: 00053 00054 /** 00055 * Create an RecordAAR reading the data from the buffer. 00056 * @param header Record header. 00057 * @param buffer Buffer to read the data from. 00058 * @return an object of type recordAAR or NULL 00059 * @par User is in charge of freeing the pointer returned by this function. 00060 */ 00061 static RecordAAR* parse(const RecordHeader &header, 00062 const uint8_t * const buffer); 00063 00064 /** 00065 * Build a new record. 00066 * @param packageName Package of the application to start 00067 */ 00068 explicit RecordAAR(const std::string &packageName); 00069 00070 /** 00071 * Get the record type. 00072 * @return TYPE_AAR 00073 */ 00074 virtual RecordType_t get_type() const { 00075 return TYPE_AAR; 00076 } //getType 00077 00078 /** 00079 * Get the package inside this record 00080 * @return get the package inside this record 00081 */ 00082 const std::string& get_package() const { 00083 return mPackageName; 00084 } 00085 00086 /** 00087 * Change the package name of this record. 00088 * @param package new package 00089 */ 00090 void set_package(const std::string& package){ 00091 mPackageName=package; 00092 mRecordHeader.set_payload_length(mPackageName.size()); 00093 } 00094 00095 virtual uint16_t write(uint8_t *buffer); 00096 virtual ~RecordAAR() { }; 00097 00098 /** 00099 * compare two objects 00100 * @return true if the records have the same package name 00101 */ 00102 bool operator==(const RecordAAR &other) const{ 00103 return (mPackageName==other.mPackageName); 00104 } 00105 00106 private: 00107 /** 00108 * Application to start 00109 */ 00110 std::string mPackageName; 00111 00112 /** 00113 * String to use as record type for this record 00114 */ 00115 static const char sRecordType[]; 00116 }; 00117 00118 } /* namespace NDefLib */ 00119 00120 #endif /* NDEFLIB_RECORDTYPE_RECORDAAR_H_ */
Generated on Tue Jul 12 2022 14:14:48 by
1.7.2
