102be5353SAxel Dörfler /* 202be5353SAxel Dörfler Open Tracker License 302be5353SAxel Dörfler 402be5353SAxel Dörfler Terms and Conditions 502be5353SAxel Dörfler 602be5353SAxel Dörfler Copyright (c) 1991-2000, Be Incorporated. All rights reserved. 702be5353SAxel Dörfler 802be5353SAxel Dörfler Permission is hereby granted, free of charge, to any person obtaining a copy of 902be5353SAxel Dörfler this software and associated documentation files (the "Software"), to deal in 1002be5353SAxel Dörfler the Software without restriction, including without limitation the rights to 1102be5353SAxel Dörfler use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 1202be5353SAxel Dörfler of the Software, and to permit persons to whom the Software is furnished to do 1302be5353SAxel Dörfler so, subject to the following conditions: 1402be5353SAxel Dörfler 1502be5353SAxel Dörfler The above copyright notice and this permission notice applies to all licensees 1602be5353SAxel Dörfler and shall be included in all copies or substantial portions of the Software. 1702be5353SAxel Dörfler 1802be5353SAxel Dörfler THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1902be5353SAxel Dörfler IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY, 2002be5353SAxel Dörfler FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 2102be5353SAxel Dörfler BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 2202be5353SAxel Dörfler AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION 2302be5353SAxel Dörfler WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2402be5353SAxel Dörfler 2502be5353SAxel Dörfler Except as contained in this notice, the name of Be Incorporated shall not be 2602be5353SAxel Dörfler used in advertising or otherwise to promote the sale, use or other dealings in 2702be5353SAxel Dörfler this Software without prior written authorization from Be Incorporated. 2802be5353SAxel Dörfler 2902be5353SAxel Dörfler Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks 3002be5353SAxel Dörfler of Be Incorporated in the United States and other countries. Other brand product 3102be5353SAxel Dörfler names are registered trademarks or trademarks of their respective holders. 3202be5353SAxel Dörfler All rights reserved. 3302be5353SAxel Dörfler */ 3402be5353SAxel Dörfler 3502be5353SAxel Dörfler // attribute streams allow copying/filtering/transformation of attributes 3602be5353SAxel Dörfler // between file and/or memory nodes 3702be5353SAxel Dörfler // 3802be5353SAxel Dörfler // for example one can use constructs of nodes like: 3902be5353SAxel Dörfler // 4002be5353SAxel Dörfler // destinationNode << transformer << buffer << filter << sourceNode 4102be5353SAxel Dörfler // 42ea001e58SJohn Scipione // transformer may for instance perform endian-swapping or offsetting of 43ea001e58SJohn Scipione // a B_RECT attribute filter may withold certain attributes buffer is a 44ea001e58SJohn Scipione // memory allocated snapshot of attributes, may be repeatedly streamed into 4502be5353SAxel Dörfler // other files, buffers 4602be5353SAxel Dörfler // 47ea001e58SJohn Scipione // In addition to the whacky (but usefull) << syntax, calls like Read, Write 48ea001e58SJohn Scipione // are also available 497ec2c512SJohn Scipione #ifndef _ATTRIBUTE_STREAM_H 507ec2c512SJohn Scipione #define _ATTRIBUTE_STREAM_H 5102be5353SAxel Dörfler 52b05aa8b5SJohn Scipione 537ec2c512SJohn Scipione #include <ObjectList.h> 5402be5353SAxel Dörfler #include <Node.h> 5502be5353SAxel Dörfler #include <Rect.h> 5602be5353SAxel Dörfler #include <String.h> 5702be5353SAxel Dörfler #include <TypeConstants.h> 5802be5353SAxel Dörfler 5902be5353SAxel Dörfler #include <fs_attr.h> 6002be5353SAxel Dörfler 61b05aa8b5SJohn Scipione 6202be5353SAxel Dörfler namespace BPrivate { 6302be5353SAxel Dörfler 6402be5353SAxel Dörfler struct AttributeTemplate { 6502be5353SAxel Dörfler // used for read-only attribute source 6602be5353SAxel Dörfler const char* fAttributeName; 6702be5353SAxel Dörfler uint32 fAttributeType; 6802be5353SAxel Dörfler off_t fSize; 6902be5353SAxel Dörfler const char* fBits; 7002be5353SAxel Dörfler }; 7102be5353SAxel Dörfler 7202be5353SAxel Dörfler 7302be5353SAxel Dörfler class AttributeInfo { 7402be5353SAxel Dörfler // utility class for internal attribute description 7502be5353SAxel Dörfler public: 76*49d5d59cSJohn Scipione AttributeInfo(); 77d069f646SJohn Scipione AttributeInfo(const AttributeInfo& other); 78d069f646SJohn Scipione AttributeInfo(const char* name, attr_info info); 79d069f646SJohn Scipione AttributeInfo(const char* name, uint32 type, off_t size); 8002be5353SAxel Dörfler 81d069f646SJohn Scipione void SetTo(const AttributeInfo& other); 82d069f646SJohn Scipione void SetTo(const char* name, attr_info info); 83d069f646SJohn Scipione void SetTo(const char* name, uint32 type, off_t size); 8402be5353SAxel Dörfler const char* Name() const; 8502be5353SAxel Dörfler uint32 Type() const; 8602be5353SAxel Dörfler off_t Size() const; 8702be5353SAxel Dörfler 8802be5353SAxel Dörfler private: 8902be5353SAxel Dörfler BString fName; 9002be5353SAxel Dörfler attr_info fInfo; 9102be5353SAxel Dörfler }; 9202be5353SAxel Dörfler 93b05aa8b5SJohn Scipione 9402be5353SAxel Dörfler class AttributeStreamNode { 9502be5353SAxel Dörfler public: 9602be5353SAxel Dörfler AttributeStreamNode(); 9702be5353SAxel Dörfler virtual ~AttributeStreamNode(); 9802be5353SAxel Dörfler 9902be5353SAxel Dörfler AttributeStreamNode &operator<<(AttributeStreamNode &source); 10002be5353SAxel Dörfler // workhorse call 10102be5353SAxel Dörfler // to the outside makes this node a part of the stream, passing on 10202be5353SAxel Dörfler // any data it has, gets, transforms, doesn't filter out 10302be5353SAxel Dörfler // 10402be5353SAxel Dörfler // under the hood sets up streaming into the next node; hooking 105ea001e58SJohn Scipione // up source and destination, forces the stream head to start 106ea001e58SJohn Scipione // streaming 10702be5353SAxel Dörfler 10802be5353SAxel Dörfler virtual void Rewind(); 10902be5353SAxel Dörfler // get ready to start all over again 11002be5353SAxel Dörfler virtual void MakeEmpty() {} 11102be5353SAxel Dörfler // remove any attributes the node may have 11202be5353SAxel Dörfler 11302be5353SAxel Dörfler virtual off_t Contains(const char*, uint32); 11402be5353SAxel Dörfler // returns size of attribute if found 11502be5353SAxel Dörfler 116a51764c5SJohn Scipione virtual off_t Read(const char* name, const char* foreignName, 117a51764c5SJohn Scipione uint32 type, off_t size, void* buffer, void (*swapFunc)(void*) = 0); 11802be5353SAxel Dörfler // read from this node 119a51764c5SJohn Scipione virtual off_t Write(const char* name, const char* foreignName, 120a51764c5SJohn Scipione uint32 type, off_t size, const void* buffer); 12102be5353SAxel Dörfler // write to this node 12202be5353SAxel Dörfler 12302be5353SAxel Dörfler // work calls 12402be5353SAxel Dörfler virtual bool Drive(); 12502be5353SAxel Dörfler // node at the head of the stream makes the entire stream 12602be5353SAxel Dörfler // feed it 12702be5353SAxel Dörfler virtual const AttributeInfo* Next(); 12802be5353SAxel Dörfler // give me the next attribute in the stream 12902be5353SAxel Dörfler virtual const char* Get(); 130ea001e58SJohn Scipione // give me the data of the attribute in the stream that was just 131ea001e58SJohn Scipione // returned by Next assumes there is a buffering node somewhere on the 132ea001e58SJohn Scipione // way to the source, from which the resulting buffer is borrowed 13302be5353SAxel Dörfler virtual bool Fill(char* buffer) const; 134ea001e58SJohn Scipione // fill the buffer with data of the attribute in the stream that was 135ea001e58SJohn Scipione // just returned by next <buffer> is big enough to hold the entire 136ea001e58SJohn Scipione // attribute data 13702be5353SAxel Dörfler 13802be5353SAxel Dörfler virtual bool CanFeed() const { return false; } 13902be5353SAxel Dörfler // return true if can work as a source for the entire stream 14002be5353SAxel Dörfler 14102be5353SAxel Dörfler private: 14202be5353SAxel Dörfler bool Start(); 14302be5353SAxel Dörfler // utility call, used to start up the stream by finding the ultimate 14402be5353SAxel Dörfler // target of the stream and calling Drive on it 14502be5353SAxel Dörfler 14602be5353SAxel Dörfler void Detach(); 14702be5353SAxel Dörfler 14802be5353SAxel Dörfler protected: 14902be5353SAxel Dörfler AttributeStreamNode* fReadFrom; 15002be5353SAxel Dörfler AttributeStreamNode* fWriteTo; 15102be5353SAxel Dörfler }; 15202be5353SAxel Dörfler 153b05aa8b5SJohn Scipione 15402be5353SAxel Dörfler class AttributeStreamFileNode : public AttributeStreamNode { 15502be5353SAxel Dörfler // handles reading and writing attributes to and from the 15602be5353SAxel Dörfler // stream 15702be5353SAxel Dörfler public: 15802be5353SAxel Dörfler AttributeStreamFileNode(); 15902be5353SAxel Dörfler AttributeStreamFileNode(BNode*); 16002be5353SAxel Dörfler 16102be5353SAxel Dörfler virtual void MakeEmpty(); 16202be5353SAxel Dörfler virtual void Rewind(); 16302be5353SAxel Dörfler virtual off_t Contains(const char* name, uint32 type); 164b05aa8b5SJohn Scipione virtual off_t Read(const char* name, const char* foreignName, uint32 type, 165b05aa8b5SJohn Scipione off_t size, void* buffer, void (*swapFunc)(void*) = 0); 166b05aa8b5SJohn Scipione virtual off_t Write(const char* name, const char* foreignName, uint32 type, 167b05aa8b5SJohn Scipione off_t size, const void* buffer); 16802be5353SAxel Dörfler 16902be5353SAxel Dörfler void SetTo(BNode*); 17002be5353SAxel Dörfler 17102be5353SAxel Dörfler BNode* Node() 17202be5353SAxel Dörfler { return fNode; } 17302be5353SAxel Dörfler 17402be5353SAxel Dörfler protected: 17502be5353SAxel Dörfler virtual bool CanFeed() const { return true; } 17602be5353SAxel Dörfler 17702be5353SAxel Dörfler virtual bool Drive(); 17802be5353SAxel Dörfler // give me all the attributes, I'll write them into myself 17902be5353SAxel Dörfler virtual const AttributeInfo* Next(); 18002be5353SAxel Dörfler // return the info for the next attribute I can read for you 18102be5353SAxel Dörfler virtual const char* Get(); 18202be5353SAxel Dörfler virtual bool Fill(char* buffer) const; 18302be5353SAxel Dörfler 18402be5353SAxel Dörfler private: 18502be5353SAxel Dörfler AttributeInfo fCurrentAttr; 18602be5353SAxel Dörfler BNode* fNode; 18702be5353SAxel Dörfler 18802be5353SAxel Dörfler typedef AttributeStreamNode _inherited; 18902be5353SAxel Dörfler }; 19002be5353SAxel Dörfler 191b05aa8b5SJohn Scipione 19202be5353SAxel Dörfler class AttributeStreamMemoryNode : public AttributeStreamNode { 19302be5353SAxel Dörfler // in memory attribute buffer; can be both target of writing and source 19402be5353SAxel Dörfler // of reading at the same time 19502be5353SAxel Dörfler public: 19602be5353SAxel Dörfler AttributeStreamMemoryNode(); 19702be5353SAxel Dörfler 19802be5353SAxel Dörfler virtual void MakeEmpty(); 19902be5353SAxel Dörfler virtual off_t Contains(const char* name, uint32 type); 200ea001e58SJohn Scipione virtual off_t Read(const char* name, const char* foreignName, 201ea001e58SJohn Scipione uint32 type, off_t size, void* buffer, void (*swapFunc)(void*) = 0); 202ea001e58SJohn Scipione virtual off_t Write(const char* name, const char* foreignName, 203ea001e58SJohn Scipione uint32 type, off_t size, const void* buffer); 20402be5353SAxel Dörfler 20502be5353SAxel Dörfler protected: 20602be5353SAxel Dörfler virtual bool CanFeed() const { return true; } 20702be5353SAxel Dörfler virtual void Rewind(); 20802be5353SAxel Dörfler virtual bool Drive(); 20902be5353SAxel Dörfler virtual const AttributeInfo* Next(); 21002be5353SAxel Dörfler virtual const char* Get(); 21102be5353SAxel Dörfler virtual bool Fill(char* buffer) const; 21202be5353SAxel Dörfler 21302be5353SAxel Dörfler class AttrNode { 21402be5353SAxel Dörfler public: 21502be5353SAxel Dörfler AttrNode(const char* name, uint32 type, off_t size, char* data) 2169437e677SJohn Scipione : 2179437e677SJohn Scipione fAttr(name, type, size), 21802be5353SAxel Dörfler fData(data) 21902be5353SAxel Dörfler { 22002be5353SAxel Dörfler } 22102be5353SAxel Dörfler 22202be5353SAxel Dörfler ~AttrNode() 22302be5353SAxel Dörfler { 22402be5353SAxel Dörfler delete[] fData; 22502be5353SAxel Dörfler } 22602be5353SAxel Dörfler 22702be5353SAxel Dörfler AttributeInfo fAttr; 22802be5353SAxel Dörfler char* fData; 22902be5353SAxel Dörfler }; 23002be5353SAxel Dörfler 23102be5353SAxel Dörfler // utility calls 23202be5353SAxel Dörfler virtual AttrNode* BufferingGet(); 23302be5353SAxel Dörfler virtual AttrNode* BufferingGet(const char* name, uint32 type, off_t size); 23402be5353SAxel Dörfler int32 Find(const char* name, uint32 type) const; 23502be5353SAxel Dörfler 23602be5353SAxel Dörfler private: 23702be5353SAxel Dörfler BObjectList<AttrNode> fAttributes; 23802be5353SAxel Dörfler int32 fCurrentIndex; 23902be5353SAxel Dörfler 24002be5353SAxel Dörfler typedef AttributeStreamNode _inherited; 24102be5353SAxel Dörfler }; 24202be5353SAxel Dörfler 243b05aa8b5SJohn Scipione 24402be5353SAxel Dörfler class AttributeStreamTemplateNode : public AttributeStreamNode { 24502be5353SAxel Dörfler // in read-only memory attribute source 24602be5353SAxel Dörfler // can only be used as a source for Next and Get 24702be5353SAxel Dörfler public: 24802be5353SAxel Dörfler AttributeStreamTemplateNode(const AttributeTemplate*, int32 count); 24902be5353SAxel Dörfler 25002be5353SAxel Dörfler virtual off_t Contains(const char* name, uint32 type); 25102be5353SAxel Dörfler 25202be5353SAxel Dörfler protected: 25302be5353SAxel Dörfler virtual bool CanFeed() const { return true; } 25402be5353SAxel Dörfler virtual void Rewind(); 25502be5353SAxel Dörfler virtual const AttributeInfo* Next(); 25602be5353SAxel Dörfler virtual const char* Get(); 25702be5353SAxel Dörfler virtual bool Fill(char* buffer) const; 25802be5353SAxel Dörfler 25902be5353SAxel Dörfler int32 Find(const char* name, uint32 type) const; 26002be5353SAxel Dörfler 26102be5353SAxel Dörfler private: 26202be5353SAxel Dörfler AttributeInfo fCurrentAttr; 26302be5353SAxel Dörfler const AttributeTemplate* fAttributes; 26402be5353SAxel Dörfler int32 fCurrentIndex; 26502be5353SAxel Dörfler int32 fCount; 26602be5353SAxel Dörfler 26702be5353SAxel Dörfler typedef AttributeStreamNode _inherited; 26802be5353SAxel Dörfler }; 26902be5353SAxel Dörfler 270b05aa8b5SJohn Scipione 27102be5353SAxel Dörfler class AttributeStreamFilterNode : public AttributeStreamNode { 27202be5353SAxel Dörfler // filter node may not pass thru specified attributes 27302be5353SAxel Dörfler public: 27402be5353SAxel Dörfler AttributeStreamFilterNode() 27502be5353SAxel Dörfler {} 27602be5353SAxel Dörfler virtual off_t Contains(const char* name, uint32 type); 277ea001e58SJohn Scipione virtual off_t Read(const char* name, const char* foreignName, 278ea001e58SJohn Scipione uint32 type, off_t size, void* buffer, void (*swapFunc)(void*) = 0); 279ea001e58SJohn Scipione virtual off_t Write(const char* name, const char* foreignName, 280ea001e58SJohn Scipione uint32 type, off_t size, const void* buffer); 28102be5353SAxel Dörfler 28202be5353SAxel Dörfler protected: 28302be5353SAxel Dörfler virtual bool Reject(const char* name, uint32 type, off_t size); 28402be5353SAxel Dörfler // override to implement filtering 28502be5353SAxel Dörfler virtual const AttributeInfo* Next(); 28602be5353SAxel Dörfler 28702be5353SAxel Dörfler private: 28802be5353SAxel Dörfler typedef AttributeStreamNode _inherited; 28902be5353SAxel Dörfler }; 29002be5353SAxel Dörfler 291b05aa8b5SJohn Scipione 29202be5353SAxel Dörfler class NamesToAcceptAttrFilter : public AttributeStreamFilterNode { 29302be5353SAxel Dörfler // filter node that only passes thru attributes that match 29402be5353SAxel Dörfler // a list of names 29502be5353SAxel Dörfler public: 29602be5353SAxel Dörfler NamesToAcceptAttrFilter(const char**); 29702be5353SAxel Dörfler 29802be5353SAxel Dörfler protected: 29902be5353SAxel Dörfler virtual bool Reject(const char* name, uint32 type, off_t size); 30002be5353SAxel Dörfler 30102be5353SAxel Dörfler private: 30202be5353SAxel Dörfler const char** fNameList; 30302be5353SAxel Dörfler }; 30402be5353SAxel Dörfler 305b05aa8b5SJohn Scipione 30602be5353SAxel Dörfler class SelectiveAttributeTransformer : public AttributeStreamNode { 30702be5353SAxel Dörfler // node applies a transformation on specified attributes 30802be5353SAxel Dörfler public: 309a51764c5SJohn Scipione SelectiveAttributeTransformer(const char* attributeName, 310a51764c5SJohn Scipione bool (*)(const char*, uint32 , off_t , void*, void*), void* params); 31102be5353SAxel Dörfler virtual ~SelectiveAttributeTransformer(); 31202be5353SAxel Dörfler 313a51764c5SJohn Scipione virtual off_t Read(const char* name, const char* foreignName, uint32 type, 314a51764c5SJohn Scipione off_t size, void* buffer, void (*swapFunc)(void*) = 0); 31502be5353SAxel Dörfler 31602be5353SAxel Dörfler virtual void Rewind(); 31702be5353SAxel Dörfler 31802be5353SAxel Dörfler protected: 319a51764c5SJohn Scipione virtual bool WillTransform(const char* name, uint32 type, off_t size, 320a51764c5SJohn Scipione const char* data) const; 321ea001e58SJohn Scipione // override to implement filtering, should only return true if 322ea001e58SJohn Scipione // transformation will occur 323a51764c5SJohn Scipione virtual char* CopyAndApplyTransformer(const char* name, uint32 type, 324a51764c5SJohn Scipione off_t size, const char* data); 32502be5353SAxel Dörfler // makes a copy of data 326a51764c5SJohn Scipione virtual bool ApplyTransformer(const char* name, uint32 type, off_t size, 327a51764c5SJohn Scipione char* data); 32802be5353SAxel Dörfler // transforms in place 32902be5353SAxel Dörfler virtual const AttributeInfo* Next(); 33002be5353SAxel Dörfler virtual const char* Get(); 33102be5353SAxel Dörfler 33202be5353SAxel Dörfler private: 33302be5353SAxel Dörfler AttributeInfo fCurrentAttr; 33402be5353SAxel Dörfler const char* fAttributeNameToTransform; 33502be5353SAxel Dörfler bool (*fTransformFunc)(const char*, uint32 , off_t , void*, void*); 33602be5353SAxel Dörfler void* fTransformParams; 33702be5353SAxel Dörfler 33802be5353SAxel Dörfler BObjectList<char> fTransformedBuffers; 33902be5353SAxel Dörfler 34002be5353SAxel Dörfler typedef AttributeStreamNode _inherited; 34102be5353SAxel Dörfler }; 34202be5353SAxel Dörfler 343b05aa8b5SJohn Scipione 34402be5353SAxel Dörfler template <class Type> 34502be5353SAxel Dörfler class AttributeStreamConstValue : public AttributeStreamNode { 34602be5353SAxel Dörfler public: 347a51764c5SJohn Scipione AttributeStreamConstValue(const char* name, uint32 attributeType, 348a51764c5SJohn Scipione Type value); 34902be5353SAxel Dörfler 350b05aa8b5SJohn Scipione protected: 35102be5353SAxel Dörfler virtual bool CanFeed() const { return true; } 35202be5353SAxel Dörfler virtual void Rewind() { fRewound = true; } 35302be5353SAxel Dörfler virtual const AttributeInfo* Next(); 35402be5353SAxel Dörfler virtual const char* Get(); 35502be5353SAxel Dörfler virtual bool Fill(char* buffer) const; 35602be5353SAxel Dörfler 35702be5353SAxel Dörfler int32 Find(const char* name, uint32 type) const; 35802be5353SAxel Dörfler 35902be5353SAxel Dörfler private: 36002be5353SAxel Dörfler AttributeInfo fAttr; 36102be5353SAxel Dörfler Type fValue; 36202be5353SAxel Dörfler bool fRewound; 36302be5353SAxel Dörfler 36402be5353SAxel Dörfler typedef AttributeStreamNode _inherited; 36502be5353SAxel Dörfler }; 36602be5353SAxel Dörfler 367b05aa8b5SJohn Scipione 36802be5353SAxel Dörfler template<class Type> 36902be5353SAxel Dörfler AttributeStreamConstValue<Type>::AttributeStreamConstValue(const char* name, 37002be5353SAxel Dörfler uint32 attributeType, Type value) 3717ec2c512SJohn Scipione : 3727ec2c512SJohn Scipione fAttr(name, attributeType, sizeof(Type)), 37302be5353SAxel Dörfler fValue(value), 37402be5353SAxel Dörfler fRewound(true) 37502be5353SAxel Dörfler { 37602be5353SAxel Dörfler } 37702be5353SAxel Dörfler 378b05aa8b5SJohn Scipione 37902be5353SAxel Dörfler template<class Type> 38002be5353SAxel Dörfler const AttributeInfo* 38102be5353SAxel Dörfler AttributeStreamConstValue<Type>::Next() 38202be5353SAxel Dörfler { 38302be5353SAxel Dörfler if (!fRewound) 38402be5353SAxel Dörfler return NULL; 38502be5353SAxel Dörfler 38602be5353SAxel Dörfler fRewound = false; 38702be5353SAxel Dörfler return &fAttr; 38802be5353SAxel Dörfler } 38902be5353SAxel Dörfler 390b05aa8b5SJohn Scipione 39102be5353SAxel Dörfler template<class Type> 39202be5353SAxel Dörfler const char* 39302be5353SAxel Dörfler AttributeStreamConstValue<Type>::Get() 39402be5353SAxel Dörfler { 39502be5353SAxel Dörfler return (const char*)&fValue; 39602be5353SAxel Dörfler } 39702be5353SAxel Dörfler 398b05aa8b5SJohn Scipione 39902be5353SAxel Dörfler template<class Type> 40002be5353SAxel Dörfler bool 40102be5353SAxel Dörfler AttributeStreamConstValue<Type>::Fill(char* buffer) const 40202be5353SAxel Dörfler { 40302be5353SAxel Dörfler memcpy(buffer, &fValue, sizeof(Type)); 40402be5353SAxel Dörfler return true; 40502be5353SAxel Dörfler } 40602be5353SAxel Dörfler 407b05aa8b5SJohn Scipione 40802be5353SAxel Dörfler template<class Type> 40902be5353SAxel Dörfler int32 41002be5353SAxel Dörfler AttributeStreamConstValue<Type>::Find(const char* name, uint32 type) const 41102be5353SAxel Dörfler { 412fc7c01a1SRene Gollent if (strcmp(fAttr.Name(), name) == 0 && type == fAttr.Type()) 41302be5353SAxel Dörfler return 0; 41402be5353SAxel Dörfler 41502be5353SAxel Dörfler return -1; 41602be5353SAxel Dörfler } 41702be5353SAxel Dörfler 418b05aa8b5SJohn Scipione 41902be5353SAxel Dörfler class AttributeStreamBoolValue : public AttributeStreamConstValue<bool> { 42002be5353SAxel Dörfler public: 42102be5353SAxel Dörfler AttributeStreamBoolValue(const char* name, bool value) 4227ec2c512SJohn Scipione : 4237ec2c512SJohn Scipione AttributeStreamConstValue<bool>(name, B_BOOL_TYPE, value) 4247ec2c512SJohn Scipione { 4257ec2c512SJohn Scipione } 42602be5353SAxel Dörfler }; 42702be5353SAxel Dörfler 428b05aa8b5SJohn Scipione 42902be5353SAxel Dörfler class AttributeStreamInt32Value : public AttributeStreamConstValue<int32> { 43002be5353SAxel Dörfler public: 43102be5353SAxel Dörfler AttributeStreamInt32Value(const char* name, int32 value) 4327ec2c512SJohn Scipione : 4337ec2c512SJohn Scipione AttributeStreamConstValue<int32>(name, B_INT32_TYPE, value) 4347ec2c512SJohn Scipione { 4357ec2c512SJohn Scipione } 43602be5353SAxel Dörfler }; 43702be5353SAxel Dörfler 438b05aa8b5SJohn Scipione 43902be5353SAxel Dörfler class AttributeStreamInt64Value : public AttributeStreamConstValue<int64> { 44002be5353SAxel Dörfler public: 44102be5353SAxel Dörfler AttributeStreamInt64Value(const char* name, int64 value) 4427ec2c512SJohn Scipione : 4437ec2c512SJohn Scipione AttributeStreamConstValue<int64>(name, B_INT64_TYPE, value) 4447ec2c512SJohn Scipione { 4457ec2c512SJohn Scipione } 44602be5353SAxel Dörfler }; 44702be5353SAxel Dörfler 448b05aa8b5SJohn Scipione 44902be5353SAxel Dörfler class AttributeStreamRectValue : public AttributeStreamConstValue<BRect> { 45002be5353SAxel Dörfler public: 45102be5353SAxel Dörfler AttributeStreamRectValue(const char* name, BRect value) 4527ec2c512SJohn Scipione : 4537ec2c512SJohn Scipione AttributeStreamConstValue<BRect>(name, B_RECT_TYPE, value) 4547ec2c512SJohn Scipione { 4557ec2c512SJohn Scipione } 45602be5353SAxel Dörfler }; 45702be5353SAxel Dörfler 458b05aa8b5SJohn Scipione 45902be5353SAxel Dörfler class AttributeStreamFloatValue : public AttributeStreamConstValue<float> { 46002be5353SAxel Dörfler public: 46102be5353SAxel Dörfler AttributeStreamFloatValue(const char* name, float value) 4627ec2c512SJohn Scipione : 4637ec2c512SJohn Scipione AttributeStreamConstValue<float>(name, B_FLOAT_TYPE, value) 4647ec2c512SJohn Scipione { 4657ec2c512SJohn Scipione } 46602be5353SAxel Dörfler }; 46702be5353SAxel Dörfler 468b05aa8b5SJohn Scipione } // namespace BPrivate 46902be5353SAxel Dörfler 47002be5353SAxel Dörfler using namespace BPrivate; 47102be5353SAxel Dörfler 4727ec2c512SJohn Scipione 4737ec2c512SJohn Scipione #endif // _ATTRIBUTE_STREAM_H 474