1/*
2 * Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _ERRNO_MAINTAINER_H
6#define _ERRNO_MAINTAINER_H
7
8
9#include <errno.h>
10
11
12namespace BPrivate {
13
14
15/**
16 * A helper class resetting errno to 0 if it has been set during the execution
17 * of ICU methods. Any changes of errno shall only be done by our callers.
18 */
19class ErrnoMaintainer {
20public:
21	ErrnoMaintainer()
22		: fErrnoUponEntry(errno)
23	{
24	}
25
26	~ErrnoMaintainer()
27	{
28		errno = fErrnoUponEntry;
29	}
30
31private:
32	int fErrnoUponEntry;
33};
34
35
36}	// namespace BPrivate
37
38
39#endif	// _ERRNO_MAINTAINER_H
40