Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Commit

Permalink
cout
Browse files Browse the repository at this point in the history
  • Loading branch information
AsPJT committed Sep 2, 2018
1 parent d269a93 commit 5ff08cd
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 16 deletions.
Binary file added dx_cout/Log.txt
Binary file not shown.
50 changes: 35 additions & 15 deletions dx_cout/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,46 @@
#include "DxLib.h"
#include "coutDx.hpp"

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
ChangeWindowMode(TRUE);
// DXライブラリ初期化処理
if (DxLib_Init() == -1)
{
return -1; // エラーが起きたら直ちに終了
}
if (DxLib_Init() == -1) return -1;

LoadGraph("a.jpg", TRUE);
const char char_ = 'a';
const unsigned char uchar_ = 'a';
const signed char schar_ = 'a';
const unsigned short ushort_ = 1;
const short short_ = -1;
const unsigned int uint_ = 1;
const int int_ = -1;
const unsigned long ulong_ = 1;
const long long_ = -1;
const unsigned long long ulonglong_ = 1;
const long long longlong_ = -1;
const float float_ = 1.0f;
const double double_ = 1.0;
const long double longdouble_ = 1.0;
const char* const char_ptr_ = "Hello World!";
const std::string string_ = "Hello World!";

while (CheckHitKeyAll() == 0)
{
// メッセージループに代わる処理をする
if (ProcessMessage() == -1)
{
break; // エラーが起きたらループを抜ける
}
}
coutDx << char_ << endlDx;
coutDx << uchar_ << endlDx;
coutDx << schar_ << endlDx;
coutDx << ushort_ << endlDx;
coutDx << short_ << endlDx;
coutDx << uint_ << endlDx;
coutDx << int_ << endlDx;
coutDx << ulong_ << endlDx;
coutDx << long_ << endlDx;
coutDx << ulonglong_ << endlDx;
coutDx << longlong_ << endlDx;
coutDx << float_ << endlDx;
coutDx << double_ << endlDx;
coutDx << longdouble_ << endlDx;
coutDx << char_ptr_ << endlDx;
coutDx << string_ << endlDx;

WaitKey();
DxLib_End();

return 0;
}
114 changes: 114 additions & 0 deletions dx_cout/coutDx.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#pragma once
#include <string>

#ifdef __DXLIB
#ifndef DX_NON_NAMESPACE
namespace DxLib
{
#endif // DX_NON_NAMESPACE

struct EndlDx {
EndlDx() = default;
~EndlDx() = default;
};
constexpr EndlDx endlDx;

struct ClearDx {
ClearDx() = default;
~ClearDx() = default;
};
constexpr ClearDx clearDx;

class CoutDx {
public:

const CoutDx& operator<<(const char var_) const {
printfDx("%c", var_);
return *this;
}
const CoutDx& operator<<(const signed char var_) const {
printfDx("%c", (char)var_);
return *this;
}
const CoutDx& operator<<(const unsigned char var_) const {
printfDx("%c", (char)var_);
return *this;
}
const CoutDx& operator<<(const short var_) const {
printfDx("%d", var_);
return *this;
}
const CoutDx& operator<<(const unsigned short var_) const {
printfDx("%u", var_);
return *this;
}
const CoutDx& operator<<(const int var_) const {
printfDx("%d", var_);
return *this;
}
const CoutDx& operator<<(const unsigned int var_) const {
printfDx("%u", var_);
return *this;
}
const CoutDx& operator<<(const long var_) const {
printfDx("%ld", var_);
return *this;
}
const CoutDx& operator<<(const unsigned long var_) const {
printfDx("%lu", var_);
return *this;
}
const CoutDx& operator<<(const long long var_) const {
printfDx("%lld", var_);
return *this;
}
const CoutDx& operator<<(const unsigned long long var_) const {
printfDx("%llu", var_);
return *this;
}

const CoutDx& operator<<(const float var_) const {
printfDx("%f", var_);
return *this;
}
const CoutDx& operator<<(const double var_) const {
printfDx("%f", var_);
return *this;
}
const CoutDx& operator<<(const long double var_) const {
printfDx("%lf", var_);
return *this;
}

const CoutDx& operator<<(const char* const var_) const {
printfDx("%s", var_);
return *this;
}
const CoutDx& operator<<(const std::string& var_) const {
printfDx("%s", var_.c_str());
return *this;
}

const CoutDx& operator<<(const EndlDx& var_) const {
printfDx("\n");
return *this;
}
const CoutDx& operator<<(const ClearDx& var_) const {
clsDx();
return *this;
}
const CoutDx& endl() const {
printfDx("\n");
return *this;
}
const CoutDx& clear() const {
clsDx();
return *this;
}
};
constexpr CoutDx coutDx;

#ifndef DX_NON_NAMESPACE
}
#endif // DX_NON_NAMESPACE
#endif
5 changes: 4 additions & 1 deletion dx_cout/dx_cout.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{ADF29D8E-3996-43B6-9819-1C247CFFAC98}</ProjectGuid>
<RootNamespace>saisai</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand Down Expand Up @@ -137,6 +137,9 @@
<ItemGroup>
<ClCompile Include="Source.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="coutDx.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
5 changes: 5 additions & 0 deletions dx_cout/dx_cout.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@
<Filter>ソース ファイル</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="coutDx.hpp">
<Filter>ヘッダー ファイル</Filter>
</ClInclude>
</ItemGroup>
</Project>

0 comments on commit 5ff08cd

Please sign in to comment.