0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C++ std・zlib関係メモ

Last updated at Posted at 2015-06-11

■std::stringを使用するには?

 ●Application.mkを使用する場合
  APP_STL := gnustl_static

 ●使用インクルード

  #include <string>

 ●const char* →std::string

 std::string teststring = std::string((char*)testdata);

■ハッシュを作成するには?

●xCodeのヘッダーに定義したらエラーになったので、C++11だとないのかも

●使用インクルード

# ifdef __ANDROID__
# include <tr1/functional>
# endif
std::tr1::hash<std::string>()(文字列);

■zlibの関数を使用するには?

 ●Android.mkを使用する場合、追加したい場合は下記のように += -lz
  LOCAL_LDLIBS += -lz

 ●使用インクルード

# include <zlib.h>

 ●inflateInit2、inflate、inflateEnd とかでコンパイルが起こらなくなり、
  使用できる。

■ファイル入出力

●使用インクルード

# include <iostream>
# include <fstream>
    // ファイル入力
    std::ifstream fin;    
    fin.open(保存パスのstd::string.c_str(), ios::in);

    // ■ファイル出力

  //ファイルを開く
    ofstream fout;
    fout.open(保存パスのstd::string.c_str(), ios::out|ios::app);
    fout.write(保存データの.c_str(),保存データサイズ );
    fout.close();  //ファイルを閉じる

■複数のソースをmakeしたい時は、LOCAL_SRC_FILESでソースファイル名をスペース区切りで記述すればOK

LOCAL_ARM_MODE  := arm
LOCAL_PATH      := $(NDK_PROJECT_PATH)
LOCAL_MODULE    := libTestPlugin
LOCAL_CFLAGS    := -Werror
LOCAL_SRC_FILES := DixHash32.cpp MiniZipTest.cpp
LOCAL_LDLIBS    := -llog
LOCAL_LDLIBS    += -lz
include $(BUILD_SHARED_LIBRARY)

■C++用ハッシュ作成

 昔からお世話になってるゲームつくろーさんのライブラリを使用
 http://marupeke296.com/TOOL_No10_Hash32.html

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?