summaryrefslogtreecommitdiff
path: root/src/lib/util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-10-17 00:06:10 +0100
committerCarl Hetherington <cth@carlh.net>2012-10-17 00:06:10 +0100
commit7ef2ba523ca2ddc0470f5837bc88ad9c597361e2 (patch)
tree9aaa33632f2c41e8c3129543c8214c8c3d7274cb /src/lib/util.cc
parent9e93c860759b8d04277596781706488f59a3cc12 (diff)
parentc37c744bbb236b1fd39f86e4f0ab36652d403d67 (diff)
Merge branch 'master' of /home/carl/git/dvdomatic
Diffstat (limited to 'src/lib/util.cc')
-rw-r--r--src/lib/util.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc
index c2b24944d..cc201a0af 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -615,6 +615,12 @@ Rectangle::intersection (Rectangle const & other) const
);
}
+/** Round a number up to the nearest multiple of another number.
+ * @param a Number to round.
+ * @param t Multiple to round to.
+ * @return Rounded number.
+ */
+
int
round_up (int a, int t)
{
@@ -622,6 +628,13 @@ round_up (int a, int t)
return a - (a % t);
}
+/** Read a sequence of key / value pairs from a text stream;
+ * the keys are the first words on the line, and the values are
+ * the remainder of the line following the key. Lines beginning
+ * with # are ignored.
+ * @param s Stream to read.
+ * @return key/value pairs.
+ */
multimap<string, string>
read_key_value (istream &s)
{
@@ -675,6 +688,13 @@ get_required_int (multimap<string, string> const & kv, string k)
return lexical_cast<int> (v);
}
+float
+get_required_float (multimap<string, string> const & kv, string k)
+{
+ string const v = get_required_string (kv, k);
+ return lexical_cast<float> (v);
+}
+
string
get_optional_string (multimap<string, string> const & kv, string k)
{