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: 7602be5353SAxel Dörfler AttributeInfo() 7702be5353SAxel Dörfler {} 78*d069f646SJohn Scipione AttributeInfo(const AttributeInfo& other); 79*d069f646SJohn Scipione AttributeInfo(const char* name, attr_info info); 80*d069f646SJohn Scipione AttributeInfo(const char* name, uint32 type, off_t size); 8102be5353SAxel Dörfler 82*d069f646SJohn Scipione void SetTo(const AttributeInfo& other); 83*d069f646SJohn Scipione void SetTo(const char* name, attr_info info); 84*d069f646SJohn Scipione void SetTo(const char* name, uint32 type, off_t size); 8502be5353SAxel Dörfler const char* Name() const; 8602be5353SAxel Dörfler uint32 Type() const; 8702be5353SAxel Dörfler off_t Size() const; 8802be5353SAxel Dörfler 8902be5353SAxel Dörfler private: 9002be5353SAxel Dörfler BString fName; 9102be5353SAxel Dörfler attr_info fInfo; 9202be5353SAxel Dörfler }; 9302be5353SAxel Dörfler 94b05aa8b5SJohn Scipione 9502be5353SAxel Dörfler class AttributeStreamNode { 9602be5353SAxel Dörfler public: 9702be5353SAxel Dörfler AttributeStreamNode(); 9802be5353SAxel Dörfler virtual ~AttributeStreamNode(); 9902be5353SAxel Dörfler 10002be5353SAxel Dörfler AttributeStreamNode &operator<<(AttributeStreamNode &source); 10102be5353SAxel Dörfler // workhorse call 10202be5353SAxel Dörfler // to the outside makes this node a part of the stream, passing on 10302be5353SAxel Dörfler // any data it has, gets, transforms, doesn't filter out 10402be5353SAxel Dörfler // 10502be5353SAxel Dörfler // under the hood sets up streaming into the next node; hooking 106ea001e58SJohn Scipione // up source and destination, forces the stream head to start 107ea001e58SJohn Scipione // streaming 10802be5353SAxel Dörfler 10902be5353SAxel Dörfler virtual void Rewind(); 11002be5353SAxel Dörfler // get ready to start all over again 11102be5353SAxel Dörfler virtual void MakeEmpty() {} 11202be5353SAxel Dörfler // remove any attributes the node may have 11302be5353SAxel Dörfler 11402be5353SAxel Dörfler virtual off_t Contains(const char*, uint32); 11502be5353SAxel Dörfler // returns size of attribute if found 11602be5353SAxel Dörfler 117a51764c5SJohn Scipione virtual off_t Read(const char* name, const char* foreignName, 118a51764c5SJohn Scipione uint32 type, off_t size, void* buffer, void (*swapFunc)(void*) = 0); 11902be5353SAxel Dörfler // read from this node 120a51764c5SJohn Scipione virtual off_t Write(const char* name, const char* foreignName, 121a51764c5SJohn Scipione uint32 type, off_t size, const void* buffer); 12202be5353SAxel Dörfler // write to this node 12302be5353SAxel Dörfler 12402be5353SAxel Dörfler // work calls 12502be5353SAxel Dörfler virtual bool Drive(); 12602be5353SAxel Dörfler // node at the head of the stream makes the entire stream 12702be5353SAxel Dörfler // feed it 12802be5353SAxel Dörfler virtual const AttributeInfo* Next(); 12902be5353SAxel Dörfler // give me the next attribute in the stream 13002be5353SAxel Dörfler virtual const char* Get(); 131ea001e58SJohn Scipione // give me the data of the attribute in the stream that was just 132ea001e58SJohn Scipione // returned by Next assumes there is a buffering node somewhere on the 133ea001e58SJohn Scipione // way to the source, from which the resulting buffer is borrowed 13402be5353SAxel Dörfler virtual bool Fill(char* buffer) const; 135ea001e58SJohn Scipione // fill the buffer with data of the attribute in the stream that was 136ea001e58SJohn Scipione // just returned by next <buffer> is big enough to hold the entire 137ea001e58SJohn Scipione // attribute data 13802be5353SAxel Dörfler 13902be5353SAxel Dörfler virtual bool CanFeed() const { return false; } 14002be5353SAxel Dörfler // return true if can work as a source for the entire stream 14102be5353SAxel Dörfler 14202be5353SAxel Dörfler private: 14302be5353SAxel Dörfler bool Start(); 14402be5353SAxel Dörfler // utility call, used to start up the stream by finding the ultimate 14502be5353SAxel Dörfler // target of the stream and calling Drive on it 14602be5353SAxel Dörfler 14702be5353SAxel Dörfler void Detach(); 14802be5353SAxel Dörfler 14902be5353SAxel Dörfler protected: 15002be5353SAxel Dörfler AttributeStreamNode* fReadFrom; 15102be5353SAxel Dörfler AttributeStreamNode* fWriteTo; 15202be5353SAxel Dörfler }; 15302be5353SAxel Dörfler 154b05aa8b5SJohn Scipione 15502be5353SAxel Dörfler class AttributeStreamFileNode : public AttributeStreamNode { 15602be5353SAxel Dörfler // handles reading and writing attributes to and from the 15702be5353SAxel Dörfler // stream 15802be5353SAxel Dörfler public: 15902be5353SAxel Dörfler AttributeStreamFileNode(); 16002be5353SAxel Dörfler AttributeStreamFileNode(BNode*); 16102be5353SAxel Dörfler 16202be5353SAxel Dörfler virtual void MakeEmpty(); 16302be5353SAxel Dörfler virtual void Rewind(); 16402be5353SAxel Dörfler virtual off_t Contains(const char* name, uint32 type); 165b05aa8b5SJohn Scipione virtual off_t Read(const char* name, const char* foreignName, uint32 type, 166b05aa8b5SJohn Scipione off_t size, void* buffer, void (*swapFunc)(void*) = 0); 167b05aa8b5SJohn Scipione virtual off_t Write(const char* name, const char* foreignName, uint32 type, 168b05aa8b5SJohn Scipione off_t size, const void* buffer); 16902be5353SAxel Dörfler 17002be5353SAxel Dörfler void SetTo(BNode*); 17102be5353SAxel Dörfler 17202be5353SAxel Dörfler BNode* Node() 17302be5353SAxel Dörfler { return fNode; } 17402be5353SAxel Dörfler 17502be5353SAxel Dörfler protected: 17602be5353SAxel Dörfler virtual bool CanFeed() const { return true; } 17702be5353SAxel Dörfler 17802be5353SAxel Dörfler virtual bool Drive(); 17902be5353SAxel Dörfler // give me all the attributes, I'll write them into myself 18002be5353SAxel Dörfler virtual const AttributeInfo* Next(); 18102be5353SAxel Dörfler // return the info for the next attribute I can read for you 18202be5353SAxel Dörfler virtual const char* Get(); 18302be5353SAxel Dörfler virtual bool Fill(char* buffer) const; 18402be5353SAxel Dörfler 18502be5353SAxel Dörfler private: 18602be5353SAxel Dörfler AttributeInfo fCurrentAttr; 18702be5353SAxel Dörfler BNode* fNode; 18802be5353SAxel Dörfler 18902be5353SAxel Dörfler typedef AttributeStreamNode _inherited; 19002be5353SAxel Dörfler }; 19102be5353SAxel Dörfler 192b05aa8b5SJohn Scipione 19302be5353SAxel Dörfler class AttributeStreamMemoryNode : public AttributeStreamNode { 19402be5353SAxel Dörfler // in memory attribute buffer; can be both target of writing and source 19502be5353SAxel Dörfler // of reading at the same time 19602be5353SAxel Dörfler public: 19702be5353SAxel Dörfler AttributeStreamMemoryNode(); 19802be5353SAxel Dörfler 19902be5353SAxel Dörfler virtual void MakeEmpty(); 20002be5353SAxel Dörfler virtual off_t Contains(const char* name, uint32 type); 201ea001e58SJohn Scipione virtual off_t Read(const char* name, const char* foreignName, 202ea001e58SJohn Scipione uint32 type, off_t size, void* buffer, void (*swapFunc)(void*) = 0); 203ea001e58SJohn Scipione virtual off_t Write(const char* name, const char* foreignName, 204ea001e58SJohn Scipione uint32 type, off_t size, const void* buffer); 20502be5353SAxel Dörfler 20602be5353SAxel Dörfler protected: 20702be5353SAxel Dörfler virtual bool CanFeed() const { return true; } 20802be5353SAxel Dörfler virtual void Rewind(); 20902be5353SAxel Dörfler virtual bool Drive(); 21002be5353SAxel Dörfler virtual const AttributeInfo* Next(); 21102be5353SAxel Dörfler virtual const char* Get(); 21202be5353SAxel Dörfler virtual bool Fill(char* buffer) const; 21302be5353SAxel Dörfler 21402be5353SAxel Dörfler class AttrNode { 21502be5353SAxel Dörfler public: 21602be5353SAxel Dörfler AttrNode(const char* name, uint32 type, off_t size, char* data) 2179437e677SJohn Scipione : 2189437e677SJohn Scipione fAttr(name, type, size), 21902be5353SAxel Dörfler fData(data) 22002be5353SAxel Dörfler { 22102be5353SAxel Dörfler } 22202be5353SAxel Dörfler 22302be5353SAxel Dörfler ~AttrNode() 22402be5353SAxel Dörfler { 22502be5353SAxel Dörfler delete[] fData; 22602be5353SAxel Dörfler } 22702be5353SAxel Dörfler 22802be5353SAxel Dörfler AttributeInfo fAttr; 22902be5353SAxel Dörfler char* fData; 23002be5353SAxel Dörfler }; 23102be5353SAxel Dörfler 23202be5353SAxel Dörfler // utility calls 23302be5353SAxel Dörfler virtual AttrNode* BufferingGet(); 23402be5353SAxel Dörfler virtual AttrNode* BufferingGet(const char* name, uint32 type, off_t size); 23502be5353SAxel Dörfler int32 Find(const char* name, uint32 type) const; 23602be5353SAxel Dörfler 23702be5353SAxel Dörfler private: 23802be5353SAxel Dörfler BObjectList<AttrNode> fAttributes; 23902be5353SAxel Dörfler int32 fCurrentIndex; 24002be5353SAxel Dörfler 24102be5353SAxel Dörfler typedef AttributeStreamNode _inherited; 24202be5353SAxel Dörfler }; 24302be5353SAxel Dörfler 244b05aa8b5SJohn Scipione 24502be5353SAxel Dörfler class AttributeStreamTemplateNode : public AttributeStreamNode { 24602be5353SAxel Dörfler // in read-only memory attribute source 24702be5353SAxel Dörfler // can only be used as a source for Next and Get 24802be5353SAxel Dörfler public: 24902be5353SAxel Dörfler AttributeStreamTemplateNode(const AttributeTemplate*, int32 count); 25002be5353SAxel Dörfler 25102be5353SAxel Dörfler virtual off_t Contains(const char* name, uint32 type); 25202be5353SAxel Dörfler 25302be5353SAxel Dörfler protected: 25402be5353SAxel Dörfler virtual bool CanFeed() const { return true; } 25502be5353SAxel Dörfler virtual void Rewind(); 25602be5353SAxel Dörfler virtual const AttributeInfo* Next(); 25702be5353SAxel Dörfler virtual const char* Get(); 25802be5353SAxel Dörfler virtual bool Fill(char* buffer) const; 25902be5353SAxel Dörfler 26002be5353SAxel Dörfler int32 Find(const char* name, uint32 type) const; 26102be5353SAxel Dörfler 26202be5353SAxel Dörfler private: 26302be5353SAxel Dörfler AttributeInfo fCurrentAttr; 26402be5353SAxel Dörfler const AttributeTemplate* fAttributes; 26502be5353SAxel Dörfler int32 fCurrentIndex; 26602be5353SAxel Dörfler int32 fCount; 26702be5353SAxel Dörfler 26802be5353SAxel Dörfler typedef AttributeStreamNode _inherited; 26902be5353SAxel Dörfler }; 27002be5353SAxel Dörfler 271b05aa8b5SJohn Scipione 27202be5353SAxel Dörfler class AttributeStreamFilterNode : public AttributeStreamNode { 27302be5353SAxel Dörfler // filter node may not pass thru specified attributes 27402be5353SAxel Dörfler public: 27502be5353SAxel Dörfler AttributeStreamFilterNode() 27602be5353SAxel Dörfler {} 27702be5353SAxel Dörfler virtual off_t Contains(const char* name, uint32 type); 278ea001e58SJohn Scipione virtual off_t Read(const char* name, const char* foreignName, 279ea001e58SJohn Scipione uint32 type, off_t size, void* buffer, void (*swapFunc)(void*) = 0); 280ea001e58SJohn Scipione virtual off_t Write(const char* name, const char* foreignName, 281ea001e58SJohn Scipione uint32 type, off_t size, const void* buffer); 28202be5353SAxel Dörfler 28302be5353SAxel Dörfler protected: 28402be5353SAxel Dörfler virtual bool Reject(const char* name, uint32 type, off_t size); 28502be5353SAxel Dörfler // override to implement filtering 28602be5353SAxel Dörfler virtual const AttributeInfo* Next(); 28702be5353SAxel Dörfler 28802be5353SAxel Dörfler private: 28902be5353SAxel Dörfler typedef AttributeStreamNode _inherited; 29002be5353SAxel Dörfler }; 29102be5353SAxel Dörfler 292b05aa8b5SJohn Scipione 29302be5353SAxel Dörfler class NamesToAcceptAttrFilter : public AttributeStreamFilterNode { 29402be5353SAxel Dörfler // filter node that only passes thru attributes that match 29502be5353SAxel Dörfler // a list of names 29602be5353SAxel Dörfler public: 29702be5353SAxel Dörfler NamesToAcceptAttrFilter(const char**); 29802be5353SAxel Dörfler 29902be5353SAxel Dörfler protected: 30002be5353SAxel Dörfler virtual bool Reject(const char* name, uint32 type, off_t size); 30102be5353SAxel Dörfler 30202be5353SAxel Dörfler private: 30302be5353SAxel Dörfler const char** fNameList; 30402be5353SAxel Dörfler }; 30502be5353SAxel Dörfler 306b05aa8b5SJohn Scipione 30702be5353SAxel Dörfler class SelectiveAttributeTransformer : public AttributeStreamNode { 30802be5353SAxel Dörfler // node applies a transformation on specified attributes 30902be5353SAxel Dörfler public: 310a51764c5SJohn Scipione SelectiveAttributeTransformer(const char* attributeName, 311a51764c5SJohn Scipione bool (*)(const char*, uint32 , off_t , void*, void*), void* params); 31202be5353SAxel Dörfler virtual ~SelectiveAttributeTransformer(); 31302be5353SAxel Dörfler 314a51764c5SJohn Scipione virtual off_t Read(const char* name, const char* foreignName, uint32 type, 315a51764c5SJohn Scipione off_t size, void* buffer, void (*swapFunc)(void*) = 0); 31602be5353SAxel Dörfler 31702be5353SAxel Dörfler virtual void Rewind(); 31802be5353SAxel Dörfler 31902be5353SAxel Dörfler protected: 320a51764c5SJohn Scipione virtual bool WillTransform(const char* name, uint32 type, off_t size, 321a51764c5SJohn Scipione const char* data) const; 322ea001e58SJohn Scipione // override to implement filtering, should only return true if 323ea001e58SJohn Scipione // transformation will occur 324a51764c5SJohn Scipione virtual char* CopyAndApplyTransformer(const char* name, uint32 type, 325a51764c5SJohn Scipione off_t size, const char* data); 32602be5353SAxel Dörfler // makes a copy of data 327a51764c5SJohn Scipione virtual bool ApplyTransformer(const char* name, uint32 type, off_t size, 328a51764c5SJohn Scipione char* data); 32902be5353SAxel Dörfler // transforms in place 33002be5353SAxel Dörfler virtual const AttributeInfo* Next(); 33102be5353SAxel Dörfler virtual const char* Get(); 33202be5353SAxel Dörfler 33302be5353SAxel Dörfler private: 33402be5353SAxel Dörfler AttributeInfo fCurrentAttr; 33502be5353SAxel Dörfler const char* fAttributeNameToTransform; 33602be5353SAxel Dörfler bool (*fTransformFunc)(const char*, uint32 , off_t , void*, void*); 33702be5353SAxel Dörfler void* fTransformParams; 33802be5353SAxel Dörfler 33902be5353SAxel Dörfler BObjectList<char> fTransformedBuffers; 34002be5353SAxel Dörfler 34102be5353SAxel Dörfler typedef AttributeStreamNode _inherited; 34202be5353SAxel Dörfler }; 34302be5353SAxel Dörfler 344b05aa8b5SJohn Scipione 34502be5353SAxel Dörfler template <class Type> 34602be5353SAxel Dörfler class AttributeStreamConstValue : public AttributeStreamNode { 34702be5353SAxel Dörfler public: 348a51764c5SJohn Scipione AttributeStreamConstValue(const char* name, uint32 attributeType, 349a51764c5SJohn Scipione Type value); 35002be5353SAxel Dörfler 351b05aa8b5SJohn Scipione protected: 35202be5353SAxel Dörfler virtual bool CanFeed() const { return true; } 35302be5353SAxel Dörfler virtual void Rewind() { fRewound = true; } 35402be5353SAxel Dörfler virtual const AttributeInfo* Next(); 35502be5353SAxel Dörfler virtual const char* Get(); 35602be5353SAxel Dörfler virtual bool Fill(char* buffer) const; 35702be5353SAxel Dörfler 35802be5353SAxel Dörfler int32 Find(const char* name, uint32 type) const; 35902be5353SAxel Dörfler 36002be5353SAxel Dörfler private: 36102be5353SAxel Dörfler AttributeInfo fAttr; 36202be5353SAxel Dörfler Type fValue; 36302be5353SAxel Dörfler bool fRewound; 36402be5353SAxel Dörfler 36502be5353SAxel Dörfler typedef AttributeStreamNode _inherited; 36602be5353SAxel Dörfler }; 36702be5353SAxel Dörfler 368b05aa8b5SJohn Scipione 36902be5353SAxel Dörfler template<class Type> 37002be5353SAxel Dörfler AttributeStreamConstValue<Type>::AttributeStreamConstValue(const char* name, 37102be5353SAxel Dörfler uint32 attributeType, Type value) 3727ec2c512SJohn Scipione : 3737ec2c512SJohn Scipione fAttr(name, attributeType, sizeof(Type)), 37402be5353SAxel Dörfler fValue(value), 37502be5353SAxel Dörfler fRewound(true) 37602be5353SAxel Dörfler { 37702be5353SAxel Dörfler } 37802be5353SAxel Dörfler 379b05aa8b5SJohn Scipione 38002be5353SAxel Dörfler template<class Type> 38102be5353SAxel Dörfler const AttributeInfo* 38202be5353SAxel Dörfler AttributeStreamConstValue<Type>::Next() 38302be5353SAxel Dörfler { 38402be5353SAxel Dörfler if (!fRewound) 38502be5353SAxel Dörfler return NULL; 38602be5353SAxel Dörfler 38702be5353SAxel Dörfler fRewound = false; 38802be5353SAxel Dörfler return &fAttr; 38902be5353SAxel Dörfler } 39002be5353SAxel Dörfler 391b05aa8b5SJohn Scipione 39202be5353SAxel Dörfler template<class Type> 39302be5353SAxel Dörfler const char* 39402be5353SAxel Dörfler AttributeStreamConstValue<Type>::Get() 39502be5353SAxel Dörfler { 39602be5353SAxel Dörfler return (const char*)&fValue; 39702be5353SAxel Dörfler } 39802be5353SAxel Dörfler 399b05aa8b5SJohn Scipione 40002be5353SAxel Dörfler template<class Type> 40102be5353SAxel Dörfler bool 40202be5353SAxel Dörfler AttributeStreamConstValue<Type>::Fill(char* buffer) const 40302be5353SAxel Dörfler { 40402be5353SAxel Dörfler memcpy(buffer, &fValue, sizeof(Type)); 40502be5353SAxel Dörfler return true; 40602be5353SAxel Dörfler } 40702be5353SAxel Dörfler 408b05aa8b5SJohn Scipione 40902be5353SAxel Dörfler template<class Type> 41002be5353SAxel Dörfler int32 41102be5353SAxel Dörfler AttributeStreamConstValue<Type>::Find(const char* name, uint32 type) const 41202be5353SAxel Dörfler { 413fc7c01a1SRene Gollent if (strcmp(fAttr.Name(), name) == 0 && type == fAttr.Type()) 41402be5353SAxel Dörfler return 0; 41502be5353SAxel Dörfler 41602be5353SAxel Dörfler return -1; 41702be5353SAxel Dörfler } 41802be5353SAxel Dörfler 419b05aa8b5SJohn Scipione 42002be5353SAxel Dörfler class AttributeStreamBoolValue : public AttributeStreamConstValue<bool> { 42102be5353SAxel Dörfler public: 42202be5353SAxel Dörfler AttributeStreamBoolValue(const char* name, bool value) 4237ec2c512SJohn Scipione : 4247ec2c512SJohn Scipione AttributeStreamConstValue<bool>(name, B_BOOL_TYPE, value) 4257ec2c512SJohn Scipione { 4267ec2c512SJohn Scipione } 42702be5353SAxel Dörfler }; 42802be5353SAxel Dörfler 429b05aa8b5SJohn Scipione 43002be5353SAxel Dörfler class AttributeStreamInt32Value : public AttributeStreamConstValue<int32> { 43102be5353SAxel Dörfler public: 43202be5353SAxel Dörfler AttributeStreamInt32Value(const char* name, int32 value) 4337ec2c512SJohn Scipione : 4347ec2c512SJohn Scipione AttributeStreamConstValue<int32>(name, B_INT32_TYPE, value) 4357ec2c512SJohn Scipione { 4367ec2c512SJohn Scipione } 43702be5353SAxel Dörfler }; 43802be5353SAxel Dörfler 439b05aa8b5SJohn Scipione 44002be5353SAxel Dörfler class AttributeStreamInt64Value : public AttributeStreamConstValue<int64> { 44102be5353SAxel Dörfler public: 44202be5353SAxel Dörfler AttributeStreamInt64Value(const char* name, int64 value) 4437ec2c512SJohn Scipione : 4447ec2c512SJohn Scipione AttributeStreamConstValue<int64>(name, B_INT64_TYPE, value) 4457ec2c512SJohn Scipione { 4467ec2c512SJohn Scipione } 44702be5353SAxel Dörfler }; 44802be5353SAxel Dörfler 449b05aa8b5SJohn Scipione 45002be5353SAxel Dörfler class AttributeStreamRectValue : public AttributeStreamConstValue<BRect> { 45102be5353SAxel Dörfler public: 45202be5353SAxel Dörfler AttributeStreamRectValue(const char* name, BRect value) 4537ec2c512SJohn Scipione : 4547ec2c512SJohn Scipione AttributeStreamConstValue<BRect>(name, B_RECT_TYPE, value) 4557ec2c512SJohn Scipione { 4567ec2c512SJohn Scipione } 45702be5353SAxel Dörfler }; 45802be5353SAxel Dörfler 459b05aa8b5SJohn Scipione 46002be5353SAxel Dörfler class AttributeStreamFloatValue : public AttributeStreamConstValue<float> { 46102be5353SAxel Dörfler public: 46202be5353SAxel Dörfler AttributeStreamFloatValue(const char* name, float value) 4637ec2c512SJohn Scipione : 4647ec2c512SJohn Scipione AttributeStreamConstValue<float>(name, B_FLOAT_TYPE, value) 4657ec2c512SJohn Scipione { 4667ec2c512SJohn Scipione } 46702be5353SAxel Dörfler }; 46802be5353SAxel Dörfler 469b05aa8b5SJohn Scipione } // namespace BPrivate 47002be5353SAxel Dörfler 47102be5353SAxel Dörfler using namespace BPrivate; 47202be5353SAxel Dörfler 4737ec2c512SJohn Scipione 4747ec2c512SJohn Scipione #endif // _ATTRIBUTE_STREAM_H 475