1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/src/cplus/rcbase.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 +** RCBase.h - Mixin class for NSPR C++ wrappers 1.11 +*/ 1.12 + 1.13 +#if defined(_RCRUNTIME_H) 1.14 +#else 1.15 +#define _RCRUNTIME_H 1.16 + 1.17 +#include <prerror.h> 1.18 + 1.19 +/* 1.20 +** Class: RCBase (mixin) 1.21 +** 1.22 +** Generally mixed into every base class. The functions in this class are all 1.23 +** static. Therefore this entire class is just syntatic sugar. It gives the 1.24 +** illusion that errors (in particular) are retrieved via the same object 1.25 +** that just reported a failure. It also (unfortunately) might lead one to 1.26 +** believe that the errors are persistent in that object. They're not. 1.27 +*/ 1.28 + 1.29 +class PR_IMPLEMENT(RCBase) 1.30 +{ 1.31 +public: 1.32 + virtual ~RCBase(); 1.33 + 1.34 + static void AbortSelf(); 1.35 + 1.36 + static PRErrorCode GetError(); 1.37 + static PRInt32 GetOSError(); 1.38 + 1.39 + static PRSize GetErrorTextLength(); 1.40 + static PRSize CopyErrorText(char *text); 1.41 + 1.42 + static void SetError(PRErrorCode error, PRInt32 oserror); 1.43 + static void SetErrorText(PRSize textLength, const char *text); 1.44 + 1.45 +protected: 1.46 + RCBase() { } 1.47 +}; /* RCObject */ 1.48 + 1.49 +inline PRErrorCode RCBase::GetError() { return PR_GetError(); } 1.50 +inline PRInt32 RCBase::GetOSError() { return PR_GetOSError(); } 1.51 + 1.52 +#endif /* defined(_RCRUNTIME_H) */ 1.53 + 1.54 +/* rcbase.h */