|
|
@ -105,6 +105,7 @@ public: |
|
|
|
const Unit *getUnit() const { return v_; } |
|
|
|
const Unit *getUnit() const { return v_; } |
|
|
|
static inline size_t getUnitSize() { return op_.N; } |
|
|
|
static inline size_t getUnitSize() { return op_.N; } |
|
|
|
static inline size_t getBitSize() { return op_.bitSize; } |
|
|
|
static inline size_t getBitSize() { return op_.bitSize; } |
|
|
|
|
|
|
|
static inline size_t getByteSize() { return (op_.bitSize + 7) / 8; } |
|
|
|
static inline const fp::Op& getOp() { return op_; } |
|
|
|
static inline const fp::Op& getOp() { return op_; } |
|
|
|
void dump() const |
|
|
|
void dump() const |
|
|
|
{ |
|
|
|
{ |
|
|
@ -221,7 +222,7 @@ public: |
|
|
|
void setStr(const std::string& str, int ioMode = 0) |
|
|
|
void setStr(const std::string& str, int ioMode = 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (ioMode & (IoArray | IoArrayRaw)) { |
|
|
|
if (ioMode & (IoArray | IoArrayRaw)) { |
|
|
|
const size_t n = getBitSize() / 8; |
|
|
|
const size_t n = getByteSize(); |
|
|
|
if (str.size() != n) throw cybozu::Exception("FpT:setStr:bad size") << str.size() << n << ioMode; |
|
|
|
if (str.size() != n) throw cybozu::Exception("FpT:setStr:bad size") << str.size() << n << ioMode; |
|
|
|
if (ioMode & IoArrayRaw) { |
|
|
|
if (ioMode & IoArrayRaw) { |
|
|
|
memcpy(v_, str.c_str(), n); |
|
|
|
memcpy(v_, str.c_str(), n); |
|
|
@ -289,15 +290,16 @@ public: |
|
|
|
} |
|
|
|
} |
|
|
|
void getStr(std::string& str, int ioMode = 10) const |
|
|
|
void getStr(std::string& str, int ioMode = 10) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
const size_t n = getByteSize(); |
|
|
|
if (ioMode & IoArrayRaw) { |
|
|
|
if (ioMode & IoArrayRaw) { |
|
|
|
str.resize(getBitSize() / 8); |
|
|
|
str.resize(n); |
|
|
|
memcpy(&str[0], v_, str.size()); |
|
|
|
memcpy(&str[0], v_, str.size()); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
fp::Block b; |
|
|
|
fp::Block b; |
|
|
|
getBlock(b); |
|
|
|
getBlock(b); |
|
|
|
if (ioMode & IoArray) { |
|
|
|
if (ioMode & IoArray) { |
|
|
|
str.resize(getBitSize() / 8); |
|
|
|
str.resize(n); |
|
|
|
memcpy(&str[0], b.p, str.size()); |
|
|
|
memcpy(&str[0], b.p, str.size()); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -380,7 +382,7 @@ public: |
|
|
|
int ioMode = fp::detectIoMode(getIoMode(), is); |
|
|
|
int ioMode = fp::detectIoMode(getIoMode(), is); |
|
|
|
std::string str; |
|
|
|
std::string str; |
|
|
|
if (ioMode & (IoArray | IoArrayRaw)) { |
|
|
|
if (ioMode & (IoArray | IoArrayRaw)) { |
|
|
|
str.resize(getBitSize() / 8); |
|
|
|
str.resize(getByteSize()); |
|
|
|
is.read(&str[0], str.size()); |
|
|
|
is.read(&str[0], str.size()); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
is >> str; |
|
|
|
is >> str; |
|
|
|