12cb26c0aSOliver Tappe /* 22cb26c0aSOliver Tappe * Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de. 32cb26c0aSOliver Tappe * Distributed under the terms of the MIT License. 42cb26c0aSOliver Tappe */ 52cb26c0aSOliver Tappe #ifndef _ERRNO_MAINTAINER_H 62cb26c0aSOliver Tappe #define _ERRNO_MAINTAINER_H 72cb26c0aSOliver Tappe 82cb26c0aSOliver Tappe 92cb26c0aSOliver Tappe #include <errno.h> 102cb26c0aSOliver Tappe 112cb26c0aSOliver Tappe 122cb26c0aSOliver Tappe namespace BPrivate { 132cb26c0aSOliver Tappe 142cb26c0aSOliver Tappe 152cb26c0aSOliver Tappe /** 162cb26c0aSOliver Tappe * A helper class resetting errno to 0 if it has been set during the execution 172cb26c0aSOliver Tappe * of ICU methods. Any changes of errno shall only be done by our callers. 182cb26c0aSOliver Tappe */ 192cb26c0aSOliver Tappe class ErrnoMaintainer { 202cb26c0aSOliver Tappe public: ErrnoMaintainer()212cb26c0aSOliver Tappe ErrnoMaintainer() 222cb26c0aSOliver Tappe : fErrnoUponEntry(errno) 232cb26c0aSOliver Tappe { 242cb26c0aSOliver Tappe } 252cb26c0aSOliver Tappe ~ErrnoMaintainer()262cb26c0aSOliver Tappe ~ErrnoMaintainer() 272cb26c0aSOliver Tappe { 28*1f848981SOliver Tappe errno = fErrnoUponEntry; 292cb26c0aSOliver Tappe } 30*1f848981SOliver Tappe 312cb26c0aSOliver Tappe private: 322cb26c0aSOliver Tappe int fErrnoUponEntry; 332cb26c0aSOliver Tappe }; 342cb26c0aSOliver Tappe 352cb26c0aSOliver Tappe 362cb26c0aSOliver Tappe } // namespace BPrivate 372cb26c0aSOliver Tappe 382cb26c0aSOliver Tappe 392cb26c0aSOliver Tappe #endif // _ERRNO_MAINTAINER_H 40