summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-04-06 13:33:11 +0800
committerPeng Wu <alexepico@gmail.com>2011-04-06 13:33:11 +0800
commitf7c301f3d5a6b87dba2b0747367c0aaa30604526 (patch)
treedec19096a0cb45cccbef5ced979f06584a7c4509
parent0d68d1990958df65f8cde110756ee18c785d51cc (diff)
downloadlibpinyin-f7c301f3d5a6b87dba2b0747367c0aaa30604526.tar.gz
libpinyin-f7c301f3d5a6b87dba2b0747367c0aaa30604526.tar.xz
libpinyin-f7c301f3d5a6b87dba2b0747367c0aaa30604526.zip
add get/set array header methods
-rw-r--r--src/storage/flexible_ngram.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/storage/flexible_ngram.h b/src/storage/flexible_ngram.h
index 0f8644c..a193e69 100644
--- a/src/storage/flexible_ngram.h
+++ b/src/storage/flexible_ngram.h
@@ -54,6 +54,7 @@ public:
m_chunk.set_size(sizeof(ArrayHeader));
memset(m_chunk.begin(), 0, sizeof(ArrayHeader));
}
+
/* retrieve all items */
bool retrieve_all(/* out */ FlexibleBigramPhraseArray array);
@@ -70,10 +71,18 @@ public:
/* in */ const ArrayItem & item);
/* get array header */
- bool get_array_header(/* out */ ArrayHeader & header);
+ bool get_array_header(/* out */ ArrayHeader & header){
+ char * buf_begin = (char *)m_chunk.begin();
+ memcpy(&header, buf_begin, sizeof(ArrayHeader));
+ return true;
+ }
/* set array header */
- bool set_array_header(/* in */ const ArrayHeader & header);
+ bool set_array_header(/* in */ const ArrayHeader & header){
+ char * buf_begin = (char *)m_chunk.begin();
+ memcpy(buf_begin, &header, sizeof(ArrayHeader));
+ return true;
+ }
};
template<typename MagicHeader, typename ArrayHeader,