DataBlock.hh (6285:ce086eca1ede) | DataBlock.hh (6347:a532849ca78f) |
---|---|
1 2/* 3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 42 unchanged lines hidden (view full) --- 51 52 // Public Methods 53 void assign(uint8* data); 54 55 void clear(); 56 uint8 getByte(int whichByte) const; 57 const uint8* getData(int offset, int len) const; 58 void setByte(int whichByte, uint8 data); | 1 2/* 3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 42 unchanged lines hidden (view full) --- 51 52 // Public Methods 53 void assign(uint8* data); 54 55 void clear(); 56 uint8 getByte(int whichByte) const; 57 const uint8* getData(int offset, int len) const; 58 void setByte(int whichByte, uint8 data); |
59 const uint8* getBlock() const; 60 uint8* copyData(uint8* dest, int offset, int size) const; 61 void setBlock(uint8* data) { setData(data, 0, System::getBlockSizeBytes()); } |
|
59 void setData(uint8* data, int offset, int len); 60 void copyPartial(const DataBlock & dblk, int offset, int len); 61 bool equal(const DataBlock& obj) const; 62 void print(ostream& out) const; 63 64private: 65 void alloc(); 66 // Data Members (m_ prefix) --- 74 unchanged lines hidden (view full) --- 141} 142 143inline 144void DataBlock::copyPartial(const DataBlock & dblk, int offset, int len) 145{ 146 setData(&dblk.m_data[offset], offset, len); 147} 148 | 62 void setData(uint8* data, int offset, int len); 63 void copyPartial(const DataBlock & dblk, int offset, int len); 64 bool equal(const DataBlock& obj) const; 65 void print(ostream& out) const; 66 67private: 68 void alloc(); 69 // Data Members (m_ prefix) --- 74 unchanged lines hidden (view full) --- 144} 145 146inline 147void DataBlock::copyPartial(const DataBlock & dblk, int offset, int len) 148{ 149 setData(&dblk.m_data[offset], offset, len); 150} 151 |
152inline 153const uint8* DataBlock::getBlock() const 154{ 155 return m_data; 156} 157 158inline 159uint8* DataBlock::copyData(uint8* dest, int offset, int size) const 160{ 161 assert(offset + size <= RubySystem::getBlockSizeBytes()); 162 memcpy(dest, m_data + offset, size); 163 return dest; 164} 165 166 |
|
149// ******************* Definitions ******************* 150 151// Output operator definition 152extern inline 153ostream& operator<<(ostream& out, const DataBlock& obj) 154{ 155 obj.print(out); 156 out << flush; 157 return out; 158} 159 160extern inline 161bool operator==(const DataBlock& obj1,const DataBlock& obj2) 162{ 163 return (obj1.equal(obj2)); 164} 165 166#endif //DATABLOCK_H | 167// ******************* Definitions ******************* 168 169// Output operator definition 170extern inline 171ostream& operator<<(ostream& out, const DataBlock& obj) 172{ 173 obj.print(out); 174 out << flush; 175 return out; 176} 177 178extern inline 179bool operator==(const DataBlock& obj1,const DataBlock& obj2) 180{ 181 return (obj1.equal(obj2)); 182} 183 184#endif //DATABLOCK_H |