1 //------------------------------------------------------------------------------ 2 // MessageCStringItemTest.h 3 // 4 //------------------------------------------------------------------------------ 5 6 #ifndef MESSAGECSTRINGITEMTEST_H 7 #define MESSAGECSTRINGITEMTEST_H 8 9 // Standard Includes ----------------------------------------------------------- 10 11 // System Includes ------------------------------------------------------------- 12 #include <Debug.h> 13 14 // Project Includes ------------------------------------------------------------ 15 16 // Local Includes -------------------------------------------------------------- 17 #include "MessageItemTest.h" 18 19 // Local Defines --------------------------------------------------------------- 20 21 // Globals --------------------------------------------------------------------- 22 23 typedef TMessageItemFuncPolicy 24 < 25 const char*, 26 &BMessage::AddString, 27 &BMessage::FindString, 28 &BMessage::FindString, 29 &BMessage::FindString, 30 &BMessage::HasString, 31 &BMessage::ReplaceString 32 > 33 TCStringFuncPolicy; 34 35 struct TCStringInitPolicy : public ArrayTypeBase<const char*> 36 { 37 typedef const char* TypePtr; 38 39 inline static const char* Zero() { return sStr1; } 40 inline static const char* Test1() { return sStr2; } 41 inline static const char* Test2() { return sStr3; } 42 inline static size_t SizeOf(const char*& data) { return strlen(data) + 1; } 43 inline static ArrayType Array() 44 { 45 ArrayType array; 46 array.push_back(Zero()); 47 array.push_back(Test1()); 48 array.push_back(Test2()); 49 return array; 50 } 51 52 private: 53 static const char* sStr1; 54 static const char* sStr2; 55 static const char* sStr3; 56 }; 57 const char* TCStringInitPolicy::sStr1 = ""; 58 const char* TCStringInitPolicy::sStr2 = "cstring one"; 59 const char* TCStringInitPolicy::sStr3 = "Bibbity-bobbity-boo!"; 60 //------------------------------------------------------------------------------ 61 struct TCStringAssertPolicy 62 { 63 inline static const char* Zero() { return ""; } 64 inline static const char* Invalid() { return ""; } 65 static bool Size(size_t size, const char* data) 66 ;//{ return size == msg.FlattenedSize(); } 67 }; 68 bool TCStringAssertPolicy::Size(size_t size, const char* data) 69 { 70 return size == strlen(data) + 1; 71 } 72 //------------------------------------------------------------------------------ 73 struct TCStringComparePolicy 74 { 75 static bool Compare(const char* lhs, const char* rhs); 76 }; 77 bool TCStringCtypedef const char* TypePtr; 78 omparePolicy::Compare(const char* lhs, const char* rhs) 79 { 80 if (!lhs) 81 return rhs; 82 if (!rhs) 83 return lhs; 84 return strcmp(lhs, rhs) == 0; 85 } 86 //------------------------------------------------------------------------------ 87 template<> 88 struct TypePolicy<const char*> 89 { 90 typedef const char* TypePtr; 91 enum { FixedSize = false }; 92 inline const char* Dereference(TypePtr p) { return p; } 93 inline const char* AddressOf(const char*& t) { return t; } 94 }; 95 //------------------------------------------------------------------------------ 96 typedef TMessageItemTest 97 < 98 const char*, 99 B_STRING_TYPE, 100 TCStringFuncPolicy, 101 TCStringInitPolicy, 102 TCStringAssertPolicy, 103 TCStringComparePolicy 104 > 105 TMessageCStringItemTest; 106 107 108 #endif // MESSAGECSTRINGITEMTEST_H 109 110 /* 111 * $Log $ 112 * 113 * $Id $ 114 * 115 */ 116 117