- Timestamp:
- 06/08/15 21:27:49 (9 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/cf/bin.h
r7 r11 11 11 12 12 #include <vector> 13 #include <string> 13 14 #include <stdio.h> 14 15 … … 38 39 * @param in asciiz-byte 39 40 */ 40 bin(const cf::char_t *in);41 bin(const std::string & in); 41 42 42 43 /** … … 116 117 117 118 /** 118 * set 119 * set 119 120 * @param in bin 120 121 */ 121 122 bin & operator =(const bin & in); 123 124 /** 125 * set 126 * @param in string 127 */ 128 bin & operator =(const std::string & in); 122 129 123 130 /** … … 151 158 152 159 /** 160 * get a byte 161 * @return a byte 162 * @param index index 163 */ 164 cf::uint8_t operator [](const cf::size_t index) const; 165 166 /** 167 * get as string 168 * @return string 169 */ 170 std::string toString() const; 171 172 /** 153 173 * dump binary to file-pointer 154 174 * @param prefix prefix for output -
trunk/include/cf/network.h
r10 r11 245 245 * host to network long 246 246 * @return long for network 247 * @param long for host247 * @param in long for host 248 248 */ 249 249 static cf::uint32_t htonl(cf::uint32_t in); … … 252 252 * host to network short 253 253 * @return short for network 254 * @param short for host254 * @param in short for host 255 255 */ 256 256 static cf::uint16_t htons(cf::uint16_t in); … … 259 259 * network to host long 260 260 * @return long for host 261 * @param long for network261 * @param in long for network 262 262 */ 263 263 static cf::uint32_t ntohl(cf::uint32_t in); … … 266 266 * network to host short 267 267 * @return short for host 268 * @param short for network268 * @param in short for network 269 269 */ 270 270 static cf::uint16_t ntohs(cf::uint16_t in); -
trunk/include/cf/task.h
r7 r11 9 9 #include "cf/exception.h" 10 10 11 #define SYNCHRONIZED(_s) for (cf::task::scopedLock _sl(&_s) ; _sl. synchronizer()->locked() ; _sl.synchronizer()->unlock())11 #define SYNCHRONIZED(_s) for (cf::task::scopedLock _sl(&_s) ; _sl.locked() ; _sl.unlock()) 12 12 13 13 namespace cf … … 116 116 117 117 /** 118 * get synchronizer 119 * @return an instance of synchronizer 120 */ 121 ISynchronizer * synchronizer(); 118 * is locked ? 119 * @return true; false 120 */ 121 cf::bool_t locked() const; 122 123 /** 124 * unlock 125 */ 126 cf::void_t unlock() 127 throw (cf::exception); 122 128 }; 123 129 -
trunk/src/bin.cpp
r10 r11 15 15 } 16 16 17 cf::bin::bin(const cf::char_t * in) 17 cf::bin::bin(const std::string & in) 18 : mBin(in.begin(), in.end()) 18 19 { 19 if (!in)20 return;21 22 set(reinterpret_cast<const cf::uint8_t *>(in),23 strlen(reinterpret_cast<const char *>(in)));24 20 } 25 21 … … 98 94 } 99 95 96 cf::bin & cf::bin::operator =(const std::string & in) 97 { 98 mBin.assign(in.begin(), in.end()); 99 return *this; 100 } 101 100 102 cf::void_t cf::bin::operator +=(const cf::bin & in) 101 103 { … … 122 124 } 123 125 126 cf::uint8_t cf::bin::operator [](const cf::size_t index) const 127 { 128 if (index > size()) 129 THROW_EXCEPTION("invalid index"); 130 131 return mBin[index]; 132 } 133 124 134 cf::size_t cf::bin::find(const cf::uint8_t * in, 125 135 const cf::size_t length) const … … 137 147 138 148 return -1; 149 } 150 151 std::string cf::bin::toString() const 152 { 153 return std::string(mBin.begin(), mBin.end()); 139 154 } 140 155 -
trunk/src/task.cpp
r4 r11 145 145 : mSynchronizer(inst) 146 146 { 147 if (! synchronizer())147 if (!mSynchronizer) 148 148 THROW_EXCEPTION("invalid synchronizer"); 149 149 150 synchronizer()->lock();150 mSynchronizer->lock(); 151 151 } 152 152 … … 155 155 try 156 156 { 157 synchronizer()->unlock();157 unlock(); 158 158 } 159 159 catch (...) … … 162 162 } 163 163 164 cf::task::ISynchronizer * cf::task::scopedLock::synchronizer() 165 { 166 return mSynchronizer; 164 cf::bool_t cf::task::scopedLock::locked() const 165 { 166 return mSynchronizer->locked(); 167 } 168 169 cf::void_t cf::task::scopedLock::unlock() 170 throw (cf::exception) 171 { 172 mSynchronizer->unlock(); 167 173 } 168 174
Note:
See TracChangeset
for help on using the changeset viewer.