#pragma once

#include "define.h"


#include "namespace_start.h"



class CTm{
private:

	tm timet;

public:

	const tm *SetNowLocalTime();

	const tm *SetNowGmTime();

	const tm *SetLocalTime(time_t timer);

	const tm *SetGmTime(time_t timer);

	operator tm*();
};

UInt FormatTime(NString &str,const NString &format,tm* timeptr);

///
///ユーザID取得
///
extern Void GetnliteUserId(NString  &id);


///
///iniファイル読み込み
///
extern Int ReadIni(const NString &path,const NString &section,const NString &key,NString &val);

///
///特定バイト列検索
///
template<typename T>
inline const T * memmem(const T *base,  ULong   count, const void *pattern,UInt   length ){

	// 検索バイト数 0 では検索は常に失敗する。
	if ( count <= 0 ){
		return nullptr;
	}

	// 最初に一致する位置を探す
	const Byte *start = reinterpret_cast<const Byte *>( base );
	for( const Byte *p = start;p + length <= start + count;++p ){
		if ( 0 == memcmp( p, pattern, length ) )
		{
			return reinterpret_cast<const T *>( p );
		}
	}

	return nullptr;

}

///
///文字列変換
///

extern Bool ToSJIS(MString &buf,const U16String &target);

extern Bool ToSJIS(MString &buf,const CharU16 *target,UInt targetSize);
	
extern Bool ToUTF8(MString &buf,const U16String &target);

extern Bool ToUTF8(MString &buf,const CharU16 *target,UInt targetSize);

extern Bool UTF8ToUTF16(U16String &buf,const MString &target);

extern Bool UTF8ToUTF16(U16String &buf,const Char *target,UInt targetSize);

extern Bool SJISToUTF16(U16String &buf,const MString &target);

extern Bool SJISToUTF16(U16String &buf,const Char *target,UInt targetSize);


///
///ファイル存在確認
///
extern Bool PathIsFile(const NString &path);

#include "namespace_end.h"

#pragma comment(lib,"Iphlpapi.lib")
#pragma comment(lib,"Crypt32.lib")
#pragma comment(lib,"Shlwapi.lib")