summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-06-03 19:52:31 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-06-03 21:17:58 +0200
commitccc6e69a294edacf7bec77cb2c2640ada7fe1f77 (patch)
tree49b05e95d9003b7f1f4f66620c3e051a27648d91 /AK
parente92fe52031be8d502cf0e6aa08bd2037a11096e9 (diff)
downloadserenity-ccc6e69a294edacf7bec77cb2c2640ada7fe1f77.zip
LibC: Implement popen() and pclose().
I feel reasonably confident that I might have gotten these right. :^)
Diffstat (limited to 'AK')
-rw-r--r--AK/ValueRestorer.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/AK/ValueRestorer.h b/AK/ValueRestorer.h
new file mode 100644
index 0000000000..99fa43e187
--- /dev/null
+++ b/AK/ValueRestorer.h
@@ -0,0 +1,26 @@
+#pragma once
+
+namespace AK {
+
+template<typename T>
+class ValueRestorer {
+public:
+ ValueRestorer(T& variable)
+ : m_variable(variable)
+ , m_saved_value(variable)
+ {
+ }
+
+ ~ValueRestorer()
+ {
+ m_variable = m_saved_value;
+ }
+
+private:
+ T& m_variable;
+ T m_saved_value;
+};
+
+}
+
+using AK::ValueRestorer;