mirror of
https://github.com/tribufu/sdk-cpp
synced 2025-06-15 11:14:20 +00:00
Create c++ project
This commit is contained in:
12
.editorconfig
Normal file
12
.editorconfig
Normal file
@ -0,0 +1,12 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
* text=auto eol=lf
|
63
.gitignore
vendored
63
.gitignore
vendored
@ -1,32 +1,33 @@
|
||||
# Prerequisites
|
||||
*.d
|
||||
.vs/
|
||||
.vscode/
|
||||
bin/
|
||||
binaries/
|
||||
build/
|
||||
obj/
|
||||
saved/
|
||||
target/
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
.DS_Store
|
||||
.env
|
||||
*.crt
|
||||
*.csproj
|
||||
*.filters
|
||||
*.fsproj
|
||||
*.key
|
||||
*.log
|
||||
*.make
|
||||
*.mwb.bak
|
||||
*.pem
|
||||
*.sln
|
||||
*.user
|
||||
*.vcxproj
|
||||
*.vpp.*
|
||||
*.wasm
|
||||
*.xcodeproj
|
||||
*.xcworkspace
|
||||
Cargo.lock
|
||||
desktop.ini
|
||||
keystore.jks
|
||||
local.properties
|
||||
Makefile
|
||||
next-env.d.ts
|
||||
|
@ -186,7 +186,7 @@
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
14
bootstrap.ps1
Normal file
14
bootstrap.ps1
Normal file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
if ($IsWindows)
|
||||
{
|
||||
& "./vendor/premake/windows/premake5.exe" "vs2022"
|
||||
}
|
||||
elseif ($IsMacOS)
|
||||
{
|
||||
& "./vendor/premake/mac/premake5" "xcode4"
|
||||
}
|
||||
elseif ($IsLinux)
|
||||
{
|
||||
& "./vendor/premake/linux/premake5" "gmake2"
|
||||
}
|
10
bootstrap.sh
Normal file
10
bootstrap.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
if [ "$(expr substr $(uname -s) 1 5)" = "Linux" ]
|
||||
then
|
||||
./vendor/premake/linux/premake5 gmake2
|
||||
|
||||
elif [ "$(uname)" = "Darwin" ]
|
||||
then
|
||||
./vendor/premake/mac/premake5 xcode4
|
||||
fi
|
12
examples/main.cpp
Normal file
12
examples/main.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <tribufu/sdk.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
auto client = TribufuClient(0, "client_secret");
|
||||
std::cout << "client_id: " << client.get_id() << std::endl;
|
||||
return 0;
|
||||
}
|
187
examples/premake5.lua
Normal file
187
examples/premake5.lua
Normal file
@ -0,0 +1,187 @@
|
||||
--- @diagnostic disable: undefined-global
|
||||
|
||||
project "example"
|
||||
location "."
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
|
||||
cppdialect "C++20"
|
||||
|
||||
targetdir("../bin/%{cfg.platform:gsub('-', '/')}")
|
||||
objdir("../target/%{cfg.buildcfg}/obj/%{prj.name}/%{cfg.platform:gsub('-', '/')}")
|
||||
|
||||
files
|
||||
{
|
||||
"**.cpp",
|
||||
"**.h",
|
||||
"**.h",
|
||||
}
|
||||
|
||||
includedirs
|
||||
{
|
||||
"../include",
|
||||
"../vendor",
|
||||
}
|
||||
|
||||
libdirs
|
||||
{
|
||||
"../bin/%{cfg.platform:gsub('-', '/')}",
|
||||
}
|
||||
|
||||
-- Profile
|
||||
|
||||
filter { "configurations:debug" }
|
||||
runtime "Debug"
|
||||
symbols "On"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_DEVEL",
|
||||
"DEBUG",
|
||||
"TRACE",
|
||||
}
|
||||
|
||||
filter { "configurations:release" }
|
||||
runtime "Release"
|
||||
optimize "On"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_RETAIL",
|
||||
"RELEASE",
|
||||
}
|
||||
|
||||
-- Platform
|
||||
|
||||
filter { "platforms:windows-*" }
|
||||
system "windows"
|
||||
systemversion "latest"
|
||||
staticruntime "On"
|
||||
|
||||
toolset "msc"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_DESKTOP",
|
||||
"TRIBUFU_WINDOWS",
|
||||
}
|
||||
|
||||
links
|
||||
{
|
||||
"tribufu_sdk++",
|
||||
}
|
||||
|
||||
prelinkcommands
|
||||
{
|
||||
}
|
||||
|
||||
filter { "platforms:mac-*" }
|
||||
system "macosx"
|
||||
systemversion "10.15"
|
||||
|
||||
toolset "clang"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_APPLE",
|
||||
"TRIBUFU_DESKTOP",
|
||||
"TRIBUFU_MAC",
|
||||
}
|
||||
|
||||
links
|
||||
{
|
||||
"tribufu_sdk++",
|
||||
}
|
||||
|
||||
prelinkcommands
|
||||
{
|
||||
}
|
||||
|
||||
filter { "platforms:linux-*" }
|
||||
system "linux"
|
||||
|
||||
toolset "gcc"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_DESKTOP",
|
||||
"TRIBUFU_LINUX",
|
||||
"TRIBUFU_UNIX",
|
||||
}
|
||||
|
||||
links
|
||||
{
|
||||
"tribufu_sdk++",
|
||||
}
|
||||
|
||||
prelinkcommands
|
||||
{
|
||||
}
|
||||
|
||||
filter { "platforms:android-*" }
|
||||
system "android"
|
||||
|
||||
toolset "clang"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_ANDROID",
|
||||
"TRIBUFU_MOBILE",
|
||||
"TRIBUFU_UNIX",
|
||||
}
|
||||
|
||||
links
|
||||
{
|
||||
"tribufu_sdk++",
|
||||
}
|
||||
|
||||
prelinkcommands
|
||||
{
|
||||
}
|
||||
|
||||
filter { "platforms:ios-*" }
|
||||
system "ios"
|
||||
systemversion "13.0"
|
||||
|
||||
toolset "clang"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_APPLE",
|
||||
"TRIBUFU_IOS",
|
||||
"TRIBUFU_MOBILE",
|
||||
}
|
||||
|
||||
links
|
||||
{
|
||||
"tribufu_sdk++",
|
||||
}
|
||||
|
||||
-- Architecture
|
||||
|
||||
filter { "platforms:*-i686" }
|
||||
architecture "x32"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_32BITS",
|
||||
"TRIBUFU_I686",
|
||||
}
|
||||
|
||||
filter { "platforms:*-x86_64" }
|
||||
architecture "x64"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_64BITS",
|
||||
"TRIBUFU_X8664",
|
||||
}
|
||||
|
||||
filter { "platforms:*-aarch64" }
|
||||
architecture "ARM64"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_64BITS",
|
||||
"TRIBUFU_AARCH64",
|
||||
}
|
5
include/tribufu.h
Normal file
5
include/tribufu.h
Normal file
@ -0,0 +1,5 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/sdk.h>
|
35
include/tribufu/client.h
Normal file
35
include/tribufu/client.h
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/pch.h>
|
||||
|
||||
#include <cpp-httplib/httplib.h>
|
||||
|
||||
const char *VERSION = "0.0.4";
|
||||
|
||||
class TribufuClient
|
||||
{
|
||||
private:
|
||||
uint64_t id;
|
||||
std::string secret;
|
||||
// httplib::Client http;
|
||||
|
||||
public:
|
||||
TribufuClient(uint64_t id, const std::string &secret) //: http("https://api.tribufu.com")
|
||||
{
|
||||
this->id = id;
|
||||
this->secret = secret;
|
||||
|
||||
/*
|
||||
this->http.set_default_headers({{"User-Agent", "Tribufu/" + std::string(VERSION) + " (+https://api.tribufu.com; C++)"},
|
||||
{"X-Tribufu-Language", "cpp"},
|
||||
{"X-Tribufu-Version", VERSION}});
|
||||
*/
|
||||
}
|
||||
|
||||
uint64_t get_id() const
|
||||
{
|
||||
return this->id;
|
||||
}
|
||||
};
|
12
include/tribufu/pch.h
Normal file
12
include/tribufu/pch.h
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#else
|
||||
#error "C++ compiler required."
|
||||
#endif
|
5
include/tribufu/sdk.h
Normal file
5
include/tribufu/sdk.h
Normal file
@ -0,0 +1,5 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/client.h>
|
32
premake5.lua
Normal file
32
premake5.lua
Normal file
@ -0,0 +1,32 @@
|
||||
--- @diagnostic disable: undefined-global
|
||||
|
||||
workspace "SDK-CPP"
|
||||
location "."
|
||||
|
||||
configurations { "debug", "release" }
|
||||
|
||||
if _ACTION == "vs2022" then
|
||||
platforms {
|
||||
"windows-aarch64",
|
||||
"windows-i686",
|
||||
"windows-x86_64",
|
||||
}
|
||||
end
|
||||
|
||||
if _ACTION == "gmake2" then
|
||||
platforms {
|
||||
"linux-aarch64",
|
||||
"linux-i686",
|
||||
"linux-x86_64",
|
||||
}
|
||||
end
|
||||
|
||||
if _ACTION == "xcode4" then
|
||||
platforms {
|
||||
"mac-aarch64",
|
||||
"mac-x86_64",
|
||||
}
|
||||
end
|
||||
|
||||
include "src"
|
||||
include "examples"
|
4
scripts/msbuild.ps1
Normal file
4
scripts/msbuild.ps1
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
# Windows (x86_64)
|
||||
msbuild /p:Configuration="debug" /p:Platform="windows-x86_64"
|
3
src/client.cpp
Normal file
3
src/client.cpp
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#include <tribufu/client.h>
|
3
src/pch.cpp
Normal file
3
src/pch.cpp
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#include <tribufu/pch.h>
|
208
src/premake5.lua
Normal file
208
src/premake5.lua
Normal file
@ -0,0 +1,208 @@
|
||||
--- @diagnostic disable: undefined-global
|
||||
|
||||
project "tribufu_sdk++"
|
||||
location "."
|
||||
language "C++"
|
||||
|
||||
cppdialect "C++20"
|
||||
|
||||
targetdir("../bin/%{cfg.platform:gsub('-', '/')}")
|
||||
objdir("../target/%{cfg.buildcfg}/obj/%{prj.name}/%{cfg.platform:gsub('-', '/')}")
|
||||
|
||||
-- pchheader "tribufu/pch.h"
|
||||
-- pchsource "pch.cpp"
|
||||
|
||||
files
|
||||
{
|
||||
"**.cpp",
|
||||
"**.h",
|
||||
"**.h",
|
||||
"../include/tribufu/**.h",
|
||||
"../include/tribufu/**.h",
|
||||
}
|
||||
|
||||
vpaths
|
||||
{
|
||||
["Sources"] = { "**.cpp" },
|
||||
["Headers"] = { "**.h", "**.h", "../include/tribufu/**.h", "../include/tribufu/**.h" },
|
||||
}
|
||||
|
||||
includedirs
|
||||
{
|
||||
"../include",
|
||||
"../vendor",
|
||||
}
|
||||
|
||||
libdirs
|
||||
{
|
||||
"../bin/%{cfg.platform:gsub('-', '/')}",
|
||||
}
|
||||
|
||||
-- Profile
|
||||
|
||||
filter { "configurations:debug" }
|
||||
runtime "Debug"
|
||||
symbols "On"
|
||||
|
||||
defines
|
||||
{
|
||||
"DEBUG",
|
||||
"TRACE",
|
||||
"TRIBUFU_DEBUG",
|
||||
"TRIBUFU_TRACE",
|
||||
}
|
||||
|
||||
filter { "configurations:release" }
|
||||
runtime "Release"
|
||||
optimize "On"
|
||||
|
||||
defines
|
||||
{
|
||||
"RELEASE",
|
||||
"TRIBUFU_RELEASE",
|
||||
}
|
||||
|
||||
-- Platform
|
||||
|
||||
filter { "platforms:windows-*" }
|
||||
kind "StaticLib"
|
||||
system "windows"
|
||||
systemversion "latest"
|
||||
staticruntime "On"
|
||||
|
||||
toolset "msc"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_WINDOWS",
|
||||
"TRIBUFU_DESKTOP",
|
||||
"TRIBUFU_DYNAMIC",
|
||||
"TRIBUFU_LIBRARY",
|
||||
}
|
||||
|
||||
links
|
||||
{
|
||||
}
|
||||
|
||||
prelinkcommands
|
||||
{
|
||||
}
|
||||
|
||||
filter { "platforms:mac-*" }
|
||||
kind "StaticLib"
|
||||
system "macosx"
|
||||
systemversion "10.15"
|
||||
|
||||
toolset "clang"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_MAC",
|
||||
"TRIBUFU_APPLE",
|
||||
"TRIBUFU_DESKTOP",
|
||||
"TRIBUFU_DYNAMIC",
|
||||
"TRIBUFU_LIBRARY",
|
||||
}
|
||||
|
||||
links
|
||||
{
|
||||
}
|
||||
|
||||
prelinkcommands
|
||||
{
|
||||
}
|
||||
|
||||
filter { "platforms:linux-*" }
|
||||
kind "StaticLib"
|
||||
system "linux"
|
||||
|
||||
toolset "gcc"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_LINUX",
|
||||
"TRIBUFU_UNIX",
|
||||
"TRIBUFU_DESKTOP",
|
||||
"TRIBUFU_DYNAMIC",
|
||||
"TRIBUFU_LIBRARY",
|
||||
}
|
||||
|
||||
links
|
||||
{
|
||||
}
|
||||
|
||||
prelinkcommands
|
||||
{
|
||||
}
|
||||
|
||||
filter { "platforms:android-*" }
|
||||
kind "StaticLib"
|
||||
system "android"
|
||||
|
||||
toolset "clang"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_ANDROID",
|
||||
"TRIBUFU_UNIX",
|
||||
"TRIBUFU_MOBILE",
|
||||
"TRIBUFU_DYNAMIC",
|
||||
"TRIBUFU_LIBRARY",
|
||||
}
|
||||
|
||||
links
|
||||
{
|
||||
}
|
||||
|
||||
prelinkcommands
|
||||
{
|
||||
}
|
||||
|
||||
filter { "platforms:ios-*" }
|
||||
kind "StaticLib"
|
||||
system "ios"
|
||||
systemversion "13.0"
|
||||
|
||||
toolset "clang"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_IOS",
|
||||
"TRIBUFU_APPLE",
|
||||
"TRIBUFU_MOBILE",
|
||||
"TRIBUFU_MONOLITHIC",
|
||||
"TRIBUFU_LIBRARY",
|
||||
}
|
||||
|
||||
links
|
||||
{
|
||||
}
|
||||
|
||||
-- Architecture
|
||||
|
||||
filter { "platforms:*-i686" }
|
||||
architecture "x32"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_I686",
|
||||
"TRIBUFU_32BITS",
|
||||
}
|
||||
|
||||
filter { "platforms:*-x86_64" }
|
||||
architecture "x64"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_X8664",
|
||||
"TRIBUFU_64BITS",
|
||||
}
|
||||
|
||||
filter { "platforms:*-aarch64" }
|
||||
architecture "ARM64"
|
||||
|
||||
defines
|
||||
{
|
||||
"TRIBUFU_AARCH64",
|
||||
"TRIBUFU_64BITS",
|
||||
}
|
0
vendor/.gitkeep
vendored
Normal file
0
vendor/.gitkeep
vendored
Normal file
21
vendor/cpp-httplib/LICENSE.txt
vendored
Normal file
21
vendor/cpp-httplib/LICENSE.txt
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 yhirose
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
9258
vendor/cpp-httplib/httplib.h
vendored
Normal file
9258
vendor/cpp-httplib/httplib.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
27
vendor/premake/LICENSE.txt
vendored
Normal file
27
vendor/premake/LICENSE.txt
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
Copyright (c) 2003-2019 Jason Perkins and individual contributors.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of Premake nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
BIN
vendor/premake/linux/premake5
vendored
Normal file
BIN
vendor/premake/linux/premake5
vendored
Normal file
Binary file not shown.
BIN
vendor/premake/mac/premake5
vendored
Normal file
BIN
vendor/premake/mac/premake5
vendored
Normal file
Binary file not shown.
BIN
vendor/premake/windows/premake5.exe
vendored
Normal file
BIN
vendor/premake/windows/premake5.exe
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user