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 // 4202be5353SAxel Dörfler // transformer may for instance perform endian-swapping or offsetting of a B_RECT attribute 4302be5353SAxel Dörfler // filter may withold certain attributes 4402be5353SAxel Dörfler // buffer is a memory allocated snapshot of attributes, may be repeatedly streamed into 4502be5353SAxel Dörfler // other files, buffers 4602be5353SAxel Dörfler // 4702be5353SAxel Dörfler // In addition to the whacky (but usefull) << syntax, calls like Read, Write are also 4802be5353SAxel Dörfler // available 4902be5353SAxel Dörfler #ifndef __ATTRIBUTE_STREAM__ 5002be5353SAxel Dörfler #define __ATTRIBUTE_STREAM__ 5102be5353SAxel Dörfler 52b05aa8b5SJohn Scipione 5302be5353SAxel Dörfler #include <Node.h> 5402be5353SAxel Dörfler #include <Rect.h> 5502be5353SAxel Dörfler #include <String.h> 5602be5353SAxel Dörfler #include <TypeConstants.h> 5702be5353SAxel Dörfler 5802be5353SAxel Dörfler #include <fs_attr.h> 5902be5353SAxel Dörfler 6002be5353SAxel Dörfler #include "ObjectList.h" 6102be5353SAxel Dörfler 62b05aa8b5SJohn Scipione 6302be5353SAxel Dörfler namespace BPrivate { 6402be5353SAxel Dörfler 6502be5353SAxel Dörfler struct AttributeTemplate { 6602be5353SAxel Dörfler // used for read-only attribute source 6702be5353SAxel Dörfler const char* fAttributeName; 6802be5353SAxel Dörfler uint32 fAttributeType; 6902be5353SAxel Dörfler off_t fSize; 7002be5353SAxel Dörfler const char* fBits; 7102be5353SAxel Dörfler }; 7202be5353SAxel Dörfler 7302be5353SAxel Dörfler 7402be5353SAxel Dörfler class AttributeInfo { 7502be5353SAxel Dörfler // utility class for internal attribute description 7602be5353SAxel Dörfler public: 7702be5353SAxel Dörfler AttributeInfo() 7802be5353SAxel Dörfler {} 7902be5353SAxel Dörfler AttributeInfo(const AttributeInfo &); 8002be5353SAxel Dörfler AttributeInfo(const char*, attr_info); 8102be5353SAxel Dörfler AttributeInfo(const char*, uint32, off_t); 8202be5353SAxel Dörfler 8302be5353SAxel Dörfler void SetTo(const AttributeInfo &); 8402be5353SAxel Dörfler void SetTo(const char*, attr_info); 8502be5353SAxel Dörfler void SetTo(const char*, uint32, off_t); 8602be5353SAxel Dörfler const char* Name() const; 8702be5353SAxel Dörfler uint32 Type() const; 8802be5353SAxel Dörfler off_t Size() const; 8902be5353SAxel Dörfler 9002be5353SAxel Dörfler private: 9102be5353SAxel Dörfler BString fName; 9202be5353SAxel Dörfler attr_info fInfo; 9302be5353SAxel Dörfler }; 9402be5353SAxel Dörfler 95b05aa8b5SJohn Scipione 9602be5353SAxel Dörfler class AttributeStreamNode { 9702be5353SAxel Dörfler public: 9802be5353SAxel Dörfler AttributeStreamNode(); 9902be5353SAxel Dörfler virtual ~AttributeStreamNode(); 10002be5353SAxel Dörfler 10102be5353SAxel Dörfler AttributeStreamNode &operator<<(AttributeStreamNode &source); 10202be5353SAxel Dörfler // workhorse call 10302be5353SAxel Dörfler // to the outside makes this node a part of the stream, passing on 10402be5353SAxel Dörfler // any data it has, gets, transforms, doesn't filter out 10502be5353SAxel Dörfler // 10602be5353SAxel Dörfler // under the hood sets up streaming into the next node; hooking 10702be5353SAxel Dörfler // up source and destination, forces the stream head to start 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 117*a51764c5SJohn Scipione virtual off_t Read(const char* name, const char* foreignName, 118*a51764c5SJohn Scipione uint32 type, off_t size, void* buffer, void (*swapFunc)(void*) = 0); 11902be5353SAxel Dörfler // read from this node 120*a51764c5SJohn Scipione virtual off_t Write(const char* name, const char* foreignName, 121*a51764c5SJohn 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(); 13102be5353SAxel Dörfler // give me the data of the attribute in the stream that was just returned 13202be5353SAxel Dörfler // by Next 13302be5353SAxel Dörfler // assumes there is a buffering node somewhere on the way to 13402be5353SAxel Dörfler // the source, from which the resulting buffer is borrowed 13502be5353SAxel Dörfler virtual bool Fill(char* buffer) const; 13602be5353SAxel Dörfler // fill the buffer with data of the attribute in the stream that was just returned 13702be5353SAxel Dörfler // by next 13802be5353SAxel Dörfler // <buffer> is big enough to hold the entire attribute data 13902be5353SAxel Dörfler 14002be5353SAxel Dörfler virtual bool CanFeed() const { return false; } 14102be5353SAxel Dörfler // return true if can work as a source for the entire stream 14202be5353SAxel Dörfler 14302be5353SAxel Dörfler private: 14402be5353SAxel Dörfler bool Start(); 14502be5353SAxel Dörfler // utility call, used to start up the stream by finding the ultimate 14602be5353SAxel Dörfler // target of the stream and calling Drive on it 14702be5353SAxel Dörfler 14802be5353SAxel Dörfler void Detach(); 14902be5353SAxel Dörfler 15002be5353SAxel Dörfler protected: 15102be5353SAxel Dörfler AttributeStreamNode* fReadFrom; 15202be5353SAxel Dörfler AttributeStreamNode* fWriteTo; 15302be5353SAxel Dörfler }; 15402be5353SAxel Dörfler 155b05aa8b5SJohn Scipione 15602be5353SAxel Dörfler class AttributeStreamFileNode : public AttributeStreamNode { 15702be5353SAxel Dörfler // handles reading and writing attributes to and from the 15802be5353SAxel Dörfler // stream 15902be5353SAxel Dörfler public: 16002be5353SAxel Dörfler AttributeStreamFileNode(); 16102be5353SAxel Dörfler AttributeStreamFileNode(BNode*); 16202be5353SAxel Dörfler 16302be5353SAxel Dörfler virtual void MakeEmpty(); 16402be5353SAxel Dörfler virtual void Rewind(); 16502be5353SAxel Dörfler virtual off_t Contains(const char* name, uint32 type); 166b05aa8b5SJohn Scipione virtual off_t Read(const char* name, const char* foreignName, uint32 type, 167b05aa8b5SJohn Scipione off_t size, void* buffer, void (*swapFunc)(void*) = 0); 168b05aa8b5SJohn Scipione virtual off_t Write(const char* name, const char* foreignName, uint32 type, 169b05aa8b5SJohn Scipione off_t size, const void* buffer); 17002be5353SAxel Dörfler 17102be5353SAxel Dörfler void SetTo(BNode*); 17202be5353SAxel Dörfler 17302be5353SAxel Dörfler BNode* Node() 17402be5353SAxel Dörfler { return fNode; } 17502be5353SAxel Dörfler 17602be5353SAxel Dörfler protected: 17702be5353SAxel Dörfler virtual bool CanFeed() const { return true; } 17802be5353SAxel Dörfler 17902be5353SAxel Dörfler virtual bool Drive(); 18002be5353SAxel Dörfler // give me all the attributes, I'll write them into myself 18102be5353SAxel Dörfler virtual const AttributeInfo* Next(); 18202be5353SAxel Dörfler // return the info for the next attribute I can read for you 18302be5353SAxel Dörfler virtual const char* Get(); 18402be5353SAxel Dörfler virtual bool Fill(char* buffer) const; 18502be5353SAxel Dörfler 18602be5353SAxel Dörfler private: 18702be5353SAxel Dörfler AttributeInfo fCurrentAttr; 18802be5353SAxel Dörfler BNode* fNode; 18902be5353SAxel Dörfler 19002be5353SAxel Dörfler typedef AttributeStreamNode _inherited; 19102be5353SAxel Dörfler }; 19202be5353SAxel Dörfler 193b05aa8b5SJohn Scipione 19402be5353SAxel Dörfler class AttributeStreamMemoryNode : public AttributeStreamNode { 19502be5353SAxel Dörfler // in memory attribute buffer; can be both target of writing and source 19602be5353SAxel Dörfler // of reading at the same time 19702be5353SAxel Dörfler public: 19802be5353SAxel Dörfler AttributeStreamMemoryNode(); 19902be5353SAxel Dörfler 20002be5353SAxel Dörfler virtual void MakeEmpty(); 20102be5353SAxel Dörfler virtual off_t Contains(const char* name, uint32 type); 20202be5353SAxel Dörfler virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, 20302be5353SAxel Dörfler void* buffer, void (*swapFunc)(void*) = 0); 20402be5353SAxel Dörfler virtual off_t Write(const char* name, const char* foreignName, uint32 type, off_t size, 20502be5353SAxel Dörfler const void* buffer); 20602be5353SAxel Dörfler 20702be5353SAxel Dörfler protected: 20802be5353SAxel Dörfler virtual bool CanFeed() const { return true; } 20902be5353SAxel Dörfler virtual void Rewind(); 21002be5353SAxel Dörfler virtual bool Drive(); 21102be5353SAxel Dörfler virtual const AttributeInfo* Next(); 21202be5353SAxel Dörfler virtual const char* Get(); 21302be5353SAxel Dörfler virtual bool Fill(char* buffer) const; 21402be5353SAxel Dörfler 21502be5353SAxel Dörfler class AttrNode { 21602be5353SAxel Dörfler public: 21702be5353SAxel Dörfler AttrNode(const char* name, uint32 type, off_t size, char* data) 21802be5353SAxel Dörfler : 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); 27802be5353SAxel Dörfler virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, 27902be5353SAxel Dörfler void* buffer, void (*swapFunc)(void*) = 0); 28002be5353SAxel Dörfler virtual off_t Write(const char* name, const char* foreignName, uint32 type, off_t size, 28102be5353SAxel Dörfler 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: 310*a51764c5SJohn Scipione SelectiveAttributeTransformer(const char* attributeName, 311*a51764c5SJohn Scipione bool (*)(const char*, uint32 , off_t , void*, void*), void* params); 31202be5353SAxel Dörfler virtual ~SelectiveAttributeTransformer(); 31302be5353SAxel Dörfler 314*a51764c5SJohn Scipione virtual off_t Read(const char* name, const char* foreignName, uint32 type, 315*a51764c5SJohn 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: 320*a51764c5SJohn Scipione virtual bool WillTransform(const char* name, uint32 type, off_t size, 321*a51764c5SJohn Scipione const char* data) const; 32202be5353SAxel Dörfler // override to implement filtering; should only return true if transformation will 32302be5353SAxel Dörfler // occur 324*a51764c5SJohn Scipione virtual char* CopyAndApplyTransformer(const char* name, uint32 type, 325*a51764c5SJohn Scipione off_t size, const char* data); 32602be5353SAxel Dörfler // makes a copy of data 327*a51764c5SJohn Scipione virtual bool ApplyTransformer(const char* name, uint32 type, off_t size, 328*a51764c5SJohn 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: 348*a51764c5SJohn Scipione AttributeStreamConstValue(const char* name, uint32 attributeType, 349*a51764c5SJohn 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) 37202be5353SAxel Dörfler : 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) 42202be5353SAxel Dörfler : AttributeStreamConstValue<bool>(name, B_BOOL_TYPE, value) 42302be5353SAxel Dörfler {} 42402be5353SAxel Dörfler }; 42502be5353SAxel Dörfler 426b05aa8b5SJohn Scipione 42702be5353SAxel Dörfler class AttributeStreamInt32Value : public AttributeStreamConstValue<int32> { 42802be5353SAxel Dörfler public: 42902be5353SAxel Dörfler AttributeStreamInt32Value(const char* name, int32 value) 43002be5353SAxel Dörfler : AttributeStreamConstValue<int32>(name, B_INT32_TYPE, value) 43102be5353SAxel Dörfler {} 43202be5353SAxel Dörfler }; 43302be5353SAxel Dörfler 434b05aa8b5SJohn Scipione 43502be5353SAxel Dörfler class AttributeStreamInt64Value : public AttributeStreamConstValue<int64> { 43602be5353SAxel Dörfler public: 43702be5353SAxel Dörfler AttributeStreamInt64Value(const char* name, int64 value) 43802be5353SAxel Dörfler : AttributeStreamConstValue<int64>(name, B_INT64_TYPE, value) 43902be5353SAxel Dörfler {} 44002be5353SAxel Dörfler }; 44102be5353SAxel Dörfler 442b05aa8b5SJohn Scipione 44302be5353SAxel Dörfler class AttributeStreamRectValue : public AttributeStreamConstValue<BRect> { 44402be5353SAxel Dörfler public: 44502be5353SAxel Dörfler AttributeStreamRectValue(const char* name, BRect value) 44602be5353SAxel Dörfler : AttributeStreamConstValue<BRect>(name, B_RECT_TYPE, value) 44702be5353SAxel Dörfler {} 44802be5353SAxel Dörfler }; 44902be5353SAxel Dörfler 450b05aa8b5SJohn Scipione 45102be5353SAxel Dörfler class AttributeStreamFloatValue : public AttributeStreamConstValue<float> { 45202be5353SAxel Dörfler public: 45302be5353SAxel Dörfler AttributeStreamFloatValue(const char* name, float value) 45402be5353SAxel Dörfler : AttributeStreamConstValue<float>(name, B_FLOAT_TYPE, value) 45502be5353SAxel Dörfler {} 45602be5353SAxel Dörfler }; 45702be5353SAxel Dörfler 458b05aa8b5SJohn Scipione } // namespace BPrivate 45902be5353SAxel Dörfler 46002be5353SAxel Dörfler using namespace BPrivate; 46102be5353SAxel Dörfler 46202be5353SAxel Dörfler #endif 463