clang-format: Indent namespaces

This commit is contained in:
tt2468
2022-06-08 00:37:04 -07:00
parent 22fee0312d
commit 5b8fd096d5
13 changed files with 310 additions and 313 deletions

View File

@ -64,7 +64,7 @@ IndentWidth: 8
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
NamespaceIndentation: All
#ObjCBinPackProtocolList: Auto # requires clang-format 7
ObjCBlockIndentWidth: 8
ObjCSpaceAfterProperty: true

View File

@ -20,7 +20,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#pragma once
namespace EventSubscription {
enum EventSubscription {
enum EventSubscription {
/**
* Subcription value used to disable all events.
*
@ -163,7 +163,8 @@ enum EventSubscription {
* @initialVersion 5.0.0
* @api enums
*/
All = (General | Config | Scenes | Inputs | Transitions | Filters | Outputs | SceneItems | MediaInputs | Vendors | Ui),
All = (General | Config | Scenes | Inputs | Transitions | Filters | Outputs | SceneItems | MediaInputs | Vendors |
Ui),
/**
* Subscription value to receive the `InputVolumeMeters` high-volume event.
*
@ -208,5 +209,5 @@ enum EventSubscription {
* @api enums
*/
SceneItemTransformChanged = (1 << 19),
};
};
}

View File

@ -24,7 +24,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include "rpc/RequestBatchRequest.h"
namespace RequestBatchHandler {
std::vector<RequestResult> ProcessRequestBatch(QThreadPool &threadPool, SessionPtr session,
std::vector<RequestResult> ProcessRequestBatch(QThreadPool &threadPool, SessionPtr session,
RequestBatchExecutionType::RequestBatchExecutionType executionType,
std::vector<RequestBatchRequest> &requests, json &variables, bool haltOnFailure);
std::vector<RequestBatchRequest> &requests, json &variables,
bool haltOnFailure);
}

View File

@ -22,7 +22,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <stdint.h>
namespace RequestBatchExecutionType {
enum RequestBatchExecutionType : int8_t {
enum RequestBatchExecutionType : int8_t {
/**
* Not a request batch.
*
@ -75,10 +75,7 @@ enum RequestBatchExecutionType : int8_t {
* @api enums
*/
Parallel = 2,
};
};
inline bool IsValid(int8_t executionType)
{
return executionType >= None && executionType <= Parallel;
}
inline bool IsValid(int8_t executionType) { return executionType >= None && executionType <= Parallel; }
}

View File

@ -20,7 +20,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#pragma once
namespace RequestStatus {
enum RequestStatus {
enum RequestStatus {
/**
* Unknown status, should never be used.
*
@ -402,5 +402,5 @@ enum RequestStatus {
* @api enums
*/
CannotAct = 703,
};
};
}

View File

@ -23,16 +23,16 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <QRunnable>
namespace Utils {
namespace Compat {
// Reimplement QRunnable for std::function. Retrocompatability for Qt < 5.15
class StdFunctionRunnable : public QRunnable {
namespace Compat {
// Reimplement QRunnable for std::function. Retrocompatability for Qt < 5.15
class StdFunctionRunnable : public QRunnable {
std::function<void()> cb;
public:
public:
StdFunctionRunnable(std::function<void()> func);
void run() override;
};
};
QRunnable *CreateFunctionRunnable(std::function<void()> func);
}
QRunnable *CreateFunctionRunnable(std::function<void()> func);
}
}

View File

@ -23,10 +23,10 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <QString>
namespace Utils {
namespace Crypto {
std::string GenerateSalt();
std::string GenerateSecret(std::string password, std::string salt);
bool CheckAuthenticationString(std::string secret, std::string challenge, std::string authenticationString);
std::string GeneratePassword(size_t length = 16);
}
namespace Crypto {
std::string GenerateSalt();
std::string GenerateSecret(std::string password, std::string salt);
bool CheckAuthenticationString(std::string secret, std::string challenge, std::string authenticationString);
std::string GeneratePassword(size_t length = 16);
}
}

View File

@ -71,15 +71,12 @@ NLOHMANN_JSON_SERIALIZE_ENUM(obs_blending_type, {
})
namespace Utils {
namespace Json {
bool JsonArrayIsValidObsArray(const json &j);
obs_data_t *JsonToObsData(json j);
json ObsDataToJson(obs_data_t *d, bool includeDefault = false);
bool GetJsonFileContent(std::string fileName, json &content);
bool SetJsonFileContent(std::string fileName, const json &content, bool createNew = true);
static inline bool Contains(const json &j, std::string key)
{
return j.contains(key) && !j[key].is_null();
}
}
namespace Json {
bool JsonArrayIsValidObsArray(const json &j);
obs_data_t *JsonToObsData(json j);
json ObsDataToJson(obs_data_t *d, bool includeDefault = false);
bool GetJsonFileContent(std::string fileName, json &content);
bool SetJsonFileContent(std::string fileName, const json &content, bool createNew = true);
static inline bool Contains(const json &j, std::string key) { return j.contains(key) && !j[key].is_null(); }
}
}

View File

@ -172,61 +172,64 @@ NLOHMANN_JSON_SERIALIZE_ENUM(ObsMediaInputAction,
})
namespace Utils {
namespace Obs {
namespace StringHelper {
std::string GetObsVersion();
std::string GetCurrentSceneCollection();
std::string GetCurrentProfile();
std::string GetCurrentProfilePath();
std::string GetCurrentRecordOutputPath();
std::string GetLastReplayBufferFilePath();
std::string DurationToTimecode(uint64_t);
}
namespace Obs {
namespace StringHelper {
std::string GetObsVersion();
std::string GetCurrentSceneCollection();
std::string GetCurrentProfile();
std::string GetCurrentProfilePath();
std::string GetCurrentRecordOutputPath();
std::string GetLastReplayBufferFilePath();
std::string DurationToTimecode(uint64_t);
}
namespace NumberHelper {
uint64_t GetOutputDuration(obs_output_t *output);
size_t GetSceneCount();
size_t GetSourceFilterIndex(obs_source_t *source, obs_source_t *filter);
}
namespace NumberHelper {
uint64_t GetOutputDuration(obs_output_t *output);
size_t GetSceneCount();
size_t GetSourceFilterIndex(obs_source_t *source, obs_source_t *filter);
}
namespace ArrayHelper {
std::vector<std::string> GetSceneCollectionList();
std::vector<std::string> GetProfileList();
std::vector<obs_hotkey_t *> GetHotkeyList();
std::vector<std::string> GetHotkeyNameList();
std::vector<json> GetSceneList();
std::vector<std::string> GetGroupList();
std::vector<json> GetSceneItemList(obs_scene_t *scene, bool basic = false);
std::vector<json> GetInputList(std::string inputKind = "");
std::vector<std::string> GetInputKindList(bool unversioned = false, bool includeDisabled = false);
std::vector<json> GetListPropertyItems(obs_property_t *property);
std::vector<std::string> GetTransitionKindList();
std::vector<json> GetSceneTransitionList();
std::vector<json> GetSourceFilterList(obs_source_t *source);
std::vector<std::string> GetFilterKindList();
}
namespace ArrayHelper {
std::vector<std::string> GetSceneCollectionList();
std::vector<std::string> GetProfileList();
std::vector<obs_hotkey_t *> GetHotkeyList();
std::vector<std::string> GetHotkeyNameList();
std::vector<json> GetSceneList();
std::vector<std::string> GetGroupList();
std::vector<json> GetSceneItemList(obs_scene_t *scene, bool basic = false);
std::vector<json> GetInputList(std::string inputKind = "");
std::vector<std::string> GetInputKindList(bool unversioned = false, bool includeDisabled = false);
std::vector<json> GetListPropertyItems(obs_property_t *property);
std::vector<std::string> GetTransitionKindList();
std::vector<json> GetSceneTransitionList();
std::vector<json> GetSourceFilterList(obs_source_t *source);
std::vector<std::string> GetFilterKindList();
}
namespace ObjectHelper {
json GetStats();
json GetSceneItemTransform(obs_sceneitem_t *item);
}
namespace ObjectHelper {
json GetStats();
json GetSceneItemTransform(obs_sceneitem_t *item);
}
namespace SearchHelper {
obs_hotkey_t *GetHotkeyByName(std::string name);
obs_source_t *GetSceneTransitionByName(std::string name); // Increments source ref. Use OBSSourceAutoRelease
obs_sceneitem_t *GetSceneItemByName(obs_scene_t *scene, std::string name,
namespace SearchHelper {
obs_hotkey_t *GetHotkeyByName(std::string name);
obs_source_t *GetSceneTransitionByName(std::string name); // Increments source ref. Use OBSSourceAutoRelease
obs_sceneitem_t *GetSceneItemByName(obs_scene_t *scene, std::string name,
int offset = 0); // Increments ref. Use OBSSceneItemAutoRelease
}
}
namespace ActionHelper {
obs_sceneitem_t *CreateSceneItem(obs_source_t *source, obs_scene_t *scene, bool sceneItemEnabled = true,
namespace ActionHelper {
obs_sceneitem_t *
CreateSceneItem(obs_source_t *source, obs_scene_t *scene, bool sceneItemEnabled = true,
obs_transform_info *sceneItemTransform = nullptr,
obs_sceneitem_crop *sceneItemCrop = nullptr); // Increments ref. Use OBSSceneItemAutoRelease
obs_sceneitem_t *CreateInput(std::string inputName, std::string inputKind, obs_data_t *inputSettings, obs_scene_t *scene,
obs_sceneitem_t *CreateInput(std::string inputName, std::string inputKind, obs_data_t *inputSettings,
obs_scene_t *scene,
bool sceneItemEnabled = true); // Increments ref. Use OBSSceneItemAutoRelease
obs_source_t *CreateSourceFilter(obs_source_t *source, std::string filterName, std::string filterKind,
obs_source_t *
CreateSourceFilter(obs_source_t *source, std::string filterName, std::string filterKind,
obs_data_t *filterSettings); // Increments source ref. Use OBSSourceAutoRelease
void SetSourceFilterIndex(obs_source_t *source, obs_source_t *filter, size_t index);
}
}
void SetSourceFilterIndex(obs_source_t *source, obs_source_t *filter, size_t index);
}
}
}

View File

@ -31,12 +31,12 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include "Json.h"
namespace Utils {
namespace Obs {
namespace VolumeMeter {
// Some code copied from https://github.com/obsproject/obs-studio/blob/master/libobs/obs-audio-controls.c
// Keeps a running tally of the current audio levels, for a specific input
class Meter {
public:
namespace Obs {
namespace VolumeMeter {
// Some code copied from https://github.com/obsproject/obs-studio/blob/master/libobs/obs-audio-controls.c
// Keeps a running tally of the current audio levels, for a specific input
class Meter {
public:
Meter(obs_source_t *input);
~Meter();
@ -46,7 +46,7 @@ public:
std::atomic<enum obs_peak_meter_type> PeakMeterType;
private:
private:
OBSWeakSourceAutoRelease _input;
// All values in mul
@ -65,20 +65,21 @@ private:
void ProcessPeak(const struct audio_data *data);
void ProcessMagnitude(const struct audio_data *data);
static void InputAudioCaptureCallback(void *priv_data, obs_source_t *source, const struct audio_data *data, bool muted);
static void InputAudioCaptureCallback(void *priv_data, obs_source_t *source,
const struct audio_data *data, bool muted);
static void InputVolumeCallback(void *priv_data, calldata_t *cd);
};
};
// Maintains an array of active inputs
class Handler {
// Maintains an array of active inputs
class Handler {
typedef std::function<void(std::vector<json>)> UpdateCallback;
typedef std::unique_ptr<Meter> MeterPtr;
public:
public:
Handler(UpdateCallback cb, uint64_t updatePeriod = 50);
~Handler();
private:
private:
UpdateCallback _updateCallback;
std::mutex _meterMutex;
@ -93,7 +94,7 @@ private:
void UpdateThread();
static void InputActivateCallback(void *priv_data, calldata_t *cd);
static void InputDeactivateCallback(void *priv_data, calldata_t *cd);
};
}
}
};
}
}
}

View File

@ -24,12 +24,12 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <QSystemTrayIcon>
namespace Utils {
namespace Platform {
std::string GetLocalAddress();
QString GetCommandLineArgument(QString arg);
bool GetCommandLineFlagSet(QString arg);
void SendTrayNotification(QSystemTrayIcon::MessageIcon icon, QString title, QString body);
bool GetTextFileContent(std::string fileName, std::string &content);
bool SetTextFileContent(std::string filePath, std::string content, bool createNew = true);
}
namespace Platform {
std::string GetLocalAddress();
QString GetCommandLineArgument(QString arg);
bool GetCommandLineFlagSet(QString arg);
void SendTrayNotification(QSystemTrayIcon::MessageIcon icon, QString title, QString body);
bool GetTextFileContent(std::string fileName, std::string &content);
bool SetTextFileContent(std::string filePath, std::string content, bool createNew = true);
}
}

View File

@ -20,7 +20,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#pragma once
namespace WebSocketCloseCode {
enum WebSocketCloseCode {
enum WebSocketCloseCode {
/**
* For internal use only to tell the request handler not to perform any close action.
*
@ -168,5 +168,5 @@ enum WebSocketCloseCode {
* @api enums
*/
UnsupportedFeature = 4012,
};
};
}

View File

@ -20,7 +20,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#pragma once
namespace WebSocketOpCode {
enum WebSocketOpCode : uint8_t {
enum WebSocketOpCode : uint8_t {
/**
* The initial message sent by obs-websocket to newly connected clients.
*
@ -120,10 +120,7 @@ enum WebSocketOpCode : uint8_t {
* @api enums
*/
RequestBatchResponse = 9,
};
};
inline bool IsValid(uint8_t opCode)
{
return opCode >= Hello && opCode <= RequestBatchResponse;
}
inline bool IsValid(uint8_t opCode) { return opCode >= Hello && opCode <= RequestBatchResponse; }
}