nl:: বুনা:: TLV:: TLVReader
#include <src/lib/core/WeaveTLV.h>
Weave TLV ফর্ম্যাটে এনকোড করা ডেটার জন্য একটি মেমরি দক্ষ পার্সার প্রদান করে।
সারসংক্ষেপ
TLVReader ওয়েভ TLV ডেটার জন্য শুধুমাত্র ফরওয়ার্ড, "পুল-স্টাইল" পার্সার প্রয়োগ করে। TLVReader অবজেক্ট একটি কার্সার হিসাবে কাজ করে যা TLV উপাদানগুলির একটি ক্রম পুনরাবৃত্তি করতে এবং তাদের বিষয়বস্তু ব্যাখ্যা করতে ব্যবহার করা যেতে পারে। যখন একটি উপাদানের উপর অবস্থান করা হয়, তখন অ্যাপ্লিকেশনগুলি বর্তমান উপাদানের ধরন এবং ট্যাগ অনুসন্ধান করতে এবং সংশ্লিষ্ট মান বের করতে পাঠকের Get() পদ্ধতিতে কল করতে পারে। পাঠকের নেক্সট() পদ্ধতিটি উপাদান থেকে উপাদানে অগ্রসর হতে ব্যবহৃত হয়।
একটি TLVReader অবজেক্ট সর্বদা একটি TLV উপাদানের আগে, উপর বা পরে অবস্থান করে। যখন প্রথম সূচনা করা হয়, তখন একটি TLVReader এনকোডিংয়ের প্রথম উপাদানের ঠিক আগে অবস্থান করে। পড়া শুরু করার জন্য, একটি অ্যাপ্লিকেশানকে অবশ্যই নেক্সট() পদ্ধতিতে একটি প্রাথমিক কল করতে হবে যাতে প্রথম উপাদানটিতে পাঠককে অবস্থান করতে হয়। যখন একটি ধারক উপাদান একটি কাঠামোর সম্মুখীন হয়, একটি অ্যারে বা একটি পথ, OpenContainer() বা EnterContainer() পদ্ধতিগুলি কন্টেইনারের বিষয়বস্তুর মাধ্যমে পুনরাবৃত্তি করতে ব্যবহার করা যেতে পারে।
পাঠক যখন একটি TLV এনকোডিংয়ের শেষে বা একটি কন্টেইনারের মধ্যে শেষ উপাদানটিতে পৌঁছায়, তখন এটি Next() পদ্ধতি থেকে একটি WEAVE_END_OF_TLV ত্রুটি ফিরিয়ে দিয়ে অ্যাপ্লিকেশনটিকে সংকেত দেয়। পাঠক WEAVE_END_OF_TLV ফেরত দেওয়া চালিয়ে যাবে যতক্ষণ না এটি পুনরায় চালু করা হয়, বা বর্তমান ধারকটি প্রস্থান না হয় ( CloseContainer() / ExitContainer() এর মাধ্যমে)।
একটি TLVReader অবজেক্ট সরাসরি একটি নির্দিষ্ট ইনপুট বাফার থেকে বা এক বা একাধিক প্যাকেটবাফারের চেইন থেকে ডেটা পার্স করতে পারে। অতিরিক্তভাবে, অ্যাপ্লিকেশনগুলি একটি নির্বিচারে উৎস থেকে পাঠকের কাছে ডেটা ফিড করার জন্য একটি GetNextBuffer
ফাংশন সরবরাহ করতে পারে, যেমন একটি সকেট বা সিরিয়াল পোর্ট।
উত্তরাধিকার
সরাসরি পরিচিত সাবক্লাস:nl::Weave::Profiles::DataManagement_Current::CircularEventReader
nl::Weave::TLV::CircularTLVReader
পাবলিক প্রকার | |
---|---|
GetNextBufferFunct )(TLVReader &reader, uintptr_t &bufHandle, const uint8_t *&bufStart, uint32_t &bufLen) | WEAVE_ERROR(*WEAVE_ERROR (* একটি ফাংশন যা পার্স করার জন্য অতিরিক্ত TLV ডেটা পুনরুদ্ধার করতে ব্যবহার করা যেতে পারে। |
পাবলিক বৈশিষ্ট্য | |
---|---|
AppData | void * একটি পয়েন্টার ক্ষেত্র যা অ্যাপ্লিকেশন-নির্দিষ্ট ডেটার জন্য ব্যবহার করা যেতে পারে। |
GetNextBuffer | একটি ফাংশনের একটি পয়েন্টার যা TLVReader অবজেক্টের জন্য ইনপুট ডেটা তৈরি করবে। |
ImplicitProfileId | uint32_t অন্তর্নিহিত আকারে এনকোড করা প্রোফাইল ট্যাগের জন্য ব্যবহৃত প্রোফাইল আইডি। |
সুরক্ষিত বৈশিষ্ট্য | |
---|---|
mBufEnd | const uint8_t * |
mBufHandle | uintptr_t |
mContainerType | |
mControlByte | uint16_t |
mElemLenOrVal | uint64_t |
mElemTag | uint64_t |
mLenRead | uint32_t |
mMaxLen | uint32_t |
mReadPoint | const uint8_t * |
পাবলিক ফাংশন | |
---|---|
CloseContainer ( TLVReader & containerReader) | OpenContainer() এ কল করার পর একটি TLV কন্টেইনার পড়া সম্পূর্ণ করে। |
DupBytes (uint8_t *& buf, uint32_t & dataLen) | বর্তমান বাইট বা UTF8 স্ট্রিং এর মান সম্বলিত একটি বাফার বরাদ্দ করে এবং ফেরত দেয়। |
DupString (char *& buf) | বর্তমান বাইট বা UTF8 স্ট্রিংয়ের নাল-টার্মিনেটেড মান ধারণকারী একটি বাফার বরাদ্দ করে এবং ফেরত দেয়। |
EnterContainer ( TLVType & outerContainerType) | |
ExitContainer ( TLVType outerContainerType) | |
Get (bool & v) | একটি bool টাইপ হিসাবে বর্তমান উপাদানের মান পান। |
Get (int8_t & v) | একটি 8-বিট স্বাক্ষরিত পূর্ণসংখ্যা হিসাবে বর্তমান উপাদানটির মান পান। |
Get (int16_t & v) | একটি 16-বিট স্বাক্ষরিত পূর্ণসংখ্যা হিসাবে বর্তমান উপাদানটির মান পান। |
Get (int32_t & v) | একটি 32-বিট স্বাক্ষরিত পূর্ণসংখ্যা হিসাবে বর্তমান উপাদানটির মান পান। |
Get (int64_t & v) | একটি 64-বিট স্বাক্ষরিত পূর্ণসংখ্যা হিসাবে বর্তমান উপাদানটির মান পান। |
Get (uint8_t & v) | একটি 8-বিট স্বাক্ষরবিহীন পূর্ণসংখ্যা হিসাবে বর্তমান উপাদানটির মান পান। |
Get (uint16_t & v) | একটি 16-বিট স্বাক্ষরবিহীন পূর্ণসংখ্যা হিসাবে বর্তমান উপাদানটির মান পান। |
Get (uint32_t & v) | একটি 32-বিট স্বাক্ষরবিহীন পূর্ণসংখ্যা হিসাবে বর্তমান উপাদানটির মান পান। |
Get (uint64_t & v) | একটি 64-বিট স্বাক্ষরবিহীন পূর্ণসংখ্যা হিসাবে বর্তমান উপাদানটির মান পান। |
Get (float & v) | |
Get (double & v) | একটি দ্বিগুণ-নির্ভুল ফ্লোটিং পয়েন্ট সংখ্যা হিসাবে বর্তমান উপাদানটির মান পান। |
GetBufHandle (void) const | uintptr_t |
GetBytes (uint8_t *buf, uint32_t bufSize) | বর্তমান বাইট বা UTF8 স্ট্রিং উপাদানের মান পান। |
GetContainerType (void) const | TLVReader বর্তমানে যে কন্টেইনারটি পড়ছে তার ধরন প্রদান করে। |
GetControlByte (void) const | uint16_t বর্তমান TLV উপাদানের সাথে যুক্ত কন্ট্রোল বাইট ফেরত দেয়। |
GetDataPtr (const uint8_t *& data) | একটি TLV বাইট বা UTF8 স্ট্রিং উপাদানের প্রাথমিক এনকোড করা বাইটের জন্য একটি পয়েন্টার পান। |
GetLength (void) const | uint32_t বর্তমান TLV উপাদানের সাথে যুক্ত ডেটার দৈর্ঘ্য প্রদান করে। |
GetLengthRead (void) const | uint32_t পাঠক শুরু হওয়ার পর থেকে পড়া মোট বাইট সংখ্যা প্রদান করে। |
GetReadPoint (void) const | const uint8_t * পাঠকের বর্তমান অবস্থানের সাথে সঙ্গতিপূর্ণ অন্তর্নিহিত ইনপুট বাফারে পয়েন্ট পায়। |
GetRemainingLength (void) const | uint32_t সর্বাধিক পঠিত দৈর্ঘ্য না পৌঁছানো পর্যন্ত মোট বাইটের সংখ্যা প্রদান করে। |
GetString (char *buf, uint32_t bufSize) | একটি নাল টার্মিনেটেড স্ট্রিং হিসাবে বর্তমান বাইট বা UTF8 স্ট্রিং উপাদানের মান পান। |
GetTag (void) const | uint64_t বর্তমান TLV উপাদানের সাথে যুক্ত ট্যাগ প্রদান করে। |
GetType (void) const | বর্তমান TLV উপাদানের ধরন প্রদান করে। |
Init (const TLVReader & aReader) | void |
Init (const uint8_t *data, uint32_t dataLen) | void একটি একক ইনপুট বাফার থেকে পড়ার জন্য একটি TLVReader অবজেক্ট শুরু করে। |
Init ( PacketBuffer *buf, uint32_t maxLen) | void একটি একক প্যাকেটবাফার থেকে পড়ার জন্য একটি TLVReader অবজেক্ট শুরু করে। |
Init ( PacketBuffer *buf, uint32_t maxLen, bool allowDiscontiguousBuffers) | void এক বা একাধিক প্যাকেটবাফার থেকে পড়ার জন্য একটি TLVReader অবজেক্ট শুরু করে। |
Next (void) | |
Next ( TLVType expectedType, uint64_t expectedTag) | |
OpenContainer ( TLVReader & containerReader) | |
Skip (void) | |
VerifyEndOfContainer (void) | TVLReader অবজেক্টটি একটি TLV কন্টেইনারের শেষে রয়েছে তা যাচাই করে। |
সুরক্ষিত ফাংশন | |
---|---|
ClearElementState (void) | void TLVReader এর অবস্থা সাফ করুন। |
ElementType (void) const | TLVElementType এটি একটি ব্যক্তিগত পদ্ধতি যা mControlByte থেকে TLVElementType প্রদান করে। |
EnsureData ( WEAVE_ERROR noDataErr) | |
GetElementHeadLength (uint8_t & elemHeadBytes) const | এটি একটি ব্যক্তিগত পদ্ধতি যা একটি TLV উপাদান মাথার দৈর্ঘ্য গণনা করতে ব্যবহৃত হয়। |
IsContainerOpen (void) const | bool |
ReadData (uint8_t *buf, uint32_t len) | |
ReadElement (void) | |
ReadTag (TLVTagControl tagControl, const uint8_t *& p) | uint64_t |
SetContainerOpen (bool aContainerOpen) | void |
SkipData (void) | কোনো গন্তব্য বাফার ছাড়াই এটি পড়ে বর্তমান TLV- তে থাকা যেকোনো ডেটা এড়িয়ে যান। |
SkipToEndOfContainer (void) | |
VerifyElement (void) |
সুরক্ষিত স্ট্যাটিক ফাংশন | |
---|---|
FailGetNextBuffer ( TLVReader & reader, uintptr_t & bufHandle, const uint8_t *& bufStart, uint32_t & bufLen) | |
GetNextPacketBuffer ( TLVReader & reader, uintptr_t & bufHandle, const uint8_t *& bufStart, uint32_t & bufLen) |
পাবলিক প্রকার
GetNextBufferFunct
WEAVE_ERROR(* GetNextBufferFunct)(TLVReader &reader, uintptr_t &bufHandle, const uint8_t *&bufStart, uint32_t &bufLen)
একটি ফাংশন যা পার্স করার জন্য অতিরিক্ত TLV ডেটা পুনরুদ্ধার করতে ব্যবহার করা যেতে পারে।
এই ধরনের ফাংশন একটি TLVReader ইনপুট ডেটা ফিড করতে ব্যবহৃত হয়। যখন কল করা হয়, ফাংশনটি পাঠককে পার্স করার জন্য বা পাঠককে সংকেত দেওয়ার জন্য অতিরিক্ত ডেটা তৈরি করবে বলে আশা করা হয় যে আর কোনও ডেটা উপলব্ধ নেই।
বিস্তারিত | |||||||||
---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||
রিটার্ন মান |
|
পাবলিক বৈশিষ্ট্য
অ্যাপ্লিকেশন তথ্য
void * AppData
একটি পয়েন্টার ক্ষেত্র যা অ্যাপ্লিকেশন-নির্দিষ্ট ডেটার জন্য ব্যবহার করা যেতে পারে।
GetNextBuffer
GetNextBufferFunct GetNextBuffer
একটি ফাংশনের একটি পয়েন্টার যা TLVReader অবজেক্টের জন্য ইনপুট ডেটা তৈরি করবে।
NULL (ডিফল্ট মান) তে সেট করা হলে, পাঠক ধরে নেবে যে আর কোনো ইনপুট ডেটা উপলব্ধ নেই।
GetNextBuffer যে কোনো সময়ে একটি অ্যাপ্লিকেশন দ্বারা সেট করা যেতে পারে, কিন্তু সাধারণত যখন পাঠক শুরু হয় তখন সেট করা হয়।
একটি GetNextBuffer ফাংশন বাস্তবায়নের অতিরিক্ত তথ্যের জন্য GetNextBufferFunct প্রকারের সংজ্ঞা দেখুন।
অন্তর্নিহিত প্রোফাইল আইডি
uint32_t ImplicitProfileId
অন্তর্নিহিত আকারে এনকোড করা প্রোফাইল ট্যাগের জন্য ব্যবহৃত প্রোফাইল আইডি।
পাঠক যখন একটি প্রোফাইল-নির্দিষ্ট ট্যাগের মুখোমুখি হয় যা অন্তর্নিহিত আকারে এনকোড করা হয়েছে, তখন এটি ট্যাগের জন্য অনুমান করা প্রোফাইল আইডি হিসাবে ImplicitProfileId
সম্পত্তির মান ব্যবহার করে।
ডিফল্টরূপে, ImplicitProfileId
বৈশিষ্ট্য kProfileIdNotSpecified এ সেট করা আছে। TLV ডিকোড করার সময় যাতে ImplicitProfileId
-এনকোড করা ট্যাগ থাকে, অ্যাপ্লিকেশনগুলিকে অবশ্যই ইমপ্লিসিটপ্রোফাইলআইডি সেট করতে হবে এই ধরনের ট্যাগ থাকা কোনো TLV উপাদান পড়ার আগে। উপযুক্ত প্রোফাইল আইডি সাধারণত অ্যাপ্লিকেশন বা প্রোটোকলের প্রেক্ষাপটের উপর নির্ভর করে।
ImplicitProfileId
কে kProfileIdNotSpecified এ সেট করার সময় যদি একটি অন্তর্নিহিত-এনকোডেড ট্যাগের সম্মুখীন হয়, তাহলে পাঠক একটি WEAVE_ERROR_UNKNOWN_IMPLICIT_TLV_TAG ত্রুটি ফিরিয়ে দেবে।
সুরক্ষিত বৈশিষ্ট্য
mBufEnd
const uint8_t * mBufEnd
mBufHandle
uintptr_t mBufHandle
mContainerType
TLVType mContainerType
mControlByte
uint16_t mControlByte
mElemLenOrVal
uint64_t mElemLenOrVal
mElemTag
uint64_t mElemTag
mLenRead
uint32_t mLenRead
mMaxLen
uint32_t mMaxLen
mReadPoint
const uint8_t * mReadPoint
পাবলিক ফাংশন
ক্লোজ কনটেইনার
WEAVE_ERROR CloseContainer( TLVReader & containerReader )
OpenContainer() এ কল করার পর একটি TLV কন্টেইনার পড়া সম্পূর্ণ করে।
CloseContainer() পদ্ধতি OpenContainer ( ) এ কল করার পরে একটি প্যারেন্ট TLVReader অবজেক্টের অবস্থা পুনরুদ্ধার করে। OpenContainer() এপ্লিকেশনের প্রতি কলের জন্য অবশ্যই CloseContainer( ) এ একটি অনুরূপ কল করতে হবে, উভয় পদ্ধতিতে একই কন্টেইনার রিডারের একটি রেফারেন্স পাস করতে হবে।
যখন CloseContainer() ফিরে আসে, তখন মূল পাঠকটি কন্টেইনার অনুসরণকারী প্রথম উপাদানটির ঠিক আগে অবস্থান করে। এই বিন্দু থেকে একটি অ্যাপ্লিকেশন পরবর্তী () পদ্ধতি ব্যবহার করে অবশিষ্ট উপাদানগুলির মাধ্যমে অগ্রসর হতে পারে।
অন্তর্নিহিত কন্টেইনারের সমস্ত উপাদান পড়া হয়েছে কিনা তা নির্বিশেষে, অ্যাপ্লিকেশনগুলি যে কোনও সময়ে একটি অভিভাবক পাঠকের কাছে ক্লোজ কন্টেইনার() কল করতে পারে৷ CloseContainer() কল করার পরে, অ্যাপ্লিকেশনটিকে কন্টেইনার রিডারকে 'ডি-ইনিশিয়ালাইজড' বিবেচনা করা উচিত এবং এটিকে পুনরায় আরম্ভ না করে এটি ব্যবহার করা উচিত নয়।
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
ডুপবাইটস
WEAVE_ERROR DupBytes( uint8_t *& buf, uint32_t & dataLen )
বর্তমান বাইট বা UTF8 স্ট্রিং এর মান সম্বলিত একটি বাফার বরাদ্দ করে এবং ফেরত দেয়।
এই পদ্ধতিটি একটি বাফার তৈরি করে এবং বর্তমান অবস্থানে বাইট বা UTF-8 স্ট্রিং উপাদানের সাথে সম্পর্কিত ডেটার একটি অনুলিপি প্রদান করে। বাফারের জন্য মেমরি malloc() দিয়ে প্রাপ্ত করা হয় এবং যখন আর প্রয়োজন হয় না তখন কলার দ্বারা free() দিয়ে মুক্ত করা উচিত।
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
ডুপস্ট্রিং
WEAVE_ERROR DupString( char *& buf )
বর্তমান বাইট বা UTF8 স্ট্রিংয়ের নাল-টার্মিনেটেড মান ধারণকারী একটি বাফার বরাদ্দ করে এবং ফেরত দেয়।
এই পদ্ধতিটি একটি বাফার তৈরি করে এবং বর্তমান অবস্থানে বাইট বা UTF-8 স্ট্রিং উপাদানের সাথে যুক্ত ডেটার একটি নাল-টার্মিনেটেড কপি ফেরত দেয়। বাফারের জন্য মেমরি malloc() দিয়ে প্রাপ্ত করা হয় এবং যখন আর প্রয়োজন হয় না তখন কলার দ্বারা free() দিয়ে মুক্ত করা উচিত।
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
এন্টার কন্টেইনার
WEAVE_ERROR EnterContainer( TLVType & outerContainerType )
TLV কন্টেইনার উপাদানের সদস্যদের পড়ার জন্য একটি TLVReader অবজেক্ট প্রস্তুত করে।
EnterContainer() পদ্ধতিটি বর্তমান TLVReader অবজেক্টকে একটি TLV ধারক (একটি কাঠামো, অ্যারে বা পথ) এর সদস্য উপাদানগুলি পড়া শুরু করার জন্য প্রস্তুত করে। EnterContainer() অ্যাপ্লিকেশনে প্রতিটি কলের জন্য ExitContainer() এ একটি সংশ্লিষ্ট কল করতে হবে।
যখন EnterContainer() বলা হয় তখন TLVReader অবজেক্টকে পড়তে হবে কন্টেইনার এলিমেন্টে অবস্থান করতে হবে। পদ্ধতিটি একটি যুক্তি হিসাবে একটি TLVType মানের একটি রেফারেন্স নেয় যা কন্টেইনার পড়ার সময় পাঠকের প্রসঙ্গ সংরক্ষণ করতে ব্যবহৃত হবে।
যখন EnterContainer() পদ্ধতিটি ফিরে আসে, তখন পাঠকটি কন্টেইনারের প্রথম সদস্যের ঠিক আগে অবস্থান করে। বারবার Next() কল করা পাঠককে সংগ্রহের সদস্যদের মাধ্যমে শেষ না হওয়া পর্যন্ত এগিয়ে নিয়ে যাবে, এই সময়ে পাঠক WEAVE_END_OF_TLV ফিরে আসবে।
একবার অ্যাপ্লিকেশনটি একটি কন্টেইনার পড়া শেষ করলে এটি ExitContainer() পদ্ধতিতে কল করে কন্টেইনারের পরে উপাদানগুলি পড়া চালিয়ে যেতে পারে।
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
প্রস্থান কন্টেইনার
WEAVE_ERROR ExitContainer( TLVType outerContainerType )
একটি TLV কন্টেইনারের পড়া সম্পূর্ণ করে এবং কন্টেইনারের পরে উপাদানগুলি পড়ার জন্য একটি TLVReader অবজেক্ট প্রস্তুত করে।
ExitContainer() পদ্ধতি EnterContainer ( ) এ কল করার পরে একটি TLVReader অবজেক্টের অবস্থা পুনরুদ্ধার করে। EnterContainer() অ্যাপ্লিকেশনে প্রতিটি কলের জন্য অবশ্যই ExitContainer() এ একটি সংশ্লিষ্ট কল করতে হবে, EnterContainer () পদ্ধতি দ্বারা প্রত্যাবর্তিত প্রসঙ্গ মান পাস করে।
যখন ExitContainer() ফিরে আসে, তখন পাঠকটি কন্টেইনার অনুসরণকারী প্রথম উপাদানটির ঠিক আগে অবস্থান করে। এই বিন্দু থেকে একটি অ্যাপ্লিকেশন পরবর্তী () পদ্ধতি ব্যবহার করে অবশিষ্ট উপাদানগুলির মাধ্যমে অগ্রসর হতে পারে।
একবার EnterContainer() কল করা হলে, অন্তর্নিহিত কন্টেইনারের সমস্ত উপাদান পড়া হয়েছে কিনা তা নির্বিশেষে অ্যাপ্লিকেশনগুলি যেকোনো সময়ে পাঠককে ExitContainer() কল করতে পারে।
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
পাওয়া
WEAVE_ERROR Get( bool & v )
পাওয়া
WEAVE_ERROR Get( int8_t & v )
একটি 8-বিট স্বাক্ষরিত পূর্ণসংখ্যা হিসাবে বর্তমান উপাদানটির মান পান।
এনকোড করা পূর্ণসংখ্যার মান আউটপুট ডেটা টাইপের চেয়ে বড় হলে ফলাফলের মানটি কেটে ফেলা হবে।
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
পাওয়া
WEAVE_ERROR Get( int16_t & v )
একটি 16-বিট স্বাক্ষরিত পূর্ণসংখ্যা হিসাবে বর্তমান উপাদানটির মান পান।
এনকোড করা পূর্ণসংখ্যার মান আউটপুট ডেটা টাইপের চেয়ে বড় হলে ফলাফলের মানটি কেটে ফেলা হবে।
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
পাওয়া
WEAVE_ERROR Get( int32_t & v )
একটি 32-বিট স্বাক্ষরিত পূর্ণসংখ্যা হিসাবে বর্তমান উপাদানটির মান পান।
এনকোড করা পূর্ণসংখ্যার মান আউটপুট ডেটা টাইপের চেয়ে বড় হলে ফলাফলের মানটি কেটে ফেলা হবে।
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
পাওয়া
WEAVE_ERROR Get( int64_t & v )
একটি 64-বিট স্বাক্ষরিত পূর্ণসংখ্যা হিসাবে বর্তমান উপাদানটির মান পান।
এনকোড করা পূর্ণসংখ্যার মান আউটপুট ডেটা টাইপের চেয়ে বড় হলে ফলাফলের মানটি কেটে ফেলা হবে।
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
পাওয়া
WEAVE_ERROR Get( uint8_t & v )
একটি 8-বিট স্বাক্ষরবিহীন পূর্ণসংখ্যা হিসাবে বর্তমান উপাদানটির মান পান।
এনকোড করা পূর্ণসংখ্যার মান আউটপুট ডেটা টাইপের চেয়ে বড় হলে ফলাফলের মানটি কেটে ফেলা হবে। একইভাবে, যদি এনকোড করা পূর্ণসংখ্যার মান ঋণাত্মক হয়, তাহলে মানটি স্বাক্ষরবিহীন তে রূপান্তরিত হবে।
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
পাওয়া
WEAVE_ERROR Get( uint16_t & v )
একটি 16-বিট স্বাক্ষরবিহীন পূর্ণসংখ্যা হিসাবে বর্তমান উপাদানটির মান পান।
এনকোড করা পূর্ণসংখ্যার মান আউটপুট ডেটা টাইপের চেয়ে বড় হলে ফলাফলের মানটি কেটে ফেলা হবে। একইভাবে, যদি এনকোড করা পূর্ণসংখ্যার মান ঋণাত্মক হয়, তাহলে মানটি স্বাক্ষরবিহীন তে রূপান্তরিত হবে।
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
পাওয়া
WEAVE_ERROR Get( uint32_t & v )
একটি 32-বিট স্বাক্ষরবিহীন পূর্ণসংখ্যা হিসাবে বর্তমান উপাদানটির মান পান।
এনকোড করা পূর্ণসংখ্যার মান আউটপুট ডেটা টাইপের চেয়ে বড় হলে ফলাফলের মানটি কেটে ফেলা হবে। একইভাবে, যদি এনকোড করা পূর্ণসংখ্যার মান ঋণাত্মক হয়, তাহলে মানটি স্বাক্ষরবিহীন তে রূপান্তরিত হবে।
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
পাওয়া
WEAVE_ERROR Get( uint64_t & v )
একটি 64-বিট স্বাক্ষরবিহীন পূর্ণসংখ্যা হিসাবে বর্তমান উপাদানটির মান পান।
যদি এনকোড করা পূর্ণসংখ্যার মান ঋণাত্মক হয়, তাহলে মানটিকে স্বাক্ষরবিহীন তে রূপান্তর করা হবে।
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
পাওয়া
WEAVE_ERROR Get( float & v )
পাওয়া
WEAVE_ERROR Get( double & v )
একটি দ্বিগুণ-নির্ভুল ফ্লোটিং পয়েন্ট সংখ্যা হিসাবে বর্তমান উপাদানটির মান পান।
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
GetBufHandle
uintptr_t GetBufHandle( void ) const
GetBytes
WEAVE_ERROR GetBytes( uint8_t *buf, uint32_t bufSize )
বর্তমান বাইট বা UTF8 স্ট্রিং উপাদানের মান পান।
প্রয়োজনীয় ইনপুট বাফার আকার নির্ধারণ করতে, GetBytes() কল করার আগে GetLength () পদ্ধতিতে কল করুন।
বিস্তারিত | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||
রিটার্ন মান |
|
GetContainerType
TLVType GetContainerType( void ) const
TLVReader বর্তমানে যে কন্টেইনারটি পড়ছে তার ধরন প্রদান করে।
GetContainerType() পদ্ধতি TLV কন্টেইনারের ধরন প্রদান করে যার মধ্যে TLVReader পড়ছে। যদি TLVReader একটি TLV এনকোডিংয়ের বাইরের-সবচেয়ে স্তরে অবস্থান করে (যেমন বাইরের-সবচেয়ে TLV উপাদানের আগে, উপর বা পরে), পদ্ধতিটি kTLVType_NotSpecified ফেরত দেবে।
বিস্তারিত | |
---|---|
রিটার্নস | বর্তমান ধারকটির TLVType, অথবা kTLVType_NotSpecified যদি TLVReader একটি কন্টেইনারের মধ্যে অবস্থান না করে থাকে। |
GetControlByte
uint16_t GetControlByte( void ) const
বর্তমান TLV উপাদানের সাথে যুক্ত কন্ট্রোল বাইট ফেরত দেয়।
আদর্শভাবে, কন্ট্রোল বাইট সম্পর্কে কারোরই জানার প্রয়োজন নেই এবং শুধুমাত্র TLV- এর অভ্যন্তরীণ বাস্তবায়নেরই এতে অ্যাক্সেস থাকা উচিত। কিন্তু, তবুও, কন্ট্রোল বাইটে অ্যাক্সেস থাকা TLV ডিবাগ ইউটিলিটিগুলির ডিবাগিং উদ্দেশ্যে সহায়ক (যেটি TLV বাফার বিষয়বস্তু প্রিন্ট করার সময় ট্যাগ কন্ট্রোল বাইট ডিকোড করার চেষ্টা করে)।
বিস্তারিত | |
---|---|
রিটার্নস | বর্তমান TLV উপাদানের সাথে যুক্ত কন্ট্রোল বাইট ধারণকারী একটি স্বাক্ষরবিহীন পূর্ণসংখ্যা। kTLVControlByte_NotSpecified ফেরত দেওয়া হয় যদি পাঠক একটি উপাদানে অবস্থান না করে । |
GetDataPtr
WEAVE_ERROR GetDataPtr( const uint8_t *& data )
একটি TLV বাইট বা UTF8 স্ট্রিং উপাদানের প্রাথমিক এনকোড করা বাইটের জন্য একটি পয়েন্টার পান।
এই পদ্ধতি অন্তর্নিহিত ইনপুট বাফারের মধ্যে এনকোড করা স্ট্রিং মান একটি সরাসরি পয়েন্টার প্রদান করে। সফল হওয়ার জন্য, পদ্ধতির প্রয়োজন যে স্ট্রিং মান সম্পূর্ণরূপে একটি একক বাফারে উপস্থিত থাকবে। অন্যথায় পদ্ধতিটি WEAVE_ERROR_TLV_UNDERRUN প্রদান করে। এটি একাধিক বিচ্ছিন্ন বাফার থেকে ডেটা পড়ার সময় সীমিত ব্যবহারের পদ্ধতি তৈরি করে।
বিস্তারিত | |||||||||
---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||
রিটার্ন মান |
|
দৈর্ঘ্য পান
uint32_t GetLength( void ) const
বর্তমান TLV উপাদানের সাথে যুক্ত ডেটার দৈর্ঘ্য প্রদান করে।
ডেটা দৈর্ঘ্য শুধুমাত্র UTF8 স্ট্রিং বা বাইট স্ট্রিং টাইপের উপাদানগুলিতে প্রযোজ্য। UTF8 স্ট্রিং-এর জন্য, ফেরত দেওয়া মান হল স্ট্রিং-এ বাইটের সংখ্যা, অক্ষরের সংখ্যা নয়।
বিস্তারিত | |
---|---|
রিটার্নস | বর্তমান TLV উপাদানের সাথে যুক্ত ডেটার দৈর্ঘ্য (বাইটে), অথবা বর্তমান উপাদানটি যদি UTF8 স্ট্রিং বা বাইট স্ট্রিং না হয়, অথবা যদি পাঠক একটি উপাদানের উপর অবস্থান না করে থাকে। |
GetLengthRead
uint32_t GetLengthRead( void ) const
পাঠক শুরু হওয়ার পর থেকে পড়া মোট বাইট সংখ্যা প্রদান করে।
বিস্তারিত | |
---|---|
রিটার্নস | পাঠক শুরু হওয়ার পর থেকে মোট পঠিত বাইট সংখ্যা। |
GetReadPoint
const uint8_t * GetReadPoint( void ) const
পাঠকের বর্তমান অবস্থানের সাথে সঙ্গতিপূর্ণ অন্তর্নিহিত ইনপুট বাফারে পয়েন্ট পায়।
বিস্তারিত | |
---|---|
রিটার্নস | অন্তর্নিহিত ইনপুট বাফারে একটি পয়েন্টার যা পাঠকের বর্তমান অবস্থানের সাথে মিলে যায়। |
অবশিষ্ট দৈর্ঘ্য পান
uint32_t GetRemainingLength( void ) const
সর্বাধিক পঠিত দৈর্ঘ্য না পৌঁছানো পর্যন্ত মোট বাইটের সংখ্যা প্রদান করে।
বিস্তারিত | |
---|---|
রিটার্নস | সর্বাধিক পঠিত দৈর্ঘ্য না পৌঁছানো পর্যন্ত মোট বাইটের সংখ্যা। |
GetString
WEAVE_ERROR GetString( char *buf, uint32_t bufSize )
একটি নাল টার্মিনেটেড স্ট্রিং হিসাবে বর্তমান বাইট বা UTF8 স্ট্রিং উপাদানের মান পান।
প্রয়োজনীয় ইনপুট বাফার আকার নির্ধারণ করতে, GetBytes() কল করার আগে GetLength () পদ্ধতিতে কল করুন। ইনপুট বাফার নাল অক্ষর মিটমাট করার জন্য স্ট্রিং দৈর্ঘ্যের থেকে কমপক্ষে এক বাইট বড় হওয়া উচিত।
বিস্তারিত | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||
রিটার্ন মান |
|
GetTag
uint64_t GetTag( void ) const
বর্তমান TLV উপাদানের সাথে যুক্ত ট্যাগ প্রদান করে।
GetTag() দ্বারা প্রত্যাবর্তিত মান ট্যাগের ধরন নির্ধারণ করতে এবং বিভিন্ন ট্যাগ ক্ষেত্রের মান বের করতে ট্যাগ ইউটিলিটি ফাংশন ( IsProfileTag() , IsContextTag( ) , ProfileIdFromTag( ) ইত্যাদির সাথে ব্যবহার করা যেতে পারে।
বিস্তারিত | |
---|---|
রিটার্নস | বর্তমান TLV উপাদানের সাথে যুক্ত ট্যাগ সম্পর্কে তথ্য ধারণকারী একটি স্বাক্ষরবিহীন পূর্ণসংখ্যা। |
GetType
TLVType GetType( void ) const
এটা
void Init( const TLVReader & aReader )
অন্য TLVReader অবজেক্ট থেকে একটি TLVReader অবজেক্ট শুরু করে।
বিস্তারিত | |||
---|---|---|---|
পরামিতি |
|
এটা
void Init( const uint8_t *data, uint32_t dataLen )
এটা
void Init( PacketBuffer *buf, uint32_t maxLen )
একটি একক প্যাকেটবাফার থেকে পড়ার জন্য একটি TLVReader অবজেক্ট শুরু করে।
পার্সিং বাফারের স্টার্ট পজিশনে শুরু হয় (buf->DataStart()) এবং বাফারের ডেটা শেষ না হওয়া পর্যন্ত চলতে থাকে (যেমন buf->Datalen() দ্বারা চিহ্নিত করা হয়েছে), অথবা maxLen বাইট পার্স করা হয়েছে।
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
|
এটা
void Init( PacketBuffer *buf, uint32_t maxLen, bool allowDiscontiguousBuffers )
এক বা একাধিক প্যাকেটবাফার থেকে পড়ার জন্য একটি TLVReader অবজেক্ট শুরু করে।
পার্সিং প্রাথমিক বাফারের স্টার্ট পজিশনে শুরু হয় ( buf->DataStart())। যদি allowDiscontiguousBuffers সত্য হয়, পাঠক তাদের নেক্সট() পয়েন্টার দ্বারা সংযুক্ত বাফারের শৃঙ্খলের মাধ্যমে অগ্রসর হবে। পার্সিং চলতে থাকে যতক্ষণ না বাফার চেইনের সমস্ত ডেটা গ্রাস করা না হয় (যেমন buf->Datalen() দ্বারা বোঝানো হয়), বা maxLen বাইট পার্স করা না হয়।
বিস্তারিত | |||||||
---|---|---|---|---|---|---|---|
পরামিতি |
|
পরবর্তী
WEAVE_ERROR Next( void )
TLVReader অবজেক্টকে পরবর্তী TLV এলিমেন্টে অগ্রসর করে যা পড়তে হবে।
নেক্সট() পদ্ধতি টিএলভি এনকোডিং-এর পরবর্তী উপাদানে পাঠক অবজেক্টকে অবস্থান করে যা একই কন্টেনমেন্ট প্রসঙ্গে থাকে। বিশেষ করে, যদি পাঠক একটি TLV এনকোডিং-এর বাইরের-সবচেয়ে স্তরে অবস্থান করে, তাহলে Next() কল করা পাঠককে পরবর্তী, শীর্ষ-সর্বাধিক উপাদানে নিয়ে যাবে। যদি পাঠককে একটি TLV কন্টেইনার উপাদানের (একটি কাঠামো, অ্যারে বা পথ) মধ্যে অবস্থান করা হয়, তাহলে Next() কল করা পাঠককে কন্টেইনারের পরবর্তী সদস্য উপাদানে নিয়ে যাবে।
যেহেতু নেক্সট() রিডারের গতিকে বর্তমান কন্টেইনমেন্ট প্রেক্ষাপটে সীমাবদ্ধ করে, তাই যখন রিডার একটি কন্টেইনার এলিমেন্টে অবস্থান করে তখন নেক্সট() কল করলে কন্টেইনারের উপরে অগ্রসর হবে, এর সদস্য উপাদানগুলি (এবং নেস্টেড কন্টেইনারের সদস্যদের) এড়িয়ে যাবে যতক্ষণ না এটি প্রথমটিতে পৌঁছায়। ধারক পরে উপাদান.
যখন একটি নির্দিষ্ট কন্টেনমেন্ট প্রেক্ষাপটে আর কোনো উপাদান থাকে না তখন Next() পদ্ধতিটি একটি WEAVE_END_OF_TLV ত্রুটি ফিরিয়ে দেবে এবং পাঠকের অবস্থান অপরিবর্তিত থাকবে।
বিস্তারিত | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
রিটার্ন মান |
|
পরবর্তী
WEAVE_ERROR Next( TLVType expectedType, uint64_t expectedTag )
TLVReader অবজেক্টকে পরবর্তী TLV এলিমেন্টের দিকে অগ্রসর করে, নতুন এলিমেন্টের ধরন এবং ট্যাগ নিশ্চিত করে।
Next(TLVType expectType, uint64_t expectTag) পদ্ধতি হল একটি সুবিধার পদ্ধতি যা Next() এর মত একই আচরণ করে, কিন্তু নতুন TLV উপাদানের প্রকার এবং ট্যাগ সরবরাহকৃত আর্গুমেন্টের সাথে মেলে কিনা তাও যাচাই করে।
বিস্তারিত | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||||||
রিটার্ন মান |
|
ওপেন কন্টেইনার
WEAVE_ERROR OpenContainer( TLVReader & containerReader )
একটি TLV কন্টেইনার উপাদানের সদস্যদের পড়ার জন্য একটি নতুন TLVReader অবজেক্ট শুরু করে।
OpenContainer() পদ্ধতিটি একটি TLV ধারক (একটি কাঠামো, অ্যারে বা পথ) এর সদস্য উপাদানগুলি পড়ার জন্য একটি নতুন TLVReader অবজেক্ট শুরু করে। যখন OpenContainer() কল করা হয়, তখন বর্তমান TLVReader অবজেক্টটি পড়ার জন্য কন্টেইনার এলিমেন্টে অবস্থান করতে হবে। পদ্ধতিটি তার একমাত্র যুক্তি হিসাবে একটি নতুন পাঠকের একটি রেফারেন্স হিসাবে নেয় যা ধারকটি পড়ার জন্য আরম্ভ করা হবে। এই রিডারটিকে কন্টেইনার রিডার বলা হয় যখন যে রিডারে OpenContainer() বলা হয় তাকে প্যারেন্ট রিডার বলা হয়।
যখন OpenContainer() পদ্ধতিটি ফিরে আসে, তখন কন্টেইনার রিডারটি কন্টেইনারের প্রথম সদস্যের ঠিক আগে অবস্থান করে। কন্টেইনার রিডারে নেক্সট() কল করা সংগ্রহের সদস্যদের মাধ্যমে শেষ না হওয়া পর্যন্ত অগ্রসর হবে, এই সময়ে পাঠক WEAVE_END_OF_TLV ফিরে আসবে।
কন্টেইনার রিডার খোলা থাকাকালীন, অ্যাপ্লিকেশনগুলিকে কল করা বা অন্যথায় অভিভাবক পাঠকের অবস্থা পরিবর্তন করা উচিত নয়৷ একবার একটি অ্যাপ্লিকেশন কন্টেইনার রিডার ব্যবহার করা শেষ হয়ে গেলে, এটি অবশ্যই প্যারেন্ট রিডারে CloseContainer() কল করে, কন্টেইনার রিডারটিকে একটি যুক্তি হিসাবে পাস করে এটি বন্ধ করতে হবে। অ্যাপ্লিকেশনগুলি অন্তর্নিহিত কন্টেইনারে থাকা সমস্ত উপাদানগুলি পড়া সহ বা না পড়ে যে কোনও সময়ে কন্টেইনার রিডার বন্ধ করতে পারে৷ কন্টেইনার রিডার বন্ধ হওয়ার পরে, অ্যাপ্লিকেশনগুলি তাদের প্যারেন্ট রিডারের ব্যবহার চালিয়ে যেতে পারে।
কন্টেইনার রিডার প্যারেন্ট রিডার থেকে বিভিন্ন কনফিগারেশন বৈশিষ্ট্য উত্তরাধিকার সূত্রে পায়। এইগুলো:
- অন্তর্নিহিত প্রোফাইল আইডি (ImplicitProfileId)
- অ্যাপ্লিকেশন ডেটা পয়েন্টার (AppData)
- GetNextBuffer ফাংশন পয়েন্টার
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
এড়িয়ে যান
WEAVE_ERROR Skip( void )
TLVReader অবজেক্টকে বর্তমান TLV উপাদানের পরপরই অগ্রসর করে।
বাদ দিন _ _ নেক্সট() এর মতো, যদি পাঠক কলের সময় একটি কন্টেইনার উপাদানের উপর অবস্থান করে, তবে কন্টেইনারের সদস্যদের এড়িয়ে যাওয়া হবে। পাঠক কোনো উপাদানে অবস্থান না করলে তার অবস্থান অপরিবর্তিত থাকে।
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
রিটার্ন মান |
|
EndOfContainer যাচাই করুন
WEAVE_ERROR VerifyEndOfContainer( void )
TVLReader অবজেক্টটি একটি TLV কন্টেইনারের শেষে রয়েছে তা যাচাই করে।
VerifyEndOfContainer() পদ্ধতিটি যাচাই করে যে বর্তমান TLV কন্টেইনারের মধ্যে পড়ার জন্য আর কোন TLV উপাদান নেই। This is a convenience method that is equivalent to calling Next() and checking for a return value of WEAVE_END_OF_TLV.
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
রিটার্ন মান |
|
Protected functions
ClearElementState
void ClearElementState( void )
ElementType
TLVElementType ElementType( void ) const
This is a private method that returns the TLVElementType from mControlByte.
EnsureData
WEAVE_ERROR EnsureData( WEAVE_ERROR noDataErr )
GetElementHeadLength
WEAVE_ERROR GetElementHeadLength( uint8_t & elemHeadBytes ) const
This is a private method used to compute the length of a TLV element head.
IsContainerOpen
bool IsContainerOpen( void ) const
ReadData
WEAVE_ERROR ReadData( uint8_t *buf, uint32_t len )
ReadElement
WEAVE_ERROR ReadElement( void )
ReadTag
uint64_t ReadTag( TLVTagControl tagControl, const uint8_t *& p )
SetContainerOpen
void SetContainerOpen( bool aContainerOpen )
SkipData
WEAVE_ERROR SkipData( void )
Skip any data contained in the current TLV by reading over it without a destination buffer.
বিস্তারিত | |||||
---|---|---|---|---|---|
রিটার্ন মান |
|
SkipToEndOfContainer
WEAVE_ERROR SkipToEndOfContainer( void )
VerifyElement
WEAVE_ERROR VerifyElement( void )
Protected static functions
FailGetNextBuffer
WEAVE_ERROR FailGetNextBuffer( TLVReader & reader, uintptr_t & bufHandle, const uint8_t *& bufStart, uint32_t & bufLen )
GetNextPacketBuffer
WEAVE_ERROR GetNextPacketBuffer( TLVReader & reader, uintptr_t & bufHandle, const uint8_t *& bufStart, uint32_t & bufLen )
nl:: বুনা:: TLV:: TLVReader
#include <src/lib/core/WeaveTLV.h>
Provides a memory efficient parser for data encoded in Weave TLV format.
সারসংক্ষেপ
TLVReader implements a forward-only, “pull-style” parser for Weave TLV data. The TLVReader object operates as a cursor that can be used to iterate over a sequence of TLV elements and interpret their contents. When positioned on an element, applications can make calls to the reader's Get() methods to query the current element's type and tag, and to extract any associated value. The reader's Next() method is used to advance from element to element.
A TLVReader object is always positioned either before, on or after a TLV element. When first initialized, a TLVReader is positioned immediately before the first element of the encoding. To begin reading, an application must make an initial call to the Next() method to position the reader on the first element. When a container element is encounteredeither a structure, an array or a paththe OpenContainer() or EnterContainer() methods can be used to iterate through the contents of the container.
When the reader reaches the end of a TLV encoding, or the last element within a container, it signals the application by returning a WEAVE_END_OF_TLV error from the Next() method. The reader will continue to return WEAVE_END_OF_TLV until it is reinitialized, or the current container is exited (via CloseContainer() / ExitContainer() ).
A TLVReader object can parse data directly from a fixed input buffer, or from a chain of one or more PacketBuffers. Additionally, applications can supply a GetNextBuffer
function to feed data to the reader from an arbitrary source, eg a socket or a serial port.
উত্তরাধিকার
Direct Known Subclasses:nl::Weave::Profiles::DataManagement_Current::CircularEventReader
nl::Weave::TLV::CircularTLVReader
পাবলিক প্রকার | |
---|---|
GetNextBufferFunct )(TLVReader &reader, uintptr_t &bufHandle, const uint8_t *&bufStart, uint32_t &bufLen) | WEAVE_ERROR(*WEAVE_ERROR (* A function that can be used to retrieve additional TLV data to be parsed. |
পাবলিক বৈশিষ্ট্য | |
---|---|
AppData | void * A pointer field that can be used for application-specific data. |
GetNextBuffer | A pointer to a function that will produce input data for the TLVReader object. |
ImplicitProfileId | uint32_t The profile id to be used for profile tags encoded in implicit form. |
সুরক্ষিত বৈশিষ্ট্য | |
---|---|
mBufEnd | const uint8_t * |
mBufHandle | uintptr_t |
mContainerType | |
mControlByte | uint16_t |
mElemLenOrVal | uint64_t |
mElemTag | uint64_t |
mLenRead | uint32_t |
mMaxLen | uint32_t |
mReadPoint | const uint8_t * |
পাবলিক ফাংশন | |
---|---|
CloseContainer ( TLVReader & containerReader) | Completes the reading of a TLV container after a call to OpenContainer() . |
DupBytes (uint8_t *& buf, uint32_t & dataLen) | Allocates and returns a buffer containing the value of the current byte or UTF8 string. |
DupString (char *& buf) | Allocates and returns a buffer containing the null-terminated value of the current byte or UTF8 string. |
EnterContainer ( TLVType & outerContainerType) | |
ExitContainer ( TLVType outerContainerType) | |
Get (bool & v) | Get the value of the current element as a bool type. |
Get (int8_t & v) | Get the value of the current element as an 8-bit signed integer. |
Get (int16_t & v) | Get the value of the current element as a 16-bit signed integer. |
Get (int32_t & v) | Get the value of the current element as a 32-bit signed integer. |
Get (int64_t & v) | Get the value of the current element as a 64-bit signed integer. |
Get (uint8_t & v) | Get the value of the current element as an 8-bit unsigned integer. |
Get (uint16_t & v) | Get the value of the current element as a 16-bit unsigned integer. |
Get (uint32_t & v) | Get the value of the current element as a 32-bit unsigned integer. |
Get (uint64_t & v) | Get the value of the current element as a 64-bit unsigned integer. |
Get (float & v) | |
Get (double & v) | Get the value of the current element as a double-precision floating point number. |
GetBufHandle (void) const | uintptr_t |
GetBytes (uint8_t *buf, uint32_t bufSize) | Get the value of the current byte or UTF8 string element. |
GetContainerType (void) const | Returns the type of the container within which the TLVReader is currently reading. |
GetControlByte (void) const | uint16_t Returns the control byte associated with current TLV element. |
GetDataPtr (const uint8_t *& data) | Get a pointer to the initial encoded byte of a TLV byte or UTF8 string element. |
GetLength (void) const | uint32_t Returns the length of data associated with current TLV element. |
GetLengthRead (void) const | uint32_t Returns the total number of bytes read since the reader was initialized. |
GetReadPoint (void) const | const uint8_t * Gets the point in the underlying input buffer that corresponds to the reader's current position. |
GetRemainingLength (void) const | uint32_t Returns the total number of bytes that can be read until the max read length is reached. |
GetString (char *buf, uint32_t bufSize) | Get the value of the current byte or UTF8 string element as a null terminated string. |
GetTag (void) const | uint64_t Returns the tag associated with current TLV element. |
GetType (void) const | Returns the type of the current TLV element. |
Init (const TLVReader & aReader) | void |
Init (const uint8_t *data, uint32_t dataLen) | void Initializes a TLVReader object to read from a single input buffer. |
Init ( PacketBuffer *buf, uint32_t maxLen) | void Initializes a TLVReader object to read from a single PacketBuffer. |
Init ( PacketBuffer *buf, uint32_t maxLen, bool allowDiscontiguousBuffers) | void Initializes a TLVReader object to read from a one or more PacketBuffers. |
Next (void) | |
Next ( TLVType expectedType, uint64_t expectedTag) | |
OpenContainer ( TLVReader & containerReader) | |
Skip (void) | |
VerifyEndOfContainer (void) | Verifies that the TVLReader object is at the end of a TLV container. |
Protected functions | |
---|---|
ClearElementState (void) | void Clear the state of the TLVReader . |
ElementType (void) const | TLVElementType This is a private method that returns the TLVElementType from mControlByte. |
EnsureData ( WEAVE_ERROR noDataErr) | |
GetElementHeadLength (uint8_t & elemHeadBytes) const | This is a private method used to compute the length of a TLV element head. |
IsContainerOpen (void) const | bool |
ReadData (uint8_t *buf, uint32_t len) | |
ReadElement (void) | |
ReadTag (TLVTagControl tagControl, const uint8_t *& p) | uint64_t |
SetContainerOpen (bool aContainerOpen) | void |
SkipData (void) | Skip any data contained in the current TLV by reading over it without a destination buffer. |
SkipToEndOfContainer (void) | |
VerifyElement (void) |
Protected static functions | |
---|---|
FailGetNextBuffer ( TLVReader & reader, uintptr_t & bufHandle, const uint8_t *& bufStart, uint32_t & bufLen) | |
GetNextPacketBuffer ( TLVReader & reader, uintptr_t & bufHandle, const uint8_t *& bufStart, uint32_t & bufLen) |
পাবলিক প্রকার
GetNextBufferFunct
WEAVE_ERROR(* GetNextBufferFunct)(TLVReader &reader, uintptr_t &bufHandle, const uint8_t *&bufStart, uint32_t &bufLen)
A function that can be used to retrieve additional TLV data to be parsed.
Functions of this type are used to feed input data to a TLVReader . When called, the function is expected to produce additional data for the reader to parse or signal the reader that no more data is available.
বিস্তারিত | |||||||||
---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||
রিটার্ন মান |
|
পাবলিক বৈশিষ্ট্য
AppData
void * AppData
A pointer field that can be used for application-specific data.
GetNextBuffer
GetNextBufferFunct GetNextBuffer
A pointer to a function that will produce input data for the TLVReader object.
If set to NULL (the default value), the reader will assume that no further input data is available.
GetNextBuffer can be set by an application at any time, but is typically set when the reader is initialized.
See the GetNextBufferFunct type definition for additional information on implementing a GetNextBuffer function.
ImplicitProfileId
uint32_t ImplicitProfileId
The profile id to be used for profile tags encoded in implicit form.
When the reader encounters a profile-specific tag that has been encoded in implicit form, it uses the value of the ImplicitProfileId
property as the assumed profile id for the tag.
By default, the ImplicitProfileId
property is set to kProfileIdNotSpecified. When decoding TLV that contains implicitly-encoded tags, applications must set ImplicitProfileId
prior to reading any TLV elements having such tags. The appropriate profile id is usually dependent on the context of the application or protocol being spoken.
If an implicitly-encoded tag is encountered while ImplicitProfileId
is set to kProfileIdNotSpecified, the reader will return a WEAVE_ERROR_UNKNOWN_IMPLICIT_TLV_TAG error.
সুরক্ষিত বৈশিষ্ট্য
mBufEnd
const uint8_t * mBufEnd
mBufHandle
uintptr_t mBufHandle
mContainerType
TLVType mContainerType
mControlByte
uint16_t mControlByte
mElemLenOrVal
uint64_t mElemLenOrVal
mElemTag
uint64_t mElemTag
mLenRead
uint32_t mLenRead
mMaxLen
uint32_t mMaxLen
mReadPoint
const uint8_t * mReadPoint
পাবলিক ফাংশন
CloseContainer
WEAVE_ERROR CloseContainer( TLVReader & containerReader )
Completes the reading of a TLV container after a call to OpenContainer() .
The CloseContainer() method restores the state of a parent TLVReader object after a call to OpenContainer() . For every call to OpenContainer() applications must make a corresponding call to CloseContainer() , passing a reference to the same container reader to both methods.
When CloseContainer() returns, the parent reader is positioned immediately before the first element that follows the container. From this point an application can use the Next() method to advance through any remaining elements.
Applications can call close CloseContainer() on a parent reader at any point in time, regardless of whether all elements in the underlying container have been read. After CloseContainer() has been called, the application should consider the container reader 'de-initialized' and must not use it further without re-initializing it.
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
DupBytes
WEAVE_ERROR DupBytes( uint8_t *& buf, uint32_t & dataLen )
Allocates and returns a buffer containing the value of the current byte or UTF8 string.
This method creates a buffer for and returns a copy of the data associated with the byte or UTF-8 string element at the current position. Memory for the buffer is obtained with malloc() and should be freed with free() by the caller when it is no longer needed.
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
DupString
WEAVE_ERROR DupString( char *& buf )
Allocates and returns a buffer containing the null-terminated value of the current byte or UTF8 string.
This method creates a buffer for and returns a null-terminated copy of the data associated with the byte or UTF-8 string element at the current position. Memory for the buffer is obtained with malloc() and should be freed with free() by the caller when it is no longer needed.
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
EnterContainer
WEAVE_ERROR EnterContainer( TLVType & outerContainerType )
Prepares a TLVReader object for reading the members of TLV container element.
The EnterContainer() method prepares the current TLVReader object to begin reading the member elements of a TLV container (a structure, array or path). For every call to EnterContainer() applications must make a corresponding call to ExitContainer() .
When EnterContainer() is called the TLVReader object must be positioned on the container element to be read. The method takes as an argument a reference to a TLVType value which will be used to save the context of the reader while it is reading the container.
When the EnterContainer() method returns, the reader is positioned immediately before the first member of the container. Repeatedly calling Next() will advance the reader through the members of the collection until the end is reached, at which point the reader will return WEAVE_END_OF_TLV.
Once the application has finished reading a container it can continue reading the elements after the container by calling the ExitContainer() method.
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
ExitContainer
WEAVE_ERROR ExitContainer( TLVType outerContainerType )
Completes the reading of a TLV container and prepares a TLVReader object to read elements after the container.
The ExitContainer() method restores the state of a TLVReader object after a call to EnterContainer() . For every call to EnterContainer() applications must make a corresponding call to ExitContainer() , passing the context value returned by the EnterContainer() method.
When ExitContainer() returns, the reader is positioned immediately before the first element that follows the container. From this point an application can use the Next() method to advance through any remaining elements.
Once EnterContainer() has been called, applications can call ExitContainer() on a reader at any point in time, regardless of whether all elements in the underlying container have been read.
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
Get
WEAVE_ERROR Get( bool & v )
Get the value of the current element as a bool type.
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
Get
WEAVE_ERROR Get( int8_t & v )
Get the value of the current element as an 8-bit signed integer.
If the encoded integer value is larger than the output data type the resultant value will be truncated.
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
Get
WEAVE_ERROR Get( int16_t & v )
Get the value of the current element as a 16-bit signed integer.
If the encoded integer value is larger than the output data type the resultant value will be truncated.
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
Get
WEAVE_ERROR Get( int32_t & v )
Get the value of the current element as a 32-bit signed integer.
If the encoded integer value is larger than the output data type the resultant value will be truncated.
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
Get
WEAVE_ERROR Get( int64_t & v )
Get the value of the current element as a 64-bit signed integer.
If the encoded integer value is larger than the output data type the resultant value will be truncated.
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
Get
WEAVE_ERROR Get( uint8_t & v )
Get the value of the current element as an 8-bit unsigned integer.
If the encoded integer value is larger than the output data type the resultant value will be truncated. Similarly, if the encoded integer value is negative, the value will be converted to unsigned.
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
Get
WEAVE_ERROR Get( uint16_t & v )
Get the value of the current element as a 16-bit unsigned integer.
If the encoded integer value is larger than the output data type the resultant value will be truncated. Similarly, if the encoded integer value is negative, the value will be converted to unsigned.
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
Get
WEAVE_ERROR Get( uint32_t & v )
Get the value of the current element as a 32-bit unsigned integer.
If the encoded integer value is larger than the output data type the resultant value will be truncated. Similarly, if the encoded integer value is negative, the value will be converted to unsigned.
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
Get
WEAVE_ERROR Get( uint64_t & v )
Get the value of the current element as a 64-bit unsigned integer.
If the encoded integer value is negative, the value will be converted to unsigned.
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
Get
WEAVE_ERROR Get( float & v )
Get
WEAVE_ERROR Get( double & v )
Get the value of the current element as a double-precision floating point number.
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
GetBufHandle
uintptr_t GetBufHandle( void ) const
GetBytes
WEAVE_ERROR GetBytes( uint8_t *buf, uint32_t bufSize )
Get the value of the current byte or UTF8 string element.
To determine the required input buffer size, call the GetLength() method before calling GetBytes() .
বিস্তারিত | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||
রিটার্ন মান |
|
GetContainerType
TLVType GetContainerType( void ) const
Returns the type of the container within which the TLVReader is currently reading.
The GetContainerType() method returns the type of the TLV container within which the TLVReader is reading. If the TLVReader is positioned at the outer-most level of a TLV encoding (ie before, on or after the outer-most TLV element), the method will return kTLVType_NotSpecified.
বিস্তারিত | |
---|---|
রিটার্নস | The TLVType of the current container, or kTLVType_NotSpecified if the TLVReader is not positioned within a container. |
GetControlByte
uint16_t GetControlByte( void ) const
Returns the control byte associated with current TLV element.
Ideally, nobody ever needs to know about the control byte and only the internal implementation of TLV should have access to it. But, nevertheless, having access to the control byte is helpful for debugging purposes by the TLV Debug Utilities (that try to decode the tag control byte when pretty printing the TLV buffer contents).
বিস্তারিত | |
---|---|
রিটার্নস | An unsigned integer containing the control byte associated with the current TLV element. kTLVControlByte_NotSpecified is returned if the reader is not positioned on an element. |
GetDataPtr
WEAVE_ERROR GetDataPtr( const uint8_t *& data )
Get a pointer to the initial encoded byte of a TLV byte or UTF8 string element.
This method returns a direct pointer the encoded string value within the underlying input buffer. To succeed, the method requires that the entirety of the string value be present in a single buffer. Otherwise the method returns WEAVE_ERROR_TLV_UNDERRUN . This makes the method of limited use when reading data from multiple discontiguous buffers.
বিস্তারিত | |||||||||
---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||
রিটার্ন মান |
|
GetLength
uint32_t GetLength( void ) const
Returns the length of data associated with current TLV element.
Data length only applies to elements of type UTF8 string or byte string. For UTF8 strings, the value returned is the number of bytes in the string, not the number of characters.
বিস্তারিত | |
---|---|
রিটার্নস | The length (in bytes) of data associated with the current TLV element, or 0 if the current element is not a UTF8 string or byte string, or if the reader is not positioned on an element. |
GetLengthRead
uint32_t GetLengthRead( void ) const
Returns the total number of bytes read since the reader was initialized.
বিস্তারিত | |
---|---|
রিটার্নস | Total number of bytes read since the reader was initialized. |
GetReadPoint
const uint8_t * GetReadPoint( void ) const
Gets the point in the underlying input buffer that corresponds to the reader's current position.
বিস্তারিত | |
---|---|
রিটার্নস | A pointer into underlying input buffer that corresponds to the reader's current position. |
GetRemainingLength
uint32_t GetRemainingLength( void ) const
Returns the total number of bytes that can be read until the max read length is reached.
বিস্তারিত | |
---|---|
রিটার্নস | Total number of bytes that can be read until the max read length is reached. |
GetString
WEAVE_ERROR GetString( char *buf, uint32_t bufSize )
Get the value of the current byte or UTF8 string element as a null terminated string.
To determine the required input buffer size, call the GetLength() method before calling GetBytes() . The input buffer should be at least one byte bigger than the string length to accommodate the null character.
বিস্তারিত | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||
রিটার্ন মান |
|
GetTag
uint64_t GetTag( void ) const
Returns the tag associated with current TLV element.
The value returned by GetTag() can be used with the tag utility functions ( IsProfileTag() , IsContextTag() , ProfileIdFromTag() , etc.) to determine the type of tag and to extract various tag field values.
বিস্তারিত | |
---|---|
রিটার্নস | An unsigned integer containing information about the tag associated with the current TLV element. |
GetType
TLVType GetType( void ) const
Init
void Init( const TLVReader & aReader )
Init
void Init( const uint8_t *data, uint32_t dataLen )
Init
void Init( PacketBuffer *buf, uint32_t maxLen )
Initializes a TLVReader object to read from a single PacketBuffer.
Parsing begins at the buffer's start position (buf->DataStart()) and continues until the end of the data in the buffer (as denoted by buf->Datalen()), or maxLen bytes have been parsed.
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
|
Init
void Init( PacketBuffer *buf, uint32_t maxLen, bool allowDiscontiguousBuffers )
Initializes a TLVReader object to read from a one or more PacketBuffers.
Parsing begins at the initial buffer's start position (buf->DataStart()). If allowDiscontiguousBuffers is true, the reader will advance through the chain of buffers linked by their Next() pointers. Parsing continues until all data in the buffer chain has been consumed (as denoted by buf->Datalen()), or maxLen bytes have been parsed.
বিস্তারিত | |||||||
---|---|---|---|---|---|---|---|
পরামিতি |
|
Next
WEAVE_ERROR Next( void )
Advances the TLVReader object to the next TLV element to be read.
The Next() method positions the reader object on the next element in a TLV encoding that resides in the same containment context. In particular, if the reader is positioned at the outer-most level of a TLV encoding, calling Next() will advance the reader to the next, top-most element. If the reader is positioned within a TLV container element (a structure, array or path), calling Next() will advance the reader to the next member element of the container.
Since Next() constrains reader motion to the current containment context, calling Next() when the reader is positioned on a container element will advance over the container, skipping its member elements (and the members of any nested containers) until it reaches the first element after the container.
When there are no further elements within a particular containment context the Next() method will return a WEAVE_END_OF_TLV error and the position of the reader will remain unchanged.
বিস্তারিত | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
রিটার্ন মান |
|
Next
WEAVE_ERROR Next( TLVType expectedType, uint64_t expectedTag )
Advances the TLVReader object to the next TLV element to be read, asserting the type and tag of the new element.
The Next(TLVType expectedType, uint64_t expectedTag) method is a convenience method that has the same behavior as Next() , but also verifies that the type and tag of the new TLV element match the supplied arguments.
বিস্তারিত | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||||||
রিটার্ন মান |
|
OpenContainer
WEAVE_ERROR OpenContainer( TLVReader & containerReader )
Initializes a new TLVReader object for reading the members of a TLV container element.
The OpenContainer() method initializes a new TLVReader object for reading the member elements of a TLV container (a structure, array or path). When OpenContainer() is called, the current TLVReader object must be positioned on the container element to be read. The method takes as its sole argument a reference to a new reader that will be initialized to read the container. This reader is known as the container reader while the reader on which OpenContainer() is called is known as the parent reader .
When the OpenContainer() method returns, the container reader is positioned immediately before the first member of the container. Calling Next() on the container reader will advance through the members of the collection until the end is reached, at which point the reader will return WEAVE_END_OF_TLV.
While the container reader is open, applications must not make calls on or otherwise alter the state of the parent reader. Once an application has finished using the container reader it must close it by calling CloseContainer() on the parent reader, passing the container reader as an argument. Applications may close the container reader at any point, with or without reading all elements contained in the underlying container. After the container reader is closed, applications may continue their use of the parent reader.
The container reader inherits various configuration properties from the parent reader. These are:
- The implicit profile id (ImplicitProfileId)
- The application data pointer (AppData)
- The GetNextBuffer function pointer
বিস্তারিত | |||||
---|---|---|---|---|---|
পরামিতি |
| ||||
রিটার্ন মান |
|
Skip
WEAVE_ERROR Skip( void )
Advances the TLVReader object to immediately after the current TLV element.
The Skip() method positions the reader object immediately after the current TLV element, such that a subsequent call to Next() will advance the reader to the following element. Like Next() , if the reader is positioned on a container element at the time of the call, the members of the container will be skipped. If the reader is not positioned on any element, its position remains unchanged.
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
রিটার্ন মান |
|
VerifyEndOfContainer
WEAVE_ERROR VerifyEndOfContainer( void )
Verifies that the TVLReader object is at the end of a TLV container.
The VerifyEndOfContainer() method verifies that there are no further TLV elements to be read within the current TLV container. This is a convenience method that is equivalent to calling Next() and checking for a return value of WEAVE_END_OF_TLV.
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
রিটার্ন মান |
|
Protected functions
ClearElementState
void ClearElementState( void )
ElementType
TLVElementType ElementType( void ) const
This is a private method that returns the TLVElementType from mControlByte.
EnsureData
WEAVE_ERROR EnsureData( WEAVE_ERROR noDataErr )
GetElementHeadLength
WEAVE_ERROR GetElementHeadLength( uint8_t & elemHeadBytes ) const
This is a private method used to compute the length of a TLV element head.
IsContainerOpen
bool IsContainerOpen( void ) const
ReadData
WEAVE_ERROR ReadData( uint8_t *buf, uint32_t len )
ReadElement
WEAVE_ERROR ReadElement( void )
ReadTag
uint64_t ReadTag( TLVTagControl tagControl, const uint8_t *& p )
SetContainerOpen
void SetContainerOpen( bool aContainerOpen )
SkipData
WEAVE_ERROR SkipData( void )
Skip any data contained in the current TLV by reading over it without a destination buffer.
বিস্তারিত | |||||
---|---|---|---|---|---|
রিটার্ন মান |
|
SkipToEndOfContainer
WEAVE_ERROR SkipToEndOfContainer( void )
VerifyElement
WEAVE_ERROR VerifyElement( void )
Protected static functions
FailGetNextBuffer
WEAVE_ERROR FailGetNextBuffer( TLVReader & reader, uintptr_t & bufHandle, const uint8_t *& bufStart, uint32_t & bufLen )
GetNextPacketBuffer
WEAVE_ERROR GetNextPacketBuffer( TLVReader & reader, uintptr_t & bufHandle, const uint8_t *& bufStart, uint32_t & bufLen )