2cb26c0ab0
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37931 a95241bf-73f2-0310-859d-f6bbb57e9c96
40 lines
637 B
C++
40 lines
637 B
C++
/*
|
|
* Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _ERRNO_MAINTAINER_H
|
|
#define _ERRNO_MAINTAINER_H
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
/**
|
|
* A helper class resetting errno to 0 if it has been set during the execution
|
|
* of ICU methods. Any changes of errno shall only be done by our callers.
|
|
*/
|
|
class ErrnoMaintainer {
|
|
public:
|
|
ErrnoMaintainer()
|
|
: fErrnoUponEntry(errno)
|
|
{
|
|
}
|
|
|
|
~ErrnoMaintainer()
|
|
{
|
|
if (errno != 0 && fErrnoUponEntry == 0)
|
|
errno = 0;
|
|
}
|
|
private:
|
|
int fErrnoUponEntry;
|
|
};
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
|
|
#endif // _ERRNO_MAINTAINER_H
|