nl:: বুনা:: TLV:: TLVWriter
#include <src/lib/core/WeaveTLV.h>
Weave TLV ফর্ম্যাটে ডেটা লেখার জন্য একটি মেমরি দক্ষ এনকোডার প্রদান করে।
সারসংক্ষেপ
TLVWriter ওয়েভ TLV ডেটার জন্য শুধুমাত্র ফরওয়ার্ড-স্টাইল এনকোডার প্রয়োগ করে। অ্যাপ্লিকেশানগুলি লেখকের Put() পদ্ধতিগুলির একটিতে কল করে, সংশ্লিষ্ট ট্যাগ এবং প্রয়োজনীয় তথ্যগুলিকে পাস করে একটি এনকোডিংয়ে ডেটা লেখে। একইভাবে অ্যাপ্লিকেশনগুলি লেখকের OpenContainer() বা EnterContainer() পদ্ধতিতে কল করে TLV কন্টেইনার প্রকার (কাঠামো, অ্যারে বা পাথ) এনকোড করতে পারে।
একটি TLVWriter অবজেক্ট সরাসরি একটি নির্দিষ্ট আউটপুট বাফারে বা এক বা একাধিক প্যাকেটবাফার অবজেক্টের চেইনে ডেটা লিখতে পারে। অতিরিক্তভাবে, অ্যাপ্লিকেশনগুলি তাদের নিজস্ব GetNewBuffer
এবং FinalizeBuffer
ফাংশনগুলিকে একটি নির্বিচারে গন্তব্যে সরাসরি আউটপুট সরবরাহ করতে পারে, যেমন একটি সকেট বা একটি ইভেন্ট সারি৷
উত্তরাধিকার
সরাসরি পরিচিত সাবক্লাস: nl::Weave::TLV::CircularTLVWriterসুরক্ষিত প্রকার | |
---|---|
@72 { | enum |
পাবলিক প্রকার | |
---|---|
FinalizeBufferFunct )(TLVWriter &writer, uintptr_t bufHandle, uint8_t *bufStart, uint32_t bufLen) | WEAVE_ERROR(*WEAVE_ERROR (* একটি TLVWriter অবজেক্ট থেকে আউটপুট চূড়ান্ত করার জন্য ব্যবহৃত একটি ফাংশন। |
GetNewBufferFunct )(TLVWriter &writer, uintptr_t &bufHandle, uint8_t *&bufStart, uint32_t &bufLen) | WEAVE_ERROR(*WEAVE_ERROR (* একটি ফাংশন যা একটি TLVWriter এ নতুন আউটপুট বাফার স্পেস সরবরাহ করে। |
পাবলিক বৈশিষ্ট্য | |
---|---|
AppData | void * একটি পয়েন্টার ক্ষেত্র যা অ্যাপ্লিকেশন-নির্দিষ্ট ডেটার জন্য ব্যবহার করা যেতে পারে। |
FinalizeBuffer | একটি ফাংশনের একটি পয়েন্টার যা TLVWriter চূড়ান্ত হলে কল করা হবে। |
GetNewBuffer | একটি ফাংশনের একটি পয়েন্টার যা একটি TLVWriter এ নতুন আউটপুট বাফার স্পেস সরবরাহ করবে। |
ImplicitProfileId | uint32_t ট্যাগের প্রোফাইল আইডি যা অন্তর্নিহিত আকারে এনকোড করা উচিত। |
সুরক্ষিত বৈশিষ্ট্য | |
---|---|
mBufHandle | uintptr_t |
mBufStart | uint8_t * |
mContainerType | |
mLenWritten | uint32_t |
mMaxLen | uint32_t |
mRemainingLen | uint32_t |
mWritePoint | uint8_t * |
পাবলিক ফাংশন | |
---|---|
CloseContainer ( TLVWriter & containerWriter) | OpenContainer() এ কল করার পর একটি TLV কন্টেইনার লেখা সম্পূর্ণ করে। |
ContinuePutBytes (const uint8_t *buf, uint32_t len) | একটি TLV বাইট স্ট্রিং মান এনকোড করে। |
CopyContainer ( TLVReader & container) | |
CopyContainer (uint64_t tag, TLVReader & container) | সদস্য উপাদানগুলির একটি প্রাক-এনকোড করা সেট থেকে একটি TLV কন্টেইনার উপাদান এনকোড করে। |
CopyContainer (uint64_t tag, const uint8_t *encodedContainer, uint16_t encodedContainerLen) | একটি TLV কন্টেইনার উপাদান এনকোড করে যাতে একটি প্রাক-এনকোডেড কন্টেইনার থেকে সদস্য উপাদান থাকে। |
CopyElement ( TLVReader & reader) | পাঠক বস্তু থেকে লেখকের মধ্যে একটি TLV উপাদান কপি করে। |
CopyElement (uint64_t tag, TLVReader & reader) | |
EndContainer ( TLVType outerContainerType) | একটি TLV কন্টেইনার উপাদানের এনকোডিং সম্পূর্ণ করে। |
Finalize (void) | একটি TLV এনকোডিং লেখা শেষ করুন। |
GetContainerType (void) const | TLVWriter বর্তমানে যে পাত্রে লিখছে তার ধরন প্রদান করে। |
GetLengthWritten (void) | uint32_t লেখক শুরু হওয়ার পর থেকে লেখা মোট বাইট সংখ্যা প্রদান করে। |
Init (uint8_t *buf, uint32_t maxLen) | void একটি একক আউটপুট বাফারে লিখতে একটি TLVWriter অবজেক্ট শুরু করে। |
Init ( PacketBuffer *buf, uint32_t maxLen) | void একটি একক প্যাকেটবাফারে লিখতে একটি TLVWriter অবজেক্ট শুরু করে। |
Init ( PacketBuffer *buf, uint32_t maxLen, bool allowDiscontiguousBuffers) | void এক বা একাধিক প্যাকেটবাফারে লিখতে একটি TLVWriter অবজেক্ট শুরু করে। |
InitMalloced (uint8_t *& outBuf, uint32_t initialBufSize, uint32_t maxLen) | void ডায়নামিক বাফারে লিখতে একটি TLVWriter অবজেক্ট শুরু করে। |
OpenContainer (uint64_t tag, TLVType containerType, TLVWriter & containerWriter) | |
Put (uint64_t tag, int8_t v) | একটি TLV স্বাক্ষরিত পূর্ণসংখ্যা মান এনকোড করে। |
Put (uint64_t tag, int8_t v, bool preserveSize) | একটি TLV স্বাক্ষরিত পূর্ণসংখ্যা মান এনকোড করে। |
Put (uint64_t tag, int16_t v) | |
Put (uint64_t tag, int16_t v, bool preserveSize) | |
Put (uint64_t tag, int32_t v) | |
Put (uint64_t tag, int32_t v, bool preserveSize) | |
Put (uint64_t tag, int64_t v) | |
Put (uint64_t tag, int64_t v, bool preserveSize) | |
Put (uint64_t tag, uint8_t v) | একটি TLV স্বাক্ষরবিহীন পূর্ণসংখ্যা মান এনকোড করে। |
Put (uint64_t tag, uint8_t v, bool preserveSize) | একটি TLV স্বাক্ষরবিহীন পূর্ণসংখ্যা মান এনকোড করে। |
Put (uint64_t tag, uint16_t v) | |
Put (uint64_t tag, uint16_t v, bool preserveSize) | |
Put (uint64_t tag, uint32_t v) | |
Put (uint64_t tag, uint32_t v, bool preserveSize) | |
Put (uint64_t tag, uint64_t v) | |
Put (uint64_t tag, uint64_t v, bool preserveSize) | |
Put (uint64_t tag, float v) | |
Put (uint64_t tag, double v) | একটি TLV ফ্লোটিং পয়েন্ট মান এনকোড করে। |
PutBoolean (uint64_t tag, bool v) | একটি TLV বুলিয়ান মান এনকোড করে। |
PutBytes (uint64_t tag, const uint8_t *buf, uint32_t len) | একটি TLV বাইট স্ট্রিং মান এনকোড করে। |
PutNull (uint64_t tag) | একটি TLV নাল মান এনকোড করে। |
PutPreEncodedContainer (uint64_t tag, TLVType containerType, const uint8_t *data, uint32_t dataLen) | সদস্য উপাদানগুলির একটি প্রাক-এনকোড করা সেট থেকে একটি TLV কন্টেইনার উপাদান এনকোড করে। |
PutString (uint64_t tag, const char *buf) | একটি TLV UTF8 স্ট্রিং মান এনকোড করে। |
PutString (uint64_t tag, const char *buf, uint32_t len) | একটি TLV UTF8 স্ট্রিং মান এনকোড করে। |
PutStringF (uint64_t tag, const char *fmt, ...) | TLV উপাদানের বিন্যাস অনুযায়ী স্ট্রিং আউটপুট বিন্যাস এনকোড করুন। |
StartContainer (uint64_t tag, TLVType containerType, TLVType & outerContainerType) | একটি নতুন TLV কন্টেইনার উপাদান এনকোডিং শুরু করে। |
StartPutBytes (uint64_t tag, uint32_t totalLen) | একাধিক খণ্ডে একটি TLV বাইট স্ট্রিং এনকোড করে। |
VPutStringF (uint64_t tag, const char *fmt, va_list ap) | TLV উপাদানের বিন্যাস অনুযায়ী স্ট্রিং আউটপুট বিন্যাস এনকোড করুন। |
পাবলিক স্ট্যাটিক ফাংশন | |
---|---|
FinalizePacketBuffer ( TLVWriter & writer, uintptr_t bufHandle, uint8_t *bufStart, uint32_t dataLen) | প্যাকেটবাফারের একটি চেইনে লেখার জন্য একটি TLVWriter FinalizeBuffer ফাংশনের বাস্তবায়ন। |
GetNewBuffer_Malloced ( TLVWriter & writer, uintptr_t & bufHandle, uint8_t *& bufStart, uint32_t & bufLen) | একটি গতিশীল বাফারে লেখার জন্য একটি TLVWriter GetNewBuffer ফাংশনের বাস্তবায়ন। |
GetNewPacketBuffer ( TLVWriter & writer, uintptr_t & bufHandle, uint8_t *& bufStart, uint32_t & bufLen) | প্যাকেটবাফারের একটি চেইনে লেখার জন্য একটি TLVWriter GetNewBuffer ফাংশনের বাস্তবায়ন। |
সুরক্ষিত ফাংশন | |
---|---|
IsCloseContainerReserved (void) const | bool কন্টেইনারটি শুরু/খোলার সময় ক্লোজকন্টেইনার চিহ্নের জন্য ধারকটি স্থান সংরক্ষিত করবে কিনা তা নির্ধারণ করুন। |
IsContainerOpen (void) const | bool |
SetCloseContainerReserved (bool aCloseContainerReserved) | void কন্টেইনার শুরু/খোলার সময় ক্লোজকন্টেইনার চিহ্নের জন্য কন্টেইনারটি স্পেস রিজার্ভ করবে কিনা তা সেট করুন। |
SetContainerOpen (bool aContainerOpen) | void |
WriteData (const uint8_t *p, uint32_t len) | |
WriteElementHead (TLVElementType elemType, uint64_t tag, uint64_t lenOrVal) | |
WriteElementWithData ( TLVType type, uint64_t tag, const uint8_t *data, uint32_t dataLen) |
সুরক্ষিত প্রকার
@৭২
@72
পাবলিক প্রকার
চূড়ান্ত করা বাফারফাংশন
WEAVE_ERROR(* FinalizeBufferFunct)(TLVWriter &writer, uintptr_t bufHandle, uint8_t *bufStart, uint32_t bufLen)
একটি TLVWriter অবজেক্ট থেকে আউটপুট চূড়ান্ত করার জন্য ব্যবহৃত একটি ফাংশন।
এই ধরনের ফাংশনগুলিকে বলা হয় যখন একটি TLVWriter 's Finalize() পদ্ধতি বলা হয়। ফাংশনটি রাইটার অবজেক্টের আউটপুট গ্রহণের সাথে সম্পর্কিত যেকোন প্রয়োজনীয় ক্লিন-আপ বা চূড়ান্তকরণ সম্পাদন করবে বলে আশা করা হচ্ছে। এর উদাহরণগুলির মধ্যে এনকোডিংয়ের চূড়ান্ত দৈর্ঘ্য রেকর্ড করা বা একটি ফাইল বর্ণনাকারী বন্ধ করার মতো জিনিসগুলি অন্তর্ভুক্ত রয়েছে।
বিস্তারিত | |||||||||
---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||
রিটার্ন মান |
|
GetNewBufferFunct
WEAVE_ERROR(* GetNewBufferFunct)(TLVWriter &writer, uintptr_t &bufHandle, uint8_t *&bufStart, uint32_t &bufLen)
একটি ফাংশন যা একটি TLVWriter এ নতুন আউটপুট বাফার স্পেস সরবরাহ করে।
এই ধরনের ফাংশনগুলি একটি TLVWriter- এ লেখার জন্য নতুন বাফার স্পেস প্রস্তুত করতে ব্যবহৃত হয়। কল করা হলে, ফাংশনটি একটি মেমরি অবস্থানে একটি পয়েন্টার ফেরত দেবে বলে আশা করা হয় যেখানে একটি সংশ্লিষ্ট সর্বোচ্চ দৈর্ঘ্য সহ নতুন ডেটা লেখা উচিত। ফাংশনটি ডেটা ধরে রাখার জন্য একটি নতুন বাফার বরাদ্দ করে বা বিদ্যমান বাফার থেকে পূর্বে লিখিত ডেটা সাফ করে লেখার স্থান সরবরাহ করতে পারে।
বিস্তারিত | |||||||||
---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||
রিটার্ন মান |
|
পাবলিক বৈশিষ্ট্য
অ্যাপ্লিকেশন তথ্য
void * AppData
একটি পয়েন্টার ক্ষেত্র যা অ্যাপ্লিকেশন-নির্দিষ্ট ডেটার জন্য ব্যবহার করা যেতে পারে।
বাফার চূড়ান্ত করুন
FinalizeBufferFunct FinalizeBuffer
একটি ফাংশনের একটি পয়েন্টার যা TLVWriter চূড়ান্ত হলে কল করা হবে।
একটি TLVWriter অবজেক্ট FinalizeBuffer ফাংশনকে কল করবে যখনই এর Finalize() পদ্ধতি কল করা হবে। Finalize() কল করার আগে অ্যাপ্লিকেশনগুলি যে কোনও সময়ে ফাংশন পয়েন্টার সেট করতে পারে। ডিফল্টরূপে পয়েন্টারটি NULL-এ সেট করা থাকে, যার ফলে Finalize() পদ্ধতিটি ফাংশনটিকে কল করা থেকে বিরত থাকে।
একটি FinalizeBuffer ফাংশন বাস্তবায়নের অতিরিক্ত তথ্যের জন্য FinalizeBufferFunct প্রকারের সংজ্ঞা দেখুন।
GetNewBuffer
GetNewBufferFunct GetNewBuffer
একটি ফাংশনের একটি পয়েন্টার যা একটি TLVWriter এ নতুন আউটপুট বাফার স্পেস সরবরাহ করবে।
একটি TLVWriter বস্তু GetNewBuffer ফাংশনকে কল করবে যখনই বর্তমান আউটপুট বাফারের আকার অতিক্রম করে এমন ডেটা লেখার চেষ্টা করা হয়। NULL (ডিফল্ট মান) এ সেট করা হলে, আউটপুট ডেটা বর্তমান বাফারে ওভারফ্লো হলে লেখক একটি WEAVE_ERROR_NO_MEMORY ফেরত দেবেন।
GetNewBuffer যে কোনো সময়ে একটি অ্যাপ্লিকেশন দ্বারা সেট করা যেতে পারে, কিন্তু সাধারণত যখন লেখক শুরু হয় তখন সেট করা হয়।
একটি GetNewBuffer ফাংশন বাস্তবায়নের অতিরিক্ত তথ্যের জন্য GetNewBufferFunct প্রকারের সংজ্ঞা দেখুন।
অন্তর্নিহিত প্রোফাইল আইডি
uint32_t ImplicitProfileId
ট্যাগের প্রোফাইল আইডি যা অন্তর্নিহিত আকারে এনকোড করা উচিত।
যখন একজন লেখককে একটি নতুন উপাদান এনকোড করতে বলা হয়, যদি নতুন উপাদানের সাথে যুক্ত ট্যাগের প্রোফাইল আইডি ImplicitProfileId
সদস্যের মানের সাথে মেলে, লেখক প্রক্রিয়ায় প্রোফাইল আইডি বাদ দিয়ে ট্যাগটিকে অন্তর্নিহিত আকারে এনকোড করবেন।
ডিফল্টরূপে, ImplicitProfileId
বৈশিষ্ট্যটি kProfileIdNotSpecified-এ সেট করা থাকে, যা লেখককে নির্দেশ দেয় যে অন্তর্নিহিতভাবে এনকোড করা ট্যাগগুলি নির্গত না করতে। এনকোডিংয়ের বর্তমান বিন্দু থেকে শুরু করে অন্তর্নিহিত আকারে এনকোডিং ট্যাগগুলি সক্ষম করতে অ্যাপ্লিকেশনগুলি যে কোনও সময় ImplicitProfileId
সেট করতে পারে৷ সেট করার জন্য উপযুক্ত প্রোফাইল আইডি সাধারণত অ্যাপ্লিকেশান বা প্রোটোকলের প্রেক্ষাপটের উপর নির্ভর করে।
সুরক্ষিত বৈশিষ্ট্য
mBufHandle
uintptr_t mBufHandle
mBufStart
uint8_t * mBufStart
mContainerType
TLVType mContainerType
mLen লিখিত
uint32_t mLenWritten
mMaxLen
uint32_t mMaxLen
mRemainingLen
uint32_t mRemainingLen
mWritePoint
uint8_t * mWritePoint
পাবলিক ফাংশন
ক্লোজ কনটেইনার
WEAVE_ERROR CloseContainer( TLVWriter & containerWriter )
OpenContainer() এ কল করার পর একটি TLV কন্টেইনার লেখা সম্পূর্ণ করে।
OpenContainer() এ কল করার পর CloseContainer () পদ্ধতিটি একটি প্যারেন্ট TLVWriter অবজেক্টের অবস্থা পুনরুদ্ধার করে। OpenContainer() অ্যাপ্লিকেশনে প্রতিটি কলের জন্য অবশ্যই CloseContainer( ) এ একটি অনুরূপ কল করতে হবে, উভয় পদ্ধতিতে একই কন্টেইনার লেখকের একটি রেফারেন্স পাস করতে হবে।
যখন CloseContainer() ফিরে আসে, তখন অ্যাপ্লিকেশনগুলি ধারক উপাদানের পরে প্রদর্শিত অতিরিক্ত TLV উপাদানগুলি লিখতে মূল লেখককে ব্যবহার করা চালিয়ে যেতে পারে। এই মুহুর্তে সরবরাহকৃত কন্টেইনার লেখককে 'ডি-ইনিশিয়ালাইজড' হিসাবে বিবেচনা করা উচিত এবং পুনরায় আরম্ভ না করে ব্যবহার করা উচিত নয়।
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
পুটবাইট চালিয়ে যান
WEAVE_ERROR ContinuePutBytes( const uint8_t *buf, uint32_t len )
একটি TLV বাইট স্ট্রিং মান এনকোড করে।
এটি StartPutBytes এর সাথে ব্যবহার করা উচিত।
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
কপি কন্টেইনার
WEAVE_ERROR CopyContainer( TLVReader & container )
TLVReader অবজেক্ট থেকে একটি TLV কন্টেইনার উপাদান কপি করে।
CopyContainer() একটি TLVReader অবজেক্টের বর্তমান অবস্থানে অবস্থিত একটি প্রাক-এনকোডেড কন্টেইনার উপাদান কপি করে একটি নতুন TLV কন্টেইনার উপাদান এনকোড করে। পদ্ধতিটি একটি কলে নতুন কন্টেইনার উপাদানের সম্পূর্ণটি লিখে, উৎস এনকোডিং থেকে কন্টেইনারের ধরন, ট্যাগ এবং উপাদানগুলি অনুলিপি করে৷ যখন পদ্ধতিটি ফিরে আসে, তখন লেখক বস্তুটি ধারক উপাদান অনুসরণ করে অতিরিক্ত TLV উপাদান লিখতে ব্যবহার করা যেতে পারে।
বিস্তারিত | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||||||||
রিটার্ন মান |
|
কপি কন্টেইনার
WEAVE_ERROR CopyContainer( uint64_t tag, TLVReader & container )
সদস্য উপাদানগুলির একটি প্রাক-এনকোড করা সেট থেকে একটি TLV কন্টেইনার উপাদান এনকোড করে।
CopyContainer() পদ্ধতিটি একটি নতুন TLV কন্টেইনার উপাদান (একটি কাঠামো, অ্যারে বা পথ) এনকোড করে যাতে একটি TLVReader অবজেক্ট থেকে নেওয়া সদস্য উপাদানগুলির একটি সেট থাকে। যখন পদ্ধতিটি কল করা হয়, সরবরাহকৃত পাঠক বস্তুটি একটি TLV কন্টেইনার উপাদানে অবস্থান করা হবে বলে আশা করা হয়। নতুন এনকোড করা কন্টেইনারে ইনপুট কন্টেইনারের মতো একই ধরনের এবং সদস্য থাকবে। নতুন ধারকটির জন্য ট্যাগটি একটি ইনপুট পরামিতি হিসাবে নির্দিষ্ট করা হয়েছে৷
যখন পদ্ধতিটি ফিরে আসে, তখন লেখক বস্তুটি ধারক উপাদান অনুসরণ করে অতিরিক্ত TLV উপাদান লিখতে ব্যবহার করা যেতে পারে।
বিস্তারিত | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||||||||
রিটার্ন মান |
|
কপি কন্টেইনার
WEAVE_ERROR CopyContainer( uint64_t tag, const uint8_t *encodedContainer, uint16_t encodedContainerLen )
একটি TLV কন্টেইনার উপাদান এনকোড করে যাতে একটি প্রাক-এনকোডেড কন্টেইনার থেকে সদস্য উপাদান থাকে।
CopyContainer() পদ্ধতিটি একটি নতুন TLV কন্টেইনার উপাদান (একটি কাঠামো, অ্যারে বা পাথ) এনকোড করে যাতে একটি সরবরাহকৃত প্রাক-এনকোড করা কন্টেইনারের বিষয়বস্তু থেকে নেওয়া সদস্য উপাদানগুলির একটি সেট থাকে। যখন পদ্ধতিটি কল করা হয়, সরবরাহকৃত ইনপুট বাফারের ডেটা একটি TLV কন্টেইনার উপাদান হিসাবে পার্স করা হয় এবং একটি নতুন ধারক লেখা হয় যাতে ইনপুট ধারক হিসাবে একই প্রকার এবং সদস্য থাকে। নতুন ধারকটির জন্য ট্যাগটি একটি ইনপুট পরামিতি হিসাবে নির্দিষ্ট করা হয়েছে৷
যখন পদ্ধতিটি ফিরে আসে, তখন লেখক বস্তুটি ধারক উপাদান অনুসরণ করে অতিরিক্ত TLV উপাদান লিখতে ব্যবহার করা যেতে পারে।
বিস্তারিত | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||||||
রিটার্ন মান |
|
কপি এলিমেন্ট
WEAVE_ERROR CopyElement( TLVReader & reader )
পাঠক বস্তু থেকে লেখকের মধ্যে একটি TLV উপাদান কপি করে।
CopyElement() পদ্ধতিটি একটি নতুন TLV উপাদানকে এনকোড করে যার প্রকার, ট্যাগ এবং মান একটি TLVReader অবজেক্ট থেকে নেওয়া হয়। যখন পদ্ধতিটি কল করা হয়, সরবরাহকৃত পাঠক বস্তুটি উৎস TLV উপাদানে অবস্থান করা হবে বলে আশা করা হয়। নতুন এনকোড করা উপাদানটিতে ইনপুট কন্টেইনারের মতো একই প্রকার, ট্যাগ এবং বিষয়বস্তু থাকবে। যদি সরবরাহ করা উপাদানটি একটি TLV কন্টেইনার (কাঠামো, অ্যারে বা পথ) হয়, তাহলে ধারকটির সম্পূর্ণ বিষয়বস্তু অনুলিপি করা হবে।
বিস্তারিত | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||||||||
রিটার্ন মান |
|
কপি এলিমেন্ট
WEAVE_ERROR CopyElement( uint64_t tag, TLVReader & reader )
শেষ কন্টেইনার
WEAVE_ERROR EndContainer( TLVType outerContainerType )
একটি TLV কন্টেইনার উপাদানের এনকোডিং সম্পূর্ণ করে।
EndContainer() পদ্ধতিটি একটি TLV কন্টেইনার উপাদানের এনকোডিং সম্পূর্ণ করে এবং StartContainer() এ পূর্বে কল করার পরে একটি TLVWrite অবজেক্টের অবস্থা পুনরুদ্ধার করে। StartContainer() অ্যাপ্লিকেশানগুলিতে প্রতিটি কলের জন্য অবশ্যই EndContainer()-এ একটি সংশ্লিষ্ট কল করতে হবে, StartContainer () কল দ্বারা প্রত্যাবর্তিত TLVType মান পাস করে। যখন EndContainer() ফিরে আসে, লেখক অবজেক্টটি অতিরিক্ত TLV উপাদান লিখতে ব্যবহার করা যেতে পারে যা কন্টেইনার উপাদান অনুসরণ করে।
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
চূড়ান্ত করা
WEAVE_ERROR Finalize( void )
একটি TLV এনকোডিং লেখা শেষ করুন।
Finalize() পদ্ধতি অন্তর্নিহিত আউটপুট বাফারে একটি TLV এনকোডিং লেখার প্রক্রিয়া সম্পন্ন করে। পদ্ধতিটি বাফারের বিষয়বস্তু ব্যবহার করার আগে অ্যাপ্লিকেশন দ্বারা কল করা আবশ্যক। Finalize() শুধুমাত্র তখনই কল করা যাবে যখন বর্তমান লেখকের জন্য কোন কন্টেইনার রাইটার খোলা থাকবে না। (দেখুন OpenContainer()
)।
বিস্তারিত | |||||||
---|---|---|---|---|---|---|---|
রিটার্ন মান |
|
GetContainerType
TLVType GetContainerType( void ) const
TLVWriter বর্তমানে যে পাত্রে লিখছে তার ধরন প্রদান করে।
GetContainerType() পদ্ধতি TLV কন্টেইনারের ধরন প্রদান করে যার মধ্যে TLVWriter বর্তমানে লিখছে। যদি TLVWriter একটি পাত্রের মধ্যে উপাদানগুলি না লিখছে (যেমন যদি একটি এনকোডিংয়ের বাইরের-সবচেয়ে স্তরে লেখা হয়) পদ্ধতিটি kTLVType_NotSpecified প্রদান করে।
বিস্তারিত | |
---|---|
রিটার্নস | বর্তমান কন্টেইনারের TLVType, অথবা kTLVType_NotSpecified যদি TLVWriter একটি কন্টেইনারের মধ্যে উপাদান না লিখে। |
GetLengthWritten
uint32_t GetLengthWritten( void )
লেখক শুরু হওয়ার পর থেকে লেখা মোট বাইট সংখ্যা প্রদান করে।
বিস্তারিত | |
---|---|
রিটার্নস | লেখক শুরু হওয়ার পর থেকে লেখা মোট বাইট সংখ্যা। |
এটা
void Init( uint8_t *buf, uint32_t maxLen )
এটা
void Init( PacketBuffer *buf, uint32_t maxLen )
এটা
void Init( PacketBuffer *buf, uint32_t maxLen, bool allowDiscontiguousBuffers )
এক বা একাধিক প্যাকেটবাফারে লিখতে একটি TLVWriter অবজেক্ট শুরু করে।
নির্দিষ্ট বাফারে বিদ্যমান ডেটার শেষ বাইটের পরপরই লেখা শুরু হয়। যদি allowDiscontiguousBuffers
সত্য হয় তবে অতিরিক্ত প্যাকেটবাফারগুলি বরাদ্দ করা হবে এবং সরবরাহ করা বাফারে শৃঙ্খলাবদ্ধ করা হবে যাতে লেখা ডেটার পরিমাণ মিটমাট করা যায়। যদি নির্দিষ্ট আউটপুট বাফারটি ইতিমধ্যেই বাফারগুলির একটি চেইনের প্রধান হয়, তবে নতুন বাফারগুলি বরাদ্দ করার আগে আউটপুটটি চেইনের পরবর্তী বাফারগুলিতে লেখা হবে।
বিস্তারিত | |||||||
---|---|---|---|---|---|---|---|
পরামিতি |
|
InitMalloced
void InitMalloced( uint8_t *& outBuf, uint32_t initialBufSize, uint32_t maxLen )
ডায়নামিক বাফারে লিখতে একটি TLVWriter অবজেক্ট শুরু করে।
বিস্তারিত | |||||||
---|---|---|---|---|---|---|---|
পরামিতি |
|
ওপেন কনটেইনার
WEAVE_ERROR OpenContainer( uint64_t tag, TLVType containerType, TLVWriter & containerWriter )
একটি TLV কন্টেইনার উপাদানের সদস্যদের লেখার জন্য একটি নতুন TLVWriter অবজেক্ট শুরু করে।
OpenContainer() পদ্ধতিটি একটি এনকোডিং-এ TLV কন্টেইনার উপাদান (কাঠামো, অ্যারে বা পাথ) লিখতে ব্যবহৃত হয়। পদ্ধতিটি নতুন ধারকটির ধরন এবং ট্যাগ (যদি থাকে) নেয় এবং একটি নতুন লেখক বস্তুর একটি রেফারেন্স ( কন্টেইনার লেখক ) যা কন্টেইনারের উপাদানগুলি লেখার উদ্দেশ্যে আরম্ভ করা হবে। অ্যাপ্লিকেশানগুলি কন্টেইনার রাইটার ব্যবহার করে নতুন কন্টেইনারের সদস্যদের লেখে এবং তারপর কন্টেইনার এনকোডিং সম্পূর্ণ করতে CloseContainer() এ কল করে।
কন্টেইনার লেখক খোলা থাকাকালীন, অ্যাপ্লিকেশনগুলিকে কল করা বা অন্যথায় মূল লেখকের অবস্থা পরিবর্তন করা উচিত নয়।
ধারক লেখক মূল লেখকের কাছ থেকে বিভিন্ন কনফিগারেশন বৈশিষ্ট্য উত্তরাধিকার সূত্রে প্রাপ্ত। এইগুলো:
- অন্তর্নিহিত প্রোফাইল আইডি (ImplicitProfileId)
- অ্যাপ্লিকেশন ডেটা পয়েন্টার (AppData)
- GetNewBuffer এবং FinalizeBuffer ফাংশন পয়েন্টার
বিস্তারিত | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||||
রিটার্ন মান |
|
রাখুন
WEAVE_ERROR Put( uint64_t tag, int8_t v )
একটি TLV স্বাক্ষরিত পূর্ণসংখ্যা মান এনকোড করে।
এটি একটি ওভারলোড সদস্য ফাংশন, সুবিধার জন্য প্রদান করা হয়. এটি উপরের ফাংশন থেকে শুধুমাত্র কোন আর্গুমেন্ট (গুলি) গ্রহণ করে তা থেকে আলাদা।
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
রাখুন
WEAVE_ERROR Put( uint64_t tag, int8_t v, bool preserveSize )
একটি TLV স্বাক্ষরিত পূর্ণসংখ্যা মান এনকোড করে।
এটি একটি ওভারলোড সদস্য ফাংশন, সুবিধার জন্য প্রদান করা হয়. এটি উপরের ফাংশন থেকে শুধুমাত্র কোন আর্গুমেন্ট (গুলি) গ্রহণ করে তা থেকে আলাদা।
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
রাখুন
WEAVE_ERROR Put( uint64_t tag, int16_t v )
রাখুন
WEAVE_ERROR Put( uint64_t tag, int16_t v, bool preserveSize )
রাখুন
WEAVE_ERROR Put( uint64_t tag, int32_t v )
রাখুন
WEAVE_ERROR Put( uint64_t tag, int32_t v, bool preserveSize )
রাখুন
WEAVE_ERROR Put( uint64_t tag, int64_t v )
রাখুন
WEAVE_ERROR Put( uint64_t tag, int64_t v, bool preserveSize )
রাখুন
WEAVE_ERROR Put( uint64_t tag, uint8_t v )
একটি TLV স্বাক্ষরবিহীন পূর্ণসংখ্যা মান এনকোড করে।
এটি একটি ওভারলোড সদস্য ফাংশন, সুবিধার জন্য প্রদান করা হয়. এটি উপরের ফাংশন থেকে শুধুমাত্র কোন আর্গুমেন্ট (গুলি) গ্রহণ করে তা থেকে আলাদা।
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
রাখুন
WEAVE_ERROR Put( uint64_t tag, uint8_t v, bool preserveSize )
একটি TLV স্বাক্ষরবিহীন পূর্ণসংখ্যা মান এনকোড করে।
এটি একটি ওভারলোড সদস্য ফাংশন, সুবিধার জন্য প্রদান করা হয়. এটি উপরের ফাংশন থেকে শুধুমাত্র কোন আর্গুমেন্ট (গুলি) গ্রহণ করে তা থেকে আলাদা।
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
রাখুন
WEAVE_ERROR Put( uint64_t tag, uint16_t v )
রাখুন
WEAVE_ERROR Put( uint64_t tag, uint16_t v, bool preserveSize )
রাখুন
WEAVE_ERROR Put( uint64_t tag, uint32_t v )
রাখুন
WEAVE_ERROR Put( uint64_t tag, uint32_t v, bool preserveSize )
রাখুন
WEAVE_ERROR Put( uint64_t tag, uint64_t v )
রাখুন
WEAVE_ERROR Put( uint64_t tag, uint64_t v, bool preserveSize )
রাখুন
WEAVE_ERROR Put( uint64_t tag, float v )
রাখুন
WEAVE_ERROR Put( uint64_t tag, double v )
একটি TLV ফ্লোটিং পয়েন্ট মান এনকোড করে।
এটি একটি ওভারলোড সদস্য ফাংশন, সুবিধার জন্য প্রদান করা হয়. এটি উপরের ফাংশন থেকে শুধুমাত্র কোন আর্গুমেন্ট (গুলি) গ্রহণ করে তা থেকে আলাদা।
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
পুটবুলিয়ান
WEAVE_ERROR PutBoolean( uint64_t tag, bool v )
একটি TLV বুলিয়ান মান এনকোড করে।
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
পুটবাইটস
WEAVE_ERROR PutBytes( uint64_t tag, const uint8_t *buf, uint32_t len )
একটি TLV বাইট স্ট্রিং মান এনকোড করে।
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
PutNull
WEAVE_ERROR PutNull( uint64_t tag )
Encodes a TLV null value.
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
PutPreEncodedContainer
WEAVE_ERROR PutPreEncodedContainer( uint64_t tag, TLVType containerType, const uint8_t *data, uint32_t dataLen )
Encodes a TLV container element from a pre-encoded set of member elements.
The PutPreEncodedContainer() method encodes a new TLV container element (a structure, array or path) containing a set of member elements taken from a pre-encoded buffer. The input buffer is expected to contain zero or more full-encoded TLV elements, with tags that conform to the rules associated with the specified container type (eg structure members must have tags, while array members must not).
The method encodes the entirety of the container element in one call. When PutPreEncodedContainer() returns, the writer object can be used to write additional TLV elements following the container element.
বিস্তারিত | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||||
রিটার্ন মান |
|
PutString
WEAVE_ERROR PutString( uint64_t tag, const char *buf )
Encodes a TLV UTF8 string value.
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
PutString
WEAVE_ERROR PutString( uint64_t tag, const char *buf, uint32_t len )
Encodes a TLV UTF8 string value.
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
PutStringF
WEAVE_ERROR PutStringF( uint64_t tag, const char *fmt, ... )
Encode the string output formatted according to the format in the TLV element.
PutStringF is an analog of a sprintf where the output is stored in a TLV element as opposed to a character buffer. When extended printf functionality is available, the function is able to output the result string into a discontinuous underlying storage. The implementation supports the following printf enhancements:
The platform supplies a callback-based vcbprintf
that provides the ability to call a custom callback in place of putchar.
The platform supplies a variant of vsnprintf
called vsnprintf_ex
, that behaves exactly like vsnprintf except it has provisions for omitting the first n
characters of the output.
Note that while the callback-based function may be the simplest and use the least amount of code, the vsprintf_ex
variety of functions will consume less stack.
If neither of the above is available, but platform provides malloc
the function will allocate a temporary buffer to hold the output. When the platform supplies neither enhancement to the printf family nor malloc, the output is truncated such that it fits in the continuous state in the current TLV storage
বিস্তারিত | |||||||
---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||
রিটার্ন মান |
|
StartContainer
WEAVE_ERROR StartContainer( uint64_t tag, TLVType containerType, TLVType & outerContainerType )
Begins encoding a new TLV container element.
The StartContainer() method is used to write TLV container elements (structure, arrays or paths) to an encoding. The method takes the type and tag (if any) of the new container, and a reference to a TLVType value which will be used to save the current context of the writer while it is being used to write the container.
Once the StartContainer() method returns, the application should use the current TLVWriter object to write the elements of the container. When finish, the application must call the EndContainer() method to finish the encoding of the container.
বিস্তারিত | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||||
রিটার্ন মান |
|
StartPutBytes
WEAVE_ERROR StartPutBytes( uint64_t tag, uint32_t totalLen )
Encodes a TLV byte string in multiple chunks.
This should be used with ContinuePutBytes.
বিস্তারিত | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||||||||
রিটার্ন মান |
|
VPutStringF
WEAVE_ERROR VPutStringF( uint64_t tag, const char *fmt, va_list ap )
Encode the string output formatted according to the format in the TLV element.
PutStringF is an analog of a sprintf where the output is stored in a TLV element as opposed to a character buffer. When extended printf functionality is available, the function is able to output the result string into a discontinuous underlying storage. The implementation supports the following printf enhancements:
The platform supplies a callback-based vcbprintf
that provides the ability to call a custom callback in place of putchar.
The platform supplies a variant of vsnprintf
called vsnprintf_ex
, that behaves exactly like vsnprintf except it has provisions for omitting the first n
characters of the output.
Note that while the callback-based function may be the simplest and use the least amount of code, the vsprintf_ex
variety of functions will consume less stack.
If neither of the above is available, but platform provides malloc
the function will allocate a temporary buffer to hold the output. When the platform supplies neither enhancement to the printf family nor malloc, the output is truncated such that it fits in the continuous state in the current TLV storage
বিস্তারিত | |||||||
---|---|---|---|---|---|---|---|
পরামিতি |
| ||||||
রিটার্ন মান |
|
পাবলিক স্ট্যাটিক ফাংশন
FinalizePacketBuffer
WEAVE_ERROR FinalizePacketBuffer( TLVWriter & writer, uintptr_t bufHandle, uint8_t *bufStart, uint32_t dataLen )
An implementation of a TLVWriter FinalizeBuffer function for writing to a chain of PacketBuffers.
The FinalizePacketBuffer() function performs the necessary finalization required when using a TLVWriter to write to a chain of PacketBuffers. The function is designed to be used in conjunction with the GetNewPacketBuffer() function.
See the FinalizeBufferFunct type definition for additional information on the API of the FinalizePacketBuffer() function.
GetNewBuffer_Malloced
WEAVE_ERROR GetNewBuffer_Malloced( TLVWriter & writer, uintptr_t & bufHandle, uint8_t *& bufStart, uint32_t & bufLen )
An implementation of a TLVWriter GetNewBuffer function for writing to a dynamic buffer.
The GetNewBuffer_Malloced() function supplies new output space to a TLVWriter by doubling the size of the underlying dynamic buffer as needed to store the encoding. The function is designed to be assigned to the TLVWriter GetNewBuffer function pointer.
See the GetNewBufferFunct type definition for additional information on the API of the GetNewBuffer_Malloced() function.
GetNewPacketBuffer
WEAVE_ERROR GetNewPacketBuffer( TLVWriter & writer, uintptr_t & bufHandle, uint8_t *& bufStart, uint32_t & bufLen )
An implementation of a TLVWriter GetNewBuffer function for writing to a chain of PacketBuffers.
The GetNewPacketBuffer() function supplies new output space to a TLVWriter by allocating a chain of one or more PacketBuffers as needed to store the encoding. The function is designed to be assigned to the TLVWriter GetNewBuffer function pointer.
Note that when using the GetNewPacketBuffer with a TLVWriter , the corresponding FinalizePacketBuffer() function (or an equivalent) should also be used to finalize the buffer chain.
See the GetNewBufferFunct type definition for additional information on the API of the GetNewPacketBuffer() function.
Protected functions
IsCloseContainerReserved
bool IsCloseContainerReserved( void ) const
Determine whether the container should reserve space for the CloseContainer symbol at the point of starting / opening the container.
IsContainerOpen
bool IsContainerOpen( void ) const
SetCloseContainerReserved
void SetCloseContainerReserved( bool aCloseContainerReserved )
Set whether the container should reserve the space for the CloseContainer symbol at the point of starting / opening the container.
SetContainerOpen
void SetContainerOpen( bool aContainerOpen )
WriteData
WEAVE_ERROR WriteData( const uint8_t *p, uint32_t len )
WriteElementHead
WEAVE_ERROR WriteElementHead( TLVElementType elemType, uint64_t tag, uint64_t lenOrVal )
WriteElementWithData
WEAVE_ERROR WriteElementWithData( TLVType type, uint64_t tag, const uint8_t *data, uint32_t dataLen )