tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

rcbase.h (1439B)


      1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 /*
      7 ** RCBase.h - Mixin class for NSPR C++ wrappers
      8 */
      9 
     10 #if defined(_RCRUNTIME_H)
     11 #else
     12 #define _RCRUNTIME_H
     13 
     14 #include <prerror.h>
     15 
     16 /*
     17 ** Class: RCBase (mixin)
     18 **
     19 ** Generally mixed into every base class. The functions in this class are all
     20 ** static. Therefore this entire class is just syntatic sugar. It gives the
     21 ** illusion that errors (in particular) are retrieved via the same object
     22 ** that just reported a failure. It also (unfortunately) might lead one to
     23 ** believe that the errors are persistent in that object. They're not.
     24 */
     25 
     26 class PR_IMPLEMENT(RCBase)
     27 {
     28 public:
     29    virtual ~RCBase();
     30 
     31    static void AbortSelf();
     32 
     33    static PRErrorCode GetError();
     34    static PRInt32 GetOSError();
     35 
     36    static PRSize GetErrorTextLength();
     37    static PRSize CopyErrorText(char *text);
     38 
     39    static void SetError(PRErrorCode error, PRInt32 oserror);
     40    static void SetErrorText(PRSize textLength, const char *text);
     41 
     42 protected:
     43    RCBase() { }
     44 };  /* RCObject */
     45 
     46 inline PRErrorCode RCBase::GetError() {
     47    return PR_GetError();
     48 }
     49 inline PRInt32 RCBase::GetOSError() {
     50    return PR_GetOSError();
     51 }
     52 
     53 #endif  /* defined(_RCRUNTIME_H) */
     54 
     55 /* rcbase.h */