Realized encode/decode/codetable functions in C++