Lesson 35 - Get Compute Auth Token Working
This commit is contained in:
53
Plugins/GameLiftPlugin/Source/CoreSDK/CoreSDK.Build.cs
Normal file
53
Plugins/GameLiftPlugin/Source/CoreSDK/CoreSDK.Build.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
public class CoreSDK : ModuleRules
|
||||
{
|
||||
private string[] LibraryNames =
|
||||
{
|
||||
"aws-gamelift-profiles",
|
||||
"aws-gamelift-authentication",
|
||||
"aws-gamelift-core",
|
||||
};
|
||||
|
||||
public CoreSDK(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
Type = ModuleType.External;
|
||||
|
||||
PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "Include"));
|
||||
|
||||
if (Target.Type == TargetRules.TargetType.Editor || Target.Type == TargetRules.TargetType.Client)
|
||||
{
|
||||
// yaml-cpp
|
||||
string ThirdPartyPath = Path.Combine(ModuleDirectory, "ThirdParty");
|
||||
string YamlCppIncludePath = Path.Combine(Path.Combine(ThirdPartyPath, "yaml-cpp"), "include");
|
||||
string YamlCppLibPath = Path.Combine(Path.Combine(ThirdPartyPath, "yaml-cpp"), "lib");
|
||||
PublicIncludePaths.Add(YamlCppIncludePath);
|
||||
PublicAdditionalLibraries.Add(Path.Combine(YamlCppLibPath, "yaml-cpp.lib"));
|
||||
|
||||
// Core SDK
|
||||
string LibrarysPath = Path.Combine(ModuleDirectory, "Binaries", UnrealTargetPlatform.Win64.ToString());
|
||||
string OutputDir = Path.Combine("$(ProjectDir)", "Binaries", UnrealTargetPlatform.Win64.ToString());
|
||||
|
||||
foreach (string LibName in LibraryNames)
|
||||
{
|
||||
string LibFileName = LibName + ".lib";
|
||||
string DllFileName = LibName + ".dll";
|
||||
|
||||
// Add the import library
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibrarysPath, LibFileName));
|
||||
|
||||
// Do not load the DLL during startup. Delay-load the DLL when it is actually used.
|
||||
PublicDelayLoadDLLs.Add(DllFileName);
|
||||
|
||||
// This stages the DLL next to the executable when you package your game.
|
||||
RuntimeDependencies.Add(Path.Combine(OutputDir, DllFileName), Path.Combine(LibrarysPath, DllFileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
/** @file
|
||||
* @brief The C interface for the Authentication library.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <aws/gamelift/authentication/gamelift_session_manager.h>
|
||||
#include <aws/gamelift/core/api.h>
|
||||
#include <aws/gamelift/core/logging.h>
|
||||
|
||||
/**
|
||||
* @brief GameLiftSessionManager instance handle created by calling #GameLiftSessionManagerInstanceCreate()
|
||||
*/
|
||||
typedef void* GAMELIFT_SESSIONMANAGER_INSTANCE_HANDLE;
|
||||
|
||||
/**
|
||||
* @brief A pointer to an instance of a class that can receive a callback.
|
||||
*
|
||||
* @details The callback method signature is specified by each API which uses a DISPATCH_RECEIVER_HANDLE.
|
||||
*
|
||||
* For example: GameLiftSettingsGetGameName() uses a callback signature of CharPtrCallback,
|
||||
* whereas GameLiftSettingsGetCustomEnvironments() uses a callback signature of KeyValueCharPtrCallbackDispatcher.
|
||||
*/
|
||||
typedef void* DISPATCH_RECEIVER_HANDLE;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
/**
|
||||
* @brief A static dispatcher function pointer that receives a character array.
|
||||
*
|
||||
* @param dispatchReceiver A pointer to an instance of a class where the results will be dispatched to.
|
||||
* This instance must have a method signature of void ReceiveResult(const char* charPtr);
|
||||
* @param charPtr The character array pointer that the callback function receives.
|
||||
*/
|
||||
typedef void(*CharPtrCallback)(DISPATCH_RECEIVER_HANDLE dispatchReceiver, const char* charPtr);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
/**
|
||||
* @brief Create a GameLiftSessionManager instance, which can be used to access the SessionManager API.
|
||||
*
|
||||
* @details Make sure to call GameLiftSessionManagerInstanceRelease() to destroy the returned object when finished with it.
|
||||
*
|
||||
* @param clientConfigFile (Optional, can be a nullptr or empty string) Relative filepath to the generated file "awsGameLiftClientConfig.yml".
|
||||
* The config file is generated by GAMELIFT each time a feature is deployed or re-deployed, and has settings for each GAMELIFT feature you've deployed.
|
||||
* @param logCb Callback function for logging information and errors.
|
||||
* @return Pointer to the new GameLiftSessionManager instance.
|
||||
*/
|
||||
GAMELIFT_API GAMELIFT_SESSIONMANAGER_INSTANCE_HANDLE GameLiftSessionManagerInstanceCreate(const char* clientConfigFile, FuncLogCallback logCb);
|
||||
|
||||
/**
|
||||
* @brief Check if the settings are loaded for the feature.
|
||||
*
|
||||
* @detailed These settings are found in file "awsGameLiftClientConfig.yml" which is generated by GAMELIFT each time you deploy or re-deploy a feature.
|
||||
* The file is loaded by calling either GameLiftSessionManagerInstanceCreate() or GameLiftSessionManagerReloadConfigFile().
|
||||
*
|
||||
* @param sessionManagerInstance Pointer to GameLiftSessionManager instance created with GameLiftSessionManagerInstanceCreate().
|
||||
* @param featureType The feature to check.
|
||||
* @return True if the settings for the feature are loaded, false otherwise.
|
||||
*/
|
||||
GAMELIFT_API bool GameLiftSessionManagerAreSettingsLoaded(GAMELIFT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance, GameLift::FeatureType featureType);
|
||||
|
||||
/**
|
||||
* @brief Replace any loaded client settings with new settings from the provided file.
|
||||
*
|
||||
* @param sessionManagerInstance Pointer to GameLiftSessionManager instance created with GameLiftSessionManagerInstanceCreate().
|
||||
* @param clientConfigFile Relative filepath to the generated file "awsGameLiftClientConfig.yml".
|
||||
* The config file is generated by GAMELIFT each time a feature is deployed or re-deployed, and has settings for each GAMELIFT feature you've deployed.
|
||||
*/
|
||||
GAMELIFT_API void GameLiftSessionManagerReloadConfigFile(GAMELIFT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance, const char* clientConfigFile);
|
||||
|
||||
/**
|
||||
* @brief Update AccessToken, RefreshToken and IdToken values by username and password.
|
||||
*
|
||||
* @details Session manager has to configured. The user_pool_client_id and identity_region must be set.
|
||||
*
|
||||
* @param sessionManagerInstance Pointer to GameLiftSessionManager instance created with GameLiftSessionManagerInstanceCreate().
|
||||
* @param user Username
|
||||
* @param pass Password
|
||||
*/
|
||||
GAMELIFT_API unsigned int GameLiftAuthByUsernamePassword(GAMELIFT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance, const char* user, const char* pass);
|
||||
|
||||
/**
|
||||
* @brief SignUp by username and password.
|
||||
*
|
||||
* @details Create new user in Cognito user pull with username and password.
|
||||
*
|
||||
* @param sessionManagerInstance Pointer to GameLiftSessionManager instance created with GameLiftSessionManagerInstanceCreate().
|
||||
* @param user Username
|
||||
* @param pass Password
|
||||
*/
|
||||
GAMELIFT_API unsigned int GameLiftSignUpByUsernamePassword(GAMELIFT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance, const char* user, const char* pass);
|
||||
|
||||
/**
|
||||
* @brief Confirm SignUp by username and code.
|
||||
*
|
||||
* @param sessionManagerInstance Pointer to GameLiftSessionManager instance created with GameLiftSessionManagerInstanceCreate().
|
||||
* @param user Username
|
||||
* @param code Confirmation code
|
||||
*/
|
||||
GAMELIFT_API unsigned int GameLiftConfirmSignUpByUsernameCode(GAMELIFT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance, const char* user, const char* code);
|
||||
|
||||
/**
|
||||
* @brief Get tokenId.
|
||||
*
|
||||
* @details Get tokenId.
|
||||
*
|
||||
* @param sessionManagerInstance Pointer to GameLiftSessionManager instance created with GameLiftSessionManagerInstanceCreate().
|
||||
* @param dispatchReceiver Pointer to the caller object (object that will handle the callback function).
|
||||
* @param resultCb Pointer to the callback function to invoke on completion.
|
||||
*/
|
||||
GAMELIFT_API void GameLiftGetTokenId(GAMELIFT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance, DISPATCH_RECEIVER_HANDLE dispatchReceiver, CharPtrCallback resultCb);
|
||||
|
||||
/**
|
||||
* @brief Get Identity Api Gateway URL.
|
||||
*
|
||||
* @details Get Identity Api Gateway URL.
|
||||
*
|
||||
* @param sessionManagerInstance Pointer to GameLiftSessionManager instance created with GameLiftSessionManagerInstanceCreate().
|
||||
* @param dispatchReceiver Pointer to the caller object (object that will handle the callback function).
|
||||
* @param resultCb Pointer to the callback function to invoke on completion.
|
||||
*/
|
||||
GAMELIFT_API unsigned int GameLiftGetIdentityApiGatewayURL(GAMELIFT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance, DISPATCH_RECEIVER_HANDLE dispatchReceiver, CharPtrCallback resultCb);
|
||||
|
||||
/**
|
||||
* @brief Destroy the provided GameLiftSessionManager instance.
|
||||
*
|
||||
* @param sessionManagerInstance Pointer to GameLiftSessionManager instance created with GameLiftSessionManagerInstanceCreate().
|
||||
*/
|
||||
GAMELIFT_API void GameLiftSessionManagerInstanceRelease(GAMELIFT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance);
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
// Standard Library
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
// AWS SDK
|
||||
#include <aws/cognito-idp/CognitoIdentityProviderClient.h>
|
||||
#include <aws/cognito-idp/CognitoIdentityProviderErrors.h>
|
||||
#include <aws/cognito-idp/model/InitiateAuthRequest.h>
|
||||
#include <aws/cognito-idp/model/SignUpRequest.h>
|
||||
#include <aws/cognito-idp/model/ConfirmSignUpRequest.h>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/api.h>
|
||||
#include <aws/gamelift/core/awsclients/api_initializer.h>
|
||||
#include <aws/gamelift/core/awsclients/default_clients.h>
|
||||
#include <aws/gamelift/core/enums.h>
|
||||
#include <aws/gamelift/core/logging.h>
|
||||
#include <aws/gamelift/core/utils/ticker.h>
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
namespace ClientSettings
|
||||
{
|
||||
namespace Authentication
|
||||
{
|
||||
static const std::string SETTINGS_USER_POOL_CLIENT_ID = "user_pool_client_id";
|
||||
static const std::string SETTINGS_IDENTITY_REGION = "identity_region";
|
||||
static const std::string SETTINGS_IDENTITY_API_GATEWAY_BASE_URL = "identity_api_gateway_base_url";
|
||||
}
|
||||
|
||||
namespace Achievements
|
||||
{
|
||||
static const std::string SETTINGS_ACHIEVEMENTS_API_GATEWAY_BASE_URL = "achievements_api_gateway_base_url";
|
||||
static const std::string SETTINGS_ACHIEVEMENTS_ICONS_BASE_URL = "achievements_icons_base_url";
|
||||
}
|
||||
|
||||
namespace UserGameplayData
|
||||
{
|
||||
static const std::string SETTINGS_USER_GAMEPLAY_DATA_API_GATEWAY_BASE_URL = "usergamedata_api_gateway_base_url";
|
||||
}
|
||||
|
||||
namespace GameSaving
|
||||
{
|
||||
static const std::string SETTINGS_GAME_SAVING_BASE_URL = "gamesaving_api_gateway_base_url";
|
||||
}
|
||||
}
|
||||
|
||||
namespace Authentication
|
||||
{
|
||||
static const int DEFAULT_REFRESH_SECONDS_BEFORE_EXPIRATION = 120;
|
||||
static const int MAX_REFRESH_RETRY_ATTEMPTS = 5;
|
||||
|
||||
class GAMELIFT_API GameLiftSessionManager
|
||||
{
|
||||
private:
|
||||
std::mutex m_sessionTokensMutex;
|
||||
std::array<std::string, (size_t)TokenType::TokenType_COUNT> m_sessionTokens; // Indexed by TokenType enum values
|
||||
std::shared_ptr<Utils::Ticker> m_tokenRefresher;
|
||||
FuncLogCallback m_logCb = nullptr;
|
||||
std::shared_ptr<std::map<std::string, std::string>> m_clientSettings;
|
||||
Aws::CognitoIdentityProvider::CognitoIdentityProviderClient* m_cognitoClient;
|
||||
bool m_awsClientsInitializedInternally;
|
||||
|
||||
void loadConfigFile(std::string clientConfigFile) const;
|
||||
|
||||
protected:
|
||||
void executeTokenRefresh();
|
||||
|
||||
public:
|
||||
GameLiftSessionManager(const std::string& clientConfigFile, FuncLogCallback logCallback);
|
||||
virtual ~GameLiftSessionManager();
|
||||
|
||||
/**
|
||||
* @brief Initializes the AWS Clients internally.
|
||||
* Clients initialized with this method will be deleted on ~SessionManager().
|
||||
*/
|
||||
bool InitializeDefaultAwsClients();
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
unsigned int UpdateTokensByUserPass(const std::string& user, const std::string& pass);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
unsigned int SignUpByUserPass(const std::string& user, const std::string& pass);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
unsigned int ConfirmSignUp(const std::string& user, const std::string& code);
|
||||
|
||||
/**
|
||||
* @brief Sets a token's value.
|
||||
* @param tokenType The type of token to set.
|
||||
* @param value The value of the token.
|
||||
*/
|
||||
void SetToken(TokenType tokenType, const std::string& value);
|
||||
|
||||
/**
|
||||
* @brief Retrieves a token.
|
||||
* @param tokenType The type of token to retrieve.
|
||||
* @return Token string.
|
||||
*/
|
||||
std::string GetToken(TokenType tokenType);
|
||||
|
||||
/**
|
||||
* @brief Deletes a token.
|
||||
* @param tokenType The type of token to delete.
|
||||
*/
|
||||
void DeleteToken(TokenType tokenType);
|
||||
|
||||
/**
|
||||
* @brief Sets the token's session expiration.
|
||||
* @param expirationInSeconds Token duration before it expires.
|
||||
*/
|
||||
void SetSessionExpiration(int expirationInSeconds);
|
||||
|
||||
/**
|
||||
* @brief Checks if the settings are loaded for the feature. These settings are found in the generated awsGameLiftClientConfig.yml.
|
||||
* The setting are loaded either through the constructor of GameLiftSessionManager or by calling ReloadConfigFile().
|
||||
* @param featureType The feature to check
|
||||
* @return Returns true if the settings for the feature are loaded.
|
||||
*/
|
||||
bool AreSettingsLoaded(FeatureType featureType) const;
|
||||
|
||||
/**
|
||||
* @brief Get the current client settings.
|
||||
* @return A map of the current client settings.
|
||||
*/
|
||||
Aws::Map<std::string, std::string> GetClientSettings() const;
|
||||
|
||||
/**
|
||||
* @brief Reads and loads the configuration file into SessionManager.
|
||||
* @param clientConfigFile The awsGameLiftClientConfig.yml file to reload.
|
||||
*/
|
||||
void ReloadConfigFile(std::string clientConfigFile);
|
||||
|
||||
inline static std::string GetTokenTypeString(TokenType tokenType)
|
||||
{
|
||||
switch (tokenType)
|
||||
{
|
||||
case TokenType::AccessToken: return "access_token";
|
||||
case TokenType::RefreshToken: return "refresh_token";
|
||||
case TokenType::IdToken: return "id_token";
|
||||
case TokenType::IamSessionToken: return "session_token";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
// Sets the CognitoIdentityProviderClient explicitly.
|
||||
// It's the caller responsibility to call delete on the instance passed to this method.
|
||||
inline void SetCognitoClient(Aws::CognitoIdentityProvider::CognitoIdentityProviderClient* client)
|
||||
{
|
||||
m_awsClientsInitializedInternally = false;
|
||||
m_cognitoClient = client;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
/** @file
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#define GAMELIFT_API __declspec(dllexport)
|
||||
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
// Standard Lib
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/api.h>
|
||||
#include <aws/gamelift/core/logging.h>
|
||||
|
||||
// yaml-cpp
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
using namespace GameLift::Logger;
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
static const std::string GAMELIFT_AWS_REGION_MAPPINGS_FILE_NAME = "awsGameLiftAwsRegionMappings.yml";
|
||||
static const std::string GAMELIFT_FIVE_LETTER_REGION_CODES_PREFIX = "five_letter_region_codes";
|
||||
|
||||
class GAMELIFT_API AwsRegionMappings
|
||||
{
|
||||
private:
|
||||
std::string m_pluginRootPath;
|
||||
YAML::Node m_regionShortCodes;
|
||||
FuncLogCallback m_logCb;
|
||||
|
||||
// Make the constructors and destructor private to prevent duplicate instances
|
||||
AwsRegionMappings() {};
|
||||
AwsRegionMappings(const std::string& pluginRootPath, FuncLogCallback logCallback);
|
||||
~AwsRegionMappings();
|
||||
|
||||
std::string GetRegionMappingsFilePath() const;
|
||||
|
||||
public:
|
||||
// Delete constructors and operator overloading that should not be used
|
||||
AwsRegionMappings(const AwsRegionMappings&) = delete;
|
||||
const AwsRegionMappings& operator=(const AwsRegionMappings&) = delete;
|
||||
|
||||
static AwsRegionMappings& getInstance(const std::string& pluginRootPath, FuncLogCallback logCallback);
|
||||
|
||||
/**
|
||||
* @brief Get the 5-letter region code for AWS region.
|
||||
*
|
||||
* @details Converts an input AWS region code to it's 5-letter short code based on mapping in GAMELIFT_AWS_REGION_MAPPINGS_FILE_NAME in gamelift root directory.
|
||||
*
|
||||
* @param fullRegionCode Input aws region code.
|
||||
* @returns 5-letter short region code based on mapping in GAMELIFT_AWS_REGION_MAPPINGS_FILE_NAME in plugin, empty string if error or doesn't exist in map.
|
||||
*/
|
||||
std::string getFiveLetterRegionCode(const std::string& fullRegionCode) const;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
// Standard Library
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/api.h>
|
||||
#include <aws/gamelift/core/logging.h>
|
||||
|
||||
// Forward declarations
|
||||
namespace Aws { struct SDKOptions; }
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
// This singleton class helps ensure that the AWS SDK InitAPI and ShutdownAPI methods are only called once
|
||||
class GAMELIFT_API AwsApiInitializer
|
||||
{
|
||||
private:
|
||||
static std::mutex m_mutex;
|
||||
static bool m_isAwsSdkInitialized;
|
||||
static std::unique_ptr<Aws::SDKOptions> m_awsSdkOptions;
|
||||
static int m_count;
|
||||
|
||||
public:
|
||||
// Calls Aws::InitAPI()
|
||||
static void Initialize(FuncLogCallback log = nullptr, const void* caller = nullptr);
|
||||
|
||||
// Calls Aws::ShutdownAPI()
|
||||
static void Shutdown(FuncLogCallback log = nullptr, const void* caller = nullptr);
|
||||
|
||||
static bool IsInitialized();
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// AWS SDK
|
||||
#include <aws/apigateway/APIGatewayClient.h>
|
||||
#include <aws/apigateway/APIGateway_EXPORTS.h>
|
||||
#include <aws/cloudformation/CloudFormationClient.h>
|
||||
#include <aws/cognito-idp/CognitoIdentityProviderClient.h>
|
||||
#include <aws/core/auth/AWSCredentials.h>
|
||||
#include <aws/gamelift/GameLiftClient.h>
|
||||
#include <aws/lambda/LambdaClient.h>
|
||||
#include <aws/s3/S3Client.h>
|
||||
#include <aws/secretsmanager/SecretsManagerClient.h>
|
||||
#include <aws/ssm/SSMClient.h>
|
||||
#include <aws/sts/STSClient.h>
|
||||
#include <aws/ecr/ECRClient.h>
|
||||
#include <aws/sts/model/AssumeRoleRequest.h>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/model/account_credentials.h>
|
||||
#include <aws/gamelift/core/model/account_info.h>
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
class DefaultClients
|
||||
{
|
||||
private:
|
||||
template <class T>
|
||||
static inline T* getDefaultClient(const AccountCredentialsCopy& credentials)
|
||||
{
|
||||
Aws::Client::ClientConfiguration clientConfig;
|
||||
Aws::Auth::AWSCredentials creds;
|
||||
|
||||
clientConfig.region = credentials.region.c_str();
|
||||
creds.SetAWSAccessKeyId(credentials.accessKey.c_str());
|
||||
creds.SetAWSSecretKey(credentials.accessSecret.c_str());
|
||||
creds.SetSessionToken(credentials.accessToken.c_str());
|
||||
|
||||
return new T(creds, clientConfig);
|
||||
}
|
||||
|
||||
static inline Aws::S3::S3Client* getDefaultS3Client(const AccountCredentialsCopy& credentials)
|
||||
{
|
||||
Aws::Client::ClientConfiguration clientConfig;
|
||||
Aws::Auth::AWSCredentials creds;
|
||||
|
||||
clientConfig.region = credentials.region.c_str();
|
||||
creds.SetAWSAccessKeyId(credentials.accessKey.c_str());
|
||||
creds.SetAWSSecretKey(credentials.accessSecret.c_str());
|
||||
creds.SetSessionToken(credentials.accessToken.c_str());
|
||||
|
||||
return new Aws::S3::S3Client(
|
||||
creds,
|
||||
Aws::MakeShared<Aws::S3::S3EndpointProvider>(Aws::S3::S3Client::GetAllocationTag()),
|
||||
clientConfig);
|
||||
}
|
||||
|
||||
public:
|
||||
static inline Aws::S3::S3Client* GetDefaultS3Client(const AccountCredentialsCopy& credentials)
|
||||
{
|
||||
return getDefaultS3Client(credentials);
|
||||
}
|
||||
|
||||
static inline Aws::SSM::SSMClient* GetDefaultSSMClient(const AccountCredentialsCopy& credentials)
|
||||
{
|
||||
return getDefaultClient<Aws::SSM::SSMClient>(credentials);
|
||||
}
|
||||
|
||||
static inline Aws::CloudFormation::CloudFormationClient* GetDefaultCloudFormationClient(const AccountCredentialsCopy& credentials)
|
||||
{
|
||||
return getDefaultClient<Aws::CloudFormation::CloudFormationClient>(credentials);
|
||||
}
|
||||
|
||||
static inline Aws::SecretsManager::SecretsManagerClient* GetDefaultSecretsManagerClient(const AccountCredentialsCopy& credentials)
|
||||
{
|
||||
return getDefaultClient<Aws::SecretsManager::SecretsManagerClient>(credentials);
|
||||
}
|
||||
|
||||
static inline Aws::CognitoIdentityProvider::CognitoIdentityProviderClient* GetDefaultCognitoIdentityProviderClient(const Aws::Client::ClientConfiguration& clientConfig)
|
||||
{
|
||||
return new Aws::CognitoIdentityProvider::CognitoIdentityProviderClient(clientConfig);
|
||||
}
|
||||
|
||||
static inline Aws::APIGateway::APIGatewayClient* GetDefaultApiGatewayClient(const AccountCredentialsCopy& credentials)
|
||||
{
|
||||
return getDefaultClient<Aws::APIGateway::APIGatewayClient>(credentials);
|
||||
}
|
||||
|
||||
static inline Aws::Lambda::LambdaClient* GetDefaultLambdaClient(const AccountCredentialsCopy& credentials)
|
||||
{
|
||||
return getDefaultClient<Aws::Lambda::LambdaClient>(credentials);
|
||||
}
|
||||
|
||||
static inline Aws::GameLift::GameLiftClient* GetDefaultGameLiftClient(const AccountCredentialsCopy& credentials)
|
||||
{
|
||||
return getDefaultClient<Aws::GameLift::GameLiftClient>(credentials);
|
||||
}
|
||||
static inline Aws::ECR::ECRClient* GetDefaultECRClient(const AccountCredentialsCopy& credentials)
|
||||
{
|
||||
return getDefaultClient<Aws::ECR::ECRClient>(credentials);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
// Standard Library
|
||||
|
||||
// AWS SDK
|
||||
#include <aws/gamelift/core/logging.h>
|
||||
#include <aws/core/utils/memory/AWSMemory.h>
|
||||
#include <aws/core/utils/memory/stl/AWSMap.h>
|
||||
#include <aws/core/utils/memory/stl/AWSList.h>
|
||||
#include <aws/core/utils/memory/stl/AWSString.h>
|
||||
#include <aws/core/config/AWSProfileConfigLoader.h>
|
||||
|
||||
namespace Aws {
|
||||
namespace Config
|
||||
{
|
||||
class ConfigAndCredentialsCacheManager;
|
||||
}
|
||||
}
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
namespace Config
|
||||
{
|
||||
class GAMELIFT_API GameLiftConfigManager
|
||||
{
|
||||
private:
|
||||
FuncLogCallback m_logCb = nullptr;
|
||||
|
||||
Aws::Map<Aws::String, Aws::Config::Profile> m_profiles;
|
||||
|
||||
protected:
|
||||
void SetProfiles(const Aws::Map<Aws::String, Aws::Config::Profile>& profiles);
|
||||
|
||||
public:
|
||||
GameLiftConfigManager(FuncLogCallback logCallback, const Aws::Map<Aws::String, Aws::Config::Profile>& profiles);
|
||||
GameLiftConfigManager(FuncLogCallback logCallback);
|
||||
virtual ~GameLiftConfigManager();
|
||||
|
||||
Aws::List<Aws::String> GetProfileNames();
|
||||
|
||||
bool CreateProfile(const Aws::String& profileName);
|
||||
bool RenameProfile(const Aws::String& profileName, const Aws::String& newProfileName);
|
||||
|
||||
const Aws::String& GetAccessKey(const Aws::String& profileName) const;
|
||||
bool SetAccessKey(const Aws::String& profileName, const Aws::String& accessKey);
|
||||
const Aws::String& GetSecretAccessKey(const Aws::String& profileName) const;
|
||||
bool SetSecretAccessKey(const Aws::String& profileName, const Aws::String& secretAccessKey);
|
||||
const Aws::String& GetSessionToken(const Aws::String& profileName) const;
|
||||
bool SetSessionToken(const Aws::String& profileName, const Aws::String& accessToken);
|
||||
const Aws::String& GetRegion(const Aws::String& profileName) const;
|
||||
bool SetRegion(const Aws::String& profileName, const Aws::String& region);
|
||||
|
||||
bool Save();
|
||||
|
||||
private:
|
||||
bool Exist(const Aws::String& profileName) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
/** @file
|
||||
* @brief The C interface for the Config library.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <aws/gamelift/core/logging.h>
|
||||
|
||||
/**
|
||||
* @brief GameLiftConfigManager instance handle created by calling #GameLiftConfigManagerInstanceCreate()
|
||||
*/
|
||||
typedef void* GAMELIFT_CONFIGMANAGER_INSTANCE_HANDLE;
|
||||
|
||||
/**
|
||||
* @brief A pointer to an instance of a class that can receive a callback.
|
||||
*
|
||||
* @details The callback method signature is specified by each API which uses a DISPATCH_RECEIVER_HANDLE.
|
||||
*/
|
||||
typedef void* DISPATCH_RECEIVER_HANDLE;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
/**
|
||||
* @brief A static dispatcher function pointer that receives a character array.
|
||||
*
|
||||
* @param dispatchReceiver A pointer to an instance of a class where the results will be dispatched to.
|
||||
* This instance must have a method signature of void ReceiveResult(const char* charPtr);
|
||||
* @param charPtr The character array pointer that the callback function receives.
|
||||
*/
|
||||
typedef void(*CharPtrCallback)(DISPATCH_RECEIVER_HANDLE dispatchReceiver, const char* charPtr);
|
||||
|
||||
/**
|
||||
* @brief A static dispatcher function pointer that receives key/value pairs, one invocation at a time.
|
||||
*
|
||||
* @param dispatchReceiver A pointer to an instance of a class where the results will be dispatched to.
|
||||
* This instance must have have a method signature of void ReceiveResult(const char* charKey, const char* charValue);
|
||||
* @param charKey The key that the callback function receives.
|
||||
* @param charValue The value that the callback function receives.
|
||||
*/
|
||||
typedef void(*KeyValueCharPtrCallbackDispatcher)(DISPATCH_RECEIVER_HANDLE dispatchReceiver, const char* charKey, const char* charValue);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
/**
|
||||
* @brief Create a GameLiftConfigManager instance, which can be used to access the Core Config API.
|
||||
*
|
||||
* @details Make sure to call GameLiftConfigManagerInstanceRelease() to destroy the returned object when finished with it.
|
||||
*
|
||||
* @param logCb Callback function for logging information and errors.
|
||||
* @return Pointer to the new GameLiftConfigManager instance.
|
||||
*/
|
||||
GAMELIFT_API GAMELIFT_CONFIGMANAGER_INSTANCE_HANDLE GameLiftConfigManagerInstanceCreate(FuncLogCallback logCb);
|
||||
|
||||
/**
|
||||
* @brief Destroy the provided GameLiftConfigManager instance.
|
||||
*
|
||||
* @param configManagerInstance Pointer to GameLiftConfigManager instance created with GameLiftConfigManagerInstanceCreate().
|
||||
*/
|
||||
GAMELIFT_API void GameLiftConfigManagerInstanceRelease(GAMELIFT_CONFIGMANAGER_INSTANCE_HANDLE configManagerInstance);
|
||||
|
||||
/**
|
||||
* @brief Get number of profiles.
|
||||
*
|
||||
* @param configManagerInstance Pointer to GameLiftConfigManager instance created with GameLiftConfigManagerInstanceCreate().
|
||||
* @param dispatchReceiver Pointer to the caller object (object that will handle the callback function).
|
||||
* @param resultCb Pointer to the callback function to invoke on completion.
|
||||
* @return The result code of the operation. GAMELIFT_SUCCESS if successful, else a non-zero value in case of error. Consult errors.h file for details.
|
||||
*/
|
||||
GAMELIFT_API unsigned int GameLiftConfigManagerGetProfileNames(GAMELIFT_CONFIGMANAGER_INSTANCE_HANDLE configManagerInstance, DISPATCH_RECEIVER_HANDLE caller, CharPtrCallback resultCallback);
|
||||
|
||||
GAMELIFT_API unsigned int GameLiftConfigManagerCreateProfile(GAMELIFT_CONFIGMANAGER_INSTANCE_HANDLE configManagerInstance, const char* profileName);
|
||||
GAMELIFT_API unsigned int GameLiftConfigManagerRenameProfile(GAMELIFT_CONFIGMANAGER_INSTANCE_HANDLE configManagerInstance, const char* profileName, const char* newProfileName);
|
||||
|
||||
GAMELIFT_API const char* GameLiftConfigManagerGetAccessKey(GAMELIFT_CONFIGMANAGER_INSTANCE_HANDLE configManagerInstance, const char* profileName);
|
||||
GAMELIFT_API unsigned int GameLiftConfigManagerSetAccessKey(GAMELIFT_CONFIGMANAGER_INSTANCE_HANDLE configManagerInstance, const char* profileName, const char* accessKey);
|
||||
|
||||
GAMELIFT_API const char* GameLiftConfigManagerGetSecretAccessKey(GAMELIFT_CONFIGMANAGER_INSTANCE_HANDLE configManagerInstance, const char* profileName);
|
||||
GAMELIFT_API unsigned int GameLiftConfigManagerSetSecretAccessKey(GAMELIFT_CONFIGMANAGER_INSTANCE_HANDLE configManagerInstance, const char* profileName, const char* secretAccessKey);
|
||||
|
||||
GAMELIFT_API const char* GameLiftConfigManagerGetSessionToken(GAMELIFT_CONFIGMANAGER_INSTANCE_HANDLE configManagerInstance, const char* profileName);
|
||||
GAMELIFT_API unsigned int GameLiftConfigManagerSetSessionToken(GAMELIFT_CONFIGMANAGER_INSTANCE_HANDLE configManagerInstance, const char* profileName, const char* sessionToken);
|
||||
|
||||
GAMELIFT_API const char* GameLiftConfigManagerGetRegion(GAMELIFT_CONFIGMANAGER_INSTANCE_HANDLE configManagerInstance, const char* profileName);
|
||||
GAMELIFT_API unsigned int GameLiftConfigManagerSetRegion(GAMELIFT_CONFIGMANAGER_INSTANCE_HANDLE configManagerInstance, const char* profileName, const char* region);
|
||||
|
||||
GAMELIFT_API unsigned int GameLiftConfigManagerSave(GAMELIFT_CONFIGMANAGER_INSTANCE_HANDLE configManagerInstance);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
/** @file
|
||||
* @brief aws-gamelift-core enums.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
namespace GameLift
|
||||
{
|
||||
enum class TokenType { AccessToken = 0, RefreshToken, IdToken, IamSessionToken, TokenType_COUNT /* TokenType_COUNT must be the last item in this enum */ };
|
||||
enum class FeatureType { Main, Identity, Authentication, Achievements, GameStateCloudSaving, UserGameplayData };
|
||||
enum class TemplateType { Base, Instance };
|
||||
enum class EnvironmentType { Development = 0, QA = 1, Staging = 2, Production = 3, Custom = 4 };
|
||||
enum class FederatedIdentityProvider { Facebook = 0, Google = 1, Apple = 2, Amazon = 3 };
|
||||
|
||||
inline std::string GetFeatureTypeString(FeatureType feature)
|
||||
{
|
||||
switch (feature)
|
||||
{
|
||||
case FeatureType::Main: return "main";
|
||||
case FeatureType::Identity: return "identity";
|
||||
case FeatureType::Authentication: return "authentication";
|
||||
case FeatureType::Achievements: return "achievements";
|
||||
case FeatureType::GameStateCloudSaving: return "gamesaving";
|
||||
case FeatureType::UserGameplayData: return "usergamedata";
|
||||
default: return "main";
|
||||
}
|
||||
}
|
||||
|
||||
inline FeatureType GetFeatureTypeFromString(const std::string& feature)
|
||||
{
|
||||
if (feature == "identity") return FeatureType::Identity;
|
||||
if (feature == "authentication") return FeatureType::Authentication;
|
||||
if (feature == "achievements") return FeatureType::Achievements;
|
||||
if (feature == "gamesaving") return FeatureType::GameStateCloudSaving;
|
||||
if (feature == "usergamedata") return FeatureType::UserGameplayData;
|
||||
|
||||
return FeatureType::Main;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
/** @file
|
||||
* @brief The GameLift status codes.
|
||||
*
|
||||
* @details View the status codes by clicking "Go to the source code of this file" at the top of the page.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
namespace GameLift
|
||||
{
|
||||
// Standard status codes (0-500)
|
||||
static const unsigned int GAMELIFT_SUCCESS = 0x0;
|
||||
static const unsigned int GAMELIFT_ERROR_INVALID_PROVIDER = 0x2;
|
||||
static const unsigned int GAMELIFT_ERROR_PARAMETERS_FILE_SAVE_FAILED = 0x3;
|
||||
static const unsigned int GAMELIFT_ERROR_CLOUDFORMATION_FILE_SAVE_FAILED = 0x4;
|
||||
static const unsigned int GAMELIFT_ERROR_FUNCTIONS_COPY_FAILED = 0x4;
|
||||
static const unsigned int GAMELIFT_ERROR_SETTINGS_FILE_SAVE_FAILED = 0x5;
|
||||
static const unsigned int GAMELIFT_ERROR_NO_ID_TOKEN = 0x6;
|
||||
static const unsigned int GAMELIFT_ERROR_HTTP_REQUEST_FAILED = 0x7;
|
||||
static const unsigned int GAMELIFT_ERROR_PARSE_JSON_FAILED = 0x8;
|
||||
static const unsigned int GAMELIFT_ERROR_SIGN_REQUEST_FAILED= 0x9;
|
||||
static const unsigned int GAMELIFT_ERROR_SETTINGS_FILE_READ_FAILED = 0xA;
|
||||
static const unsigned int GAMELIFT_ERROR_FILE_OPEN_FAILED = 0xB;
|
||||
static const unsigned int GAMELIFT_ERROR_FILE_WRITE_FAILED = 0xC;
|
||||
static const unsigned int GAMELIFT_ERROR_FILE_READ_FAILED = 0xD;
|
||||
static const unsigned int GAMELIFT_ERROR_DIRECTORY_CREATE_FAILED = 0xE;
|
||||
static const unsigned int GAMELIFT_ERROR_DIRECTORY_NOT_FOUND = 0xF;
|
||||
static const unsigned int GAMELIFT_ERROR_METHOD_NOT_IMPLEMENTED = 0x15E;
|
||||
static const unsigned int GAMELIFT_ERROR_GENERAL = 0x15F;
|
||||
static const unsigned int GAMELIFT_ERROR_REGION_CODE_CONVERSION_FAILED = 0x160;
|
||||
|
||||
// Bootstrapping status codes (501-1000)
|
||||
static const unsigned int GAMELIFT_ERROR_BOOTSTRAP_BUCKET_LOOKUP_FAILED = 0x1F5;
|
||||
static const unsigned int GAMELIFT_ERROR_BOOTSTRAP_BUCKET_CREATION_FAILED = 0x1F6;
|
||||
static const unsigned int GAMELIFT_ERROR_BOOTSTRAP_INVALID_REGION_CODE = 0x1F7;
|
||||
static const unsigned int GAMELIFT_ERROR_BOOTSTRAP_MISSING_PLUGIN_ROOT = 0x1F8;
|
||||
static const unsigned int GAMELIFT_ERROR_BOOTSTRAP_REGION_CODE_CONVERSION_FAILED = 0x1F9;
|
||||
|
||||
// Resource creation status codes (1001-1500)
|
||||
static const unsigned int GAMELIFT_ERROR_FUNCTIONS_PATH_NOT_FOUND = 0x3E9;
|
||||
static const unsigned int GAMELIFT_ERROR_CLOUDFORMATION_PATH_NOT_FOUND = 0x3EA;
|
||||
static const unsigned int GAMELIFT_ERROR_FUNCTION_ZIP_INIT_FAILED = 0x3EB;
|
||||
static const unsigned int GAMELIFT_ERROR_FUNCTION_ZIP_WRITE_FAILED = 0x3EC;
|
||||
static const unsigned int GAMELIFT_ERROR_PARAMSTORE_WRITE_FAILED = 0x3ED;
|
||||
static const unsigned int GAMELIFT_ERROR_BOOTSTRAP_BUCKET_UPLOAD_FAILED = 0x3EE;
|
||||
static const unsigned int GAMELIFT_ERROR_SECRETSMANAGER_WRITE_FAILED = 0x3EF;
|
||||
static const unsigned int GAMELIFT_ERROR_CLOUDFORMATION_STACK_CREATION_FAILED = 0x3F0;
|
||||
static const unsigned int GAMELIFT_ERROR_CLOUDFORMATION_STACK_UPDATE_FAILED = 0x3F1;
|
||||
static const unsigned int GAMELIFT_ERROR_CLOUDFORMATION_RESOURCE_CREATION_FAILED = 0x3F2;
|
||||
static const unsigned int GAMELIFT_ERROR_CLOUDFORMATION_STACK_DELETE_FAILED = 0x3F3;
|
||||
static const unsigned int GAMELIFT_ERROR_CLOUDFORMATION_DESCRIBE_RESOURCE_FAILED = 0x3F4;
|
||||
static const unsigned int GAMELIFT_ERROR_CLOUDFORMATION_DESCRIBE_STACKS_FAILED = 0x3F5;
|
||||
static const unsigned int GAMELIFT_ERROR_APIGATEWAY_DEPLOYMENT_CREATION_FAILED = 0x3F6;
|
||||
static const unsigned int GAMELIFT_ERROR_APIGATEWAY_STAGE_DEPLOYMENT_FAILED = 0x3F7;
|
||||
static const unsigned int GAMELIFT_ERROR_LAYERS_PATH_NOT_FOUND = 0x3F8;
|
||||
static const unsigned int GAMELIFT_ERROR_LAYER_ZIP_INIT_FAILED = 0x3F9;
|
||||
static const unsigned int GAMELIFT_ERROR_LAYER_ZIP_WRITE_FAILED = 0x3FA;
|
||||
static const unsigned int GAMELIFT_ERROR_LAYER_CREATION_FAILED = 0x3FB;
|
||||
static const unsigned int GAMELIFT_ERROR_CLOUDFORMATION_GET_TEMPLATE_FAILED = 0x3FC;
|
||||
static const unsigned int GAMELIFT_ERROR_PARAMSTORE_READ_FAILED = 0x3FD;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SERVER_PATH_NOT_FOUND = 0x3FE;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SERVER_ZIP_INIT_FAILED = 0x3FF;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SERVER_ZIP_WRITE_FAILED = 0x400;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SERVER_ZIP_READ_FAILED = 0x401;
|
||||
static const unsigned int GAMELIFT_ERROR_CLOUDFORMATION_CANCEL_STACK_UPDATE_FAILED = 0x402;
|
||||
static const unsigned int GAMELIFT_ERROR_BOOTSTRAP_BUCKET_DELETE_FAILED = 0x403;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SERVER_ADDONS_PATH_NOT_FOUND = 0x404;
|
||||
|
||||
// Resource creation status codes (0x500-0x510)
|
||||
static const unsigned int GAMELIFT_ERROR_CONFIGMANAGER_GET_PROFILE_NAMES = 0x500;
|
||||
static const unsigned int GAMELIFT_ERROR_CONFIGMANAGER_CREATE_PROFILE = 0x501;
|
||||
static const unsigned int GAMELIFT_ERROR_CONFIGMANAGER_RENAME_PROFILE = 0x502;
|
||||
static const unsigned int GAMELIFT_ERROR_CONFIGMANAGER_GET_ACCESS_KEY = 0x503;
|
||||
static const unsigned int GAMELIFT_ERROR_CONFIGMANAGER_SET_ACCESS_KEY = 0x504;
|
||||
static const unsigned int GAMELIFT_ERROR_CONFIGMANAGER_GET_SECRET_ACCESS_KEY = 0x505;
|
||||
static const unsigned int GAMELIFT_ERROR_CONFIGMANAGER_SET_SECRET_ACCESS_KEY = 0x506;
|
||||
static const unsigned int GAMELIFT_ERROR_CONFIGMANAGER_GET_SESSION_TOKEN = 0x507;
|
||||
static const unsigned int GAMELIFT_ERROR_CONFIGMANAGER_SET_SESSION_TOKEN = 0x508;
|
||||
static const unsigned int GAMELIFT_ERROR_CONFIGMANAGER_GET_REGION = 0x509;
|
||||
static const unsigned int GAMELIFT_ERROR_CONFIGMANAGER_SET_REGION = 0x50A;
|
||||
static const unsigned int GAMELIFT_ERROR_CONFIGMANAGER_SAVE = 0x50B;
|
||||
static const char* GAMELIFT_EMPTY_STRING = "";
|
||||
|
||||
// Identity status codes (0x10000 - 0x103FF)
|
||||
static const unsigned int GAMELIFT_ERROR_REGISTER_USER_FAILED = 0x10000;
|
||||
static const unsigned int GAMELIFT_ERROR_CONFIRM_REGISTRATION_FAILED = 0x10001;
|
||||
static const unsigned int GAMELIFT_ERROR_RESEND_CONFIRMATION_CODE_FAILED = 0x10002;
|
||||
static const unsigned int GAMELIFT_ERROR_LOGIN_FAILED = 0x10003;
|
||||
static const unsigned int GAMELIFT_ERROR_FORGOT_PASSWORD_FAILED = 0x10004;
|
||||
static const unsigned int GAMELIFT_ERROR_CONFIRM_FORGOT_PASSWORD_FAILED = 0x10005;
|
||||
static const unsigned int GAMELIFT_ERROR_GET_USER_FAILED = 0x10006;
|
||||
static const unsigned int GAMELIFT_ERROR_LOGOUT_FAILED = 0x10007;
|
||||
static const unsigned int GAMELIFT_ERROR_MALFORMED_USERNAME = 0x10008;
|
||||
static const unsigned int GAMELIFT_ERROR_MALFORMED_PASSWORD = 0x10009;
|
||||
static const unsigned int GAMELIFT_ERROR_INVALID_FEDERATED_IDENTITY_PROVIDER = 0x10010;
|
||||
|
||||
// Authentication status codes (0x10400 - 0x107FF)
|
||||
|
||||
// Achievements status codes (0x10800 - 0x10BFF)
|
||||
static const unsigned int GAMELIFT_ERROR_ACHIEVEMENTS_ICON_UPLOAD_FAILED = 0x10800;
|
||||
static const unsigned int GAMELIFT_ERROR_ACHIEVEMENTS_INVALID_ID = 0x10801;
|
||||
|
||||
// User Gameplay Data status codes (0x10C00 - 0x10FFF)
|
||||
static const unsigned int GAMELIFT_ERROR_USER_GAMEPLAY_DATA_PAYLOAD_INVALID = 0x010C00;
|
||||
static const unsigned int GAMELIFT_ERROR_USER_GAMEPLAY_DATA_API_CALL_FAILED = 0x010C01;
|
||||
static const unsigned int GAMELIFT_ERROR_USER_GAMEPLAY_DATA_API_CALL_DROPPED = 0x010C02;
|
||||
static const unsigned int GAMELIFT_WARNING_USER_GAMEPLAY_DATA_API_CALL_ENQUEUED = 0x010C03;
|
||||
static const unsigned int GAMELIFT_ERROR_MALFORMED_BUNDLE_NAME = 0x010C04;
|
||||
static const unsigned int GAMELIFT_ERROR_MALFORMED_BUNDLE_ITEM_KEY = 0x010C05;
|
||||
static const unsigned int GAMELIFT_ERROR_USER_GAMEPLAY_DATA_CACHE_WRITE_FAILED = 0x010C06;
|
||||
static const unsigned int GAMELIFT_ERROR_USER_GAMEPLAY_DATA_CACHE_READ_FAILED = 0x010C07;
|
||||
|
||||
// Game Saving status codes (0x11000 - 0x113FF)
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SAVING_SLOT_NOT_FOUND = 0x11000;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SAVING_CLOUD_SLOT_IS_NEWER = 0x11001;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SAVING_SYNC_CONFLICT = 0x11002;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SAVING_DOWNLOAD_SLOT_ALREADY_IN_SYNC = 0x11003;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SAVING_UPLOAD_SLOT_ALREADY_IN_SYNC = 0x11004;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SAVING_EXCEEDED_MAX_SIZE = 0x11005;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SAVING_FILE_EMPTY = 0x11006;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SAVING_FILE_FAILED_TO_OPEN = 0x11007;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SAVING_LOCAL_SLOT_IS_NEWER = 0x11008;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SAVING_SLOT_UNKNOWN_SYNC_STATUS = 0x11009;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SAVING_MALFORMED_SLOT_NAME = 0x1100A;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SAVING_MISSING_SHA = 0x1100B;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SAVING_SLOT_TAMPERED = 0x1100C;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SAVING_BUFFER_TOO_SMALL = 0x1100D;
|
||||
static const unsigned int GAMELIFT_ERROR_GAME_SAVING_MAX_CLOUD_SLOTS_EXCEEDED = 0x1100E;
|
||||
|
||||
// Standard warning status codes (0x11400-0x116FF)
|
||||
static const unsigned int GAMELIFT_WARNING_SECRETSMANAGER_SECRET_NOT_FOUND = 0x11400;
|
||||
|
||||
// Error messages
|
||||
static const char* ERR_INVALID_GAMELIFT_PROVIDER = "Invalid Provider";
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,412 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Standard Library
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <regex>
|
||||
|
||||
// AWS SDK
|
||||
#include <aws/core/utils/base64/Base64.h>
|
||||
#include <aws/cloudformation/CloudFormationClient.h>
|
||||
#include <aws/cloudformation/model/CreateStackRequest.h>
|
||||
#include <aws/cloudformation/model/DeleteStackRequest.h>
|
||||
#include <aws/cloudformation/model/DescribeStackEventsRequest.h>
|
||||
#include <aws/cloudformation/model/DescribeStackResourcesRequest.h>
|
||||
#include <aws/cloudformation/model/DescribeStacksRequest.h>
|
||||
#include <aws/cloudformation/model/GetTemplateRequest.h>
|
||||
#include <aws/cloudformation/model/StackStatus.h>
|
||||
#include <aws/cloudformation/model/UpdateStackRequest.h>
|
||||
#include <aws/cloudformation/model/CancelUpdateStackRequest.h>
|
||||
#include <aws/lambda/LambdaClient.h>
|
||||
#include <aws/lambda/model/DeleteLayerVersionRequest.h>
|
||||
#include <aws/lambda/model/PublishLayerVersionRequest.h>
|
||||
#include <aws/s3/S3Client.h>
|
||||
#include <aws/s3/model/PutObjectRequest.h>
|
||||
#include <aws/s3/model/DeleteObjectRequest.h>
|
||||
#include <aws/ssm/SSMClient.h>
|
||||
#include <aws/ssm/model/GetParameterRequest.h>
|
||||
#include <aws/ssm/model/PutParameterRequest.h>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/awsclients/api_initializer.h>
|
||||
#include <aws/gamelift/core/awsclients/default_clients.h>
|
||||
#include <aws/gamelift/core/enums.h>
|
||||
#include <aws/gamelift/core/feature_resources_callback.h>
|
||||
#include <aws/gamelift/core/gamelift_feature.h>
|
||||
#include <aws/gamelift/core/model/account_credentials.h>
|
||||
#include <aws/gamelift/core/model/account_info.h>
|
||||
#include <aws/gamelift/core/model/config_consts.h>
|
||||
#include <aws/gamelift/core/model/template_consts.h>
|
||||
#include <aws/gamelift/core/paramstore_keys.h>
|
||||
#include <aws/gamelift/core/zipper.h>
|
||||
#include <aws/gamelift/core/utils/file_utils.h>
|
||||
#include <aws/gamelift/core/aws_region_mappings.h>
|
||||
|
||||
// yaml-cpp
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
/**
|
||||
* GameLiftFeatureResources offers methods for working on the AWS resources of a single GAMELIFT feature (ex: "achievements").
|
||||
*
|
||||
* Each instance of this class operates on one feature, which is specified in it's constructor.
|
||||
*
|
||||
* For example, it can deploy/delete the feature's CloudFormation stack and create it's instance template files for deployment.
|
||||
*/
|
||||
class GAMELIFT_API GameLiftFeatureResources
|
||||
{
|
||||
private:
|
||||
AccountInfoCopy m_accountInfo;
|
||||
AccountCredentialsCopy m_credentials;
|
||||
FeatureType m_featureType;
|
||||
FuncLogCallback m_logCb = nullptr;
|
||||
|
||||
Aws::S3::S3Client* m_s3Client;
|
||||
Aws::SSM::SSMClient* m_ssmClient;
|
||||
Aws::CloudFormation::CloudFormationClient* m_cfClient;
|
||||
Aws::Lambda::LambdaClient* m_lambdaClient;
|
||||
|
||||
bool m_isUsingSharedS3Client = false;
|
||||
bool m_isUsingSharedSSMClient = false;
|
||||
bool m_isUsingSharedCfClient = false;
|
||||
bool m_isUsingSharedLambdaClient = false;
|
||||
|
||||
std::string m_stackName;
|
||||
std::string m_layersReplacementId;
|
||||
std::string m_functionsReplacementId;
|
||||
|
||||
std::string m_pluginRoot;
|
||||
std::string m_gameliftRoot;
|
||||
std::string m_baseLayersPath;
|
||||
std::string m_baseFunctionsPath;
|
||||
std::string m_baseCloudformationPath;
|
||||
std::string m_baseConfigOutputsPath;
|
||||
std::string m_instanceLayersPath;
|
||||
std::string m_instanceFunctionsPath;
|
||||
std::string m_instanceCloudformationPath;
|
||||
|
||||
std::unordered_map<std::string, bool> m_resouceStatusMap;
|
||||
|
||||
Aws::Vector<Aws::CloudFormation::Model::Parameter> getStackParameters(TemplateType templateType) const;
|
||||
std::string getRawStackParameters(TemplateType templateType) const;
|
||||
std::string getFeatureDashboardTemplate(TemplateType templateType) const;
|
||||
std::string getCloudFormationTemplate(TemplateType templateType) const;
|
||||
unsigned int createStack() const;
|
||||
unsigned int updateStack() const;
|
||||
unsigned int cancelUpdateStack() const;
|
||||
unsigned int deleteStack() const;
|
||||
Aws::CloudFormation::Model::StackStatus periodicallyDescribeStackEvents();
|
||||
void describeStackEvents();
|
||||
unsigned int getDeployedTemplateBody(const std::string stackName, std::string& templateBody) const;
|
||||
bool isTerminalState(Aws::CloudFormation::Model::StackStatus status);
|
||||
bool isFailedState(Aws::CloudFormation::Model::StackStatus status);
|
||||
bool isFailedResourceStatus(Aws::CloudFormation::Model::ResourceStatus status);
|
||||
bool isCreateOrUpdateInProgressState(Aws::CloudFormation::Model::StackStatus status);
|
||||
std::string getTempLayersPath() const;
|
||||
std::string getTempFunctionsPath() const;
|
||||
std::string getTempGameServerPath() const;
|
||||
std::string MakeGameServerTempZipPath(const std::string& gameServerPath, const std::string& gameServerHash) const;
|
||||
YAML::Node getClientConfigYaml() const;
|
||||
Aws::Vector<std::tuple<std::string, std::string>> getConfigOutputParameters() const;
|
||||
unsigned int writeCloudFormationParameterInstance(const std::string& cfParams) const;
|
||||
unsigned int writeCloudFormationTemplateInstance(const std::string& cfParams) const;
|
||||
unsigned int writeCloudFormationDashboardInstance(const std::string& cfTemplate) const;
|
||||
unsigned int writeClientConfigYamlToDisk(const YAML::Node& paramsYml) const;
|
||||
unsigned int removeOutputsFromClientConfiguration() const;
|
||||
unsigned int writeClientConfigurationWithOutputs(Aws::Vector<Aws::CloudFormation::Model::Output> outputs) const;
|
||||
std::string getFeatureLayerNameFromDirName(const std::string& layerDirName) const;
|
||||
Aws::Lambda::Model::PublishLayerVersionOutcome createFeatureLayer(const std::string& layerDirName, const std::string& s3ObjectName);
|
||||
bool lambdaLayerHashChanged(const std::string& layerName, const std::string& layerHash) const;
|
||||
std::pair<bool, std::string> gameServerHashChanged(const std::string& gameServerName, const std::string& gameServerHash) const;
|
||||
std::pair<bool, std::string> gameServerAddonsHashChanged(const std::string& gameServerName, const std::string& gameServerAddonsHash) const;
|
||||
std::pair<bool, std::string> paramHashChanged(const std::string& paramName, const std::string& paramHash) const;
|
||||
unsigned int createAndSetLambdaLayerHash(const std::string& layerName, const std::string& layerHash) const;
|
||||
unsigned int createAndSetLambdaLayerArn(const std::string& layerName, const std::string& layerArn) const;
|
||||
unsigned int createAndSetGameServerHash(const std::string& gameServerName, const std::string& gameServerHash) const;
|
||||
unsigned int createAndSetGameServerAddonsHash(const std::string& gameServerName, const std::string& gameServerAddonsHash) const;
|
||||
unsigned int createAndSetParamHash(const std::string& paramName, const std::string& paramHash) const;
|
||||
static std::string createSanitizedResourceName(const std::string& originalName);
|
||||
std::string getShortRegionCode();
|
||||
|
||||
public:
|
||||
GameLiftFeatureResources(const AccountInfo accountInfo, const AccountCredentials credentials, FeatureType featureType, FuncLogCallback logCb);
|
||||
GameLiftFeatureResources(const AccountInfoCopy& accountInfo, const AccountCredentialsCopy& credentials, FeatureType featureType, FuncLogCallback logCb);
|
||||
~GameLiftFeatureResources();
|
||||
|
||||
// Clients initialized with his method will be deleted in the class destructor.
|
||||
void InitializeDefaultAwsClients();
|
||||
|
||||
// Returns Account Info
|
||||
AccountInfoCopy GetAccountInfo()
|
||||
{
|
||||
return m_accountInfo;
|
||||
}
|
||||
|
||||
// Returns Account Credentials
|
||||
AccountCredentialsCopy GetAccountCredentials()
|
||||
{
|
||||
return m_credentials;
|
||||
}
|
||||
|
||||
// Sets the root directory of the plugin's installation
|
||||
inline void SetPluginRoot(const std::string& pluginRoot)
|
||||
{
|
||||
m_pluginRoot = pluginRoot;
|
||||
m_baseLayersPath = pluginRoot + ResourceDirectories::LAYERS_DIRECTORY + GetFeatureTypeString(m_featureType) + "/";
|
||||
m_baseFunctionsPath = pluginRoot + ResourceDirectories::FUNCTIONS_DIRECTORY + GetFeatureTypeString(m_featureType) + "/";
|
||||
m_baseCloudformationPath = pluginRoot + ResourceDirectories::CLOUDFORMATION_DIRECTORY + GetFeatureTypeString(m_featureType) + "/";
|
||||
m_baseConfigOutputsPath = pluginRoot + ResourceDirectories::CONFIG_OUTPUTS_DIRECTORY + GetFeatureTypeString(m_featureType) + "/";
|
||||
}
|
||||
|
||||
// Returns the root directory of the plugin's installation
|
||||
inline const std::string& GetPluginRoot()
|
||||
{
|
||||
return m_pluginRoot;
|
||||
}
|
||||
|
||||
// The value GAMELIFT_ROOT where instance templates and settings are going to be stored
|
||||
inline void SetGameLiftRoot(const std::string& gameliftRoot)
|
||||
{
|
||||
m_gameliftRoot = gameliftRoot;
|
||||
m_instanceLayersPath = gameliftRoot + "/" + m_accountInfo.gameName + "/" + m_accountInfo.environment.GetEnvironmentString() + ResourceDirectories::LAYERS_DIRECTORY + GetFeatureTypeString(m_featureType) + "/";
|
||||
m_instanceFunctionsPath = gameliftRoot + "/" + m_accountInfo.gameName + "/" + m_accountInfo.environment.GetEnvironmentString() + ResourceDirectories::FUNCTIONS_DIRECTORY + GetFeatureTypeString(m_featureType) + "/";
|
||||
m_instanceCloudformationPath = gameliftRoot + "/" + m_accountInfo.gameName + "/" + m_accountInfo.environment.GetEnvironmentString() + ResourceDirectories::CLOUDFORMATION_DIRECTORY + GetFeatureTypeString(m_featureType) + "/";
|
||||
}
|
||||
|
||||
// Returns the Path to a client config file where results of deployment are stored
|
||||
std::string getClientConfigFilePath() const;
|
||||
|
||||
// Returns the GAMELIFT_ROOT where instance templates and settings are stored
|
||||
inline const std::string& GetGameLiftRoot()
|
||||
{
|
||||
return m_gameliftRoot;
|
||||
}
|
||||
|
||||
// Sets the base CloudFormation path
|
||||
inline void SetBaseCloudFormationPath(const std::string& cloudFormationPath)
|
||||
{
|
||||
m_baseCloudformationPath = cloudFormationPath + GetFeatureTypeString(m_featureType) + "/";
|
||||
}
|
||||
|
||||
// Sets the base Lambda Layers path
|
||||
inline void SetBaseLayersPath(const std::string& layersPath)
|
||||
{
|
||||
m_baseLayersPath = layersPath + GetFeatureTypeString(m_featureType) + "/";
|
||||
}
|
||||
|
||||
// Sets the base Lambda Functions path
|
||||
inline void SetBaseFunctionsPath(const std::string& functionsPath)
|
||||
{
|
||||
m_baseFunctionsPath = functionsPath + GetFeatureTypeString(m_featureType) + "/";
|
||||
}
|
||||
|
||||
// Sets the instance CloudFormation path
|
||||
inline void SetInstanceCloudFormationPath(const std::string& cloudFormationPath)
|
||||
{
|
||||
m_instanceCloudformationPath = cloudFormationPath + GetFeatureTypeString(m_featureType) + "/";
|
||||
}
|
||||
|
||||
// Sets the instance Lambda Layers path
|
||||
void SetInstanceLayersPath(const std::string& layersPath)
|
||||
{
|
||||
m_instanceLayersPath = layersPath + GetFeatureTypeString(m_featureType) + "/";
|
||||
}
|
||||
|
||||
// Sets the instance Lambda Functions path
|
||||
void SetInstanceFunctionsPath(const std::string& functionsPath)
|
||||
{
|
||||
m_instanceFunctionsPath = functionsPath + GetFeatureTypeString(m_featureType) + "/";
|
||||
}
|
||||
|
||||
// Returns the base Lambda Functions path
|
||||
inline const std::string& GetBaseFunctionsPath() const
|
||||
{
|
||||
return m_baseFunctionsPath;
|
||||
}
|
||||
|
||||
// Returns the base CloudFormation path
|
||||
inline const std::string& GetBaseCloudFormationPath() const
|
||||
{
|
||||
return m_baseCloudformationPath;
|
||||
}
|
||||
|
||||
// Returns the instance Lambda Functions path
|
||||
inline const std::string& GetInstanceFunctionsPath() const
|
||||
{
|
||||
return m_instanceFunctionsPath;
|
||||
}
|
||||
|
||||
// Returns the instance CloudFormation path
|
||||
inline const std::string& GetInstanceCloudFormationPath() const
|
||||
{
|
||||
return m_instanceCloudformationPath;
|
||||
}
|
||||
|
||||
bool IsCloudFormationInstanceTemplatePresent() const;
|
||||
|
||||
unsigned int SaveDeployedCloudFormationTemplate() const;
|
||||
unsigned int SaveCloudFormationInstance(const Aws::Map<std::string, std::string>& vars);
|
||||
unsigned int UpdateCloudFormationParameters(const Aws::Map<std::string, std::string>& vars);
|
||||
unsigned int SaveLayerInstances() const;
|
||||
unsigned int SaveFunctionInstances() const;
|
||||
|
||||
std::string GetStackName() const;
|
||||
void SetLayersReplacementId(const std::string& replacementId);
|
||||
void SetFunctionsReplacementId(const std::string& replacementId);
|
||||
const std::string& GetFunctionsReplacementId();
|
||||
unsigned int CreateAndSetLayersReplacementId();
|
||||
unsigned int CreateAndSetFunctionsReplacementId();
|
||||
unsigned int RetrieveFunctionsReplacementId();
|
||||
unsigned int UploadDashboard(const std::string& path);
|
||||
unsigned int CompressFeatureLayers();
|
||||
unsigned int UploadFeatureLayers();
|
||||
unsigned int CompressFeatureFunctions();
|
||||
unsigned int UploadFeatureFunctions();
|
||||
std::pair<unsigned int, std::string> UpdateFeatureGameServerHash(const std::string& gameServerPath, const std::string& serverAddonsPath, std::function<unsigned int(const std::string& NewHash, const std::string& PrevHash)> onHashUpdated);
|
||||
std::pair<unsigned int, std::string> CompressFeatureGameServer(const std::string& gameServerPath, const std::string& additionalFilesPath, const std::string& gameServerHash);
|
||||
std::pair<unsigned int, std::string> UploadFeatureGameServer(const std::string& gameServerPathZipPath);
|
||||
unsigned int RemoveObjectFromBucket(const std::string& objectPath);
|
||||
void CleanupTempFiles();
|
||||
std::string GetCurrentStackStatus() const;
|
||||
unsigned int DescribeStackResources(FuncResourceInfoCallback resourceInfoCb) const;
|
||||
unsigned int CreateOrUpdateFeatureStack();
|
||||
unsigned int CancelUpdateFeatureStack();
|
||||
unsigned int WriteClientConfiguration() const;
|
||||
unsigned int DeleteFeatureStack();
|
||||
|
||||
inline std::string GetLambdaFunctionReplacementIDParamName() const
|
||||
{
|
||||
return std::string(GAMELIFT_LAMBDA_FUNCTIONS_REPLACEMENT_ID_PREFIX)
|
||||
.append(GetFeatureTypeString(m_featureType))
|
||||
.append("_")
|
||||
.append(m_accountInfo.gameName)
|
||||
.append("_")
|
||||
.append(m_accountInfo.environment.GetEnvironmentString());
|
||||
}
|
||||
|
||||
inline std::string GetLambdaLayerReplacementIDParamName() const
|
||||
{
|
||||
return std::string(GAMELIFT_LAMBDA_LAYERS_REPLACEMENT_ID_PREFIX)
|
||||
.append(GetFeatureTypeString(m_featureType))
|
||||
.append("_")
|
||||
.append(m_accountInfo.gameName)
|
||||
.append("_")
|
||||
.append(m_accountInfo.environment.GetEnvironmentString());
|
||||
}
|
||||
|
||||
inline std::string GetLambdaLayerARNParamName(const std::string& layerName) const
|
||||
{
|
||||
return std::string(GAMELIFT_LAMBDA_LAYER_ARN_PREFIX)
|
||||
.append(GetFeatureTypeString(m_featureType))
|
||||
.append("_")
|
||||
.append(layerName)
|
||||
.append("_")
|
||||
.append(m_accountInfo.gameName)
|
||||
.append("_")
|
||||
.append(m_accountInfo.environment.GetEnvironmentString());
|
||||
}
|
||||
|
||||
inline std::string GetLambdaLayerHashParamName(const std::string& layerName) const
|
||||
{
|
||||
return std::string(GAMELIFT_LAMBDA_LAYER_HASH_PREFIX)
|
||||
.append(GetFeatureTypeString(m_featureType))
|
||||
.append("_")
|
||||
.append(layerName)
|
||||
.append("_")
|
||||
.append(m_accountInfo.gameName)
|
||||
.append("_")
|
||||
.append(m_accountInfo.environment.GetEnvironmentString());
|
||||
}
|
||||
|
||||
inline std::string GetGameServerHashParamName(const std::string& gameServerName) const
|
||||
{
|
||||
const std::string sanitizedGameServerName = createSanitizedResourceName(gameServerName);
|
||||
return std::string(GAMELIFT_GAME_SERVER_HASH_PREFIX)
|
||||
.append(GetFeatureTypeString(m_featureType))
|
||||
.append("_")
|
||||
.append(sanitizedGameServerName)
|
||||
.append("_")
|
||||
.append(m_accountInfo.gameName)
|
||||
.append("_")
|
||||
.append(m_accountInfo.environment.GetEnvironmentString());
|
||||
}
|
||||
|
||||
inline std::string GetGameServerAddonsHashParamName(const std::string& gameServerName) const
|
||||
{
|
||||
const std::string sanitizedGameServerName = createSanitizedResourceName(gameServerName);
|
||||
return std::string(GAMELIFT_GAME_SERVER_ADDONS_PREFIX)
|
||||
.append(GetFeatureTypeString(m_featureType))
|
||||
.append("_")
|
||||
.append(sanitizedGameServerName)
|
||||
.append("_")
|
||||
.append(m_accountInfo.gameName)
|
||||
.append("_")
|
||||
.append(m_accountInfo.environment.GetEnvironmentString());
|
||||
}
|
||||
|
||||
inline std::string GetFeatureFunctionsBucketObjectPath(const std::string& filename, const std::string& extension)
|
||||
{
|
||||
return std::string(m_accountInfo.gameName)
|
||||
.append("/functions/")
|
||||
.append(GameLift::GetFeatureTypeString(m_featureType))
|
||||
.append("/")
|
||||
.append(filename)
|
||||
.append(".")
|
||||
.append(m_functionsReplacementId)
|
||||
.append(extension);
|
||||
}
|
||||
|
||||
inline std::string GetDashboardBucketObjectPath()
|
||||
{
|
||||
return std::string(m_accountInfo.gameName)
|
||||
.append("/cloudformation/")
|
||||
.append(GameLift::GetFeatureTypeString(m_featureType))
|
||||
.append("/")
|
||||
.append(TemplateFileNames::FEATURE_DASHBOARD_FILE);
|
||||
}
|
||||
|
||||
inline std::string GetFeatureLayersBucketObjectPath(const std::string& filename, const std::string& extension)
|
||||
{
|
||||
return std::string(m_accountInfo.gameName)
|
||||
.append("/layers/")
|
||||
.append(GameLift::GetFeatureTypeString(m_featureType))
|
||||
.append("/")
|
||||
.append(filename)
|
||||
.append(".")
|
||||
.append(m_layersReplacementId)
|
||||
.append(extension);
|
||||
}
|
||||
|
||||
inline void SetS3Client(Aws::S3::S3Client* s3Client, bool isShared)
|
||||
{
|
||||
m_isUsingSharedS3Client = isShared;
|
||||
m_s3Client = s3Client;
|
||||
}
|
||||
|
||||
inline void SetSSMClient(Aws::SSM::SSMClient* ssmClient, bool isShared)
|
||||
{
|
||||
m_isUsingSharedSSMClient = isShared;
|
||||
m_ssmClient = ssmClient;
|
||||
}
|
||||
|
||||
inline void SetCloudFormationClient(Aws::CloudFormation::CloudFormationClient* cfClient, bool isShared)
|
||||
{
|
||||
m_isUsingSharedCfClient = isShared;
|
||||
m_cfClient = cfClient;
|
||||
}
|
||||
|
||||
inline void SetLambdaClient(Aws::Lambda::LambdaClient* lambdaClient, bool isShared)
|
||||
{
|
||||
m_isUsingSharedLambdaClient = isShared;
|
||||
m_lambdaClient = lambdaClient;
|
||||
}
|
||||
|
||||
const std::string GetUnrealPackagedBuildVersion(const std::string& executablePath) const;
|
||||
|
||||
static std::string GetGameServerBucketPath(const std::string& gameName, const std::string& gameServerPath);
|
||||
static std::string GetGameServerZipName(const std::string& gameServerPath, const std::string& gameServerHash);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
extern "C"
|
||||
{
|
||||
typedef void(*FuncResourceInfoCallback)(const char* logicalResourceId, const char* resourceType, const char* resourceStatus);
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// AWS SDK
|
||||
#include <aws/apigateway/model/CreateDeploymentRequest.h>
|
||||
#include <aws/apigateway/model/Op.h>
|
||||
#include <aws/apigateway/model/PatchOperation.h>
|
||||
#include <aws/apigateway/model/UpdateResourceRequest.h>
|
||||
#include <aws/apigateway/model/UpdateResourceResult.h>
|
||||
#include <aws/apigateway/model/UpdateStageRequest.h>
|
||||
#include <aws/cloudformation/model/DescribeStackResourceRequest.h>
|
||||
#include <aws/gamelift/GameLiftClient.h>
|
||||
#include <aws/ecr/ECRClient.h>
|
||||
#include <aws/s3/model/Bucket.h>
|
||||
#include <aws/s3/model/CreateBucketRequest.h>
|
||||
#include <aws/s3/model/PutBucketLifecycleConfigurationRequest.h>
|
||||
#include <aws/secretsmanager/model/CreateSecretRequest.h>
|
||||
#include <aws/secretsmanager/model/DescribeSecretRequest.h>
|
||||
#include <aws/secretsmanager/model/UpdateSecretRequest.h>
|
||||
#include <aws/secretsmanager/model/DeleteSecretRequest.h>
|
||||
#include <aws/ssm/model/PutParameterRequest.h>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/awsclients/api_initializer.h>
|
||||
#include <aws/gamelift/core/errors.h>
|
||||
#include <aws/gamelift/core/feature_resources.h>
|
||||
#include <aws/gamelift/core/logging.h>
|
||||
#include <aws/gamelift/core/awsclients/default_clients.h>
|
||||
#include <aws/gamelift/core/model/account_credentials.h>
|
||||
#include <aws/gamelift/core/model/account_info.h>
|
||||
#include <aws/gamelift/core/model/template_consts.h>
|
||||
#include <aws/gamelift/core/aws_region_mappings.h>
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
/**
|
||||
* GameLiftAccount offers plugin-level, AWS account-level, and cross-feature methods.
|
||||
*
|
||||
* The feature-related methods operate on ALL features at the same time.
|
||||
* To work on a single feature, use GameLiftFeatureResources instead.
|
||||
*
|
||||
* For example, GameLiftAccount can:
|
||||
* - Get path to the plugin's installation directory.
|
||||
* - Get path to the base resources and instance resources.
|
||||
* - Create instance resource files.
|
||||
* - Create the bootstrap S3 bucket.
|
||||
* - Deploy the main stack and all feature stacks.
|
||||
* - Deploy the shared API Gateway stage.
|
||||
* - Save secrets to AWS Secrets Manager.
|
||||
*/
|
||||
class GAMELIFT_API GameLiftAccount
|
||||
{
|
||||
private:
|
||||
AccountInfoCopy m_accountInfo;
|
||||
AccountCredentialsCopy m_credentials;
|
||||
FuncLogCallback m_logCb;
|
||||
bool m_deleteClients = false;
|
||||
|
||||
Aws::S3::S3Client* m_s3Client;
|
||||
Aws::SSM::SSMClient* m_ssmClient;
|
||||
Aws::CloudFormation::CloudFormationClient* m_cfnClient;
|
||||
Aws::SecretsManager::SecretsManagerClient* m_secretsClient;
|
||||
Aws::APIGateway::APIGatewayClient* m_apigwyClient;
|
||||
Aws::Lambda::LambdaClient* m_lambdaClient;
|
||||
Aws::GameLift::GameLiftClient* m_gameLiftClient; // note: This is the client used to call AWS SDK GameLift APIs, not the client used for the game client build.
|
||||
Aws::ECR::ECRClient* m_ecrClient;
|
||||
|
||||
std::string m_pluginRoot;
|
||||
std::string m_gameliftRoot;
|
||||
std::string m_baseLayersPath;
|
||||
std::string m_baseFunctionsPath;
|
||||
std::string m_baseCloudformationPath;
|
||||
std::string m_instanceLayersPath;
|
||||
std::string m_instanceFunctionsPath;
|
||||
std::string m_instanceCloudformationPath;
|
||||
std::string m_instanceGameServerPath;
|
||||
|
||||
std::string m_stackName;
|
||||
|
||||
std::string composeSecretId(const std::string& secretName);
|
||||
bool hasBootstrapBucket(const std::string& bootstrapBucketName);
|
||||
bool isLayersPathValid(TemplateType templateType);
|
||||
bool isFunctionsPathValid(TemplateType templateType);
|
||||
bool isCloudFormationPathValid(TemplateType templateType);
|
||||
unsigned int createSecret(const std::string& secretId, const std::string& secretValue);
|
||||
unsigned int updateSecret(const std::string& secretId, const std::string& secretValue);
|
||||
unsigned int deleteSecret(const std::string& secretId);
|
||||
std::string getShortRegionCode();
|
||||
|
||||
public:
|
||||
GameLiftAccount(AccountInfo accountInfo, CredentialProfile profile, FuncLogCallback logCallback);
|
||||
GameLiftAccount(AccountInfo accountInfo, AccountCredentials credentials, FuncLogCallback logCallback);
|
||||
virtual ~GameLiftAccount();
|
||||
|
||||
bool HasBootstrapBucket();
|
||||
|
||||
using BootstrapResult = std::pair<unsigned int, std::string>;
|
||||
BootstrapResult Bootstrap();
|
||||
|
||||
void DeleteClients();
|
||||
|
||||
// Returns Account Info
|
||||
AccountInfoCopy GetAccountInfo()
|
||||
{
|
||||
return m_accountInfo;
|
||||
}
|
||||
|
||||
// Returns Account Credentials
|
||||
AccountCredentialsCopy GetAccountCredentials()
|
||||
{
|
||||
return m_credentials;
|
||||
}
|
||||
|
||||
inline void DeleteClientsOnDestruction(bool cleanup = true)
|
||||
{
|
||||
m_deleteClients = cleanup;
|
||||
}
|
||||
|
||||
// Returns the AWS account id
|
||||
inline const std::string& GetAwsAccountId()
|
||||
{
|
||||
return m_accountInfo.accountId;
|
||||
}
|
||||
|
||||
inline const std::string& GetGameName()
|
||||
{
|
||||
return m_accountInfo.gameName;
|
||||
}
|
||||
|
||||
// Generates default bootstrap bucket name based on account info.
|
||||
inline const std::string GetDefaultBucketName()
|
||||
{
|
||||
return GetDefaultBootstrapBucketName(m_accountInfo, getShortRegionCode());
|
||||
}
|
||||
|
||||
// Gets the name of the created bootstrap bucket for this account
|
||||
inline const std::string& GetBucketName()
|
||||
{
|
||||
return m_accountInfo.bucketName;
|
||||
}
|
||||
|
||||
inline void SetBucketName(const std::string& bucketName)
|
||||
{
|
||||
m_accountInfo.bucketName = bucketName;
|
||||
}
|
||||
|
||||
inline void SetGameName(const std::string& gameName)
|
||||
{
|
||||
m_accountInfo.gameName = gameName;
|
||||
}
|
||||
|
||||
inline const std::string GetDeploymentStackName();
|
||||
|
||||
// Sets the root directory of the plugin's installation
|
||||
inline void SetPluginRoot(const std::string& pluginRoot)
|
||||
{
|
||||
m_pluginRoot = pluginRoot;
|
||||
m_baseLayersPath = pluginRoot + ResourceDirectories::LAYERS_DIRECTORY;
|
||||
m_baseFunctionsPath = pluginRoot + ResourceDirectories::FUNCTIONS_DIRECTORY;
|
||||
m_baseCloudformationPath = pluginRoot + ResourceDirectories::CLOUDFORMATION_DIRECTORY;
|
||||
}
|
||||
|
||||
// Returns the root directory of the plugin's installation
|
||||
inline const std::string& GetPluginRoot()
|
||||
{
|
||||
return m_pluginRoot;
|
||||
}
|
||||
|
||||
// The value GAMELIFT_ROOT where instance templates and settings are going to be stored
|
||||
inline void SetGameLiftRoot(const std::string& gameliftRoot)
|
||||
{
|
||||
m_gameliftRoot = gameliftRoot;
|
||||
m_instanceLayersPath = gameliftRoot + "/" + m_accountInfo.gameName + "/" + m_accountInfo.environment.GetEnvironmentString() + ResourceDirectories::LAYERS_DIRECTORY;
|
||||
m_instanceFunctionsPath = gameliftRoot + "/" + m_accountInfo.gameName + "/" + m_accountInfo.environment.GetEnvironmentString() + ResourceDirectories::FUNCTIONS_DIRECTORY;
|
||||
m_instanceCloudformationPath = gameliftRoot + "/" + m_accountInfo.gameName + "/" + m_accountInfo.environment.GetEnvironmentString() + ResourceDirectories::CLOUDFORMATION_DIRECTORY;
|
||||
}
|
||||
|
||||
// Returns the GAMELIFT_ROOT where instance templates and settings are stored
|
||||
inline const std::string& GetGameLiftRoot()
|
||||
{
|
||||
return m_gameliftRoot;
|
||||
}
|
||||
|
||||
// Returns the base Lambda Layers path
|
||||
inline const std::string& GetBaseLayersPath()
|
||||
{
|
||||
return m_baseLayersPath;
|
||||
}
|
||||
|
||||
// Returns the base Lambda Functions path
|
||||
inline const std::string& GetBaseFunctionsPath()
|
||||
{
|
||||
return m_baseFunctionsPath;
|
||||
}
|
||||
|
||||
// Returns the base CloudFormation path
|
||||
inline const std::string& GetBaseCloudFormationPath()
|
||||
{
|
||||
return m_baseCloudformationPath;
|
||||
}
|
||||
|
||||
// Returns the instance Lambda Functions path
|
||||
inline const std::string& GetInstanceFunctionsPath()
|
||||
{
|
||||
return m_instanceFunctionsPath;
|
||||
}
|
||||
|
||||
// Returns the instance CloudFormation path
|
||||
inline const std::string& GetInstanceCloudFormationPath()
|
||||
{
|
||||
return m_instanceCloudformationPath;
|
||||
}
|
||||
|
||||
unsigned int CheckSecretExists(const std::string& secretName);
|
||||
unsigned int SaveSecret(const std::string& secretName, const std::string& secretValue);
|
||||
unsigned int DeleteSecret(const std::string& secretName);
|
||||
unsigned int SaveFeatureInstanceTemplates(const Aws::Map<std::string, std::string>& vars);
|
||||
unsigned int UploadDashboards();
|
||||
unsigned int UploadLayers();
|
||||
unsigned int UploadFunctions();
|
||||
unsigned int UploadGameServer(const std::string& path, const std::string& addPath, std::string& s3Path);
|
||||
bool HasValidCredentials();
|
||||
unsigned int CreateOrUpdateStacks();
|
||||
unsigned int CreateOrUpdateMainStack();
|
||||
unsigned int CreateOrUpdateFeatureStacks();
|
||||
unsigned int CreateAndSetFunctionsReplacementId();
|
||||
|
||||
using FuncReplacementIdResult = std::pair<unsigned int, std::string>;
|
||||
FuncReplacementIdResult GetMainFunctionsReplacementId();
|
||||
|
||||
unsigned int DeployApiGatewayStage();
|
||||
|
||||
// Creates an instance of GameLiftFeatureResources based on account information
|
||||
// Up to caller to destroy the instance
|
||||
GameLift::GameLiftFeatureResources* CreateGameLiftResourcesInstance();
|
||||
|
||||
// Initializes the AWS Clients internally.
|
||||
// Clients initialized witht his method will be deleted on ~GameLiftAccount().
|
||||
void InitializeDefaultAwsClients();
|
||||
|
||||
// Sets the S3Client explicitly.
|
||||
// It's the caller responsibility to call delete on the instance passed to this method.
|
||||
inline void SetS3Client(Aws::S3::S3Client* s3Client)
|
||||
{
|
||||
m_s3Client = s3Client;
|
||||
}
|
||||
|
||||
// Sets the SSMClient explicitly.
|
||||
// It's the caller responsibility to call delete on the instance passed to this method.
|
||||
inline void SetSSMClient(Aws::SSM::SSMClient* ssmClient)
|
||||
{
|
||||
m_ssmClient = ssmClient;
|
||||
}
|
||||
|
||||
// Sets the CloudFormationClient explicitly.
|
||||
// It's the caller responsibility to call delete on the instance passed to this method.
|
||||
inline void SetCloudFormationClient(Aws::CloudFormation::CloudFormationClient* cfnClient)
|
||||
{
|
||||
m_cfnClient = cfnClient;
|
||||
}
|
||||
|
||||
// Gets the CFNClient.
|
||||
inline const Aws::CloudFormation::CloudFormationClient* GetCloudFormationClient() const
|
||||
{
|
||||
return m_cfnClient;
|
||||
}
|
||||
|
||||
// Sets the SecretsManagerClient explicitly.
|
||||
// It's the caller responsibility to call delete on the instance passed to this method.
|
||||
inline void SetSecretsManagerClient(Aws::SecretsManager::SecretsManagerClient* secretsClient)
|
||||
{
|
||||
m_secretsClient = secretsClient;
|
||||
}
|
||||
|
||||
// Sets the ApiGatewayClient explicitly.
|
||||
// It's the caller responsibility to call delete on the instance passed to this method.
|
||||
inline void SetApiGatewayClient(Aws::APIGateway::APIGatewayClient* apigwyClient)
|
||||
{
|
||||
m_apigwyClient = apigwyClient;
|
||||
}
|
||||
|
||||
// Sets the LambdaClient explicitly.
|
||||
// It's the caller responsibility to call delete on the instance passed to this method.
|
||||
inline void SetLambdaClient(Aws::Lambda::LambdaClient* lambdaClient)
|
||||
{
|
||||
m_lambdaClient = lambdaClient;
|
||||
}
|
||||
|
||||
// Sets the GameLiftClient explicitly.
|
||||
// It's the caller responsibility to call delete on the instance passed to this method.
|
||||
inline void SetGameLiftClient(Aws::GameLift::GameLiftClient* gameLiftClient)
|
||||
{
|
||||
m_gameLiftClient = gameLiftClient;
|
||||
}
|
||||
|
||||
// Gets the GameLiftClient.
|
||||
inline const Aws::GameLift::GameLiftClient* GetGameLiftClient() const
|
||||
{
|
||||
return m_gameLiftClient;
|
||||
}
|
||||
|
||||
// Sets the ECRClient explicitly.
|
||||
// It's the caller responsibility to call delete on the instance passed to this method.
|
||||
inline void SetECRClient(Aws::ECR::ECRClient* ecrClient)
|
||||
{
|
||||
m_ecrClient = ecrClient;
|
||||
}
|
||||
|
||||
// Gets the ECRClient.
|
||||
inline const Aws::ECR::ECRClient* GetECRClient() const
|
||||
{
|
||||
return m_ecrClient;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
// Standard library
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
// AWS SDK
|
||||
#include <aws/core/auth/AWSCredentials.h>
|
||||
#include <aws/core/utils/json/JsonSerializer.h>
|
||||
|
||||
// GameLift
|
||||
#include "errors.h"
|
||||
#include "logging.h"
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
class GameLiftFeature
|
||||
{
|
||||
protected:
|
||||
const char* m_featureName = nullptr;
|
||||
FuncLogCallback m_logCb = nullptr;
|
||||
public:
|
||||
GameLiftFeature() {};
|
||||
virtual ~GameLiftFeature() {};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Standard Lib
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/api.h>
|
||||
#include <aws/gamelift/core/model/account_info.h>
|
||||
#include <aws/gamelift/core/model/config_consts.h>
|
||||
#include <aws/gamelift/core/errors.h>
|
||||
#include <aws/gamelift/core/logging.h>
|
||||
|
||||
// yaml-cpp
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
static const std::string GAMELIFT_SETTINGS_FILE = "saveInfo.yml";
|
||||
static const std::string GAMELIFT_SETTINGS_VERSION_KEY = "gameliftPluginVersion";
|
||||
static const std::string GAMELIFT_SETTINGS_GAME_KEY = "game";
|
||||
static const std::string GAMELIFT_SETTINGS_GAME_NAME = "name";
|
||||
static const std::string GAMELIFT_SETTINGS_SHORT_GAME_NAME = "short_name";
|
||||
static const std::string GAMELIFT_SETTINGS_LAST_USED_REGION = "lastUsedRegion";
|
||||
static const std::string GAMELIFT_SETTINGS_LAST_USED_ENVIRONMENT = "lastUsedEnvironment";
|
||||
static const std::string GAMELIFT_SETTINGS_LAST_USED_ENVIRONMENT_CODE = "code";
|
||||
static const std::string GAMELIFT_SETTINGS_ENVIRONMENTS_KEY = "customEnvironments";
|
||||
static const std::string GAMELIFT_SETTINGS_ENVIRONMENT_DESCRIPTION = "description";
|
||||
static const std::string GAMELIFT_SETTINGS_FEATURES_KEY = "features";
|
||||
static const std::string GAMELIFT_SETTINGS_FEATURE_ACTIVE = "active";
|
||||
static const std::string GAMELIFT_SETTINGS_FEATURE_VARS = "vars";
|
||||
|
||||
/**
|
||||
* GameLiftSettings offers read/write access to the "saveInfo.yml" GAMELIFT Settings file.
|
||||
*
|
||||
* The settings file contains information such as:
|
||||
* - Game name
|
||||
* - Custom deployment environments (ex: "Gamma")
|
||||
* - List of activated/deactivated features
|
||||
* - Feature-specific variables (ex: "isFacebookLoginEnabled" for Identity)
|
||||
*
|
||||
* The file is stored at "GAMELIFT_ROOT/shortGameName/saveInfo.yml".
|
||||
*
|
||||
* The file is read/written through usage of the plugin UI. For example, when a feature is activated,
|
||||
* when feature variables are filled in, or when a custom deployment environment is added or removed.
|
||||
*
|
||||
* The file is loaded during the constructor, and can be reloaded by calling Reload().
|
||||
* Call SaveSettings() to write the settings to back to disk after making modifications with any "Set", "Add/Delete", "Activate/Deactivate" methods.
|
||||
*/
|
||||
class GAMELIFT_API GameLiftSettings
|
||||
{
|
||||
private:
|
||||
std::string m_gameliftPluginVersion;
|
||||
std::string m_gameliftRootPath;
|
||||
std::string m_shortGameName;
|
||||
std::string m_currentEnvironment;
|
||||
YAML::Node m_gameliftYamlSettings;
|
||||
FuncLogCallback m_logCb;
|
||||
public:
|
||||
GameLiftSettings(const std::string& gameliftRoot, const std::string& pluginVersion, const std::string& shortGameName, const std::string& currentEnvironment, FuncLogCallback logCallback);
|
||||
~GameLiftSettings();
|
||||
void SetGameName(const std::string& gameName);
|
||||
void SetLastUsedRegion(const std::string& region);
|
||||
void SetLastUsedEnvironment(const std::string& gameName);
|
||||
void AddCustomEnvironment(const std::string& envCode, const std::string& envDescription);
|
||||
void DeleteCustomEnvironment(const std::string& envCode);
|
||||
void ActivateFeature(FeatureType featureType);
|
||||
void DeactivateFeature(FeatureType featureType);
|
||||
void SetFeatureVariables(FeatureType featureType, const std::map<std::string, std::string>& vars);
|
||||
void DeleteFeatureVariable(FeatureType featureType, std::string varName);
|
||||
unsigned int SaveSettings();
|
||||
std::string GetGameName() const;
|
||||
std::string GetLastUsedRegion() const;
|
||||
std::string GetLastUsedEnvironment() const;
|
||||
std::map<std::string, std::string> GetCustomEnvironments() const;
|
||||
std::string GetCustomEnvironmentDescription(std::string envCode) const;
|
||||
bool IsFeatureActive(FeatureType featureType) const;
|
||||
std::map<std::string, std::string> GetFeatureVariables(FeatureType featureType) const;
|
||||
std::string GetFeatureVariable(FeatureType featureType, std::string varName) const;
|
||||
std::string GetSettingsFilePath() const;
|
||||
void Reload();
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Standard Library
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
|
||||
// GameLift
|
||||
#include "api.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
typedef void(*FuncLogCallback)(unsigned int level, const char* message, int size);
|
||||
}
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
namespace Logger
|
||||
{
|
||||
enum Level : unsigned int
|
||||
{
|
||||
None = 0,
|
||||
Verbose = 1,
|
||||
Info = 2,
|
||||
Warning = 3,
|
||||
Error = 4
|
||||
};
|
||||
|
||||
class GAMELIFT_API Logging
|
||||
{
|
||||
public:
|
||||
static void Log(FuncLogCallback cb, Level level, const char* message);
|
||||
static void Log(FuncLogCallback cb, Level level, const char* message, const void* context);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Standard Library
|
||||
#include <string>
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
struct CredentialProfile
|
||||
{
|
||||
const char* name;
|
||||
};
|
||||
|
||||
// Marshalable struct to be used with P/Invoke
|
||||
struct AccountCredentials
|
||||
{
|
||||
const char* region;
|
||||
const char* accessKey;
|
||||
const char* accessSecret;
|
||||
const char* accessToken;
|
||||
const char* accountId;
|
||||
};
|
||||
|
||||
struct AccountCredentialsCopy
|
||||
{
|
||||
std::string region;
|
||||
std::string accessKey;
|
||||
std::string accessSecret;
|
||||
std::string accessToken;
|
||||
std::string shortRegionCode;
|
||||
std::string accountId;
|
||||
};
|
||||
|
||||
inline AccountCredentialsCopy CreateAccountCredentialsCopy(const AccountCredentials& credentials)
|
||||
{
|
||||
return AccountCredentialsCopy{ credentials.region, credentials.accessKey, credentials.accessSecret, (credentials.accessToken == nullptr) ? "" : credentials.accessToken };
|
||||
}
|
||||
|
||||
inline AccountCredentialsCopy CreateAccountCredentialsCopy(const AccountCredentials& credentials, const std::string& shortRegionCode)
|
||||
{
|
||||
return AccountCredentialsCopy{ credentials.region, credentials.accessKey, credentials.accessSecret, (credentials.accessToken == nullptr) ? "" : credentials.accessToken, shortRegionCode };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Standard Library
|
||||
#include <string>
|
||||
#include <regex>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/model/resource_environment.h>
|
||||
#include <aws/gamelift/core/utils/encoding_utils.h>
|
||||
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
// Marshallable struct to be used with P/Invoke
|
||||
struct AccountInfo
|
||||
{
|
||||
const char* environment;
|
||||
const char* accountId;
|
||||
const char* companyName;
|
||||
const char* gameName;
|
||||
const char* bucketName;
|
||||
};
|
||||
|
||||
struct AccountInfoCopy
|
||||
{
|
||||
ResourceEnvironment environment;
|
||||
std::string accountId;
|
||||
std::string companyName;
|
||||
std::string gameName;
|
||||
std::string bucketName;
|
||||
};
|
||||
|
||||
inline std::string TruncateAtLower(std::string str, const std::regex& pattern)
|
||||
{
|
||||
auto rbegin = std::sregex_iterator(str.begin(), str.end(), pattern);
|
||||
auto rend = std::sregex_iterator();
|
||||
std::string matchStr;
|
||||
for (std::sregex_iterator i = rbegin; i != rend; ++i)
|
||||
{
|
||||
std::smatch match = *i;
|
||||
matchStr = match.str();
|
||||
}
|
||||
|
||||
std::transform(matchStr.begin(), matchStr.end(), matchStr.begin(),
|
||||
[](unsigned char c) { return std::tolower(c); }
|
||||
);
|
||||
return matchStr;
|
||||
}
|
||||
|
||||
inline AccountInfoCopy CreateAccountInfoCopy(const AccountInfo& accountInfo)
|
||||
{
|
||||
AccountInfoCopy acctCopy{
|
||||
ResourceEnvironment(accountInfo.environment),
|
||||
accountInfo.accountId,
|
||||
accountInfo.companyName,
|
||||
accountInfo.gameName,
|
||||
accountInfo.bucketName
|
||||
};
|
||||
|
||||
// using the regex pattern for each field, truncate and convert them to lowercase
|
||||
acctCopy.accountId = TruncateAtLower(acctCopy.accountId, std::regex("\\d{12}"));
|
||||
acctCopy.gameName = TruncateAtLower(acctCopy.gameName, std::regex("[a-zA-Z0-9]{1,12}"));
|
||||
acctCopy.companyName = TruncateAtLower(acctCopy.companyName, std::regex("[a-zA-Z0-9]{3,12}"));
|
||||
|
||||
return acctCopy;
|
||||
}
|
||||
|
||||
// Method to compose bootstrap bucket name
|
||||
inline std::string GetDefaultBootstrapBucketName(const AccountInfoCopy& accountInfo, const std::string& shortRegionCode)
|
||||
{
|
||||
std::string bootstrapBucketName = "do-not-delete-gamelift-";
|
||||
|
||||
// Bootstrap bucket names have a maximum 63 characters and has the format:
|
||||
// do-not-delete-gamelift-<env>-<5_letter_aws_region_code>-<base36_account_id>-<gamename>
|
||||
bootstrapBucketName.append(accountInfo.environment.GetEnvironmentString())
|
||||
.append("-")
|
||||
.append(shortRegionCode)
|
||||
.append("-")
|
||||
.append(GameLift::Utils::EncodingUtils::DecimalToBase(accountInfo.accountId, GameLift::Utils::BASE_36));
|
||||
|
||||
return bootstrapBucketName;
|
||||
}
|
||||
|
||||
inline std::string GetBootstrapBucketName(const AccountInfoCopy& accountInfo, const std::string& shortRegionCode)
|
||||
{
|
||||
if (!accountInfo.bucketName.empty())
|
||||
{
|
||||
return accountInfo.bucketName;
|
||||
}
|
||||
|
||||
std::string bootstrapBucketName = GetDefaultBootstrapBucketName(accountInfo, shortRegionCode);
|
||||
|
||||
return bootstrapBucketName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
namespace Configuration
|
||||
{
|
||||
static const std::string DO_NOT_EDIT = "#\n# DO NOT MANUALLY EDIT\n#\n# Autogenerated by AWS GameLift\n#\n";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Standard Library
|
||||
#include <string>
|
||||
#include <regex>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/enums.h>
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
struct ResourceEnvironment
|
||||
{
|
||||
private:
|
||||
EnvironmentType environmentType;
|
||||
std::string environmentCode;
|
||||
public:
|
||||
ResourceEnvironment() {
|
||||
environmentType = EnvironmentType::Development;
|
||||
}
|
||||
|
||||
// Do not use EnvironmentType::Custom in this constructor.
|
||||
// It will be defaulted to EnvironmentType::Development if you do.
|
||||
inline ResourceEnvironment(EnvironmentType env)
|
||||
{
|
||||
this->environmentType = env;
|
||||
switch (env)
|
||||
{
|
||||
case EnvironmentType::Development: this->environmentCode = "dev";
|
||||
case EnvironmentType::QA: this->environmentCode = "qa";
|
||||
case EnvironmentType::Staging: this->environmentCode = "stg";
|
||||
case EnvironmentType::Production: this->environmentCode = "prd";
|
||||
default:
|
||||
this->environmentType = EnvironmentType::Development;
|
||||
this->environmentCode = "dev";
|
||||
}
|
||||
}
|
||||
|
||||
inline ResourceEnvironment(const std::string& envCode)
|
||||
{
|
||||
if (!std::regex_match(envCode, std::regex("[a-z0-9]{2,3}")))
|
||||
{
|
||||
throw "Invalid environment code. Environment codes are all lowercase alphanumeric characters with a maximum length of 3.";
|
||||
}
|
||||
|
||||
this->environmentCode = envCode;
|
||||
if (envCode == "dev")
|
||||
{
|
||||
this->environmentType = EnvironmentType::Development;
|
||||
}
|
||||
else if (envCode == "qa")
|
||||
{
|
||||
this->environmentType = EnvironmentType::QA;
|
||||
}
|
||||
else if (envCode == "stg")
|
||||
{
|
||||
this->environmentType = EnvironmentType::Staging;
|
||||
}
|
||||
else if (envCode == "prod")
|
||||
{
|
||||
this->environmentType = EnvironmentType::Production;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->environmentType = EnvironmentType::Custom;
|
||||
}
|
||||
}
|
||||
|
||||
inline EnvironmentType GetEnvironmentType()
|
||||
{
|
||||
return this->environmentType;
|
||||
}
|
||||
|
||||
inline std::string GetEnvironmentString() const
|
||||
{
|
||||
return this->environmentCode;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
// Template system variables. These variables are replaced when instance templates are saved.
|
||||
namespace TemplateVars
|
||||
{
|
||||
static const std::string BEGIN = "\\{\\{";
|
||||
static const std::string END = "\\}\\}";
|
||||
static const std::string AWS_GAMELIFT_ENVIRONMENT = "AWSGAMELIFT::SYS::ENV";
|
||||
static const std::string AWS_GAMELIFT_GAMENAME = "AWSGAMELIFT::SYS::GAMENAME";
|
||||
static const std::string AWS_GAMELIFT_USERVAR_PREFIX = "AWSGAMELIFT::VARS::";
|
||||
static const std::string AWS_GAMELIFT_CLOUDFORMATION_OUTPUT_PREFIX = "AWSGAMELIFT::CFNOUTPUT::";
|
||||
static const std::string AWS_GAMELIFT_BASE36_AWS_ACCOUNTID = "AWSGAMELIFT::SYS::BASE36AWSACCOUNTID";
|
||||
static const std::string AWS_GAMELIFT_SHORT_REGION_CODE = "AWSGAMELIFT::SYS::SHORTREGIONCODE";
|
||||
}
|
||||
|
||||
namespace ResourceDirectories
|
||||
{
|
||||
static const std::string CLOUDFORMATION_DIRECTORY = "/cloudformation/";
|
||||
static const std::string LAYERS_DIRECTORY = "/layers/";
|
||||
static const std::string FUNCTIONS_DIRECTORY = "/functions/";
|
||||
static const std::string CONFIG_OUTPUTS_DIRECTORY = "/configOutputs/";
|
||||
}
|
||||
|
||||
namespace TemplateFileNames
|
||||
{
|
||||
static const std::string FEATURE_DASHBOARD_FILE = "dashboard.yml";
|
||||
static const std::string CLOUDFORMATION_FILE = "cloudFormation.yml";
|
||||
static const std::string PARAMETERS_FILE = "parameters.yml";
|
||||
static const std::string FEATURE_CLIENT_CONFIGURATION_FILE = "clientConfig.yml";
|
||||
static const std::string GAMELIFT_CLIENT_CONFIGURATION_FILE = "awsGameLiftClientConfig.yml";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
namespace GameLift
|
||||
{
|
||||
static const std::string GAMELIFT_LAMBDA_LAYERS_REPLACEMENT_ID_PREFIX = "GAMELIFT_LAMBDA_LAYERS_REPLACEMENT_ID_";
|
||||
static const std::string GAMELIFT_LAMBDA_LAYER_ARN_PREFIX = "GAMELIFT_LAMBDA_LAYER_ARN_";
|
||||
static const std::string GAMELIFT_LAMBDA_LAYER_HASH_PREFIX = "GAMELIFT_LAMBDA_LAYER_HASH_";
|
||||
static const std::string GAMELIFT_GAME_SERVER_HASH_PREFIX = "GAMELIFT_GAME_SERVER_HASH_";
|
||||
static const std::string GAMELIFT_GAME_SERVER_ADDONS_PREFIX = "GAMELIFT_GAME_SERVER_ADDONS_HASH_";
|
||||
static const std::string GAMELIFT_LAMBDA_FUNCTIONS_REPLACEMENT_ID_PREFIX = "GAMELIFT_LAMBDA_FUNCTIONS_REPLACEMENT_ID_";
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// AWS SDK
|
||||
#include <aws/core/utils/DateTime.h>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/api.h>
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
namespace Utils
|
||||
{
|
||||
/**
|
||||
* This class provides a wrapper over the static functions in Aws::Utils::DateTime to enable these functions to be mocked with GTest.
|
||||
*
|
||||
* See: https://sdk.amazonaws.com/cpp/api/LATEST/class_aws_1_1_utils_1_1_date_time.html
|
||||
* See: http://google.github.io/googletest/gmock_cook_book.html#mocking-free-functions
|
||||
*/
|
||||
class GAMELIFT_API ICurrentTimeProvider
|
||||
{
|
||||
public:
|
||||
ICurrentTimeProvider() {}
|
||||
virtual ~ICurrentTimeProvider() {}
|
||||
|
||||
/**
|
||||
* Get the number of milliseconds since epoch representing this very instant.
|
||||
*/
|
||||
virtual int64_t GetCurrentTimeMilliseconds() const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Implementation that directly calls the corresponding static methods in Aws::Utils::DateTime:
|
||||
* https://sdk.amazonaws.com/cpp/api/LATEST/class_aws_1_1_utils_1_1_date_time.html
|
||||
*/
|
||||
class GAMELIFT_API AwsCurrentTimeProvider : public ICurrentTimeProvider
|
||||
{
|
||||
public:
|
||||
|
||||
int64_t GetCurrentTimeMilliseconds() const override
|
||||
{
|
||||
return Aws::Utils::DateTime::CurrentTimeMillis();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Define GameLiftInternalAssert helper macro. This is a wrapper for C++ assert() that is only compiled in
|
||||
* debug builds. No-op in Release builds.
|
||||
*/
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include <assert.h>
|
||||
|
||||
#define GameLiftInternalAssert(value) assert(value)
|
||||
|
||||
#else
|
||||
|
||||
#define GameLiftInternalAssert(value) (void)(value)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Standard Library
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/api.h>
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
namespace Utils
|
||||
{
|
||||
static const int BASE_2 = 2;
|
||||
static const int BASE_16 = 16;
|
||||
static const int BASE_36 = 36;
|
||||
|
||||
class GAMELIFT_API EncodingUtils
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Decimal to provided base encoding.
|
||||
*
|
||||
* @details Converts an input base10 string and returns the equivalent string encoded to provided base value.
|
||||
*
|
||||
* @param decimalStr Input base10 in string form.
|
||||
* @param base Base to convert to.
|
||||
* @returns String representation of 'base' encoded decimalStr, return empty string on error.
|
||||
*/
|
||||
static std::string DecimalToBase(const std::string& decimalStr, const int base);
|
||||
|
||||
/**
|
||||
* @brief Encodes a string in Base64.
|
||||
*
|
||||
* @details Converts the input string to a Base64 byte array, then converts the byte array to an ASCII compliant string.
|
||||
*
|
||||
* @param str The input string to encode.
|
||||
* @returns Base64 encoded variant of the input string.
|
||||
*/
|
||||
static std::string EncodeBase64(const std::string& str);
|
||||
|
||||
/**
|
||||
* @brief Decodes a Base64 encoded string.
|
||||
*
|
||||
* @details Decodes the input string into a byte array, then converts the byte array into a string.
|
||||
*
|
||||
* @param encodedStr The input string to decode.
|
||||
* @returns Decoded variant of the Base64 encoded input string.
|
||||
*/
|
||||
static std::string DecodeBase64(const std::string& encodedStr);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Standard Library
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
// AWS SDK
|
||||
#include <aws/core/utils/base64/Base64.h>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/api.h>
|
||||
#include <aws/gamelift/core/awsclients/default_clients.h>
|
||||
#include <aws/gamelift/core/errors.h>
|
||||
#include <aws/gamelift/core/logging.h>
|
||||
|
||||
// Forward declaration
|
||||
namespace YAML { class Node; }
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
namespace Utils
|
||||
{
|
||||
class GAMELIFT_API FileUtils
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* @brief Returns an open handler to the specified file. Creates the file if it doesn't exist. Creates missing directories in the filePath.
|
||||
*
|
||||
* @param filePath The absolute or relative path plus the filename of the file to write (UTF-8 encoded). Example: "foo.json", "..\\foo.json", or "C:\\Program Files\\foo.json".
|
||||
* @param returnFileStream (Out Parameter) An open stream to the specified file.
|
||||
* @param logCallback (Optional) If provided and the write fails, will log a human readable error message.
|
||||
* @param errorMessagePrefix (Optional) A prefix to put in front of the error message. Example: "GameSaving::DownloadCloudSlot() ".
|
||||
* @return GAMELIFT_SUCCESS if the file was successfully opened, otherwise returns GAMELIFT_ERROR_FILE_OPEN_FAILED or GAMELIFT_ERROR_DIRECTORY_CREATE_FAILED.
|
||||
*/
|
||||
static unsigned int createOrOpenFile(const std::string& filePath, std::ofstream& returnFileStream, FuncLogCallback logCallback = nullptr, const std::string& errorMessagePrefix = "");
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Calculates the hash of an entire directory.
|
||||
*
|
||||
* @param directoryPath The absolute or relative path of the directory to hash (UTF-8 encoded). Example: "foo", "..\\foo", or "C:\\Program Files\\foo".
|
||||
* @param returnedString (Out Parameter) The string to write into. If the operation fails, the string will be empty: "".
|
||||
* @param logCallback (Optional) If provided and the operation fails, will log a human readable error message.
|
||||
* @return GAMELIFT_SUCCESS if the directory hash was successfully calculated and the return string written to, otherwise returns GAMELIFT_ERROR_DIRECTORY_NOT_FOUND.
|
||||
*/
|
||||
static unsigned int CalculateDirectoryHash(const std::string& directoryPath, std::string& returnedString, FuncLogCallback logCallback = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Load a file into a string.
|
||||
*
|
||||
* @param filePath The absolute or relative path plus the filename of the file to read (UTF-8 encoded). Example: "foo.json", "..\\foo.json", or "C:\\Program Files\\foo.json".
|
||||
* @param returnedString (Out Parameter) The string to write into. If the operation fails, the string will be empty: "".
|
||||
* @param logCallback (Optional) If provided and the operation fails, will log a human readable error message.
|
||||
* @param errorMessagePrefix (Optional) A prefix to put in front of the error message. Example: "GameSaving::LoadMetadata() ".
|
||||
* @return GAMELIFT_SUCCESS if the file was successfully read from and the string written to, otherwise returns GAMELIFT_ERROR_FILE_OPEN_FAILED or GAMELIFT_ERROR_FILE_READ_FAILED.
|
||||
*/
|
||||
static unsigned int ReadFileIntoString(const std::string& filePath, std::string& returnedString, FuncLogCallback logCallback = nullptr, const std::string& errorMessagePrefix = "");
|
||||
|
||||
/**
|
||||
* @brief Write a string to a file. Overwrites the file if it already exists, otherwise creates a new file. Creates missing directories in the filePath.
|
||||
*
|
||||
* @param sourceString The string to write to the file.
|
||||
* @param filePath The absolute or relative path plus the filename of the file to write (UTF-8 encoded). Example: "foo.json", "..\\foo.json", or "C:\\Program Files\\foo.json".
|
||||
* @param logCallback (Optional) If provided and the write fails, will log a human readable error message.
|
||||
* @param errorMessagePrefix (Optional) A prefix to put in front of the error message. Example: "GameSaving::SaveMetadata() ".
|
||||
* @return GAMELIFT_SUCCESS if the file was successfully written to, otherwise returns GAMELIFT_ERROR_FILE_OPEN_FAILED, GAMELIFT_ERROR_FILE_WRITE_FAILED, or GAMELIFT_ERROR_DIRECTORY_CREATE_FAILED.
|
||||
*/
|
||||
static unsigned int WriteStringToFile(const std::string& sourceString, const std::string& filePath, FuncLogCallback logCallback = nullptr, const std::string& errorMessagePrefix = "");
|
||||
|
||||
/**
|
||||
* @brief Writes the contents of a stream to a file. Overwrites the file if it already exists, otherwise creates a new file. Creates missing directories in the filePath.
|
||||
*
|
||||
* @param sourceStream The stream to write to the file.
|
||||
* @param filePath The absolute or relative path plus the filename of the file to write (UTF-8 encoded). Example: "foo.json", "..\\foo.json", or "C:\\Program Files\\foo.json".
|
||||
* @param logCallback (Optional) If provided and the write fails, will log a human readable error message.
|
||||
* @param errorMessagePrefix (Optional) A prefix to put in front of the error message. Example: "GameSaving::DownloadCloudSlot() ".
|
||||
* @return GAMELIFT_SUCCESS if the file was successfully written to, otherwise returns GAMELIFT_ERROR_FILE_OPEN_FAILED, GAMELIFT_ERROR_FILE_WRITE_FAILED, or GAMELIFT_ERROR_DIRECTORY_CREATE_FAILED.
|
||||
*/
|
||||
static unsigned int WriteStreamToFile(const std::istream& sourceStream, const std::string& filePath, FuncLogCallback logCallback = nullptr, const std::string& errorMessagePrefix = "");
|
||||
|
||||
/**
|
||||
* @brief Loads and parses an existing YAML file.
|
||||
*
|
||||
* @param filePath The absolute or relative path plus the filename of the file to write (UTF-8 encoded). Example: "foo.json", "..\\foo.json", or "C:\\Program Files\\foo.json".
|
||||
* @param returnedNode Reference to `YAML::Node` variable that will be assigned the root node if load is successful.
|
||||
* @param logCallback (Optional) If provided and the operation fails, will log a human readable error message.
|
||||
* @param errorMessagePrefix (Optional) A prefix to put in front of the error message. Example: "GameSaving::DownloadCloudSlot() ".
|
||||
* @return GAMELIFT_SUCCESS if the file was successfully written to, otherwise returns GAMELIFT_ERROR_FILE_OPEN_FAILED, GAMELIFT_ERROR_FILE_WRITE_FAILED, or GAMELIFT_ERROR_DIRECTORY_CREATE_FAILED.
|
||||
*/
|
||||
static unsigned int ReadFileAsYAML(const std::string& filePath, YAML::Node& returnedNode, FuncLogCallback logCallback = nullptr, const std::string& errorMessagePrefix = "");
|
||||
|
||||
/**
|
||||
* @brief Writes a YAML document to a file. Overwrites the file if it already exists, otherwise creates a new file. Creates missing directories in the filePath.
|
||||
*
|
||||
* @param node The root node of the YAML document to be written to disk.
|
||||
* @param filePath The absolute or relative path plus the filename of the file to write (UTF-8 encoded). Example: "foo.json", "..\\foo.json", or "C:\\Program Files\\foo.json".
|
||||
* @param headerComment (Optional) Header string that is written before the serialized YAML, should be formatted as a YAML comment.
|
||||
* @param logCallback (Optional) If provided and the write fails, will log a human readable error message.
|
||||
* @param errorMessagePrefix (Optional) A prefix to put in front of the error message. Example: "GameSaving::DownloadCloudSlot() ".
|
||||
* @return GAMELIFT_SUCCESS if the file was successfully written to, otherwise returns GAMELIFT_ERROR_FILE_OPEN_FAILED, GAMELIFT_ERROR_FILE_WRITE_FAILED, or GAMELIFT_ERROR_DIRECTORY_CREATE_FAILED.
|
||||
*/
|
||||
static unsigned int WriteYAMLToFile(const YAML::Node& rootNode, const std::string& filePath, const std::string& headerComment = "", FuncLogCallback logCallback = nullptr, const std::string & errorMessagePrefix = "");
|
||||
|
||||
#if _WIN32
|
||||
typedef std::wstring PlatformPathString;
|
||||
#else
|
||||
typedef std::string PlatformPathString;
|
||||
#endif
|
||||
/**
|
||||
* @brief Converts UTF-8 path strings for use with platform-native file APIs
|
||||
*
|
||||
* @param pathString The UTF-8 encoded string to be converted
|
||||
* @return The converted wstring (Windows) or a copy of the source string (other platforms)
|
||||
*/
|
||||
static PlatformPathString PathFromUtf8(const std::string& pathString);
|
||||
|
||||
/**
|
||||
* @brief Converts platform-native path strings to UTF-8 for use with GameLift
|
||||
*
|
||||
* @param pathString A UTF-16 wide string (Windows), or a UTF-8 string (other platforms)
|
||||
* @return The converted UTF-8 string (Windows) or a copy of the source string (other platforms)
|
||||
*/
|
||||
static std::string PathToUtf8(const PlatformPathString& pathString);
|
||||
|
||||
/**
|
||||
* @brief Checks if the file exists
|
||||
*
|
||||
* @param pathString The absolute or relative path plus the filename of the file to check for existance (UTF-8 encoded)
|
||||
* @return True if the file exists, False - otherwise
|
||||
*/
|
||||
static bool FileExists(const std::string& filePath);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Standard Library
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <deque>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
// AWS SDK
|
||||
#include <aws/core/http/HttpClient.h>
|
||||
#include <aws/core/http/HttpRequest.h>
|
||||
#include <aws/core/http/HttpResponse.h>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/errors.h>
|
||||
#include <aws/gamelift/core/logging.h>
|
||||
#include <aws/gamelift/core/awsclients/api_initializer.h>
|
||||
#include <aws/gamelift/core/awsclients/default_clients.h>
|
||||
#include <aws/gamelift/core/utils/gamelift_httpclient_types.h>
|
||||
#include <aws/gamelift/core/utils/ticker.h>
|
||||
|
||||
using namespace GameLift::Logger;
|
||||
|
||||
#define OPERATION_ATTEMPTS_NO_LIMIT 0
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
namespace Utils
|
||||
{
|
||||
namespace HttpClient
|
||||
{
|
||||
// Base Http Client with retry capability with an internal request queue.
|
||||
class GAMELIFT_API BaseHttpClient
|
||||
{
|
||||
private:
|
||||
std::string m_clientName;
|
||||
bool m_isConnectionOk;
|
||||
size_t m_maxPendingQueueSize;
|
||||
unsigned int m_attempsCount;
|
||||
unsigned int m_secondsInterval;
|
||||
GameLift::Utils::Ticker m_requestPump;
|
||||
bool m_abortProcessingRequested;
|
||||
std::shared_ptr<Aws::Http::HttpClient> m_httpClient;
|
||||
std::shared_ptr<IRetryStrategy> m_retryStrategy;
|
||||
OperationQueue m_activeQueue; // this queue is only r/w in the background thread
|
||||
OperationQueue m_pendingQueue; // this queue is always r/w under mutex
|
||||
std::mutex m_processMutex;
|
||||
NETWORK_STATE_RECEIVER_HANDLE m_stateReceiverHandle;
|
||||
NetworkStatusChangeCallback m_statusCb;
|
||||
CACHE_PROCESSED_RECEIVER_HANDLE m_cachedProcessedReceiverHandle;
|
||||
CacheProcessedCallback m_cachedProcessedCb;
|
||||
|
||||
bool enqueuePending(std::shared_ptr<IOperation> operation);
|
||||
void preProcessQueue();
|
||||
void processActiveQueue();
|
||||
|
||||
protected:
|
||||
FuncLogCallback m_logCb = nullptr;
|
||||
RequestModifier m_authorizationHeaderSetter;
|
||||
bool m_stopProcessingOnError;
|
||||
bool m_errorDuringProcessing;
|
||||
|
||||
size_t m_cachedOperationsRemaining = 0;
|
||||
bool m_skipCacheProcessedCallback = false;
|
||||
|
||||
void notifyNetworkStateChange() const;
|
||||
void notifyCachedOperationsProcessed(bool cacheProcessingSucceeded) const;
|
||||
void setStopProcessingOnError(bool stopProcessingOnError);
|
||||
|
||||
// Determine whether an operation is retryable based on its properties and the response
|
||||
virtual bool isOperationRetryable(const std::shared_ptr<IOperation> operation, std::shared_ptr<const Aws::Http::HttpResponse> response) const = 0;
|
||||
|
||||
// Determine whether an operation should be enqueued when the client is in Unhealthy mode
|
||||
virtual bool shouldEnqueueWithUnhealthyConnection(const std::shared_ptr<IOperation> operation) const = 0;
|
||||
|
||||
// Logic to filter the internal queue before operations are processed.
|
||||
// Precondition: queue has items, filtered is empty.
|
||||
// Postcondition: filtered has items to keep.
|
||||
virtual void filterQueue(OperationQueue* queue, OperationQueue* filtered) = 0;
|
||||
|
||||
void removeCachedFromQueue(OperationQueue* queue, OperationQueue* filtered) const;
|
||||
|
||||
static bool isResponseCodeRetryable(Aws::Http::HttpResponseCode responseCode);
|
||||
|
||||
bool isPendingQueueBelowLimit() const;
|
||||
|
||||
// Sends a request for the given operation and enqueues it for retry in case of failure.
|
||||
// In case the client has lost connectivity, events are enqueued for later retry.
|
||||
RequestResult makeOperationRequest(std::shared_ptr<IOperation> operation, bool isAsyncOperation, bool overrideConnectionStatus);
|
||||
|
||||
public:
|
||||
BaseHttpClient(const std::string& clientName, std::shared_ptr<Aws::Http::HttpClient> client, RequestModifier authSetter, unsigned int retryIntervalSeconds, std::shared_ptr<IRetryStrategy> retryStrategy, size_t maxPendingQueueSize, FuncLogCallback logCb);
|
||||
virtual ~BaseHttpClient();
|
||||
|
||||
void SetNetworkChangeCallback(NETWORK_STATE_RECEIVER_HANDLE receiverHandle, NetworkStatusChangeCallback statusChangeCallback);
|
||||
void SetCacheProcessedCallback(CACHE_PROCESSED_RECEIVER_HANDLE receiverHandle, CacheProcessedCallback cacheProcessedCallback);
|
||||
void StartRetryBackgroundThread();
|
||||
void StopRetryBackgroundThread();
|
||||
|
||||
// PersistQueue should be among the last methods to be called in a client. This is to ensure that all data that a player has in the queue has been saved to the cache.
|
||||
bool PersistQueue(const std::string& file, std::function<bool(std::ostream&, const std::shared_ptr<IOperation>, FuncLogCallback)> serializer, bool clearQueue = true);
|
||||
|
||||
// LoadQueue should be among the first methods to be called in a client. This is to ensure the cache has been read into the queue so they can be processed for the player.
|
||||
bool LoadQueue(const std::string& file, std::function<bool(std::istream&, std::shared_ptr<IOperation>&, FuncLogCallback)> deserializer, bool clearFile = true);
|
||||
|
||||
// Helper to clear the offline cache from the queues, there is no need to clear the local file.
|
||||
// LoadQueue moves all cached operations from the local file to the queue and clears the local file.
|
||||
void DropAllCachedEvents();
|
||||
|
||||
// Set the low level HTTP Client. Use only for testing.
|
||||
void SetLowLevelHttpClient(std::shared_ptr<Aws::Http::HttpClient> client);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Standard Library
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <chrono>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
// AWS SDK
|
||||
#include <aws/core/http/HttpClient.h>
|
||||
#include <aws/core/http/HttpRequest.h>
|
||||
#include <aws/core/http/HttpResponse.h>
|
||||
#include <aws/core/utils/StringUtils.h>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/awsclients/api_initializer.h>
|
||||
#include <aws/gamelift/core/awsclients/default_clients.h>
|
||||
#include <aws/gamelift/core/errors.h>
|
||||
#include <aws/gamelift/core/logging.h>
|
||||
#include <aws/gamelift/core/utils/ticker.h>
|
||||
|
||||
using namespace GameLift::Logger;
|
||||
|
||||
#define OPERATION_ATTEMPTS_NO_LIMIT 0
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
namespace Utils
|
||||
{
|
||||
namespace Serialization
|
||||
{
|
||||
template <typename T, size_t N>
|
||||
GAMELIFT_API std::ostream& BinWrite(std::ostream& os, const T (&t)[N])
|
||||
{
|
||||
size_t length = N;
|
||||
os.write((char*)&length, sizeof(size_t));
|
||||
os.write((char*)t, N);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GAMELIFT_API std::ostream& BinWrite(std::ostream& os, const T& t)
|
||||
{
|
||||
os.write((char*)&t, sizeof(T));
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
template <>
|
||||
GAMELIFT_API std::ostream& BinWrite<std::string>(std::ostream& os, const std::string& s);
|
||||
|
||||
template <typename T>
|
||||
GAMELIFT_API std::istream& BinRead(std::istream& is, T& t)
|
||||
{
|
||||
is.read((char*)&t, sizeof(T));
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
template <>
|
||||
GAMELIFT_API std::istream& BinRead<std::string>(std::istream& is, std::string& s);
|
||||
|
||||
GAMELIFT_API unsigned int GetCRC(const std::string& s);
|
||||
|
||||
GAMELIFT_API unsigned int GetCRC(const char* s, size_t length);
|
||||
}
|
||||
|
||||
namespace HttpClient
|
||||
{
|
||||
typedef void* NETWORK_STATE_RECEIVER_HANDLE;
|
||||
typedef void(*NetworkStatusChangeCallback)(NETWORK_STATE_RECEIVER_HANDLE dispatchReceiver, bool isConnectionOk, const char* connectionClient);
|
||||
typedef void* CACHE_PROCESSED_RECEIVER_HANDLE;
|
||||
typedef void(*CacheProcessedCallback)(CACHE_PROCESSED_RECEIVER_HANDLE dispatchReceiver, bool isCacheProcessed);
|
||||
|
||||
// Wildcard object for response callback context
|
||||
typedef void* CallbackContext;
|
||||
|
||||
// Callback to be called when a request has received a response.
|
||||
typedef std::function<void(CallbackContext requestContext, std::shared_ptr<Aws::Http::HttpResponse>)> ResponseCallback;
|
||||
|
||||
// Callback to be called before sending a request. Used to update/modify request headers such as authorization.
|
||||
typedef std::function<void(std::shared_ptr<Aws::Http::HttpRequest>)> RequestModifier;
|
||||
|
||||
GAMELIFT_API bool TrySerializeRequestBinary(std::ostream& os, const std::shared_ptr<Aws::Http::HttpRequest> request, FuncLogCallback logCb = nullptr);
|
||||
GAMELIFT_API bool TryDeserializeRequestBinary(std::istream& is, std::shared_ptr<Aws::Http::HttpRequest>& outRequest, FuncLogCallback logCb = nullptr);
|
||||
|
||||
// Base struct for retryable client operations
|
||||
struct GAMELIFT_API IOperation
|
||||
{
|
||||
const std::chrono::milliseconds Timestamp;
|
||||
unsigned int Attempts;
|
||||
const unsigned int MaxAttempts;
|
||||
bool Discard;
|
||||
bool FromCache = false;
|
||||
|
||||
std::shared_ptr<Aws::Http::HttpRequest> Request;
|
||||
const Aws::Http::HttpResponseCode ExpectedSuccessCode;
|
||||
|
||||
CallbackContext CallbackContext;
|
||||
ResponseCallback SuccessCallback;
|
||||
ResponseCallback FailureCallback;
|
||||
|
||||
IOperation(unsigned int maxAttempts,
|
||||
bool discard,
|
||||
std::shared_ptr<Aws::Http::HttpRequest> request,
|
||||
const Aws::Http::HttpResponseCode expectedCode,
|
||||
std::chrono::milliseconds timestamp = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()))
|
||||
: Attempts(0),
|
||||
MaxAttempts(maxAttempts),
|
||||
Discard(discard),
|
||||
Request(request),
|
||||
ExpectedSuccessCode(expectedCode),
|
||||
CallbackContext(nullptr),
|
||||
SuccessCallback(nullptr),
|
||||
FailureCallback(nullptr),
|
||||
Timestamp(timestamp)
|
||||
{}
|
||||
};
|
||||
|
||||
typedef std::deque<std::shared_ptr<IOperation>> OperationQueue;
|
||||
|
||||
// Types of request results
|
||||
enum class RequestResultType
|
||||
{
|
||||
RequestMadeSuccess = 0,
|
||||
RequestMadeFailure,
|
||||
RequestDropped,
|
||||
RequestEnqueued,
|
||||
RequestAttemptedAndEnqueued
|
||||
};
|
||||
|
||||
std::string GAMELIFT_API RequestResultTypeToString(RequestResultType resultType);
|
||||
|
||||
// Result of a client request
|
||||
struct GAMELIFT_API RequestResult
|
||||
{
|
||||
RequestResult(RequestResultType type, std::shared_ptr<Aws::Http::HttpResponse> response)
|
||||
: ResultType(type), Response(response)
|
||||
{}
|
||||
|
||||
RequestResultType ResultType;
|
||||
std::shared_ptr<Aws::Http::HttpResponse> Response;
|
||||
|
||||
std::string ToString() const;
|
||||
|
||||
unsigned int ToErrorCode() const;
|
||||
};
|
||||
|
||||
// Base interface for retry strategies
|
||||
class GAMELIFT_API IRetryStrategy
|
||||
{
|
||||
public:
|
||||
IRetryStrategy() {}
|
||||
virtual ~IRetryStrategy() {}
|
||||
|
||||
virtual void IncreaseCounter() = 0;
|
||||
virtual bool ShouldRetry() = 0;
|
||||
virtual void Reset() = 0;
|
||||
};
|
||||
|
||||
// Constant Interval Strategy. With this strategy, operations are always retried in each interval.
|
||||
class GAMELIFT_API ConstantIntervalStrategy : public IRetryStrategy
|
||||
{
|
||||
public:
|
||||
ConstantIntervalStrategy() {}
|
||||
virtual ~ConstantIntervalStrategy() {}
|
||||
|
||||
virtual void IncreaseCounter() override { /* No-op by design */ };
|
||||
virtual bool ShouldRetry() override { /* Always true by design */ return true; };
|
||||
virtual void Reset() override { /* No-op by design */ };
|
||||
};
|
||||
|
||||
// Binary Exponential Backoff Strategy. With this strategy, retries are spaced out at exponential intervals.
|
||||
class GAMELIFT_API ExponentialBackoffStrategy : public IRetryStrategy
|
||||
{
|
||||
private:
|
||||
unsigned int counter;
|
||||
unsigned int maxAttempts;
|
||||
unsigned int currentStep;
|
||||
unsigned int retryThreshold;
|
||||
FuncLogCallback logCb = nullptr;
|
||||
|
||||
public:
|
||||
ExponentialBackoffStrategy(unsigned int maxAttempts, FuncLogCallback logCb = nullptr);
|
||||
virtual ~ExponentialBackoffStrategy();
|
||||
|
||||
virtual void IncreaseCounter() override;
|
||||
virtual bool ShouldRetry() override;
|
||||
virtual void Reset() override;
|
||||
};
|
||||
|
||||
enum class StrategyType
|
||||
{
|
||||
ExponentialBackoff = 0,
|
||||
ConstantInterval
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// AWS SDK
|
||||
#include <aws/sts/model/GetAccessKeyInfoRequest.h>
|
||||
#include <aws/sts/model/GetCallerIdentityRequest.h>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/api.h>
|
||||
#include <aws/gamelift/core/awsclients/api_initializer.h>
|
||||
#include <aws/gamelift/core/awsclients/default_clients.h>
|
||||
#include <aws/gamelift/core/logging.h>
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
namespace Utils
|
||||
{
|
||||
class GAMELIFT_API STSUtils
|
||||
{
|
||||
private:
|
||||
bool m_deleteClients;
|
||||
Aws::STS::STSClient* m_stsClient;
|
||||
FuncLogCallback m_logCb;
|
||||
|
||||
public:
|
||||
STSUtils(const std::string& profileName, FuncLogCallback logCallback);
|
||||
STSUtils(const std::string& accessKey, const std::string& secretKey, FuncLogCallback logCallback);
|
||||
virtual ~STSUtils();
|
||||
void SetSTSClient(Aws::STS::STSClient* stsClient);
|
||||
|
||||
std::string GetAwsAccountId() const;
|
||||
bool TryGetAssumeRoleCredentials(const std::string& roleArn, const std::string& roleSessionName, const std::string& sesionPolicy, Aws::STS::Model::Credentials& sessionCredentials) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Standard Library
|
||||
#include <functional>
|
||||
#include <chrono>
|
||||
#include <future>
|
||||
#include <cstdio>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/api.h>
|
||||
#include <aws/gamelift/core/logging.h>
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
namespace Utils
|
||||
{
|
||||
/**
|
||||
* @brief Utility class that calls a function in its own background thread at defined intervals.
|
||||
*/
|
||||
class GAMELIFT_API Ticker
|
||||
{
|
||||
private:
|
||||
static const int TICKER_PULSE = 250;
|
||||
|
||||
std::mutex m_tickerMutex;
|
||||
std::condition_variable m_completedVar;
|
||||
std::thread::id m_threadId;
|
||||
std::thread m_funcThread;
|
||||
int m_interval = 0;
|
||||
std::function<void()> m_tickFunc;
|
||||
FuncLogCallback m_logCb;
|
||||
bool m_isRunning;
|
||||
bool m_aborted;
|
||||
bool m_isCompleted;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Create a new instance of this class.
|
||||
* @param interval The interval in seconds.
|
||||
* @param tickFunc The function to call.
|
||||
* @param logCb The log callback function.
|
||||
*/
|
||||
Ticker(int interval, std::function<void()> tickFunc, FuncLogCallback logCb);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
~Ticker();
|
||||
|
||||
/**
|
||||
* @brief Start the ticker loop in a background thread.
|
||||
*/
|
||||
void Start();
|
||||
|
||||
/**
|
||||
* @brief Stop the ticker.
|
||||
*/
|
||||
void Stop();
|
||||
|
||||
/**
|
||||
* @brief Get the running state of the ticker loop.
|
||||
* @return True if the ticker is running, false otherwise.
|
||||
*/
|
||||
bool IsRunning() const;
|
||||
|
||||
/**
|
||||
* @brief Abort the loop. This should be called inside the tick function.
|
||||
*/
|
||||
void AbortLoop();
|
||||
|
||||
/**
|
||||
* @brief Rechedule the loop to a new intertval. This should be called inside the tick function.
|
||||
* @param newInterval The new interval in seconds.
|
||||
*/
|
||||
void RescheduleLoop(int newInterval);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Standard Library
|
||||
#include <regex>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/api.h>
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
namespace Utils
|
||||
{
|
||||
static const int MIN_URL_PARAM_CHARS = 1;
|
||||
static const int MAX_URL_PARAM_CHARS = 1023;
|
||||
static const int MIN_S3_PARAM_CHARS = 1;
|
||||
static const int MAX_S3_PARAM_CHARS = 1023;
|
||||
static const int MIN_PRIMARY_IDENTIFIER_CHARS = 1;
|
||||
static const int MAX_PRIMARY_IDENTIFIER_CHARS = 512;
|
||||
static const std::string PRIMARY_IDENTIFIER_REGEX = "[a-zA-Z0-9-_.]+";
|
||||
static const std::string PRIMARY_IDENTIFIER_REQUIREMENTS_TEXT = " must contain between "
|
||||
+ std::to_string(MIN_PRIMARY_IDENTIFIER_CHARS) + " and "
|
||||
+ std::to_string(MAX_PRIMARY_IDENTIFIER_CHARS)
|
||||
+ " characters, and may only contain the characters \"a - z\" and \"A - Z\", the numbers \"0 - 9\", and symbols -_.]+";
|
||||
|
||||
class GAMELIFT_API ValidationUtils
|
||||
{
|
||||
public:
|
||||
static std::string UrlEncode(const std::string& urlParameter);
|
||||
static std::string TruncateString(const std::string& str, const std::regex& pattern);
|
||||
static std::string TruncateAtLower(const std::string& str, const std::regex& pattern);
|
||||
static bool IsValidString(const std::string& str, const std::regex& pattern);
|
||||
static bool IsValidUrlParam(const std::string& urlParam);
|
||||
static bool IsValidS3KeyParam(const std::string& s3KeyParam);
|
||||
|
||||
/**
|
||||
* @brief Validates the given string as a primary identifier.
|
||||
*
|
||||
* @details A primary identifier is a string between 1 and 512 characters long, using alphanumeric characters, dashes (-),
|
||||
* underscores (_), and periods (.). Primary identifiers are safe to use in path parameters without being encoded,
|
||||
* DynamoDB partition and sort keys, and S3 object keys.
|
||||
*
|
||||
* @param identifier The identifier to validate.
|
||||
* @returns True if the identifier is a valid primary identifier, false otherwise.
|
||||
*/
|
||||
static bool IsValidPrimaryIdentifier(const std::string& identifier);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
// GameLift
|
||||
#include <aws/gamelift/core/api.h>
|
||||
|
||||
namespace GameLift
|
||||
{
|
||||
static const int MAX_ZIPPER_FILE_SIZE_IN_BYTES = 500000;
|
||||
// Wrapper for public-domain miniz ZIP writer - see miniz.inc
|
||||
// NOTE: filenames and paths use UTF-8 encoding on all platforms
|
||||
class GAMELIFT_API Zipper
|
||||
{
|
||||
private:
|
||||
void* m_zipFile;
|
||||
std::string m_sourcePath;
|
||||
FuncLogCallback m_logCb = nullptr;
|
||||
std::set<std::string> m_addedFiles; // Keep track of files we've added
|
||||
|
||||
void SetSourcePath(const std::string& sourcePath);
|
||||
const std::string& GetSourcePath() const;
|
||||
|
||||
public:
|
||||
Zipper(const std::string& sourcePath, const std::string& zipFileName, FuncLogCallback logCb);
|
||||
~Zipper();
|
||||
|
||||
bool AddDirectoryToZipFile(const std::string& directoryPath);
|
||||
bool AddDirectoryToZipFile(const std::string& directoryPath, const std::string& archivePath);
|
||||
bool AddFileToZipFile(const std::string& fileName, const std::string& archivePath);
|
||||
bool AddFileToZipFile(const std::string& fileName);
|
||||
bool CloseZipFile();
|
||||
static void NormalizePathInZip(std::string& inOutPathInZip, const std::string& relativeSoucePath);
|
||||
};
|
||||
}
|
||||
17
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/anchor.h
vendored
Normal file
17
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/anchor.h
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace YAML {
|
||||
using anchor_t = std::size_t;
|
||||
const anchor_t NullAnchor = 0;
|
||||
}
|
||||
|
||||
#endif // ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
71
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/binary.h
vendored
Normal file
71
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/binary.h
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
#ifndef BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
|
||||
namespace YAML {
|
||||
YAML_CPP_API std::string EncodeBase64(const unsigned char *data,
|
||||
std::size_t size);
|
||||
YAML_CPP_API std::vector<unsigned char> DecodeBase64(const std::string &input);
|
||||
|
||||
class YAML_CPP_API Binary {
|
||||
public:
|
||||
Binary(const unsigned char *data_, std::size_t size_)
|
||||
: m_data{}, m_unownedData(data_), m_unownedSize(size_) {}
|
||||
Binary() : Binary(nullptr, 0) {}
|
||||
Binary(const Binary &) = default;
|
||||
Binary(Binary &&) = default;
|
||||
Binary &operator=(const Binary &) = default;
|
||||
Binary &operator=(Binary &&) = default;
|
||||
|
||||
bool owned() const { return !m_unownedData; }
|
||||
std::size_t size() const { return owned() ? m_data.size() : m_unownedSize; }
|
||||
const unsigned char *data() const {
|
||||
return owned() ? &m_data[0] : m_unownedData;
|
||||
}
|
||||
|
||||
void swap(std::vector<unsigned char> &rhs) {
|
||||
if (m_unownedData) {
|
||||
m_data.swap(rhs);
|
||||
rhs.clear();
|
||||
rhs.resize(m_unownedSize);
|
||||
std::copy(m_unownedData, m_unownedData + m_unownedSize, rhs.begin());
|
||||
m_unownedData = nullptr;
|
||||
m_unownedSize = 0;
|
||||
} else {
|
||||
m_data.swap(rhs);
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const Binary &rhs) const {
|
||||
const std::size_t s = size();
|
||||
if (s != rhs.size())
|
||||
return false;
|
||||
const unsigned char *d1 = data();
|
||||
const unsigned char *d2 = rhs.data();
|
||||
for (std::size_t i = 0; i < s; i++) {
|
||||
if (*d1++ != *d2++)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator!=(const Binary &rhs) const { return !(*this == rhs); }
|
||||
|
||||
private:
|
||||
std::vector<unsigned char> m_data;
|
||||
const unsigned char *m_unownedData;
|
||||
std::size_t m_unownedSize;
|
||||
};
|
||||
} // namespace YAML
|
||||
|
||||
#endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
40
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/contrib/anchordict.h
vendored
Normal file
40
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/contrib/anchordict.h
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "../anchor.h"
|
||||
|
||||
namespace YAML {
|
||||
/**
|
||||
* An object that stores and retrieves values correlating to {@link anchor_t}
|
||||
* values.
|
||||
*
|
||||
* <p>Efficient implementation that can make assumptions about how
|
||||
* {@code anchor_t} values are assigned by the {@link Parser} class.
|
||||
*/
|
||||
template <class T>
|
||||
class AnchorDict {
|
||||
public:
|
||||
AnchorDict() : m_data{} {}
|
||||
void Register(anchor_t anchor, T value) {
|
||||
if (anchor > m_data.size()) {
|
||||
m_data.resize(anchor);
|
||||
}
|
||||
m_data[anchor - 1] = value;
|
||||
}
|
||||
|
||||
T Get(anchor_t anchor) const { return m_data[anchor - 1]; }
|
||||
|
||||
private:
|
||||
std::vector<T> m_data;
|
||||
};
|
||||
} // namespace YAML
|
||||
|
||||
#endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
149
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/contrib/graphbuilder.h
vendored
Normal file
149
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/contrib/graphbuilder.h
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
#ifndef GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/mark.h"
|
||||
#include <string>
|
||||
|
||||
namespace YAML {
|
||||
class Parser;
|
||||
|
||||
// GraphBuilderInterface
|
||||
// . Abstraction of node creation
|
||||
// . pParentNode is always nullptr or the return value of one of the NewXXX()
|
||||
// functions.
|
||||
class GraphBuilderInterface {
|
||||
public:
|
||||
virtual ~GraphBuilderInterface() = 0;
|
||||
|
||||
// Create and return a new node with a null value.
|
||||
virtual void *NewNull(const Mark &mark, void *pParentNode) = 0;
|
||||
|
||||
// Create and return a new node with the given tag and value.
|
||||
virtual void *NewScalar(const Mark &mark, const std::string &tag,
|
||||
void *pParentNode, const std::string &value) = 0;
|
||||
|
||||
// Create and return a new sequence node
|
||||
virtual void *NewSequence(const Mark &mark, const std::string &tag,
|
||||
void *pParentNode) = 0;
|
||||
|
||||
// Add pNode to pSequence. pNode was created with one of the NewXxx()
|
||||
// functions and pSequence with NewSequence().
|
||||
virtual void AppendToSequence(void *pSequence, void *pNode) = 0;
|
||||
|
||||
// Note that no moew entries will be added to pSequence
|
||||
virtual void SequenceComplete(void *pSequence) { (void)pSequence; }
|
||||
|
||||
// Create and return a new map node
|
||||
virtual void *NewMap(const Mark &mark, const std::string &tag,
|
||||
void *pParentNode) = 0;
|
||||
|
||||
// Add the pKeyNode => pValueNode mapping to pMap. pKeyNode and pValueNode
|
||||
// were created with one of the NewXxx() methods and pMap with NewMap().
|
||||
virtual void AssignInMap(void *pMap, void *pKeyNode, void *pValueNode) = 0;
|
||||
|
||||
// Note that no more assignments will be made in pMap
|
||||
virtual void MapComplete(void *pMap) { (void)pMap; }
|
||||
|
||||
// Return the node that should be used in place of an alias referencing
|
||||
// pNode (pNode by default)
|
||||
virtual void *AnchorReference(const Mark &mark, void *pNode) {
|
||||
(void)mark;
|
||||
return pNode;
|
||||
}
|
||||
};
|
||||
|
||||
// Typesafe wrapper for GraphBuilderInterface. Assumes that Impl defines
|
||||
// Node, Sequence, and Map types. Sequence and Map must derive from Node
|
||||
// (unless Node is defined as void). Impl must also implement function with
|
||||
// all of the same names as the virtual functions in GraphBuilderInterface
|
||||
// -- including the ones with default implementations -- but with the
|
||||
// prototypes changed to accept an explicit Node*, Sequence*, or Map* where
|
||||
// appropriate.
|
||||
template <class Impl>
|
||||
class GraphBuilder : public GraphBuilderInterface {
|
||||
public:
|
||||
typedef typename Impl::Node Node;
|
||||
typedef typename Impl::Sequence Sequence;
|
||||
typedef typename Impl::Map Map;
|
||||
|
||||
GraphBuilder(Impl &impl) : m_impl(impl) {
|
||||
Map *pMap = nullptr;
|
||||
Sequence *pSeq = nullptr;
|
||||
Node *pNode = nullptr;
|
||||
|
||||
// Type consistency checks
|
||||
pNode = pMap;
|
||||
pNode = pSeq;
|
||||
}
|
||||
|
||||
GraphBuilderInterface &AsBuilderInterface() { return *this; }
|
||||
|
||||
virtual void *NewNull(const Mark &mark, void *pParentNode) {
|
||||
return CheckType<Node>(m_impl.NewNull(mark, AsNode(pParentNode)));
|
||||
}
|
||||
|
||||
virtual void *NewScalar(const Mark &mark, const std::string &tag,
|
||||
void *pParentNode, const std::string &value) {
|
||||
return CheckType<Node>(
|
||||
m_impl.NewScalar(mark, tag, AsNode(pParentNode), value));
|
||||
}
|
||||
|
||||
virtual void *NewSequence(const Mark &mark, const std::string &tag,
|
||||
void *pParentNode) {
|
||||
return CheckType<Sequence>(
|
||||
m_impl.NewSequence(mark, tag, AsNode(pParentNode)));
|
||||
}
|
||||
virtual void AppendToSequence(void *pSequence, void *pNode) {
|
||||
m_impl.AppendToSequence(AsSequence(pSequence), AsNode(pNode));
|
||||
}
|
||||
virtual void SequenceComplete(void *pSequence) {
|
||||
m_impl.SequenceComplete(AsSequence(pSequence));
|
||||
}
|
||||
|
||||
virtual void *NewMap(const Mark &mark, const std::string &tag,
|
||||
void *pParentNode) {
|
||||
return CheckType<Map>(m_impl.NewMap(mark, tag, AsNode(pParentNode)));
|
||||
}
|
||||
virtual void AssignInMap(void *pMap, void *pKeyNode, void *pValueNode) {
|
||||
m_impl.AssignInMap(AsMap(pMap), AsNode(pKeyNode), AsNode(pValueNode));
|
||||
}
|
||||
virtual void MapComplete(void *pMap) { m_impl.MapComplete(AsMap(pMap)); }
|
||||
|
||||
virtual void *AnchorReference(const Mark &mark, void *pNode) {
|
||||
return CheckType<Node>(m_impl.AnchorReference(mark, AsNode(pNode)));
|
||||
}
|
||||
|
||||
private:
|
||||
Impl &m_impl;
|
||||
|
||||
// Static check for pointer to T
|
||||
template <class T, class U>
|
||||
static T *CheckType(U *p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
static Node *AsNode(void *pNode) { return static_cast<Node *>(pNode); }
|
||||
static Sequence *AsSequence(void *pSeq) {
|
||||
return static_cast<Sequence *>(pSeq);
|
||||
}
|
||||
static Map *AsMap(void *pMap) { return static_cast<Map *>(pMap); }
|
||||
};
|
||||
|
||||
void *BuildGraphOfNextDocument(Parser &parser,
|
||||
GraphBuilderInterface &graphBuilder);
|
||||
|
||||
template <class Impl>
|
||||
typename Impl::Node *BuildGraphOfNextDocument(Parser &parser, Impl &impl) {
|
||||
GraphBuilder<Impl> graphBuilder(impl);
|
||||
return static_cast<typename Impl::Node *>(
|
||||
BuildGraphOfNextDocument(parser, graphBuilder));
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
77
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/depthguard.h
vendored
Normal file
77
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/depthguard.h
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
#ifndef DEPTH_GUARD_H_00000000000000000000000000000000000000000000000000000000
|
||||
#define DEPTH_GUARD_H_00000000000000000000000000000000000000000000000000000000
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "exceptions.h"
|
||||
|
||||
namespace YAML {
|
||||
|
||||
/**
|
||||
* @brief The DeepRecursion class
|
||||
* An exception class which is thrown by DepthGuard. Ideally it should be
|
||||
* a member of DepthGuard. However, DepthGuard is a templated class which means
|
||||
* that any catch points would then need to know the template parameters. It is
|
||||
* simpler for clients to not have to know at the catch point what was the
|
||||
* maximum depth.
|
||||
*/
|
||||
class DeepRecursion : public ParserException {
|
||||
public:
|
||||
virtual ~DeepRecursion() = default;
|
||||
|
||||
DeepRecursion(int depth, const Mark& mark_, const std::string& msg_);
|
||||
|
||||
// Returns the recursion depth when the exception was thrown
|
||||
int depth() const {
|
||||
return m_depth;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_depth = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The DepthGuard class
|
||||
* DepthGuard takes a reference to an integer. It increments the integer upon
|
||||
* construction of DepthGuard and decrements the integer upon destruction.
|
||||
*
|
||||
* If the integer would be incremented past max_depth, then an exception is
|
||||
* thrown. This is ideally geared toward guarding against deep recursion.
|
||||
*
|
||||
* @param max_depth
|
||||
* compile-time configurable maximum depth.
|
||||
*/
|
||||
template <int max_depth = 2000>
|
||||
class DepthGuard final {
|
||||
public:
|
||||
DepthGuard(int & depth_, const Mark& mark_, const std::string& msg_) : m_depth(depth_) {
|
||||
++m_depth;
|
||||
if ( max_depth <= m_depth ) {
|
||||
throw DeepRecursion{m_depth, mark_, msg_};
|
||||
}
|
||||
}
|
||||
|
||||
DepthGuard(const DepthGuard & copy_ctor) = delete;
|
||||
DepthGuard(DepthGuard && move_ctor) = delete;
|
||||
DepthGuard & operator=(const DepthGuard & copy_assign) = delete;
|
||||
DepthGuard & operator=(DepthGuard && move_assign) = delete;
|
||||
|
||||
~DepthGuard() {
|
||||
--m_depth;
|
||||
}
|
||||
|
||||
int current_depth() const {
|
||||
return m_depth;
|
||||
}
|
||||
|
||||
private:
|
||||
int & m_depth;
|
||||
};
|
||||
|
||||
} // namespace YAML
|
||||
|
||||
#endif // DEPTH_GUARD_H_00000000000000000000000000000000000000000000000000000000
|
||||
33
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/dll.h
vendored
Normal file
33
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/dll.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// The following ifdef block is the standard way of creating macros which make
|
||||
// exporting from a DLL simpler. All files within this DLL are compiled with the
|
||||
// yaml_cpp_EXPORTS symbol defined on the command line. This symbol should not
|
||||
// be defined on any project that uses this DLL. This way any other project
|
||||
// whose source files include this file see YAML_CPP_API functions as being
|
||||
// imported from a DLL, whereas this DLL sees symbols defined with this macro as
|
||||
// being exported.
|
||||
#undef YAML_CPP_API
|
||||
|
||||
#ifdef YAML_CPP_DLL // Using or Building YAML-CPP DLL (definition defined
|
||||
// manually)
|
||||
#ifdef yaml_cpp_EXPORTS // Building YAML-CPP DLL (definition created by CMake
|
||||
// or defined manually)
|
||||
// #pragma message( "Defining YAML_CPP_API for DLL export" )
|
||||
#define YAML_CPP_API __declspec(dllexport)
|
||||
#else // yaml_cpp_EXPORTS
|
||||
// #pragma message( "Defining YAML_CPP_API for DLL import" )
|
||||
#define YAML_CPP_API __declspec(dllimport)
|
||||
#endif // yaml_cpp_EXPORTS
|
||||
#else // YAML_CPP_DLL
|
||||
#define YAML_CPP_API
|
||||
#endif // YAML_CPP_DLL
|
||||
|
||||
#endif // DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
57
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/emitfromevents.h
vendored
Normal file
57
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/emitfromevents.h
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <stack>
|
||||
|
||||
#include "yaml-cpp/anchor.h"
|
||||
#include "yaml-cpp/emitterstyle.h"
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
|
||||
namespace YAML {
|
||||
struct Mark;
|
||||
} // namespace YAML
|
||||
|
||||
namespace YAML {
|
||||
class Emitter;
|
||||
|
||||
class EmitFromEvents : public EventHandler {
|
||||
public:
|
||||
EmitFromEvents(Emitter& emitter);
|
||||
|
||||
void OnDocumentStart(const Mark& mark) override;
|
||||
void OnDocumentEnd() override;
|
||||
|
||||
void OnNull(const Mark& mark, anchor_t anchor) override;
|
||||
void OnAlias(const Mark& mark, anchor_t anchor) override;
|
||||
void OnScalar(const Mark& mark, const std::string& tag,
|
||||
anchor_t anchor, const std::string& value) override;
|
||||
|
||||
void OnSequenceStart(const Mark& mark, const std::string& tag,
|
||||
anchor_t anchor, EmitterStyle::value style) override;
|
||||
void OnSequenceEnd() override;
|
||||
|
||||
void OnMapStart(const Mark& mark, const std::string& tag,
|
||||
anchor_t anchor, EmitterStyle::value style) override;
|
||||
void OnMapEnd() override;
|
||||
|
||||
private:
|
||||
void BeginNode();
|
||||
void EmitProps(const std::string& tag, anchor_t anchor);
|
||||
|
||||
private:
|
||||
Emitter& m_emitter;
|
||||
|
||||
struct State {
|
||||
enum value { WaitingForSequenceEntry, WaitingForKey, WaitingForValue };
|
||||
};
|
||||
std::stack<State::value> m_stateStack;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
281
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/emitter.h
vendored
Normal file
281
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/emitter.h
vendored
Normal file
@@ -0,0 +1,281 @@
|
||||
#ifndef EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#include "yaml-cpp/binary.h"
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/emitterdef.h"
|
||||
#include "yaml-cpp/emittermanip.h"
|
||||
#include "yaml-cpp/null.h"
|
||||
#include "yaml-cpp/ostream_wrapper.h"
|
||||
|
||||
namespace YAML {
|
||||
class Binary;
|
||||
struct _Null;
|
||||
} // namespace YAML
|
||||
|
||||
namespace YAML {
|
||||
class EmitterState;
|
||||
|
||||
class YAML_CPP_API Emitter {
|
||||
public:
|
||||
Emitter();
|
||||
explicit Emitter(std::ostream& stream);
|
||||
Emitter(const Emitter&) = delete;
|
||||
Emitter& operator=(const Emitter&) = delete;
|
||||
~Emitter();
|
||||
|
||||
// output
|
||||
const char* c_str() const;
|
||||
std::size_t size() const;
|
||||
|
||||
// state checking
|
||||
bool good() const;
|
||||
const std::string GetLastError() const;
|
||||
|
||||
// global setters
|
||||
bool SetOutputCharset(EMITTER_MANIP value);
|
||||
bool SetStringFormat(EMITTER_MANIP value);
|
||||
bool SetBoolFormat(EMITTER_MANIP value);
|
||||
bool SetNullFormat(EMITTER_MANIP value);
|
||||
bool SetIntBase(EMITTER_MANIP value);
|
||||
bool SetSeqFormat(EMITTER_MANIP value);
|
||||
bool SetMapFormat(EMITTER_MANIP value);
|
||||
bool SetIndent(std::size_t n);
|
||||
bool SetPreCommentIndent(std::size_t n);
|
||||
bool SetPostCommentIndent(std::size_t n);
|
||||
bool SetFloatPrecision(std::size_t n);
|
||||
bool SetDoublePrecision(std::size_t n);
|
||||
void RestoreGlobalModifiedSettings();
|
||||
|
||||
// local setters
|
||||
Emitter& SetLocalValue(EMITTER_MANIP value);
|
||||
Emitter& SetLocalIndent(const _Indent& indent);
|
||||
Emitter& SetLocalPrecision(const _Precision& precision);
|
||||
|
||||
// overloads of write
|
||||
Emitter& Write(const std::string& str);
|
||||
Emitter& Write(bool b);
|
||||
Emitter& Write(char ch);
|
||||
Emitter& Write(const _Alias& alias);
|
||||
Emitter& Write(const _Anchor& anchor);
|
||||
Emitter& Write(const _Tag& tag);
|
||||
Emitter& Write(const _Comment& comment);
|
||||
Emitter& Write(const _Null& n);
|
||||
Emitter& Write(const Binary& binary);
|
||||
|
||||
template <typename T>
|
||||
Emitter& WriteIntegralType(T value);
|
||||
|
||||
template <typename T>
|
||||
Emitter& WriteStreamable(T value);
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
void SetStreamablePrecision(std::stringstream&) {}
|
||||
std::size_t GetFloatPrecision() const;
|
||||
std::size_t GetDoublePrecision() const;
|
||||
|
||||
void PrepareIntegralStream(std::stringstream& stream) const;
|
||||
void StartedScalar();
|
||||
|
||||
private:
|
||||
void EmitBeginDoc();
|
||||
void EmitEndDoc();
|
||||
void EmitBeginSeq();
|
||||
void EmitEndSeq();
|
||||
void EmitBeginMap();
|
||||
void EmitEndMap();
|
||||
void EmitNewline();
|
||||
void EmitKindTag();
|
||||
void EmitTag(bool verbatim, const _Tag& tag);
|
||||
|
||||
void PrepareNode(EmitterNodeType::value child);
|
||||
void PrepareTopNode(EmitterNodeType::value child);
|
||||
void FlowSeqPrepareNode(EmitterNodeType::value child);
|
||||
void BlockSeqPrepareNode(EmitterNodeType::value child);
|
||||
|
||||
void FlowMapPrepareNode(EmitterNodeType::value child);
|
||||
|
||||
void FlowMapPrepareLongKey(EmitterNodeType::value child);
|
||||
void FlowMapPrepareLongKeyValue(EmitterNodeType::value child);
|
||||
void FlowMapPrepareSimpleKey(EmitterNodeType::value child);
|
||||
void FlowMapPrepareSimpleKeyValue(EmitterNodeType::value child);
|
||||
|
||||
void BlockMapPrepareNode(EmitterNodeType::value child);
|
||||
|
||||
void BlockMapPrepareLongKey(EmitterNodeType::value child);
|
||||
void BlockMapPrepareLongKeyValue(EmitterNodeType::value child);
|
||||
void BlockMapPrepareSimpleKey(EmitterNodeType::value child);
|
||||
void BlockMapPrepareSimpleKeyValue(EmitterNodeType::value child);
|
||||
|
||||
void SpaceOrIndentTo(bool requireSpace, std::size_t indent);
|
||||
|
||||
const char* ComputeFullBoolName(bool b) const;
|
||||
const char* ComputeNullName() const;
|
||||
bool CanEmitNewline() const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<EmitterState> m_pState;
|
||||
ostream_wrapper m_stream;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline Emitter& Emitter::WriteIntegralType(T value) {
|
||||
if (!good())
|
||||
return *this;
|
||||
|
||||
PrepareNode(EmitterNodeType::Scalar);
|
||||
|
||||
std::stringstream stream;
|
||||
PrepareIntegralStream(stream);
|
||||
stream << value;
|
||||
m_stream << stream.str();
|
||||
|
||||
StartedScalar();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline Emitter& Emitter::WriteStreamable(T value) {
|
||||
if (!good())
|
||||
return *this;
|
||||
|
||||
PrepareNode(EmitterNodeType::Scalar);
|
||||
|
||||
std::stringstream stream;
|
||||
SetStreamablePrecision<T>(stream);
|
||||
|
||||
bool special = false;
|
||||
if (std::is_floating_point<T>::value) {
|
||||
if ((std::numeric_limits<T>::has_quiet_NaN ||
|
||||
std::numeric_limits<T>::has_signaling_NaN) &&
|
||||
std::isnan(value)) {
|
||||
special = true;
|
||||
stream << ".nan";
|
||||
} else if (std::numeric_limits<T>::has_infinity && std::isinf(value)) {
|
||||
special = true;
|
||||
if (std::signbit(value)) {
|
||||
stream << "-.inf";
|
||||
} else {
|
||||
stream << ".inf";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!special) {
|
||||
stream << value;
|
||||
}
|
||||
m_stream << stream.str();
|
||||
|
||||
StartedScalar();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void Emitter::SetStreamablePrecision<float>(std::stringstream& stream) {
|
||||
stream.precision(static_cast<std::streamsize>(GetFloatPrecision()));
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void Emitter::SetStreamablePrecision<double>(std::stringstream& stream) {
|
||||
stream.precision(static_cast<std::streamsize>(GetDoublePrecision()));
|
||||
}
|
||||
|
||||
// overloads of insertion
|
||||
inline Emitter& operator<<(Emitter& emitter, const std::string& v) {
|
||||
return emitter.Write(v);
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, bool v) {
|
||||
return emitter.Write(v);
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, char v) {
|
||||
return emitter.Write(v);
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, unsigned char v) {
|
||||
return emitter.Write(static_cast<char>(v));
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, const _Alias& v) {
|
||||
return emitter.Write(v);
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, const _Anchor& v) {
|
||||
return emitter.Write(v);
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, const _Tag& v) {
|
||||
return emitter.Write(v);
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, const _Comment& v) {
|
||||
return emitter.Write(v);
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, const _Null& v) {
|
||||
return emitter.Write(v);
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, const Binary& b) {
|
||||
return emitter.Write(b);
|
||||
}
|
||||
|
||||
inline Emitter& operator<<(Emitter& emitter, const char* v) {
|
||||
return emitter.Write(std::string(v));
|
||||
}
|
||||
|
||||
inline Emitter& operator<<(Emitter& emitter, int v) {
|
||||
return emitter.WriteIntegralType(v);
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, unsigned int v) {
|
||||
return emitter.WriteIntegralType(v);
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, short v) {
|
||||
return emitter.WriteIntegralType(v);
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, unsigned short v) {
|
||||
return emitter.WriteIntegralType(v);
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, long v) {
|
||||
return emitter.WriteIntegralType(v);
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, unsigned long v) {
|
||||
return emitter.WriteIntegralType(v);
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, long long v) {
|
||||
return emitter.WriteIntegralType(v);
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, unsigned long long v) {
|
||||
return emitter.WriteIntegralType(v);
|
||||
}
|
||||
|
||||
inline Emitter& operator<<(Emitter& emitter, float v) {
|
||||
return emitter.WriteStreamable(v);
|
||||
}
|
||||
inline Emitter& operator<<(Emitter& emitter, double v) {
|
||||
return emitter.WriteStreamable(v);
|
||||
}
|
||||
|
||||
inline Emitter& operator<<(Emitter& emitter, EMITTER_MANIP value) {
|
||||
return emitter.SetLocalValue(value);
|
||||
}
|
||||
|
||||
inline Emitter& operator<<(Emitter& emitter, _Indent indent) {
|
||||
return emitter.SetLocalIndent(indent);
|
||||
}
|
||||
|
||||
inline Emitter& operator<<(Emitter& emitter, _Precision precision) {
|
||||
return emitter.SetLocalPrecision(precision);
|
||||
}
|
||||
} // namespace YAML
|
||||
|
||||
#endif // EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
16
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/emitterdef.h
vendored
Normal file
16
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/emitterdef.h
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
namespace YAML {
|
||||
struct EmitterNodeType {
|
||||
enum value { NoType, Property, Scalar, FlowSeq, BlockSeq, FlowMap, BlockMap };
|
||||
};
|
||||
}
|
||||
|
||||
#endif // EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
144
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/emittermanip.h
vendored
Normal file
144
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/emittermanip.h
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
#ifndef EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace YAML {
|
||||
enum EMITTER_MANIP {
|
||||
// general manipulators
|
||||
Auto,
|
||||
TagByKind,
|
||||
Newline,
|
||||
|
||||
// output character set
|
||||
EmitNonAscii,
|
||||
EscapeNonAscii,
|
||||
EscapeAsJson,
|
||||
|
||||
// string manipulators
|
||||
// Auto, // duplicate
|
||||
SingleQuoted,
|
||||
DoubleQuoted,
|
||||
Literal,
|
||||
|
||||
// null manipulators
|
||||
LowerNull,
|
||||
UpperNull,
|
||||
CamelNull,
|
||||
TildeNull,
|
||||
|
||||
// bool manipulators
|
||||
YesNoBool, // yes, no
|
||||
TrueFalseBool, // true, false
|
||||
OnOffBool, // on, off
|
||||
UpperCase, // TRUE, N
|
||||
LowerCase, // f, yes
|
||||
CamelCase, // No, Off
|
||||
LongBool, // yes, On
|
||||
ShortBool, // y, t
|
||||
|
||||
// int manipulators
|
||||
Dec,
|
||||
Hex,
|
||||
Oct,
|
||||
|
||||
// document manipulators
|
||||
BeginDoc,
|
||||
EndDoc,
|
||||
|
||||
// sequence manipulators
|
||||
BeginSeq,
|
||||
EndSeq,
|
||||
Flow,
|
||||
Block,
|
||||
|
||||
// map manipulators
|
||||
BeginMap,
|
||||
EndMap,
|
||||
Key,
|
||||
Value,
|
||||
// Flow, // duplicate
|
||||
// Block, // duplicate
|
||||
// Auto, // duplicate
|
||||
LongKey
|
||||
};
|
||||
|
||||
struct _Indent {
|
||||
_Indent(int value_) : value(value_) {}
|
||||
int value;
|
||||
};
|
||||
|
||||
inline _Indent Indent(int value) { return _Indent(value); }
|
||||
|
||||
struct _Alias {
|
||||
_Alias(const std::string& content_) : content(content_) {}
|
||||
std::string content;
|
||||
};
|
||||
|
||||
inline _Alias Alias(const std::string& content) { return _Alias(content); }
|
||||
|
||||
struct _Anchor {
|
||||
_Anchor(const std::string& content_) : content(content_) {}
|
||||
std::string content;
|
||||
};
|
||||
|
||||
inline _Anchor Anchor(const std::string& content) { return _Anchor(content); }
|
||||
|
||||
struct _Tag {
|
||||
struct Type {
|
||||
enum value { Verbatim, PrimaryHandle, NamedHandle };
|
||||
};
|
||||
|
||||
explicit _Tag(const std::string& prefix_, const std::string& content_,
|
||||
Type::value type_)
|
||||
: prefix(prefix_), content(content_), type(type_) {}
|
||||
std::string prefix;
|
||||
std::string content;
|
||||
Type::value type;
|
||||
};
|
||||
|
||||
inline _Tag VerbatimTag(const std::string& content) {
|
||||
return _Tag("", content, _Tag::Type::Verbatim);
|
||||
}
|
||||
|
||||
inline _Tag LocalTag(const std::string& content) {
|
||||
return _Tag("", content, _Tag::Type::PrimaryHandle);
|
||||
}
|
||||
|
||||
inline _Tag LocalTag(const std::string& prefix, const std::string content) {
|
||||
return _Tag(prefix, content, _Tag::Type::NamedHandle);
|
||||
}
|
||||
|
||||
inline _Tag SecondaryTag(const std::string& content) {
|
||||
return _Tag("", content, _Tag::Type::NamedHandle);
|
||||
}
|
||||
|
||||
struct _Comment {
|
||||
_Comment(const std::string& content_) : content(content_) {}
|
||||
std::string content;
|
||||
};
|
||||
|
||||
inline _Comment Comment(const std::string& content) { return _Comment(content); }
|
||||
|
||||
struct _Precision {
|
||||
_Precision(int floatPrecision_, int doublePrecision_)
|
||||
: floatPrecision(floatPrecision_), doublePrecision(doublePrecision_) {}
|
||||
|
||||
int floatPrecision;
|
||||
int doublePrecision;
|
||||
};
|
||||
|
||||
inline _Precision FloatPrecision(int n) { return _Precision(n, -1); }
|
||||
|
||||
inline _Precision DoublePrecision(int n) { return _Precision(-1, n); }
|
||||
|
||||
inline _Precision Precision(int n) { return _Precision(n, n); }
|
||||
}
|
||||
|
||||
#endif // EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
16
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/emitterstyle.h
vendored
Normal file
16
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/emitterstyle.h
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
namespace YAML {
|
||||
struct EmitterStyle {
|
||||
enum value { Default, Block, Flow };
|
||||
};
|
||||
}
|
||||
|
||||
#endif // EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
45
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/eventhandler.h
vendored
Normal file
45
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/eventhandler.h
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "yaml-cpp/anchor.h"
|
||||
#include "yaml-cpp/emitterstyle.h"
|
||||
|
||||
namespace YAML {
|
||||
struct Mark;
|
||||
|
||||
class EventHandler {
|
||||
public:
|
||||
virtual ~EventHandler() = default;
|
||||
|
||||
virtual void OnDocumentStart(const Mark& mark) = 0;
|
||||
virtual void OnDocumentEnd() = 0;
|
||||
|
||||
virtual void OnNull(const Mark& mark, anchor_t anchor) = 0;
|
||||
virtual void OnAlias(const Mark& mark, anchor_t anchor) = 0;
|
||||
virtual void OnScalar(const Mark& mark, const std::string& tag,
|
||||
anchor_t anchor, const std::string& value) = 0;
|
||||
|
||||
virtual void OnSequenceStart(const Mark& mark, const std::string& tag,
|
||||
anchor_t anchor, EmitterStyle::value style) = 0;
|
||||
virtual void OnSequenceEnd() = 0;
|
||||
|
||||
virtual void OnMapStart(const Mark& mark, const std::string& tag,
|
||||
anchor_t anchor, EmitterStyle::value style) = 0;
|
||||
virtual void OnMapEnd() = 0;
|
||||
|
||||
virtual void OnAnchor(const Mark& /*mark*/,
|
||||
const std::string& /*anchor_name*/) {
|
||||
// empty default implementation for compatibility
|
||||
}
|
||||
};
|
||||
} // namespace YAML
|
||||
|
||||
#endif // EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
303
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/exceptions.h
vendored
Normal file
303
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/exceptions.h
vendored
Normal file
@@ -0,0 +1,303 @@
|
||||
#ifndef EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/mark.h"
|
||||
#include "yaml-cpp/noexcept.h"
|
||||
#include "yaml-cpp/traits.h"
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace YAML {
|
||||
// error messages
|
||||
namespace ErrorMsg {
|
||||
const char* const YAML_DIRECTIVE_ARGS =
|
||||
"YAML directives must have exactly one argument";
|
||||
const char* const YAML_VERSION = "bad YAML version: ";
|
||||
const char* const YAML_MAJOR_VERSION = "YAML major version too large";
|
||||
const char* const REPEATED_YAML_DIRECTIVE = "repeated YAML directive";
|
||||
const char* const TAG_DIRECTIVE_ARGS =
|
||||
"TAG directives must have exactly two arguments";
|
||||
const char* const REPEATED_TAG_DIRECTIVE = "repeated TAG directive";
|
||||
const char* const CHAR_IN_TAG_HANDLE =
|
||||
"illegal character found while scanning tag handle";
|
||||
const char* const TAG_WITH_NO_SUFFIX = "tag handle with no suffix";
|
||||
const char* const END_OF_VERBATIM_TAG = "end of verbatim tag not found";
|
||||
const char* const END_OF_MAP = "end of map not found";
|
||||
const char* const END_OF_MAP_FLOW = "end of map flow not found";
|
||||
const char* const END_OF_SEQ = "end of sequence not found";
|
||||
const char* const END_OF_SEQ_FLOW = "end of sequence flow not found";
|
||||
const char* const MULTIPLE_TAGS =
|
||||
"cannot assign multiple tags to the same node";
|
||||
const char* const MULTIPLE_ANCHORS =
|
||||
"cannot assign multiple anchors to the same node";
|
||||
const char* const MULTIPLE_ALIASES =
|
||||
"cannot assign multiple aliases to the same node";
|
||||
const char* const ALIAS_CONTENT =
|
||||
"aliases can't have any content, *including* tags";
|
||||
const char* const INVALID_HEX = "bad character found while scanning hex number";
|
||||
const char* const INVALID_UNICODE = "invalid unicode: ";
|
||||
const char* const INVALID_ESCAPE = "unknown escape character: ";
|
||||
const char* const UNKNOWN_TOKEN = "unknown token";
|
||||
const char* const DOC_IN_SCALAR = "illegal document indicator in scalar";
|
||||
const char* const EOF_IN_SCALAR = "illegal EOF in scalar";
|
||||
const char* const CHAR_IN_SCALAR = "illegal character in scalar";
|
||||
const char* const TAB_IN_INDENTATION =
|
||||
"illegal tab when looking for indentation";
|
||||
const char* const FLOW_END = "illegal flow end";
|
||||
const char* const BLOCK_ENTRY = "illegal block entry";
|
||||
const char* const MAP_KEY = "illegal map key";
|
||||
const char* const MAP_VALUE = "illegal map value";
|
||||
const char* const ALIAS_NOT_FOUND = "alias not found after *";
|
||||
const char* const ANCHOR_NOT_FOUND = "anchor not found after &";
|
||||
const char* const CHAR_IN_ALIAS =
|
||||
"illegal character found while scanning alias";
|
||||
const char* const CHAR_IN_ANCHOR =
|
||||
"illegal character found while scanning anchor";
|
||||
const char* const ZERO_INDENT_IN_BLOCK =
|
||||
"cannot set zero indentation for a block scalar";
|
||||
const char* const CHAR_IN_BLOCK = "unexpected character in block scalar";
|
||||
const char* const AMBIGUOUS_ANCHOR =
|
||||
"cannot assign the same alias to multiple nodes";
|
||||
const char* const UNKNOWN_ANCHOR = "the referenced anchor is not defined";
|
||||
|
||||
const char* const INVALID_NODE =
|
||||
"invalid node; this may result from using a map iterator as a sequence "
|
||||
"iterator, or vice-versa";
|
||||
const char* const INVALID_SCALAR = "invalid scalar";
|
||||
const char* const KEY_NOT_FOUND = "key not found";
|
||||
const char* const BAD_CONVERSION = "bad conversion";
|
||||
const char* const BAD_DEREFERENCE = "bad dereference";
|
||||
const char* const BAD_SUBSCRIPT = "operator[] call on a scalar";
|
||||
const char* const BAD_PUSHBACK = "appending to a non-sequence";
|
||||
const char* const BAD_INSERT = "inserting in a non-convertible-to-map";
|
||||
|
||||
const char* const UNMATCHED_GROUP_TAG = "unmatched group tag";
|
||||
const char* const UNEXPECTED_END_SEQ = "unexpected end sequence token";
|
||||
const char* const UNEXPECTED_END_MAP = "unexpected end map token";
|
||||
const char* const SINGLE_QUOTED_CHAR =
|
||||
"invalid character in single-quoted string";
|
||||
const char* const INVALID_ANCHOR = "invalid anchor";
|
||||
const char* const INVALID_ALIAS = "invalid alias";
|
||||
const char* const INVALID_TAG = "invalid tag";
|
||||
const char* const BAD_FILE = "bad file";
|
||||
|
||||
template <typename T>
|
||||
inline const std::string KEY_NOT_FOUND_WITH_KEY(
|
||||
const T&, typename disable_if<is_numeric<T>>::type* = 0) {
|
||||
return KEY_NOT_FOUND;
|
||||
}
|
||||
|
||||
inline const std::string KEY_NOT_FOUND_WITH_KEY(const std::string& key) {
|
||||
std::stringstream stream;
|
||||
stream << KEY_NOT_FOUND << ": " << key;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
inline const std::string KEY_NOT_FOUND_WITH_KEY(const char* key) {
|
||||
std::stringstream stream;
|
||||
stream << KEY_NOT_FOUND << ": " << key;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const std::string KEY_NOT_FOUND_WITH_KEY(
|
||||
const T& key, typename enable_if<is_numeric<T>>::type* = 0) {
|
||||
std::stringstream stream;
|
||||
stream << KEY_NOT_FOUND << ": " << key;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const std::string BAD_SUBSCRIPT_WITH_KEY(
|
||||
const T&, typename disable_if<is_numeric<T>>::type* = nullptr) {
|
||||
return BAD_SUBSCRIPT;
|
||||
}
|
||||
|
||||
inline const std::string BAD_SUBSCRIPT_WITH_KEY(const std::string& key) {
|
||||
std::stringstream stream;
|
||||
stream << BAD_SUBSCRIPT << " (key: \"" << key << "\")";
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
inline const std::string BAD_SUBSCRIPT_WITH_KEY(const char* key) {
|
||||
std::stringstream stream;
|
||||
stream << BAD_SUBSCRIPT << " (key: \"" << key << "\")";
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const std::string BAD_SUBSCRIPT_WITH_KEY(
|
||||
const T& key, typename enable_if<is_numeric<T>>::type* = nullptr) {
|
||||
std::stringstream stream;
|
||||
stream << BAD_SUBSCRIPT << " (key: \"" << key << "\")";
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
inline const std::string INVALID_NODE_WITH_KEY(const std::string& key) {
|
||||
std::stringstream stream;
|
||||
if (key.empty()) {
|
||||
return INVALID_NODE;
|
||||
}
|
||||
stream << "invalid node; first invalid key: \"" << key << "\"";
|
||||
return stream.str();
|
||||
}
|
||||
} // namespace ErrorMsg
|
||||
|
||||
class YAML_CPP_API Exception : public std::runtime_error {
|
||||
public:
|
||||
Exception(const Mark& mark_, const std::string& msg_)
|
||||
: std::runtime_error(build_what(mark_, msg_)), mark(mark_), msg(msg_) {}
|
||||
~Exception() YAML_CPP_NOEXCEPT override;
|
||||
|
||||
Exception(const Exception&) = default;
|
||||
|
||||
Mark mark;
|
||||
std::string msg;
|
||||
|
||||
private:
|
||||
static const std::string build_what(const Mark& mark,
|
||||
const std::string& msg) {
|
||||
if (mark.is_null()) {
|
||||
return msg;
|
||||
}
|
||||
|
||||
std::stringstream output;
|
||||
output << "yaml-cpp: error at line " << mark.line + 1 << ", column "
|
||||
<< mark.column + 1 << ": " << msg;
|
||||
return output.str();
|
||||
}
|
||||
};
|
||||
|
||||
class YAML_CPP_API ParserException : public Exception {
|
||||
public:
|
||||
ParserException(const Mark& mark_, const std::string& msg_)
|
||||
: Exception(mark_, msg_) {}
|
||||
ParserException(const ParserException&) = default;
|
||||
~ParserException() YAML_CPP_NOEXCEPT override;
|
||||
};
|
||||
|
||||
class YAML_CPP_API RepresentationException : public Exception {
|
||||
public:
|
||||
RepresentationException(const Mark& mark_, const std::string& msg_)
|
||||
: Exception(mark_, msg_) {}
|
||||
RepresentationException(const RepresentationException&) = default;
|
||||
~RepresentationException() YAML_CPP_NOEXCEPT override;
|
||||
};
|
||||
|
||||
// representation exceptions
|
||||
class YAML_CPP_API InvalidScalar : public RepresentationException {
|
||||
public:
|
||||
InvalidScalar(const Mark& mark_)
|
||||
: RepresentationException(mark_, ErrorMsg::INVALID_SCALAR) {}
|
||||
InvalidScalar(const InvalidScalar&) = default;
|
||||
~InvalidScalar() YAML_CPP_NOEXCEPT override;
|
||||
};
|
||||
|
||||
class YAML_CPP_API KeyNotFound : public RepresentationException {
|
||||
public:
|
||||
template <typename T>
|
||||
KeyNotFound(const Mark& mark_, const T& key_)
|
||||
: RepresentationException(mark_, ErrorMsg::KEY_NOT_FOUND_WITH_KEY(key_)) {
|
||||
}
|
||||
KeyNotFound(const KeyNotFound&) = default;
|
||||
~KeyNotFound() YAML_CPP_NOEXCEPT override;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class YAML_CPP_API TypedKeyNotFound : public KeyNotFound {
|
||||
public:
|
||||
TypedKeyNotFound(const Mark& mark_, const T& key_)
|
||||
: KeyNotFound(mark_, key_), key(key_) {}
|
||||
~TypedKeyNotFound() YAML_CPP_NOEXCEPT override = default;
|
||||
|
||||
T key;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline TypedKeyNotFound<T> MakeTypedKeyNotFound(const Mark& mark,
|
||||
const T& key) {
|
||||
return TypedKeyNotFound<T>(mark, key);
|
||||
}
|
||||
|
||||
class YAML_CPP_API InvalidNode : public RepresentationException {
|
||||
public:
|
||||
InvalidNode(const std::string& key)
|
||||
: RepresentationException(Mark::null_mark(),
|
||||
ErrorMsg::INVALID_NODE_WITH_KEY(key)) {}
|
||||
InvalidNode(const InvalidNode&) = default;
|
||||
~InvalidNode() YAML_CPP_NOEXCEPT override;
|
||||
};
|
||||
|
||||
class YAML_CPP_API BadConversion : public RepresentationException {
|
||||
public:
|
||||
explicit BadConversion(const Mark& mark_)
|
||||
: RepresentationException(mark_, ErrorMsg::BAD_CONVERSION) {}
|
||||
BadConversion(const BadConversion&) = default;
|
||||
~BadConversion() YAML_CPP_NOEXCEPT override;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class TypedBadConversion : public BadConversion {
|
||||
public:
|
||||
explicit TypedBadConversion(const Mark& mark_) : BadConversion(mark_) {}
|
||||
};
|
||||
|
||||
class YAML_CPP_API BadDereference : public RepresentationException {
|
||||
public:
|
||||
BadDereference()
|
||||
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_DEREFERENCE) {}
|
||||
BadDereference(const BadDereference&) = default;
|
||||
~BadDereference() YAML_CPP_NOEXCEPT override;
|
||||
};
|
||||
|
||||
class YAML_CPP_API BadSubscript : public RepresentationException {
|
||||
public:
|
||||
template <typename Key>
|
||||
BadSubscript(const Mark& mark_, const Key& key)
|
||||
: RepresentationException(mark_, ErrorMsg::BAD_SUBSCRIPT_WITH_KEY(key)) {}
|
||||
BadSubscript(const BadSubscript&) = default;
|
||||
~BadSubscript() YAML_CPP_NOEXCEPT override;
|
||||
};
|
||||
|
||||
class YAML_CPP_API BadPushback : public RepresentationException {
|
||||
public:
|
||||
BadPushback()
|
||||
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_PUSHBACK) {}
|
||||
BadPushback(const BadPushback&) = default;
|
||||
~BadPushback() YAML_CPP_NOEXCEPT override;
|
||||
};
|
||||
|
||||
class YAML_CPP_API BadInsert : public RepresentationException {
|
||||
public:
|
||||
BadInsert()
|
||||
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_INSERT) {}
|
||||
BadInsert(const BadInsert&) = default;
|
||||
~BadInsert() YAML_CPP_NOEXCEPT override;
|
||||
};
|
||||
|
||||
class YAML_CPP_API EmitterException : public Exception {
|
||||
public:
|
||||
EmitterException(const std::string& msg_)
|
||||
: Exception(Mark::null_mark(), msg_) {}
|
||||
EmitterException(const EmitterException&) = default;
|
||||
~EmitterException() YAML_CPP_NOEXCEPT override;
|
||||
};
|
||||
|
||||
class YAML_CPP_API BadFile : public Exception {
|
||||
public:
|
||||
explicit BadFile(const std::string& filename)
|
||||
: Exception(Mark::null_mark(),
|
||||
std::string(ErrorMsg::BAD_FILE) + ": " + filename) {}
|
||||
BadFile(const BadFile&) = default;
|
||||
~BadFile() YAML_CPP_NOEXCEPT override;
|
||||
};
|
||||
} // namespace YAML
|
||||
|
||||
#endif // EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
29
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/mark.h
vendored
Normal file
29
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/mark.h
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
|
||||
namespace YAML {
|
||||
struct YAML_CPP_API Mark {
|
||||
Mark() : pos(0), line(0), column(0) {}
|
||||
|
||||
static const Mark null_mark() { return Mark(-1, -1, -1); }
|
||||
|
||||
bool is_null() const { return pos == -1 && line == -1 && column == -1; }
|
||||
|
||||
int pos;
|
||||
int line, column;
|
||||
|
||||
private:
|
||||
Mark(int pos_, int line_, int column_)
|
||||
: pos(pos_), line(line_), column(column_) {}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
392
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/convert.h
vendored
Normal file
392
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/convert.h
vendored
Normal file
@@ -0,0 +1,392 @@
|
||||
#ifndef NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include "yaml-cpp/binary.h"
|
||||
#include "yaml-cpp/node/impl.h"
|
||||
#include "yaml-cpp/node/iterator.h"
|
||||
#include "yaml-cpp/node/node.h"
|
||||
#include "yaml-cpp/node/type.h"
|
||||
#include "yaml-cpp/null.h"
|
||||
|
||||
|
||||
namespace YAML {
|
||||
class Binary;
|
||||
struct _Null;
|
||||
template <typename T>
|
||||
struct convert;
|
||||
} // namespace YAML
|
||||
|
||||
namespace YAML {
|
||||
namespace conversion {
|
||||
inline bool IsInfinity(const std::string& input) {
|
||||
return input == ".inf" || input == ".Inf" || input == ".INF" ||
|
||||
input == "+.inf" || input == "+.Inf" || input == "+.INF";
|
||||
}
|
||||
|
||||
inline bool IsNegativeInfinity(const std::string& input) {
|
||||
return input == "-.inf" || input == "-.Inf" || input == "-.INF";
|
||||
}
|
||||
|
||||
inline bool IsNaN(const std::string& input) {
|
||||
return input == ".nan" || input == ".NaN" || input == ".NAN";
|
||||
}
|
||||
}
|
||||
|
||||
// Node
|
||||
template <>
|
||||
struct convert<Node> {
|
||||
static Node encode(const Node& rhs) { return rhs; }
|
||||
|
||||
static bool decode(const Node& node, Node& rhs) {
|
||||
rhs.reset(node);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// std::string
|
||||
template <>
|
||||
struct convert<std::string> {
|
||||
static Node encode(const std::string& rhs) { return Node(rhs); }
|
||||
|
||||
static bool decode(const Node& node, std::string& rhs) {
|
||||
if (!node.IsScalar())
|
||||
return false;
|
||||
rhs = node.Scalar();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// C-strings can only be encoded
|
||||
template <>
|
||||
struct convert<const char*> {
|
||||
static Node encode(const char* rhs) { return Node(rhs); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct convert<char*> {
|
||||
static Node encode(const char* rhs) { return Node(rhs); }
|
||||
};
|
||||
|
||||
template <std::size_t N>
|
||||
struct convert<char[N]> {
|
||||
static Node encode(const char* rhs) { return Node(rhs); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct convert<_Null> {
|
||||
static Node encode(const _Null& /* rhs */) { return Node(); }
|
||||
|
||||
static bool decode(const Node& node, _Null& /* rhs */) {
|
||||
return node.IsNull();
|
||||
}
|
||||
};
|
||||
|
||||
namespace conversion {
|
||||
template <typename T>
|
||||
typename std::enable_if< std::is_floating_point<T>::value, void>::type
|
||||
inner_encode(const T& rhs, std::stringstream& stream){
|
||||
if (std::isnan(rhs)) {
|
||||
stream << ".nan";
|
||||
} else if (std::isinf(rhs)) {
|
||||
if (std::signbit(rhs)) {
|
||||
stream << "-.inf";
|
||||
} else {
|
||||
stream << ".inf";
|
||||
}
|
||||
} else {
|
||||
stream << rhs;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<!std::is_floating_point<T>::value, void>::type
|
||||
inner_encode(const T& rhs, std::stringstream& stream){
|
||||
stream << rhs;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<(std::is_same<T, unsigned char>::value ||
|
||||
std::is_same<T, signed char>::value), bool>::type
|
||||
ConvertStreamTo(std::stringstream& stream, T& rhs) {
|
||||
int num;
|
||||
if ((stream >> std::noskipws >> num) && (stream >> std::ws).eof()) {
|
||||
if (num >= (std::numeric_limits<T>::min)() &&
|
||||
num <= (std::numeric_limits<T>::max)()) {
|
||||
rhs = (T)num;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<!(std::is_same<T, unsigned char>::value ||
|
||||
std::is_same<T, signed char>::value), bool>::type
|
||||
ConvertStreamTo(std::stringstream& stream, T& rhs) {
|
||||
if ((stream >> std::noskipws >> rhs) && (stream >> std::ws).eof()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#define YAML_DEFINE_CONVERT_STREAMABLE(type, negative_op) \
|
||||
template <> \
|
||||
struct convert<type> { \
|
||||
\
|
||||
static Node encode(const type& rhs) { \
|
||||
std::stringstream stream; \
|
||||
stream.precision(std::numeric_limits<type>::max_digits10); \
|
||||
conversion::inner_encode(rhs, stream); \
|
||||
return Node(stream.str()); \
|
||||
} \
|
||||
\
|
||||
static bool decode(const Node& node, type& rhs) { \
|
||||
if (node.Type() != NodeType::Scalar) { \
|
||||
return false; \
|
||||
} \
|
||||
const std::string& input = node.Scalar(); \
|
||||
std::stringstream stream(input); \
|
||||
stream.unsetf(std::ios::dec); \
|
||||
if ((stream.peek() == '-') && std::is_unsigned<type>::value) { \
|
||||
return false; \
|
||||
} \
|
||||
if (conversion::ConvertStreamTo(stream, rhs)) { \
|
||||
return true; \
|
||||
} \
|
||||
if (std::numeric_limits<type>::has_infinity) { \
|
||||
if (conversion::IsInfinity(input)) { \
|
||||
rhs = std::numeric_limits<type>::infinity(); \
|
||||
return true; \
|
||||
} else if (conversion::IsNegativeInfinity(input)) { \
|
||||
rhs = negative_op std::numeric_limits<type>::infinity(); \
|
||||
return true; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
if (std::numeric_limits<type>::has_quiet_NaN) { \
|
||||
if (conversion::IsNaN(input)) { \
|
||||
rhs = std::numeric_limits<type>::quiet_NaN(); \
|
||||
return true; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
return false; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(type) \
|
||||
YAML_DEFINE_CONVERT_STREAMABLE(type, -)
|
||||
|
||||
#define YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(type) \
|
||||
YAML_DEFINE_CONVERT_STREAMABLE(type, +)
|
||||
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(int);
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(short);
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long);
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long long);
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned);
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned short);
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned long);
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned long long);
|
||||
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(char);
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(signed char);
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned char);
|
||||
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(float);
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(double);
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long double);
|
||||
|
||||
#undef YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
|
||||
#undef YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED
|
||||
#undef YAML_DEFINE_CONVERT_STREAMABLE
|
||||
|
||||
// bool
|
||||
template <>
|
||||
struct convert<bool> {
|
||||
static Node encode(bool rhs) { return rhs ? Node("true") : Node("false"); }
|
||||
|
||||
YAML_CPP_API static bool decode(const Node& node, bool& rhs);
|
||||
};
|
||||
|
||||
// std::map
|
||||
template <typename K, typename V, typename C, typename A>
|
||||
struct convert<std::map<K, V, C, A>> {
|
||||
static Node encode(const std::map<K, V, C, A>& rhs) {
|
||||
Node node(NodeType::Map);
|
||||
for (const auto& element : rhs)
|
||||
node.force_insert(element.first, element.second);
|
||||
return node;
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, std::map<K, V, C, A>& rhs) {
|
||||
if (!node.IsMap())
|
||||
return false;
|
||||
|
||||
rhs.clear();
|
||||
for (const auto& element : node)
|
||||
#if defined(__GNUC__) && __GNUC__ < 4
|
||||
// workaround for GCC 3:
|
||||
rhs[element.first.template as<K>()] = element.second.template as<V>();
|
||||
#else
|
||||
rhs[element.first.as<K>()] = element.second.as<V>();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// std::vector
|
||||
template <typename T, typename A>
|
||||
struct convert<std::vector<T, A>> {
|
||||
static Node encode(const std::vector<T, A>& rhs) {
|
||||
Node node(NodeType::Sequence);
|
||||
for (const auto& element : rhs)
|
||||
node.push_back(element);
|
||||
return node;
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, std::vector<T, A>& rhs) {
|
||||
if (!node.IsSequence())
|
||||
return false;
|
||||
|
||||
rhs.clear();
|
||||
for (const auto& element : node)
|
||||
#if defined(__GNUC__) && __GNUC__ < 4
|
||||
// workaround for GCC 3:
|
||||
rhs.push_back(element.template as<T>());
|
||||
#else
|
||||
rhs.push_back(element.as<T>());
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// std::list
|
||||
template <typename T, typename A>
|
||||
struct convert<std::list<T,A>> {
|
||||
static Node encode(const std::list<T,A>& rhs) {
|
||||
Node node(NodeType::Sequence);
|
||||
for (const auto& element : rhs)
|
||||
node.push_back(element);
|
||||
return node;
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, std::list<T,A>& rhs) {
|
||||
if (!node.IsSequence())
|
||||
return false;
|
||||
|
||||
rhs.clear();
|
||||
for (const auto& element : node)
|
||||
#if defined(__GNUC__) && __GNUC__ < 4
|
||||
// workaround for GCC 3:
|
||||
rhs.push_back(element.template as<T>());
|
||||
#else
|
||||
rhs.push_back(element.as<T>());
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// std::array
|
||||
template <typename T, std::size_t N>
|
||||
struct convert<std::array<T, N>> {
|
||||
static Node encode(const std::array<T, N>& rhs) {
|
||||
Node node(NodeType::Sequence);
|
||||
for (const auto& element : rhs) {
|
||||
node.push_back(element);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, std::array<T, N>& rhs) {
|
||||
if (!isNodeValid(node)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto i = 0u; i < node.size(); ++i) {
|
||||
#if defined(__GNUC__) && __GNUC__ < 4
|
||||
// workaround for GCC 3:
|
||||
rhs[i] = node[i].template as<T>();
|
||||
#else
|
||||
rhs[i] = node[i].as<T>();
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
static bool isNodeValid(const Node& node) {
|
||||
return node.IsSequence() && node.size() == N;
|
||||
}
|
||||
};
|
||||
|
||||
// std::pair
|
||||
template <typename T, typename U>
|
||||
struct convert<std::pair<T, U>> {
|
||||
static Node encode(const std::pair<T, U>& rhs) {
|
||||
Node node(NodeType::Sequence);
|
||||
node.push_back(rhs.first);
|
||||
node.push_back(rhs.second);
|
||||
return node;
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, std::pair<T, U>& rhs) {
|
||||
if (!node.IsSequence())
|
||||
return false;
|
||||
if (node.size() != 2)
|
||||
return false;
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ < 4
|
||||
// workaround for GCC 3:
|
||||
rhs.first = node[0].template as<T>();
|
||||
#else
|
||||
rhs.first = node[0].as<T>();
|
||||
#endif
|
||||
#if defined(__GNUC__) && __GNUC__ < 4
|
||||
// workaround for GCC 3:
|
||||
rhs.second = node[1].template as<U>();
|
||||
#else
|
||||
rhs.second = node[1].as<U>();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// binary
|
||||
template <>
|
||||
struct convert<Binary> {
|
||||
static Node encode(const Binary& rhs) {
|
||||
return Node(EncodeBase64(rhs.data(), rhs.size()));
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, Binary& rhs) {
|
||||
if (!node.IsScalar())
|
||||
return false;
|
||||
|
||||
std::vector<unsigned char> data = DecodeBase64(node.Scalar());
|
||||
if (data.empty() && !node.Scalar().empty())
|
||||
return false;
|
||||
|
||||
rhs.swap(data);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
235
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/detail/impl.h
vendored
Normal file
235
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/detail/impl.h
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
#ifndef NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/node/detail/node.h"
|
||||
#include "yaml-cpp/node/detail/node_data.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
|
||||
namespace YAML {
|
||||
namespace detail {
|
||||
template <typename Key, typename Enable = void>
|
||||
struct get_idx {
|
||||
static node* get(const std::vector<node*>& /* sequence */,
|
||||
const Key& /* key */, shared_memory_holder /* pMemory */) {
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key>
|
||||
struct get_idx<Key,
|
||||
typename std::enable_if<std::is_unsigned<Key>::value &&
|
||||
!std::is_same<Key, bool>::value>::type> {
|
||||
static node* get(const std::vector<node*>& sequence, const Key& key,
|
||||
shared_memory_holder /* pMemory */) {
|
||||
return key < sequence.size() ? sequence[key] : nullptr;
|
||||
}
|
||||
|
||||
static node* get(std::vector<node*>& sequence, const Key& key,
|
||||
shared_memory_holder pMemory) {
|
||||
if (key > sequence.size() || (key > 0 && !sequence[key - 1]->is_defined()))
|
||||
return nullptr;
|
||||
if (key == sequence.size())
|
||||
sequence.push_back(&pMemory->create_node());
|
||||
return sequence[key];
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key>
|
||||
struct get_idx<Key, typename std::enable_if<std::is_signed<Key>::value>::type> {
|
||||
static node* get(const std::vector<node*>& sequence, const Key& key,
|
||||
shared_memory_holder pMemory) {
|
||||
return key >= 0 ? get_idx<std::size_t>::get(
|
||||
sequence, static_cast<std::size_t>(key), pMemory)
|
||||
: nullptr;
|
||||
}
|
||||
static node* get(std::vector<node*>& sequence, const Key& key,
|
||||
shared_memory_holder pMemory) {
|
||||
return key >= 0 ? get_idx<std::size_t>::get(
|
||||
sequence, static_cast<std::size_t>(key), pMemory)
|
||||
: nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Enable = void>
|
||||
struct remove_idx {
|
||||
static bool remove(std::vector<node*>&, const Key&, std::size_t&) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key>
|
||||
struct remove_idx<
|
||||
Key, typename std::enable_if<std::is_unsigned<Key>::value &&
|
||||
!std::is_same<Key, bool>::value>::type> {
|
||||
|
||||
static bool remove(std::vector<node*>& sequence, const Key& key,
|
||||
std::size_t& seqSize) {
|
||||
if (key >= sequence.size()) {
|
||||
return false;
|
||||
} else {
|
||||
sequence.erase(sequence.begin() + key);
|
||||
if (seqSize > key) {
|
||||
--seqSize;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key>
|
||||
struct remove_idx<Key,
|
||||
typename std::enable_if<std::is_signed<Key>::value>::type> {
|
||||
|
||||
static bool remove(std::vector<node*>& sequence, const Key& key,
|
||||
std::size_t& seqSize) {
|
||||
return key >= 0 ? remove_idx<std::size_t>::remove(
|
||||
sequence, static_cast<std::size_t>(key), seqSize)
|
||||
: false;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline bool node::equals(const T& rhs, shared_memory_holder pMemory) {
|
||||
T lhs;
|
||||
if (convert<T>::decode(Node(*this, pMemory), lhs)) {
|
||||
return lhs == rhs;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool node::equals(const char* rhs, shared_memory_holder pMemory) {
|
||||
std::string lhs;
|
||||
if (convert<std::string>::decode(Node(*this, std::move(pMemory)), lhs)) {
|
||||
return lhs == rhs;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// indexing
|
||||
template <typename Key>
|
||||
inline node* node_data::get(const Key& key,
|
||||
shared_memory_holder pMemory) const {
|
||||
switch (m_type) {
|
||||
case NodeType::Map:
|
||||
break;
|
||||
case NodeType::Undefined:
|
||||
case NodeType::Null:
|
||||
return nullptr;
|
||||
case NodeType::Sequence:
|
||||
if (node* pNode = get_idx<Key>::get(m_sequence, key, pMemory))
|
||||
return pNode;
|
||||
return nullptr;
|
||||
case NodeType::Scalar:
|
||||
throw BadSubscript(m_mark, key);
|
||||
}
|
||||
|
||||
auto it = std::find_if(m_map.begin(), m_map.end(), [&](const kv_pair m) {
|
||||
return m.first->equals(key, pMemory);
|
||||
});
|
||||
|
||||
return it != m_map.end() ? it->second : nullptr;
|
||||
}
|
||||
|
||||
template <typename Key>
|
||||
inline node& node_data::get(const Key& key, shared_memory_holder pMemory) {
|
||||
switch (m_type) {
|
||||
case NodeType::Map:
|
||||
break;
|
||||
case NodeType::Undefined:
|
||||
case NodeType::Null:
|
||||
case NodeType::Sequence:
|
||||
if (node* pNode = get_idx<Key>::get(m_sequence, key, pMemory)) {
|
||||
m_type = NodeType::Sequence;
|
||||
return *pNode;
|
||||
}
|
||||
|
||||
convert_to_map(pMemory);
|
||||
break;
|
||||
case NodeType::Scalar:
|
||||
throw BadSubscript(m_mark, key);
|
||||
}
|
||||
|
||||
auto it = std::find_if(m_map.begin(), m_map.end(), [&](const kv_pair m) {
|
||||
return m.first->equals(key, pMemory);
|
||||
});
|
||||
|
||||
if (it != m_map.end()) {
|
||||
return *it->second;
|
||||
}
|
||||
|
||||
node& k = convert_to_node(key, pMemory);
|
||||
node& v = pMemory->create_node();
|
||||
insert_map_pair(k, v);
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename Key>
|
||||
inline bool node_data::remove(const Key& key, shared_memory_holder pMemory) {
|
||||
if (m_type == NodeType::Sequence) {
|
||||
return remove_idx<Key>::remove(m_sequence, key, m_seqSize);
|
||||
}
|
||||
|
||||
if (m_type == NodeType::Map) {
|
||||
kv_pairs::iterator it = m_undefinedPairs.begin();
|
||||
while (it != m_undefinedPairs.end()) {
|
||||
kv_pairs::iterator jt = std::next(it);
|
||||
if (it->first->equals(key, pMemory)) {
|
||||
m_undefinedPairs.erase(it);
|
||||
}
|
||||
it = jt;
|
||||
}
|
||||
|
||||
auto iter = std::find_if(m_map.begin(), m_map.end(), [&](const kv_pair m) {
|
||||
return m.first->equals(key, pMemory);
|
||||
});
|
||||
|
||||
if (iter != m_map.end()) {
|
||||
m_map.erase(iter);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// map
|
||||
template <typename Key, typename Value>
|
||||
inline void node_data::force_insert(const Key& key, const Value& value,
|
||||
shared_memory_holder pMemory) {
|
||||
switch (m_type) {
|
||||
case NodeType::Map:
|
||||
break;
|
||||
case NodeType::Undefined:
|
||||
case NodeType::Null:
|
||||
case NodeType::Sequence:
|
||||
convert_to_map(pMemory);
|
||||
break;
|
||||
case NodeType::Scalar:
|
||||
throw BadInsert();
|
||||
}
|
||||
|
||||
node& k = convert_to_node(key, pMemory);
|
||||
node& v = convert_to_node(value, pMemory);
|
||||
insert_map_pair(k, v);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline node& node_data::convert_to_node(const T& rhs,
|
||||
shared_memory_holder pMemory) {
|
||||
Node value = convert<T>::encode(rhs);
|
||||
value.EnsureNodeExists();
|
||||
pMemory->merge(*value.m_pMemory);
|
||||
return *value.m_pNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -0,0 +1,96 @@
|
||||
#ifndef VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/node/detail/node_iterator.h"
|
||||
#include "yaml-cpp/node/node.h"
|
||||
#include "yaml-cpp/node/ptr.h"
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
|
||||
|
||||
namespace YAML {
|
||||
namespace detail {
|
||||
struct iterator_value;
|
||||
|
||||
template <typename V>
|
||||
class iterator_base {
|
||||
|
||||
private:
|
||||
template <typename>
|
||||
friend class iterator_base;
|
||||
struct enabler {};
|
||||
using base_type = node_iterator;
|
||||
|
||||
struct proxy {
|
||||
explicit proxy(const V& x) : m_ref(x) {}
|
||||
V* operator->() { return std::addressof(m_ref); }
|
||||
operator V*() { return std::addressof(m_ref); }
|
||||
|
||||
V m_ref;
|
||||
};
|
||||
|
||||
public:
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
using value_type = V;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using pointer = V*;
|
||||
using reference = V;
|
||||
|
||||
public:
|
||||
iterator_base() : m_iterator(), m_pMemory() {}
|
||||
explicit iterator_base(base_type rhs, shared_memory_holder pMemory)
|
||||
: m_iterator(rhs), m_pMemory(pMemory) {}
|
||||
|
||||
template <class W>
|
||||
iterator_base(const iterator_base<W>& rhs,
|
||||
typename std::enable_if<std::is_convertible<W*, V*>::value,
|
||||
enabler>::type = enabler())
|
||||
: m_iterator(rhs.m_iterator), m_pMemory(rhs.m_pMemory) {}
|
||||
|
||||
iterator_base<V>& operator++() {
|
||||
++m_iterator;
|
||||
return *this;
|
||||
}
|
||||
|
||||
iterator_base<V> operator++(int) {
|
||||
iterator_base<V> iterator_pre(*this);
|
||||
++(*this);
|
||||
return iterator_pre;
|
||||
}
|
||||
|
||||
template <typename W>
|
||||
bool operator==(const iterator_base<W>& rhs) const {
|
||||
return m_iterator == rhs.m_iterator;
|
||||
}
|
||||
|
||||
template <typename W>
|
||||
bool operator!=(const iterator_base<W>& rhs) const {
|
||||
return m_iterator != rhs.m_iterator;
|
||||
}
|
||||
|
||||
value_type operator*() const {
|
||||
const typename base_type::value_type& v = *m_iterator;
|
||||
if (v.pNode)
|
||||
return value_type(Node(*v, m_pMemory));
|
||||
if (v.first && v.second)
|
||||
return value_type(Node(*v.first, m_pMemory), Node(*v.second, m_pMemory));
|
||||
return value_type();
|
||||
}
|
||||
|
||||
proxy operator->() const { return proxy(**this); }
|
||||
|
||||
private:
|
||||
base_type m_iterator;
|
||||
shared_memory_holder m_pMemory;
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace YAML
|
||||
|
||||
#endif // VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include <list>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace YAML {
|
||||
|
||||
namespace detail {
|
||||
struct iterator_value;
|
||||
template <typename V>
|
||||
class iterator_base;
|
||||
}
|
||||
|
||||
using iterator = detail::iterator_base<detail::iterator_value>;
|
||||
using const_iterator = detail::iterator_base<const detail::iterator_value>;
|
||||
}
|
||||
|
||||
#endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
47
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/detail/memory.h
vendored
Normal file
47
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/detail/memory.h
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/node/ptr.h"
|
||||
|
||||
namespace YAML {
|
||||
namespace detail {
|
||||
class node;
|
||||
} // namespace detail
|
||||
} // namespace YAML
|
||||
|
||||
namespace YAML {
|
||||
namespace detail {
|
||||
class YAML_CPP_API memory {
|
||||
public:
|
||||
memory() : m_nodes{} {}
|
||||
node& create_node();
|
||||
void merge(const memory& rhs);
|
||||
|
||||
private:
|
||||
using Nodes = std::set<shared_node>;
|
||||
Nodes m_nodes;
|
||||
};
|
||||
|
||||
class YAML_CPP_API memory_holder {
|
||||
public:
|
||||
memory_holder() : m_pMemory(new memory) {}
|
||||
|
||||
node& create_node() { return m_pMemory->create_node(); }
|
||||
void merge(memory_holder& rhs);
|
||||
|
||||
private:
|
||||
shared_memory m_pMemory;
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace YAML
|
||||
|
||||
#endif // VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
177
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/detail/node.h
vendored
Normal file
177
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/detail/node.h
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
#ifndef NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/emitterstyle.h"
|
||||
#include "yaml-cpp/node/detail/node_ref.h"
|
||||
#include "yaml-cpp/node/ptr.h"
|
||||
#include "yaml-cpp/node/type.h"
|
||||
#include <set>
|
||||
#include <atomic>
|
||||
|
||||
namespace YAML {
|
||||
namespace detail {
|
||||
class node {
|
||||
private:
|
||||
struct less {
|
||||
bool operator ()(const node* l, const node* r) const {return l->m_index < r->m_index;}
|
||||
};
|
||||
|
||||
public:
|
||||
node() : m_pRef(new node_ref), m_dependencies{}, m_index{} {}
|
||||
node(const node&) = delete;
|
||||
node& operator=(const node&) = delete;
|
||||
|
||||
bool is(const node& rhs) const { return m_pRef == rhs.m_pRef; }
|
||||
const node_ref* ref() const { return m_pRef.get(); }
|
||||
|
||||
bool is_defined() const { return m_pRef->is_defined(); }
|
||||
const Mark& mark() const { return m_pRef->mark(); }
|
||||
NodeType::value type() const { return m_pRef->type(); }
|
||||
|
||||
const std::string& scalar() const { return m_pRef->scalar(); }
|
||||
const std::string& tag() const { return m_pRef->tag(); }
|
||||
EmitterStyle::value style() const { return m_pRef->style(); }
|
||||
|
||||
template <typename T>
|
||||
bool equals(const T& rhs, shared_memory_holder pMemory);
|
||||
bool equals(const char* rhs, shared_memory_holder pMemory);
|
||||
|
||||
void mark_defined() {
|
||||
if (is_defined())
|
||||
return;
|
||||
|
||||
m_pRef->mark_defined();
|
||||
for (node* dependency : m_dependencies)
|
||||
dependency->mark_defined();
|
||||
m_dependencies.clear();
|
||||
}
|
||||
|
||||
void add_dependency(node& rhs) {
|
||||
if (is_defined())
|
||||
rhs.mark_defined();
|
||||
else
|
||||
m_dependencies.insert(&rhs);
|
||||
}
|
||||
|
||||
void set_ref(const node& rhs) {
|
||||
if (rhs.is_defined())
|
||||
mark_defined();
|
||||
m_pRef = rhs.m_pRef;
|
||||
}
|
||||
void set_data(const node& rhs) {
|
||||
if (rhs.is_defined())
|
||||
mark_defined();
|
||||
m_pRef->set_data(*rhs.m_pRef);
|
||||
}
|
||||
|
||||
void set_mark(const Mark& mark) { m_pRef->set_mark(mark); }
|
||||
|
||||
void set_type(NodeType::value type) {
|
||||
if (type != NodeType::Undefined)
|
||||
mark_defined();
|
||||
m_pRef->set_type(type);
|
||||
}
|
||||
void set_null() {
|
||||
mark_defined();
|
||||
m_pRef->set_null();
|
||||
}
|
||||
void set_scalar(const std::string& scalar) {
|
||||
mark_defined();
|
||||
m_pRef->set_scalar(scalar);
|
||||
}
|
||||
void set_tag(const std::string& tag) {
|
||||
mark_defined();
|
||||
m_pRef->set_tag(tag);
|
||||
}
|
||||
|
||||
// style
|
||||
void set_style(EmitterStyle::value style) {
|
||||
mark_defined();
|
||||
m_pRef->set_style(style);
|
||||
}
|
||||
|
||||
// size/iterator
|
||||
std::size_t size() const { return m_pRef->size(); }
|
||||
|
||||
const_node_iterator begin() const {
|
||||
return static_cast<const node_ref&>(*m_pRef).begin();
|
||||
}
|
||||
node_iterator begin() { return m_pRef->begin(); }
|
||||
|
||||
const_node_iterator end() const {
|
||||
return static_cast<const node_ref&>(*m_pRef).end();
|
||||
}
|
||||
node_iterator end() { return m_pRef->end(); }
|
||||
|
||||
// sequence
|
||||
void push_back(node& input, shared_memory_holder pMemory) {
|
||||
m_pRef->push_back(input, pMemory);
|
||||
input.add_dependency(*this);
|
||||
m_index = m_amount.fetch_add(1);
|
||||
}
|
||||
void insert(node& key, node& value, shared_memory_holder pMemory) {
|
||||
m_pRef->insert(key, value, pMemory);
|
||||
key.add_dependency(*this);
|
||||
value.add_dependency(*this);
|
||||
}
|
||||
|
||||
// indexing
|
||||
template <typename Key>
|
||||
node* get(const Key& key, shared_memory_holder pMemory) const {
|
||||
// NOTE: this returns a non-const node so that the top-level Node can wrap
|
||||
// it, and returns a pointer so that it can be nullptr (if there is no such
|
||||
// key).
|
||||
return static_cast<const node_ref&>(*m_pRef).get(key, pMemory);
|
||||
}
|
||||
template <typename Key>
|
||||
node& get(const Key& key, shared_memory_holder pMemory) {
|
||||
node& value = m_pRef->get(key, pMemory);
|
||||
value.add_dependency(*this);
|
||||
return value;
|
||||
}
|
||||
template <typename Key>
|
||||
bool remove(const Key& key, shared_memory_holder pMemory) {
|
||||
return m_pRef->remove(key, pMemory);
|
||||
}
|
||||
|
||||
node* get(node& key, shared_memory_holder pMemory) const {
|
||||
// NOTE: this returns a non-const node so that the top-level Node can wrap
|
||||
// it, and returns a pointer so that it can be nullptr (if there is no such
|
||||
// key).
|
||||
return static_cast<const node_ref&>(*m_pRef).get(key, pMemory);
|
||||
}
|
||||
node& get(node& key, shared_memory_holder pMemory) {
|
||||
node& value = m_pRef->get(key, pMemory);
|
||||
key.add_dependency(*this);
|
||||
value.add_dependency(*this);
|
||||
return value;
|
||||
}
|
||||
bool remove(node& key, shared_memory_holder pMemory) {
|
||||
return m_pRef->remove(key, pMemory);
|
||||
}
|
||||
|
||||
// map
|
||||
template <typename Key, typename Value>
|
||||
void force_insert(const Key& key, const Value& value,
|
||||
shared_memory_holder pMemory) {
|
||||
m_pRef->force_insert(key, value, pMemory);
|
||||
}
|
||||
|
||||
private:
|
||||
shared_node_ref m_pRef;
|
||||
using nodes = std::set<node*, less>;
|
||||
nodes m_dependencies;
|
||||
size_t m_index;
|
||||
static std::atomic<size_t> m_amount;
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace YAML
|
||||
|
||||
#endif // NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
127
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/detail/node_data.h
vendored
Normal file
127
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/detail/node_data.h
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
#ifndef VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/node/detail/node_iterator.h"
|
||||
#include "yaml-cpp/node/iterator.h"
|
||||
#include "yaml-cpp/node/ptr.h"
|
||||
#include "yaml-cpp/node/type.h"
|
||||
|
||||
namespace YAML {
|
||||
namespace detail {
|
||||
class node;
|
||||
} // namespace detail
|
||||
} // namespace YAML
|
||||
|
||||
namespace YAML {
|
||||
namespace detail {
|
||||
class YAML_CPP_API node_data {
|
||||
public:
|
||||
node_data();
|
||||
node_data(const node_data&) = delete;
|
||||
node_data& operator=(const node_data&) = delete;
|
||||
|
||||
void mark_defined();
|
||||
void set_mark(const Mark& mark);
|
||||
void set_type(NodeType::value type);
|
||||
void set_tag(const std::string& tag);
|
||||
void set_null();
|
||||
void set_scalar(const std::string& scalar);
|
||||
void set_style(EmitterStyle::value style);
|
||||
|
||||
bool is_defined() const { return m_isDefined; }
|
||||
const Mark& mark() const { return m_mark; }
|
||||
NodeType::value type() const {
|
||||
return m_isDefined ? m_type : NodeType::Undefined;
|
||||
}
|
||||
const std::string& scalar() const { return m_scalar; }
|
||||
const std::string& tag() const { return m_tag; }
|
||||
EmitterStyle::value style() const { return m_style; }
|
||||
|
||||
// size/iterator
|
||||
std::size_t size() const;
|
||||
|
||||
const_node_iterator begin() const;
|
||||
node_iterator begin();
|
||||
|
||||
const_node_iterator end() const;
|
||||
node_iterator end();
|
||||
|
||||
// sequence
|
||||
void push_back(node& node, const shared_memory_holder& pMemory);
|
||||
void insert(node& key, node& value, const shared_memory_holder& pMemory);
|
||||
|
||||
// indexing
|
||||
template <typename Key>
|
||||
node* get(const Key& key, shared_memory_holder pMemory) const;
|
||||
template <typename Key>
|
||||
node& get(const Key& key, shared_memory_holder pMemory);
|
||||
template <typename Key>
|
||||
bool remove(const Key& key, shared_memory_holder pMemory);
|
||||
|
||||
node* get(node& key, const shared_memory_holder& pMemory) const;
|
||||
node& get(node& key, const shared_memory_holder& pMemory);
|
||||
bool remove(node& key, const shared_memory_holder& pMemory);
|
||||
|
||||
// map
|
||||
template <typename Key, typename Value>
|
||||
void force_insert(const Key& key, const Value& value,
|
||||
shared_memory_holder pMemory);
|
||||
|
||||
public:
|
||||
static const std::string& empty_scalar();
|
||||
|
||||
private:
|
||||
void compute_seq_size() const;
|
||||
void compute_map_size() const;
|
||||
|
||||
void reset_sequence();
|
||||
void reset_map();
|
||||
|
||||
void insert_map_pair(node& key, node& value);
|
||||
void convert_to_map(const shared_memory_holder& pMemory);
|
||||
void convert_sequence_to_map(const shared_memory_holder& pMemory);
|
||||
|
||||
template <typename T>
|
||||
static node& convert_to_node(const T& rhs, shared_memory_holder pMemory);
|
||||
|
||||
private:
|
||||
bool m_isDefined;
|
||||
Mark m_mark;
|
||||
NodeType::value m_type;
|
||||
std::string m_tag;
|
||||
EmitterStyle::value m_style;
|
||||
|
||||
// scalar
|
||||
std::string m_scalar;
|
||||
|
||||
// sequence
|
||||
using node_seq = std::vector<node *>;
|
||||
node_seq m_sequence;
|
||||
|
||||
mutable std::size_t m_seqSize;
|
||||
|
||||
// map
|
||||
using node_map = std::vector<std::pair<node*, node*>>;
|
||||
node_map m_map;
|
||||
|
||||
using kv_pair = std::pair<node*, node*>;
|
||||
using kv_pairs = std::list<kv_pair>;
|
||||
mutable kv_pairs m_undefinedPairs;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -0,0 +1,181 @@
|
||||
#ifndef VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/node/ptr.h"
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace YAML {
|
||||
namespace detail {
|
||||
struct iterator_type {
|
||||
enum value { NoneType, Sequence, Map };
|
||||
};
|
||||
|
||||
template <typename V>
|
||||
struct node_iterator_value : public std::pair<V*, V*> {
|
||||
using kv = std::pair<V*, V*>;
|
||||
|
||||
node_iterator_value() : kv(), pNode(nullptr) {}
|
||||
explicit node_iterator_value(V& rhs) : kv(), pNode(&rhs) {}
|
||||
explicit node_iterator_value(V& key, V& value) : kv(&key, &value), pNode(nullptr) {}
|
||||
|
||||
V& operator*() const { return *pNode; }
|
||||
V& operator->() const { return *pNode; }
|
||||
|
||||
V* pNode;
|
||||
};
|
||||
|
||||
using node_seq = std::vector<node *>;
|
||||
using node_map = std::vector<std::pair<node*, node*>>;
|
||||
|
||||
template <typename V>
|
||||
struct node_iterator_type {
|
||||
using seq = node_seq::iterator;
|
||||
using map = node_map::iterator;
|
||||
};
|
||||
|
||||
template <typename V>
|
||||
struct node_iterator_type<const V> {
|
||||
using seq = node_seq::const_iterator;
|
||||
using map = node_map::const_iterator;
|
||||
};
|
||||
|
||||
template <typename V>
|
||||
class node_iterator_base {
|
||||
private:
|
||||
struct enabler {};
|
||||
|
||||
struct proxy {
|
||||
explicit proxy(const node_iterator_value<V>& x) : m_ref(x) {}
|
||||
node_iterator_value<V>* operator->() { return std::addressof(m_ref); }
|
||||
operator node_iterator_value<V>*() { return std::addressof(m_ref); }
|
||||
|
||||
node_iterator_value<V> m_ref;
|
||||
};
|
||||
|
||||
public:
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
using value_type = node_iterator_value<V>;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using pointer = node_iterator_value<V>*;
|
||||
using reference = node_iterator_value<V>;
|
||||
using SeqIter = typename node_iterator_type<V>::seq;
|
||||
using MapIter = typename node_iterator_type<V>::map;
|
||||
|
||||
node_iterator_base()
|
||||
: m_type(iterator_type::NoneType), m_seqIt(), m_mapIt(), m_mapEnd() {}
|
||||
explicit node_iterator_base(SeqIter seqIt)
|
||||
: m_type(iterator_type::Sequence),
|
||||
m_seqIt(seqIt),
|
||||
m_mapIt(),
|
||||
m_mapEnd() {}
|
||||
explicit node_iterator_base(MapIter mapIt, MapIter mapEnd)
|
||||
: m_type(iterator_type::Map),
|
||||
m_seqIt(),
|
||||
m_mapIt(mapIt),
|
||||
m_mapEnd(mapEnd) {
|
||||
m_mapIt = increment_until_defined(m_mapIt);
|
||||
}
|
||||
|
||||
template <typename W>
|
||||
node_iterator_base(const node_iterator_base<W>& rhs,
|
||||
typename std::enable_if<std::is_convertible<W*, V*>::value,
|
||||
enabler>::type = enabler())
|
||||
: m_type(rhs.m_type),
|
||||
m_seqIt(rhs.m_seqIt),
|
||||
m_mapIt(rhs.m_mapIt),
|
||||
m_mapEnd(rhs.m_mapEnd) {}
|
||||
|
||||
template <typename>
|
||||
friend class node_iterator_base;
|
||||
|
||||
template <typename W>
|
||||
bool operator==(const node_iterator_base<W>& rhs) const {
|
||||
if (m_type != rhs.m_type)
|
||||
return false;
|
||||
|
||||
switch (m_type) {
|
||||
case iterator_type::NoneType:
|
||||
return true;
|
||||
case iterator_type::Sequence:
|
||||
return m_seqIt == rhs.m_seqIt;
|
||||
case iterator_type::Map:
|
||||
return m_mapIt == rhs.m_mapIt;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename W>
|
||||
bool operator!=(const node_iterator_base<W>& rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
node_iterator_base<V>& operator++() {
|
||||
switch (m_type) {
|
||||
case iterator_type::NoneType:
|
||||
break;
|
||||
case iterator_type::Sequence:
|
||||
++m_seqIt;
|
||||
break;
|
||||
case iterator_type::Map:
|
||||
++m_mapIt;
|
||||
m_mapIt = increment_until_defined(m_mapIt);
|
||||
break;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
node_iterator_base<V> operator++(int) {
|
||||
node_iterator_base<V> iterator_pre(*this);
|
||||
++(*this);
|
||||
return iterator_pre;
|
||||
}
|
||||
|
||||
value_type operator*() const {
|
||||
switch (m_type) {
|
||||
case iterator_type::NoneType:
|
||||
return value_type();
|
||||
case iterator_type::Sequence:
|
||||
return value_type(**m_seqIt);
|
||||
case iterator_type::Map:
|
||||
return value_type(*m_mapIt->first, *m_mapIt->second);
|
||||
}
|
||||
return value_type();
|
||||
}
|
||||
|
||||
proxy operator->() const { return proxy(**this); }
|
||||
|
||||
MapIter increment_until_defined(MapIter it) {
|
||||
while (it != m_mapEnd && !is_defined(it))
|
||||
++it;
|
||||
return it;
|
||||
}
|
||||
|
||||
bool is_defined(MapIter it) const {
|
||||
return it->first->is_defined() && it->second->is_defined();
|
||||
}
|
||||
|
||||
private:
|
||||
typename iterator_type::value m_type;
|
||||
|
||||
SeqIter m_seqIt;
|
||||
MapIter m_mapIt, m_mapEnd;
|
||||
};
|
||||
|
||||
using node_iterator = node_iterator_base<node>;
|
||||
using const_node_iterator = node_iterator_base<const node>;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -0,0 +1,98 @@
|
||||
#ifndef VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/node/type.h"
|
||||
#include "yaml-cpp/node/ptr.h"
|
||||
#include "yaml-cpp/node/detail/node_data.h"
|
||||
|
||||
namespace YAML {
|
||||
namespace detail {
|
||||
class node_ref {
|
||||
public:
|
||||
node_ref() : m_pData(new node_data) {}
|
||||
node_ref(const node_ref&) = delete;
|
||||
node_ref& operator=(const node_ref&) = delete;
|
||||
|
||||
bool is_defined() const { return m_pData->is_defined(); }
|
||||
const Mark& mark() const { return m_pData->mark(); }
|
||||
NodeType::value type() const { return m_pData->type(); }
|
||||
const std::string& scalar() const { return m_pData->scalar(); }
|
||||
const std::string& tag() const { return m_pData->tag(); }
|
||||
EmitterStyle::value style() const { return m_pData->style(); }
|
||||
|
||||
void mark_defined() { m_pData->mark_defined(); }
|
||||
void set_data(const node_ref& rhs) { m_pData = rhs.m_pData; }
|
||||
|
||||
void set_mark(const Mark& mark) { m_pData->set_mark(mark); }
|
||||
void set_type(NodeType::value type) { m_pData->set_type(type); }
|
||||
void set_tag(const std::string& tag) { m_pData->set_tag(tag); }
|
||||
void set_null() { m_pData->set_null(); }
|
||||
void set_scalar(const std::string& scalar) { m_pData->set_scalar(scalar); }
|
||||
void set_style(EmitterStyle::value style) { m_pData->set_style(style); }
|
||||
|
||||
// size/iterator
|
||||
std::size_t size() const { return m_pData->size(); }
|
||||
|
||||
const_node_iterator begin() const {
|
||||
return static_cast<const node_data&>(*m_pData).begin();
|
||||
}
|
||||
node_iterator begin() { return m_pData->begin(); }
|
||||
|
||||
const_node_iterator end() const {
|
||||
return static_cast<const node_data&>(*m_pData).end();
|
||||
}
|
||||
node_iterator end() { return m_pData->end(); }
|
||||
|
||||
// sequence
|
||||
void push_back(node& node, shared_memory_holder pMemory) {
|
||||
m_pData->push_back(node, pMemory);
|
||||
}
|
||||
void insert(node& key, node& value, shared_memory_holder pMemory) {
|
||||
m_pData->insert(key, value, pMemory);
|
||||
}
|
||||
|
||||
// indexing
|
||||
template <typename Key>
|
||||
node* get(const Key& key, shared_memory_holder pMemory) const {
|
||||
return static_cast<const node_data&>(*m_pData).get(key, pMemory);
|
||||
}
|
||||
template <typename Key>
|
||||
node& get(const Key& key, shared_memory_holder pMemory) {
|
||||
return m_pData->get(key, pMemory);
|
||||
}
|
||||
template <typename Key>
|
||||
bool remove(const Key& key, shared_memory_holder pMemory) {
|
||||
return m_pData->remove(key, pMemory);
|
||||
}
|
||||
|
||||
node* get(node& key, shared_memory_holder pMemory) const {
|
||||
return static_cast<const node_data&>(*m_pData).get(key, pMemory);
|
||||
}
|
||||
node& get(node& key, shared_memory_holder pMemory) {
|
||||
return m_pData->get(key, pMemory);
|
||||
}
|
||||
bool remove(node& key, shared_memory_holder pMemory) {
|
||||
return m_pData->remove(key, pMemory);
|
||||
}
|
||||
|
||||
// map
|
||||
template <typename Key, typename Value>
|
||||
void force_insert(const Key& key, const Value& value,
|
||||
shared_memory_holder pMemory) {
|
||||
m_pData->force_insert(key, value, pMemory);
|
||||
}
|
||||
|
||||
private:
|
||||
shared_node_data m_pData;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
32
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/emit.h
vendored
Normal file
32
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/emit.h
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
|
||||
namespace YAML {
|
||||
class Emitter;
|
||||
class Node;
|
||||
|
||||
/**
|
||||
* Emits the node to the given {@link Emitter}. If there is an error in writing,
|
||||
* {@link Emitter#good} will return false.
|
||||
*/
|
||||
YAML_CPP_API Emitter& operator<<(Emitter& out, const Node& node);
|
||||
|
||||
/** Emits the node to the given output stream. */
|
||||
YAML_CPP_API std::ostream& operator<<(std::ostream& out, const Node& node);
|
||||
|
||||
/** Converts the node to a YAML string. */
|
||||
YAML_CPP_API std::string Dump(const Node& node);
|
||||
} // namespace YAML
|
||||
|
||||
#endif // NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
385
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/impl.h
vendored
Normal file
385
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/impl.h
vendored
Normal file
@@ -0,0 +1,385 @@
|
||||
#ifndef NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include "yaml-cpp/node/detail/memory.h"
|
||||
#include "yaml-cpp/node/detail/node.h"
|
||||
#include "yaml-cpp/node/iterator.h"
|
||||
#include "yaml-cpp/node/node.h"
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace YAML {
|
||||
inline Node::Node()
|
||||
: m_isValid(true), m_invalidKey{}, m_pMemory(nullptr), m_pNode(nullptr) {}
|
||||
|
||||
inline Node::Node(NodeType::value type)
|
||||
: m_isValid(true),
|
||||
m_invalidKey{},
|
||||
m_pMemory(new detail::memory_holder),
|
||||
m_pNode(&m_pMemory->create_node()) {
|
||||
m_pNode->set_type(type);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline Node::Node(const T& rhs)
|
||||
: m_isValid(true),
|
||||
m_invalidKey{},
|
||||
m_pMemory(new detail::memory_holder),
|
||||
m_pNode(&m_pMemory->create_node()) {
|
||||
Assign(rhs);
|
||||
}
|
||||
|
||||
inline Node::Node(const detail::iterator_value& rhs)
|
||||
: m_isValid(rhs.m_isValid),
|
||||
m_invalidKey(rhs.m_invalidKey),
|
||||
m_pMemory(rhs.m_pMemory),
|
||||
m_pNode(rhs.m_pNode) {}
|
||||
|
||||
inline Node::Node(const Node& rhs) = default;
|
||||
|
||||
inline Node::Node(Zombie)
|
||||
: m_isValid(false), m_invalidKey{}, m_pMemory{}, m_pNode(nullptr) {}
|
||||
|
||||
inline Node::Node(Zombie, const std::string& key)
|
||||
: m_isValid(false), m_invalidKey(key), m_pMemory{}, m_pNode(nullptr) {}
|
||||
|
||||
inline Node::Node(detail::node& node, detail::shared_memory_holder pMemory)
|
||||
: m_isValid(true), m_invalidKey{}, m_pMemory(pMemory), m_pNode(&node) {}
|
||||
|
||||
inline Node::~Node() = default;
|
||||
|
||||
inline void Node::EnsureNodeExists() const {
|
||||
if (!m_isValid)
|
||||
throw InvalidNode(m_invalidKey);
|
||||
if (!m_pNode) {
|
||||
m_pMemory.reset(new detail::memory_holder);
|
||||
m_pNode = &m_pMemory->create_node();
|
||||
m_pNode->set_null();
|
||||
}
|
||||
}
|
||||
|
||||
inline bool Node::IsDefined() const {
|
||||
if (!m_isValid) {
|
||||
return false;
|
||||
}
|
||||
return m_pNode ? m_pNode->is_defined() : true;
|
||||
}
|
||||
|
||||
inline Mark Node::Mark() const {
|
||||
if (!m_isValid) {
|
||||
throw InvalidNode(m_invalidKey);
|
||||
}
|
||||
return m_pNode ? m_pNode->mark() : Mark::null_mark();
|
||||
}
|
||||
|
||||
inline NodeType::value Node::Type() const {
|
||||
if (!m_isValid)
|
||||
throw InvalidNode(m_invalidKey);
|
||||
return m_pNode ? m_pNode->type() : NodeType::Null;
|
||||
}
|
||||
|
||||
// access
|
||||
|
||||
// template helpers
|
||||
template <typename T, typename S>
|
||||
struct as_if {
|
||||
explicit as_if(const Node& node_) : node(node_) {}
|
||||
const Node& node;
|
||||
|
||||
T operator()(const S& fallback) const {
|
||||
if (!node.m_pNode)
|
||||
return fallback;
|
||||
|
||||
T t;
|
||||
if (convert<T>::decode(node, t))
|
||||
return t;
|
||||
return fallback;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename S>
|
||||
struct as_if<std::string, S> {
|
||||
explicit as_if(const Node& node_) : node(node_) {}
|
||||
const Node& node;
|
||||
|
||||
std::string operator()(const S& fallback) const {
|
||||
if (node.Type() == NodeType::Null)
|
||||
return "null";
|
||||
if (node.Type() != NodeType::Scalar)
|
||||
return fallback;
|
||||
return node.Scalar();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct as_if<T, void> {
|
||||
explicit as_if(const Node& node_) : node(node_) {}
|
||||
const Node& node;
|
||||
|
||||
T operator()() const {
|
||||
if (!node.m_pNode)
|
||||
throw TypedBadConversion<T>(node.Mark());
|
||||
|
||||
T t;
|
||||
if (convert<T>::decode(node, t))
|
||||
return t;
|
||||
throw TypedBadConversion<T>(node.Mark());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct as_if<std::string, void> {
|
||||
explicit as_if(const Node& node_) : node(node_) {}
|
||||
const Node& node;
|
||||
|
||||
std::string operator()() const {
|
||||
if (node.Type() == NodeType::Null)
|
||||
return "null";
|
||||
if (node.Type() != NodeType::Scalar)
|
||||
throw TypedBadConversion<std::string>(node.Mark());
|
||||
return node.Scalar();
|
||||
}
|
||||
};
|
||||
|
||||
// access functions
|
||||
template <typename T>
|
||||
inline T Node::as() const {
|
||||
if (!m_isValid)
|
||||
throw InvalidNode(m_invalidKey);
|
||||
return as_if<T, void>(*this)();
|
||||
}
|
||||
|
||||
template <typename T, typename S>
|
||||
inline T Node::as(const S& fallback) const {
|
||||
if (!m_isValid)
|
||||
return fallback;
|
||||
return as_if<T, S>(*this)(fallback);
|
||||
}
|
||||
|
||||
inline const std::string& Node::Scalar() const {
|
||||
if (!m_isValid)
|
||||
throw InvalidNode(m_invalidKey);
|
||||
return m_pNode ? m_pNode->scalar() : detail::node_data::empty_scalar();
|
||||
}
|
||||
|
||||
inline const std::string& Node::Tag() const {
|
||||
if (!m_isValid)
|
||||
throw InvalidNode(m_invalidKey);
|
||||
return m_pNode ? m_pNode->tag() : detail::node_data::empty_scalar();
|
||||
}
|
||||
|
||||
inline void Node::SetTag(const std::string& tag) {
|
||||
EnsureNodeExists();
|
||||
m_pNode->set_tag(tag);
|
||||
}
|
||||
|
||||
inline EmitterStyle::value Node::Style() const {
|
||||
if (!m_isValid)
|
||||
throw InvalidNode(m_invalidKey);
|
||||
return m_pNode ? m_pNode->style() : EmitterStyle::Default;
|
||||
}
|
||||
|
||||
inline void Node::SetStyle(EmitterStyle::value style) {
|
||||
EnsureNodeExists();
|
||||
m_pNode->set_style(style);
|
||||
}
|
||||
|
||||
// assignment
|
||||
inline bool Node::is(const Node& rhs) const {
|
||||
if (!m_isValid || !rhs.m_isValid)
|
||||
throw InvalidNode(m_invalidKey);
|
||||
if (!m_pNode || !rhs.m_pNode)
|
||||
return false;
|
||||
return m_pNode->is(*rhs.m_pNode);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline Node& Node::operator=(const T& rhs) {
|
||||
Assign(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Node& Node::operator=(const Node& rhs) {
|
||||
if (is(rhs))
|
||||
return *this;
|
||||
AssignNode(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Node::reset(const YAML::Node& rhs) {
|
||||
if (!m_isValid || !rhs.m_isValid)
|
||||
throw InvalidNode(m_invalidKey);
|
||||
m_pMemory = rhs.m_pMemory;
|
||||
m_pNode = rhs.m_pNode;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void Node::Assign(const T& rhs) {
|
||||
if (!m_isValid)
|
||||
throw InvalidNode(m_invalidKey);
|
||||
AssignData(convert<T>::encode(rhs));
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void Node::Assign(const std::string& rhs) {
|
||||
EnsureNodeExists();
|
||||
m_pNode->set_scalar(rhs);
|
||||
}
|
||||
|
||||
inline void Node::Assign(const char* rhs) {
|
||||
EnsureNodeExists();
|
||||
m_pNode->set_scalar(rhs);
|
||||
}
|
||||
|
||||
inline void Node::Assign(char* rhs) {
|
||||
EnsureNodeExists();
|
||||
m_pNode->set_scalar(rhs);
|
||||
}
|
||||
|
||||
inline void Node::AssignData(const Node& rhs) {
|
||||
EnsureNodeExists();
|
||||
rhs.EnsureNodeExists();
|
||||
|
||||
m_pNode->set_data(*rhs.m_pNode);
|
||||
m_pMemory->merge(*rhs.m_pMemory);
|
||||
}
|
||||
|
||||
inline void Node::AssignNode(const Node& rhs) {
|
||||
if (!m_isValid)
|
||||
throw InvalidNode(m_invalidKey);
|
||||
rhs.EnsureNodeExists();
|
||||
|
||||
if (!m_pNode) {
|
||||
m_pNode = rhs.m_pNode;
|
||||
m_pMemory = rhs.m_pMemory;
|
||||
return;
|
||||
}
|
||||
|
||||
m_pNode->set_ref(*rhs.m_pNode);
|
||||
m_pMemory->merge(*rhs.m_pMemory);
|
||||
m_pNode = rhs.m_pNode;
|
||||
}
|
||||
|
||||
// size/iterator
|
||||
inline std::size_t Node::size() const {
|
||||
if (!m_isValid)
|
||||
throw InvalidNode(m_invalidKey);
|
||||
return m_pNode ? m_pNode->size() : 0;
|
||||
}
|
||||
|
||||
inline const_iterator Node::begin() const {
|
||||
if (!m_isValid)
|
||||
return const_iterator();
|
||||
return m_pNode ? const_iterator(m_pNode->begin(), m_pMemory)
|
||||
: const_iterator();
|
||||
}
|
||||
|
||||
inline iterator Node::begin() {
|
||||
if (!m_isValid)
|
||||
return iterator();
|
||||
return m_pNode ? iterator(m_pNode->begin(), m_pMemory) : iterator();
|
||||
}
|
||||
|
||||
inline const_iterator Node::end() const {
|
||||
if (!m_isValid)
|
||||
return const_iterator();
|
||||
return m_pNode ? const_iterator(m_pNode->end(), m_pMemory) : const_iterator();
|
||||
}
|
||||
|
||||
inline iterator Node::end() {
|
||||
if (!m_isValid)
|
||||
return iterator();
|
||||
return m_pNode ? iterator(m_pNode->end(), m_pMemory) : iterator();
|
||||
}
|
||||
|
||||
// sequence
|
||||
template <typename T>
|
||||
inline void Node::push_back(const T& rhs) {
|
||||
if (!m_isValid)
|
||||
throw InvalidNode(m_invalidKey);
|
||||
push_back(Node(rhs));
|
||||
}
|
||||
|
||||
inline void Node::push_back(const Node& rhs) {
|
||||
EnsureNodeExists();
|
||||
rhs.EnsureNodeExists();
|
||||
|
||||
m_pNode->push_back(*rhs.m_pNode, m_pMemory);
|
||||
m_pMemory->merge(*rhs.m_pMemory);
|
||||
}
|
||||
|
||||
template<typename Key>
|
||||
std::string key_to_string(const Key& key) {
|
||||
return streamable_to_string<Key, is_streamable<std::stringstream, Key>::value>().impl(key);
|
||||
}
|
||||
|
||||
// indexing
|
||||
template <typename Key>
|
||||
inline const Node Node::operator[](const Key& key) const {
|
||||
EnsureNodeExists();
|
||||
detail::node* value =
|
||||
static_cast<const detail::node&>(*m_pNode).get(key, m_pMemory);
|
||||
if (!value) {
|
||||
return Node(ZombieNode, key_to_string(key));
|
||||
}
|
||||
return Node(*value, m_pMemory);
|
||||
}
|
||||
|
||||
template <typename Key>
|
||||
inline Node Node::operator[](const Key& key) {
|
||||
EnsureNodeExists();
|
||||
detail::node& value = m_pNode->get(key, m_pMemory);
|
||||
return Node(value, m_pMemory);
|
||||
}
|
||||
|
||||
template <typename Key>
|
||||
inline bool Node::remove(const Key& key) {
|
||||
EnsureNodeExists();
|
||||
return m_pNode->remove(key, m_pMemory);
|
||||
}
|
||||
|
||||
inline const Node Node::operator[](const Node& key) const {
|
||||
EnsureNodeExists();
|
||||
key.EnsureNodeExists();
|
||||
m_pMemory->merge(*key.m_pMemory);
|
||||
detail::node* value =
|
||||
static_cast<const detail::node&>(*m_pNode).get(*key.m_pNode, m_pMemory);
|
||||
if (!value) {
|
||||
return Node(ZombieNode, key_to_string(key));
|
||||
}
|
||||
return Node(*value, m_pMemory);
|
||||
}
|
||||
|
||||
inline Node Node::operator[](const Node& key) {
|
||||
EnsureNodeExists();
|
||||
key.EnsureNodeExists();
|
||||
m_pMemory->merge(*key.m_pMemory);
|
||||
detail::node& value = m_pNode->get(*key.m_pNode, m_pMemory);
|
||||
return Node(value, m_pMemory);
|
||||
}
|
||||
|
||||
inline bool Node::remove(const Node& key) {
|
||||
EnsureNodeExists();
|
||||
key.EnsureNodeExists();
|
||||
return m_pNode->remove(*key.m_pNode, m_pMemory);
|
||||
}
|
||||
|
||||
// map
|
||||
template <typename Key, typename Value>
|
||||
inline void Node::force_insert(const Key& key, const Value& value) {
|
||||
EnsureNodeExists();
|
||||
m_pNode->force_insert(key, value, m_pMemory);
|
||||
}
|
||||
|
||||
// free functions
|
||||
inline bool operator==(const Node& lhs, const Node& rhs) { return lhs.is(rhs); }
|
||||
} // namespace YAML
|
||||
|
||||
#endif // NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
31
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/iterator.h
vendored
Normal file
31
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/iterator.h
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/node/node.h"
|
||||
#include "yaml-cpp/node/detail/iterator_fwd.h"
|
||||
#include "yaml-cpp/node/detail/iterator.h"
|
||||
#include <list>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace YAML {
|
||||
namespace detail {
|
||||
struct iterator_value : public Node, std::pair<Node, Node> {
|
||||
iterator_value() = default;
|
||||
explicit iterator_value(const Node& rhs)
|
||||
: Node(rhs),
|
||||
std::pair<Node, Node>(Node(Node::ZombieNode), Node(Node::ZombieNode)) {}
|
||||
explicit iterator_value(const Node& key, const Node& value)
|
||||
: Node(Node::ZombieNode), std::pair<Node, Node>(key, value) {}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
148
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/node.h
vendored
Normal file
148
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/node.h
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
#ifndef NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/emitterstyle.h"
|
||||
#include "yaml-cpp/mark.h"
|
||||
#include "yaml-cpp/node/detail/iterator_fwd.h"
|
||||
#include "yaml-cpp/node/ptr.h"
|
||||
#include "yaml-cpp/node/type.h"
|
||||
|
||||
namespace YAML {
|
||||
namespace detail {
|
||||
class node;
|
||||
class node_data;
|
||||
struct iterator_value;
|
||||
} // namespace detail
|
||||
} // namespace YAML
|
||||
|
||||
namespace YAML {
|
||||
class YAML_CPP_API Node {
|
||||
public:
|
||||
friend class NodeBuilder;
|
||||
friend class NodeEvents;
|
||||
friend struct detail::iterator_value;
|
||||
friend class detail::node;
|
||||
friend class detail::node_data;
|
||||
template <typename>
|
||||
friend class detail::iterator_base;
|
||||
template <typename T, typename S>
|
||||
friend struct as_if;
|
||||
|
||||
using iterator = YAML::iterator;
|
||||
using const_iterator = YAML::const_iterator;
|
||||
|
||||
Node();
|
||||
explicit Node(NodeType::value type);
|
||||
template <typename T>
|
||||
explicit Node(const T& rhs);
|
||||
explicit Node(const detail::iterator_value& rhs);
|
||||
Node(const Node& rhs);
|
||||
~Node();
|
||||
|
||||
YAML::Mark Mark() const;
|
||||
NodeType::value Type() const;
|
||||
bool IsDefined() const;
|
||||
bool IsNull() const { return Type() == NodeType::Null; }
|
||||
bool IsScalar() const { return Type() == NodeType::Scalar; }
|
||||
bool IsSequence() const { return Type() == NodeType::Sequence; }
|
||||
bool IsMap() const { return Type() == NodeType::Map; }
|
||||
|
||||
// bool conversions
|
||||
explicit operator bool() const { return IsDefined(); }
|
||||
bool operator!() const { return !IsDefined(); }
|
||||
|
||||
// access
|
||||
template <typename T>
|
||||
T as() const;
|
||||
template <typename T, typename S>
|
||||
T as(const S& fallback) const;
|
||||
const std::string& Scalar() const;
|
||||
|
||||
const std::string& Tag() const;
|
||||
void SetTag(const std::string& tag);
|
||||
|
||||
// style
|
||||
// WARNING: This API might change in future releases.
|
||||
EmitterStyle::value Style() const;
|
||||
void SetStyle(EmitterStyle::value style);
|
||||
|
||||
// assignment
|
||||
bool is(const Node& rhs) const;
|
||||
template <typename T>
|
||||
Node& operator=(const T& rhs);
|
||||
Node& operator=(const Node& rhs);
|
||||
void reset(const Node& rhs = Node());
|
||||
|
||||
// size/iterator
|
||||
std::size_t size() const;
|
||||
|
||||
const_iterator begin() const;
|
||||
iterator begin();
|
||||
|
||||
const_iterator end() const;
|
||||
iterator end();
|
||||
|
||||
// sequence
|
||||
template <typename T>
|
||||
void push_back(const T& rhs);
|
||||
void push_back(const Node& rhs);
|
||||
|
||||
// indexing
|
||||
template <typename Key>
|
||||
const Node operator[](const Key& key) const;
|
||||
template <typename Key>
|
||||
Node operator[](const Key& key);
|
||||
template <typename Key>
|
||||
bool remove(const Key& key);
|
||||
|
||||
const Node operator[](const Node& key) const;
|
||||
Node operator[](const Node& key);
|
||||
bool remove(const Node& key);
|
||||
|
||||
// map
|
||||
template <typename Key, typename Value>
|
||||
void force_insert(const Key& key, const Value& value);
|
||||
|
||||
private:
|
||||
enum Zombie { ZombieNode };
|
||||
explicit Node(Zombie);
|
||||
explicit Node(Zombie, const std::string&);
|
||||
explicit Node(detail::node& node, detail::shared_memory_holder pMemory);
|
||||
|
||||
void EnsureNodeExists() const;
|
||||
|
||||
template <typename T>
|
||||
void Assign(const T& rhs);
|
||||
void Assign(const char* rhs);
|
||||
void Assign(char* rhs);
|
||||
|
||||
void AssignData(const Node& rhs);
|
||||
void AssignNode(const Node& rhs);
|
||||
|
||||
private:
|
||||
bool m_isValid;
|
||||
// String representation of invalid key, if the node is invalid.
|
||||
std::string m_invalidKey;
|
||||
mutable detail::shared_memory_holder m_pMemory;
|
||||
mutable detail::node* m_pNode;
|
||||
};
|
||||
|
||||
YAML_CPP_API bool operator==(const Node& lhs, const Node& rhs);
|
||||
|
||||
YAML_CPP_API Node Clone(const Node& node);
|
||||
|
||||
template <typename T>
|
||||
struct convert;
|
||||
}
|
||||
|
||||
#endif // NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
78
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/parse.h
vendored
Normal file
78
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/parse.h
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
#ifndef VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
|
||||
namespace YAML {
|
||||
class Node;
|
||||
|
||||
/**
|
||||
* Loads the input string as a single YAML document.
|
||||
*
|
||||
* @throws {@link ParserException} if it is malformed.
|
||||
*/
|
||||
YAML_CPP_API Node Load(const std::string& input);
|
||||
|
||||
/**
|
||||
* Loads the input string as a single YAML document.
|
||||
*
|
||||
* @throws {@link ParserException} if it is malformed.
|
||||
*/
|
||||
YAML_CPP_API Node Load(const char* input);
|
||||
|
||||
/**
|
||||
* Loads the input stream as a single YAML document.
|
||||
*
|
||||
* @throws {@link ParserException} if it is malformed.
|
||||
*/
|
||||
YAML_CPP_API Node Load(std::istream& input);
|
||||
|
||||
/**
|
||||
* Loads the input file as a single YAML document.
|
||||
*
|
||||
* @throws {@link ParserException} if it is malformed.
|
||||
* @throws {@link BadFile} if the file cannot be loaded.
|
||||
*/
|
||||
YAML_CPP_API Node LoadFile(const std::string& filename);
|
||||
|
||||
/**
|
||||
* Loads the input string as a list of YAML documents.
|
||||
*
|
||||
* @throws {@link ParserException} if it is malformed.
|
||||
*/
|
||||
YAML_CPP_API std::vector<Node> LoadAll(const std::string& input);
|
||||
|
||||
/**
|
||||
* Loads the input string as a list of YAML documents.
|
||||
*
|
||||
* @throws {@link ParserException} if it is malformed.
|
||||
*/
|
||||
YAML_CPP_API std::vector<Node> LoadAll(const char* input);
|
||||
|
||||
/**
|
||||
* Loads the input stream as a list of YAML documents.
|
||||
*
|
||||
* @throws {@link ParserException} if it is malformed.
|
||||
*/
|
||||
YAML_CPP_API std::vector<Node> LoadAll(std::istream& input);
|
||||
|
||||
/**
|
||||
* Loads the input file as a list of YAML documents.
|
||||
*
|
||||
* @throws {@link ParserException} if it is malformed.
|
||||
* @throws {@link BadFile} if the file cannot be loaded.
|
||||
*/
|
||||
YAML_CPP_API std::vector<Node> LoadAllFromFile(const std::string& filename);
|
||||
} // namespace YAML
|
||||
|
||||
#endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
29
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/ptr.h
vendored
Normal file
29
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/ptr.h
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include <memory>
|
||||
|
||||
namespace YAML {
|
||||
namespace detail {
|
||||
class node;
|
||||
class node_ref;
|
||||
class node_data;
|
||||
class memory;
|
||||
class memory_holder;
|
||||
|
||||
using shared_node = std::shared_ptr<node>;
|
||||
using shared_node_ref = std::shared_ptr<node_ref>;
|
||||
using shared_node_data = std::shared_ptr<node_data>;
|
||||
using shared_memory_holder = std::shared_ptr<memory_holder>;
|
||||
using shared_memory = std::shared_ptr<memory>;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
16
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/type.h
vendored
Normal file
16
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/node/type.h
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
namespace YAML {
|
||||
struct NodeType {
|
||||
enum value { Undefined, Null, Scalar, Sequence, Map };
|
||||
};
|
||||
}
|
||||
|
||||
#endif // VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
18
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/noexcept.h
vendored
Normal file
18
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/noexcept.h
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef NOEXCEPT_H_768872DA_476C_11EA_88B8_90B11C0C0FF8
|
||||
#define NOEXCEPT_H_768872DA_476C_11EA_88B8_90B11C0C0FF8
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// This is here for compatibility with older versions of Visual Studio
|
||||
// which don't support noexcept.
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#define YAML_CPP_NOEXCEPT _NOEXCEPT
|
||||
#else
|
||||
#define YAML_CPP_NOEXCEPT noexcept
|
||||
#endif
|
||||
|
||||
#endif
|
||||
26
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/null.h
vendored
Normal file
26
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/null.h
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include <string>
|
||||
|
||||
namespace YAML {
|
||||
class Node;
|
||||
|
||||
struct YAML_CPP_API _Null {};
|
||||
inline bool operator==(const _Null&, const _Null&) { return true; }
|
||||
inline bool operator!=(const _Null&, const _Null&) { return false; }
|
||||
|
||||
YAML_CPP_API bool IsNull(const Node& node); // old API only
|
||||
YAML_CPP_API bool IsNullString(const std::string& str);
|
||||
|
||||
extern YAML_CPP_API _Null Null;
|
||||
}
|
||||
|
||||
#endif // NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
76
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/ostream_wrapper.h
vendored
Normal file
76
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/ostream_wrapper.h
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
#ifndef OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
|
||||
namespace YAML {
|
||||
class YAML_CPP_API ostream_wrapper {
|
||||
public:
|
||||
ostream_wrapper();
|
||||
explicit ostream_wrapper(std::ostream& stream);
|
||||
ostream_wrapper(const ostream_wrapper&) = delete;
|
||||
ostream_wrapper(ostream_wrapper&&) = delete;
|
||||
ostream_wrapper& operator=(const ostream_wrapper&) = delete;
|
||||
ostream_wrapper& operator=(ostream_wrapper&&) = delete;
|
||||
~ostream_wrapper();
|
||||
|
||||
void write(const std::string& str);
|
||||
void write(const char* str, std::size_t size);
|
||||
|
||||
void set_comment() { m_comment = true; }
|
||||
|
||||
const char* str() const {
|
||||
if (m_pStream) {
|
||||
return nullptr;
|
||||
} else {
|
||||
m_buffer[m_pos] = '\0';
|
||||
return &m_buffer[0];
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t row() const { return m_row; }
|
||||
std::size_t col() const { return m_col; }
|
||||
std::size_t pos() const { return m_pos; }
|
||||
bool comment() const { return m_comment; }
|
||||
|
||||
private:
|
||||
void update_pos(char ch);
|
||||
|
||||
private:
|
||||
mutable std::vector<char> m_buffer;
|
||||
std::ostream* const m_pStream;
|
||||
|
||||
std::size_t m_pos;
|
||||
std::size_t m_row, m_col;
|
||||
bool m_comment;
|
||||
};
|
||||
|
||||
template <std::size_t N>
|
||||
inline ostream_wrapper& operator<<(ostream_wrapper& stream,
|
||||
const char (&str)[N]) {
|
||||
stream.write(str, N - 1);
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline ostream_wrapper& operator<<(ostream_wrapper& stream,
|
||||
const std::string& str) {
|
||||
stream.write(str);
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline ostream_wrapper& operator<<(ostream_wrapper& stream, char ch) {
|
||||
stream.write(&ch, 1);
|
||||
return stream;
|
||||
}
|
||||
} // namespace YAML
|
||||
|
||||
#endif // OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
90
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/parser.h
vendored
Normal file
90
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/parser.h
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
#ifndef PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <ios>
|
||||
#include <memory>
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
|
||||
namespace YAML {
|
||||
class EventHandler;
|
||||
class Node;
|
||||
class Scanner;
|
||||
struct Directives;
|
||||
struct Token;
|
||||
|
||||
/**
|
||||
* A parser turns a stream of bytes into one stream of "events" per YAML
|
||||
* document in the input stream.
|
||||
*/
|
||||
class YAML_CPP_API Parser {
|
||||
public:
|
||||
/** Constructs an empty parser (with no input. */
|
||||
Parser();
|
||||
|
||||
Parser(const Parser&) = delete;
|
||||
Parser(Parser&&) = delete;
|
||||
Parser& operator=(const Parser&) = delete;
|
||||
Parser& operator=(Parser&&) = delete;
|
||||
|
||||
/**
|
||||
* Constructs a parser from the given input stream. The input stream must
|
||||
* live as long as the parser.
|
||||
*/
|
||||
explicit Parser(std::istream& in);
|
||||
|
||||
~Parser();
|
||||
|
||||
/** Evaluates to true if the parser has some valid input to be read. */
|
||||
explicit operator bool() const;
|
||||
|
||||
/**
|
||||
* Resets the parser with the given input stream. Any existing state is
|
||||
* erased.
|
||||
*/
|
||||
void Load(std::istream& in);
|
||||
|
||||
/**
|
||||
* Handles the next document by calling events on the {@code eventHandler}.
|
||||
*
|
||||
* @throw a ParserException on error.
|
||||
* @return false if there are no more documents
|
||||
*/
|
||||
bool HandleNextDocument(EventHandler& eventHandler);
|
||||
|
||||
void PrintTokens(std::ostream& out);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Reads any directives that are next in the queue, setting the internal
|
||||
* {@code m_pDirectives} state.
|
||||
*/
|
||||
void ParseDirectives();
|
||||
|
||||
void HandleDirective(const Token& token);
|
||||
|
||||
/**
|
||||
* Handles a "YAML" directive, which should be of the form 'major.minor' (like
|
||||
* a version number).
|
||||
*/
|
||||
void HandleYamlDirective(const Token& token);
|
||||
|
||||
/**
|
||||
* Handles a "TAG" directive, which should be of the form 'handle prefix',
|
||||
* where 'handle' is converted to 'prefix' in the file.
|
||||
*/
|
||||
void HandleTagDirective(const Token& token);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Scanner> m_pScanner;
|
||||
std::unique_ptr<Directives> m_pDirectives;
|
||||
};
|
||||
} // namespace YAML
|
||||
|
||||
#endif // PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
50
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/stlemitter.h
vendored
Normal file
50
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/stlemitter.h
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
namespace YAML {
|
||||
template <typename Seq>
|
||||
inline Emitter& EmitSeq(Emitter& emitter, const Seq& seq) {
|
||||
emitter << BeginSeq;
|
||||
for (const auto& v : seq)
|
||||
emitter << v;
|
||||
emitter << EndSeq;
|
||||
return emitter;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline Emitter& operator<<(Emitter& emitter, const std::vector<T>& v) {
|
||||
return EmitSeq(emitter, v);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline Emitter& operator<<(Emitter& emitter, const std::list<T>& v) {
|
||||
return EmitSeq(emitter, v);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline Emitter& operator<<(Emitter& emitter, const std::set<T>& v) {
|
||||
return EmitSeq(emitter, v);
|
||||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
inline Emitter& operator<<(Emitter& emitter, const std::map<K, V>& m) {
|
||||
emitter << BeginMap;
|
||||
for (const auto& v : m)
|
||||
emitter << Key << v.first << Value << v.second;
|
||||
emitter << EndMap;
|
||||
return emitter;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
135
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/traits.h
vendored
Normal file
135
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/traits.h
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
#ifndef TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace YAML {
|
||||
template <typename>
|
||||
struct is_numeric {
|
||||
enum { value = false };
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_numeric<char> {
|
||||
enum { value = true };
|
||||
};
|
||||
template <>
|
||||
struct is_numeric<unsigned char> {
|
||||
enum { value = true };
|
||||
};
|
||||
template <>
|
||||
struct is_numeric<int> {
|
||||
enum { value = true };
|
||||
};
|
||||
template <>
|
||||
struct is_numeric<unsigned int> {
|
||||
enum { value = true };
|
||||
};
|
||||
template <>
|
||||
struct is_numeric<long int> {
|
||||
enum { value = true };
|
||||
};
|
||||
template <>
|
||||
struct is_numeric<unsigned long int> {
|
||||
enum { value = true };
|
||||
};
|
||||
template <>
|
||||
struct is_numeric<short int> {
|
||||
enum { value = true };
|
||||
};
|
||||
template <>
|
||||
struct is_numeric<unsigned short int> {
|
||||
enum { value = true };
|
||||
};
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1310)
|
||||
template <>
|
||||
struct is_numeric<__int64> {
|
||||
enum { value = true };
|
||||
};
|
||||
template <>
|
||||
struct is_numeric<unsigned __int64> {
|
||||
enum { value = true };
|
||||
};
|
||||
#else
|
||||
template <>
|
||||
struct is_numeric<long long> {
|
||||
enum { value = true };
|
||||
};
|
||||
template <>
|
||||
struct is_numeric<unsigned long long> {
|
||||
enum { value = true };
|
||||
};
|
||||
#endif
|
||||
template <>
|
||||
struct is_numeric<float> {
|
||||
enum { value = true };
|
||||
};
|
||||
template <>
|
||||
struct is_numeric<double> {
|
||||
enum { value = true };
|
||||
};
|
||||
template <>
|
||||
struct is_numeric<long double> {
|
||||
enum { value = true };
|
||||
};
|
||||
|
||||
template <bool, class T = void>
|
||||
struct enable_if_c {
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct enable_if_c<false, T> {};
|
||||
|
||||
template <class Cond, class T = void>
|
||||
struct enable_if : public enable_if_c<Cond::value, T> {};
|
||||
|
||||
template <bool, class T = void>
|
||||
struct disable_if_c {
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct disable_if_c<true, T> {};
|
||||
|
||||
template <class Cond, class T = void>
|
||||
struct disable_if : public disable_if_c<Cond::value, T> {};
|
||||
}
|
||||
|
||||
template <typename S, typename T>
|
||||
struct is_streamable {
|
||||
template <typename SS, typename TT>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<SS&>() << std::declval<TT>(), std::true_type());
|
||||
|
||||
template <typename, typename>
|
||||
static auto test(...) -> std::false_type;
|
||||
|
||||
static const bool value = decltype(test<S, T>(0))::value;
|
||||
};
|
||||
|
||||
template<typename Key, bool Streamable>
|
||||
struct streamable_to_string {
|
||||
static std::string impl(const Key& key) {
|
||||
std::stringstream ss;
|
||||
ss << key;
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Key>
|
||||
struct streamable_to_string<Key, false> {
|
||||
static std::string impl(const Key&) {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
#endif // TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
24
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/yaml.h
vendored
Normal file
24
Plugins/GameLiftPlugin/Source/CoreSDK/ThirdParty/yaml-cpp/include/yaml-cpp/yaml.h
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
|
||||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/parser.h"
|
||||
#include "yaml-cpp/emitter.h"
|
||||
#include "yaml-cpp/emitterstyle.h"
|
||||
#include "yaml-cpp/stlemitter.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
|
||||
#include "yaml-cpp/node/node.h"
|
||||
#include "yaml-cpp/node/impl.h"
|
||||
#include "yaml-cpp/node/convert.h"
|
||||
#include "yaml-cpp/node/iterator.h"
|
||||
#include "yaml-cpp/node/detail/impl.h"
|
||||
#include "yaml-cpp/node/parse.h"
|
||||
#include "yaml-cpp/node/emit.h"
|
||||
|
||||
#endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
Reference in New Issue
Block a user