C言語にてバイナリデータを Base64 文字列に変換する
の続きです。
Boost はC++用のソフトウェアライブラリです。
Base64の変換テーブルを内蔵していて、base64_from_binary などの関数がある。
下記を参考した。
template <typename InputStream, typename OutputStream> inline OutputStream& encode(InputStream& is, OutputStream& os) { copy(EncodeItr(InputItr(is)), EncodeItr(InputItr()), OutputItr(os)); return os; }
イテレータを使ってシンプルに記述できる。
Stream は扱いにくいので、APIを std::string std::vector に変更する。
サンプルコードをguthubに公開した。 https://github.com/ohwada/MAC_cpp_Samples/tree/master/boost/base64