aboutsummaryrefslogtreecommitdiff
path: root/primedev/util/utils.h
blob: c8cbc7e873cf5a3b3fc0aa64cc6f888f74e70e0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#pragma once

void RemoveAsciiControlSequences(char* str, bool allow_color_codes);

template <typename T> class ScopeGuard
{
public:
	auto operator=(ScopeGuard&) = delete;
	ScopeGuard(ScopeGuard&) = delete;

	ScopeGuard(T callback) : m_callback(callback) {}
	~ScopeGuard()
	{
		if (!m_dismissed)
			m_callback();
	}
	void Dismiss()
	{
		m_dismissed = true;
	}

private:
	bool m_dismissed = false;
	T m_callback;
};