Skip to content

Commit 97ad46d

Browse files
committed
0.0.8
- Solved #11 and #12, - added file Types.h, - replaced nlohmann/json as inserted a library to the submodule
1 parent 18cc21a commit 97ad46d

21 files changed

Lines changed: 178 additions & 22987 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,4 +1041,5 @@ dkms.conf
10411041

10421042
# VKAPI
10431043
include/Config.hpp
1044+
include/nlohmann*
10441045
src/main.cpp

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "submodules/json"]
2+
path = submodules/json
3+
url = https://github.com/nlohmann/json

CMakeLists.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,28 @@ include(GNUInstallDirs)
77

88
set(VKAPI_MAJOR_VERSION 0)
99
set(VKAPI_MINOR_VERSION 0)
10-
set(VKAPI_PATCH_VERSION 5)
10+
set(VKAPI_PATCH_VERSION 8)
1111
set(VKAPI_VERSION_STRING "${VKAPI_MAJOR_VERSION}.${VKAPI_MINOR_VERSION}.${VKAPI_PATCH_VERSION}")
1212

13-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/Config.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/include/Config.hpp @ONLY)
14-
1513
set(CMAKE_INCLUDE_CURRENT_DIR ON)
1614

1715
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
1816
set(MACOSX TRUE)
1917
endif()
2018

21-
set(NLOHMANN_JSON_PATH "${PROJECT_SOURCE_DIR}/include")
19+
# set(NLOHMANN_JSON_PATH "${PROJECT_SOURCE_DIR}/include")
2220
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR})
2321

2422
option(BUILD_LIBRARY "Determines that, as a result, we get" ON)
2523
option(BUILD_EXAMPLES "Determines whether examples should be performed" ON)
2624

25+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/Config.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/include/Config.hpp @ONLY)
26+
2727
file(GLOB TARGET_SRC "./src/*.cpp")
2828
file(GLOB TARGET_HEADERS "./include/*.hpp")
2929

30+
include(submodules/install.cmake)
31+
3032
if(BUILD_LIBRARY)
3133
add_library(${PROJECT_NAME} STATIC ${TARGET_SRC} ${TARGET_HEADERS})
3234
else()
@@ -37,18 +39,18 @@ else()
3739
add_executable(${PROJECT_NAME} ${TARGET_SRC} ${TARGET_HEADERS})
3840
endif()
3941

42+
# Include headers
4043
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_INSTALL_INCLUDEDIR})
4144

42-
# Include json
43-
target_link_directories(${PROJECT_NAME} PUBLIC ${NLOHMANN_JSON_PATH})
45+
# Link nlohmann_json
46+
target_link_libraries(${PROJECT_NAME} PUBLIC nlohmann_json)
4447

4548
# Link curl
4649
if(UNIX)
4750
find_package(CURL REQUIRED)
4851
target_link_directories(${PROJECT_NAME} PUBLIC ${CURL_INCLUDE_DIR})
4952
else()
5053
include(FindPkgConfig)
51-
# find_package(CURL REQUIRED)
5254
pkg_check_modules(CURL libcurl REQUIRED)
5355
endif()
5456

VKAPIConfig.cmake.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include(CMakeFindDependencyMacro)
2+
23
find_dependency(CURL REQUIRED)
34

45
@PACKAGE_INIT@

examples/1/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ int main(int argc, const char** argv)
1515
} else {
1616
std::cout << "Auth is failed!" << std::endl;
1717
}
18-
} catch (std::exception ex) {
18+
} catch (std::exception& ex) {
1919
std::cout << ex.what() << std::endl;
2020
}
2121

examples/2/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ int main(int argc, const char** argv)
2323
} else {
2424
// The further behaviour
2525
}
26-
} catch (std::exception ex) {
26+
} catch (std::exception& ex) {
2727
std::cout << ex.what() << std::endl;
2828
}
2929

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ project(VKAPI_TESTS LANGUAGES CXX)
33

44
set(VKAPI_MAJOR_VERSION 0)
55
set(VKAPI_MINOR_VERSION 0)
6-
set(VKAPI_PATCH_VERSION 5)
6+
set(VKAPI_PATCH_VERSION 8)
77

88
set(MODULES 1 2)
99

include/BotBase.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Contains the class for working with vkbot.
33
* @file BotBase.hpp
44
* @author qucals
5-
* @version 0.0.7 24/08/21
5+
* @version 0.0.8 24/08/21
66
*/
77

88
#ifndef VKAPI_BOTBASE_HPP
@@ -19,7 +19,7 @@ namespace base
1919
namespace bot
2020
{
2121

22-
constexpr const char* DEFAULT_TIME_WAIT = "25";
22+
_VKAPI_CONSTEXPR const char* DEFAULT_TIME_WAIT = "25";
2323

2424
/**
2525
* @brief The class for working from bots by Long Poll Server.
@@ -160,7 +160,6 @@ class BotBase : public ClientBase
160160
*
161161
* @retval a string (URL) of this method.
162162
*/
163-
_VKAPI_COMPLEXITY_FUNCTION
164163
_VKAPI_STATIC std::string MethodToString(METHODS method);
165164

166165
/**
@@ -226,7 +225,6 @@ class BotBase : public ClientBase
226225
*
227226
* @retval the type of event in enum (EVENTS).
228227
*/
229-
_VKAPI_COMPLEXITY_FUNCTION
230228
_VKAPI_STATIC EVENTS GetTypeEvent(const std::string& typeEvent);
231229

232230
private:
@@ -269,6 +267,8 @@ class BotBase : public ClientBase
269267
std::string m_timeStamp;
270268

271269
std::string m_timeWait;
270+
271+
272272
};
273273

274274
} // namespace bot

include/ClientBase.hpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Contains general objects for working with VK API.
33
* @file ClientBase.hpp
44
* @author qucals
5-
* @version 0.0.7 24/08/21
5+
* @version 0.0.8 24/08/21
66
*/
77

88
#ifndef VKAPI_CLIENTBASE_HPP
@@ -14,6 +14,7 @@
1414
#include "Utilities.hpp" // ConvertStrToUrlCode
1515
#include "Exceptions.hpp" // already_connected, not_connected, empty_argument
1616
#include "Defines.hpp"
17+
#include "Types.hpp"
1718

1819
#ifdef __VKAPI_VERSION_ADDED_OPTIONAL
1920
#if __VKAPI_COMPILED_VERSION >= __VKAPI_VERSION_ADDED_OPTIONAL
@@ -39,22 +40,14 @@ namespace vk
3940
namespace base
4041
{
4142

42-
#ifndef VKAPI_OPTIONAL_HPP
43-
typedef nlohmann::json JsonType;
44-
45-
typedef long long int IdType;
46-
typedef unsigned long long UIdType;
47-
typedef bool IndicatorType;
48-
#endif // VKAPI_OPTIONAL_HPP
49-
5043
#define VKAPI_INVALID_REQUEST "invalid_request"
5144
#define VKAPI_NEED_CAPTCHA "need_captcha"
5245

53-
constexpr const char* VKAPI_API_URL = "https://api.vk.com/method/";
54-
constexpr const char* VKAPI_AUTH_URL = "https://oauth.vk.com/token?";
55-
constexpr const char* VKAPI_OAUTH_URL = "https://oauth.vk.com/authorize?";
56-
constexpr const char* VKAPI_OAUTH_URL_SECOND = "https://oauth.vk.com/access_token?";
57-
constexpr const char* VKAPI_API_VERSION = "5.120";
46+
_VKAPI_CONSTEXPR const char* VKAPI_API_URL = "https://api.vk.com/method/";
47+
_VKAPI_CONSTEXPR const char* VKAPI_AUTH_URL = "https://oauth.vk.com/token?";
48+
_VKAPI_CONSTEXPR const char* VKAPI_OAUTH_URL = "https://oauth.vk.com/authorize?";
49+
_VKAPI_CONSTEXPR const char* VKAPI_OAUTH_URL_SECOND = "https://oauth.vk.com/access_token?";
50+
_VKAPI_CONSTEXPR const char* VKAPI_API_VERSION = "5.120";
5851

5952
// The types of error which the VK server can return.
6053
// You can see the description of these on https://vk.com/dev/errors

include/Defines.hpp

Lines changed: 39 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Contains general defines about the language.
33
* @file Defines.hpp
44
* @author qucals
5-
* @version 0.0.7 24/08/21
5+
* @version 0.0.8 24/08/21
66
*/
77

88
#ifndef VKAPI_DEFINES_HPP
@@ -35,65 +35,37 @@
3535
#endif // (__cplusplus >= 202002L)
3636

3737
#ifdef __CPLUSPLUS_OVER_11
38-
#ifndef _VKAPI_OVERRIDE
39-
#define _VKAPI_OVERRIDE override
40-
#endif // _VKAPI_OVERRIDE
38+
#define _VKAPI_OVERRIDE override
39+
#define _VKAPI_FINAL final
40+
#define _VKAPI_NOEXCEPT noexcept
41+
#define _VKAPI_EXPLICIT explicit
42+
#define _VKAPI_CONSTEXPR constexpr
4143

42-
#ifndef _VKAPI_FINAL
43-
#define _VKAPI_FINAL final
44-
#endif // _VKAPI_FINAL
45-
46-
#ifndef _VKAPI_NOEXCEPT
47-
#define _VKAPI_NOEXCEPT noexcept
48-
#endif // _VKAPI_NOEXCEPT
49-
50-
#ifndef _VKAPI_EXPLICIT
51-
#define _VKAPI_EXPLICIT explicit
52-
#endif // _VKAPI_EXPLICIT
53-
54-
#ifndef _VKAPI_MOVE
5544
#include <utility>
56-
#define _VKAPI_MOVE(x) std::move(x)
57-
#endif // _VKAPI_MOVE(x)
45+
#define _VKAPI_MOVE(x) std::move(x)
5846
#else
59-
#ifndef _VKAPI_OVERRIDE
6047
#define _VKAPI_OVERRIDE
61-
#endif // _VKAPI_OVERRIDE
62-
63-
#ifndef _VKAPI_FINAL
6448
#define _VKAPI_FINAL
65-
#endif // _VKAPI_FINAL
66-
67-
#ifndef _VKAPI_NOEXCEPT
6849
#define _VKAPI_NOEXCEPT
69-
#endif // _VKAPI_NOEXCEPT
70-
71-
#ifndef _VKAPI_EXPLICIT
7250
#define _VKAPI_EXPLICIT
73-
#endif // _VKAPI_EXPLICIT
74-
75-
#ifndef _VKAPI_MOVE
76-
#define _VKAPI_MOVE(x) x
77-
#endif // _VKAPI_MOVE
51+
#define _VKAPI_CONSTEXPR
52+
#define _VKAPI_MOVE(x) x
7853
#endif
7954

80-
#ifndef _VKAPI_VIRTUAL
81-
#define _VKAPI_VIRTUAL virtual
82-
#endif // _VKAPI_VIRTUAL
55+
#define _VKAPI_VIRTUAL virtual
56+
#define _VKAPI_INLINE inline
8357

84-
#ifndef _VKAPI_INLINE
85-
#define _VKAPI_INLINE inline
86-
#endif // _VKAPI_INLINE
87-
88-
#ifndef _VKAPI_UNUSED
8958
#define _VKAPI_UNUSED(x) (void)(x)
90-
#endif // _VKAPI_UNUSED
9159

9260
#if defined(_MSC_VER)
61+
#define _VKAPI_MSVC 1
62+
9363
#define __DISABLE_WARNING_PUSH __pragma(warning(push))
9464
#define __DISABLE_WARNING_POP __pragma(warning(pop))
9565
#define __DISABLE_WARNING(warningNumber) __pragma(warning(disable : warningNumber))
9666
#elif defined(__GNUC__) || defined(__clang__)
67+
#define _VKAPI_CLANG 1
68+
9769
#define __DO_PRAGMA(X) _Pragma(#X)
9870
#define __DISABLE_WARNING_PUSH __DO_PRAGMA("GCC diagnostic push")
9971
#define __DISABLE_WARNING_POP __DO_PRAGMA("GCC diagnostic pop")
@@ -104,11 +76,32 @@
10476
#define __DISABLE_WARNING
10577
#endif
10678

79+
#ifndef _VKAPI_MSVC
80+
#define _VKAPI_MSVC 0
81+
#endif // _VKAPI_MSVC
82+
83+
#ifndef _VKAPI_CLANG
84+
#define _VKAPI_CLANG 0
85+
#endif // _VKAPI_CLANG
86+
87+
#if _VKAPI_MSVC
88+
#define _VKAPI_UNUSED_FOR_ANALYZER
89+
#elif _VKAPI_CLANG
90+
#define _VKAPI_UNUSED_FOR_ANALYZER __attribute__((unused))
91+
#endif
92+
93+
#ifndef _VKAPI_DEBUG_PRINT
94+
#if __DEBUG__
95+
#define _VKAPI_DEBUG_STDCERR(x) (std::cerr << (x))
96+
#define _VKAPI_DEBUG_STDCOUT(x) (std::cout << (x))
97+
#else
98+
#define _VKAPI_DEBUG_STDCERR(x)
99+
#define _VKAPI_DEBUG_STDCOUT(x)
100+
#endif // __DEBUG__
101+
#endif // _VKAPI_DEBUG_PRINT
102+
107103
#ifndef __VKAPI_VERSION_ADDED_OPTIONAL
108104
#define __VKAPI_VERSION_ADDED_OPTIONAL __VKAPI_VERSION_NUM(0, 0, 7)
109105
#endif // __VKAPI_VERSION_ADDED_OPTIONAL
110106

111-
// TODO(#14): Write defines for disable complexity warnings
112-
#define _VKAPI_COMPLEXITY_FUNCTION
113-
114107
#endif //VKAPI_DEFINES_HPP

0 commit comments

Comments
 (0)