Utilities.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * The contents of this file are subject to the Mozilla Public
  3. * License Version 1.1 (the "License"); you may not use this file
  4. * except in compliance with the License. You may obtain a copy of
  5. * the License at http://www.mozilla.org/MPL/
  6. *
  7. * Software distributed under the License is distributed on an "AS
  8. * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9. * implied. See the License for the specific language governing
  10. * rights and limitations under the License.
  11. *
  12. * The Original Code is Vision.
  13. *
  14. * The Initial Developer of the Original Code is The Vision Team.
  15. * Portions created by The Vision Team are
  16. * Copyright (C) 1999, 2000, 2001 The Vision Team. All Rights
  17. * Reserved.
  18. *
  19. * Contributor(s): Wade Majors <wade@ezri.org>
  20. * Todd Lair
  21. * Andrew Bazan
  22. */
  23. #ifndef _UTILITIES_H
  24. #define _UTILITIES_H_
  25. #include <String.h>
  26. template<class T> class AutoDestructor {
  27. public:
  28. AutoDestructor(T *t)
  29. {
  30. fObject = t;
  31. }
  32. virtual ~AutoDestructor(void)
  33. {
  34. delete fObject;
  35. }
  36. void SetTo(T *t)
  37. {
  38. delete fObject;
  39. fObject = t;
  40. }
  41. private:
  42. T *fObject;
  43. };
  44. class BMessage;
  45. class BPoint;
  46. BString GetWord (const char *, int32);
  47. BString RestOfString (const char *, int32);
  48. BString GetNick (const char *);
  49. BString GetIdent (const char *);
  50. BString GetAddress (const char *);
  51. BString TimeStamp (void);
  52. BString ExpandKeyed (const char *, const char *, const char **);
  53. BString DurationString (int64);
  54. BString StringToURI (const char *);
  55. const char *RelToAbsPath (const char *);
  56. BString GetWordColon (const char *, int32);
  57. int32 Get440Len (const char *);
  58. uint16 CheckClickCount(BPoint, BPoint &, bigtime_t, bigtime_t &, int16 &);
  59. bool IsValidUTF8(const char *string, int32 length);
  60. #endif