[haiku-commits] haiku: hrev45766 - src/apps/webpositive/support

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 16 Jun 2013 14:07:54 +0200 (CEST)

hrev45766 adds 1 changeset to branch 'master'
old head: 3d319aec2612dfdc4bd8a53e957ef302378c5bc6
new head: 2fd5f1736a6dfe230cae0c0f784fcad4b5f74473
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=2fd5f17+%5E3d319ae

----------------------------------------------------------------------------

2fd5f17: WebPositive: Now that it lives in the tree, get rid of the copied 
shared code.

                                      [ Stephan Aßmus <superstippi@xxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev45766
Commit:      2fd5f1736a6dfe230cae0c0f784fcad4b5f74473
URL:         http://cgit.haiku-os.org/haiku/commit/?id=2fd5f17
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sun Jun 16 12:06:16 2013 UTC

----------------------------------------------------------------------------

19 files changed, 18 insertions(+), 4710 deletions(-)
src/apps/webpositive/BrowserApp.cpp            |    1 -
src/apps/webpositive/BrowserWindow.cpp         |    8 +-
src/apps/webpositive/BrowserWindow.h           |   15 +-
src/apps/webpositive/Jamfile                   |   13 +-
src/apps/webpositive/support/AutoLocker.h      |  178 ---
src/apps/webpositive/support/DateTime.cpp      | 1473 --------------------
src/apps/webpositive/support/DateTime.h        |  225 ---
src/apps/webpositive/support/HashMap.h         |  481 -------
src/apps/webpositive/support/HashSet.h         |  342 -----
src/apps/webpositive/support/IconButton.cpp    |  929 ------------
src/apps/webpositive/support/IconButton.h      |  134 --
src/apps/webpositive/support/IconUtils.h       |   80 --
src/apps/webpositive/support/NavMenu.h         |  168 ---
src/apps/webpositive/support/OpenHashTable.h   |  514 -------
src/apps/webpositive/support/SlowMenu.h        |   76 -
src/apps/webpositive/support/StringForSize.cpp |   43 -
src/apps/webpositive/support/StringForSize.h   |   23 -
src/apps/webpositive/svn_revision.cpp          |   10 -
src/apps/webpositive/svn_revision.h            |   15 -

----------------------------------------------------------------------------

diff --git a/src/apps/webpositive/BrowserApp.cpp 
b/src/apps/webpositive/BrowserApp.cpp
index 131952d..5b17b6c 100644
--- a/src/apps/webpositive/BrowserApp.cpp
+++ b/src/apps/webpositive/BrowserApp.cpp
@@ -47,7 +47,6 @@
 #include "DownloadWindow.h"
 #include "SettingsMessage.h"
 #include "SettingsWindow.h"
-#include "svn_revision.h"
 #include "NetworkCookieJar.h"
 #include "WebKitInfo.h"
 #include "WebPage.h"
diff --git a/src/apps/webpositive/BrowserWindow.cpp 
b/src/apps/webpositive/BrowserWindow.cpp
index 7785796..b833da0 100644
--- a/src/apps/webpositive/BrowserWindow.cpp
+++ b/src/apps/webpositive/BrowserWindow.cpp
@@ -462,19 +462,19 @@ BrowserWindow::BrowserWindow(BRect frame, 
SettingsMessage* appSettings,
        }
 
        // Back, Forward, Stop & Home buttons
-       fBackButton = new IconButton("Back", 0, NULL, new BMessage(GO_BACK));
+       fBackButton = new BIconButton("Back", NULL, new BMessage(GO_BACK));
        fBackButton->SetIcon(201);
        fBackButton->TrimIcon();
 
-       fForwardButton = new IconButton("Forward", 0, NULL, new 
BMessage(GO_FORWARD));
+       fForwardButton = new BIconButton("Forward", NULL, new 
BMessage(GO_FORWARD));
        fForwardButton->SetIcon(202);
        fForwardButton->TrimIcon();
 
-       fStopButton = new IconButton("Stop", 0, NULL, new BMessage(STOP));
+       fStopButton = new BIconButton("Stop", NULL, new BMessage(STOP));
        fStopButton->SetIcon(204);
        fStopButton->TrimIcon();
 
-       fHomeButton = new IconButton("Home", 0, NULL, new BMessage(HOME));
+       fHomeButton = new BIconButton("Home", NULL, new BMessage(HOME));
        fHomeButton->SetIcon(206);
        fHomeButton->TrimIcon();
        if (!fAppSettings->GetValue(kSettingsKeyShowHomeButton, true))
diff --git a/src/apps/webpositive/BrowserWindow.h 
b/src/apps/webpositive/BrowserWindow.h
index bf80d75..5b87aa3 100644
--- a/src/apps/webpositive/BrowserWindow.h
+++ b/src/apps/webpositive/BrowserWindow.h
@@ -47,11 +47,16 @@ class BStatusBar;
 class BStringView;
 class BTextControl;
 class BWebView;
-class IconButton;
 class SettingsMessage;
 class TabManager;
 class URLInputGroup;
 
+namespace BPrivate {
+       class BIconButton;
+}
+
+using BPrivate::BIconButton;
+
 enum {
        INTERFACE_ELEMENT_MENU                  = 1 << 0,
        INTERFACE_ELEMENT_TABS                  = 1 << 1,
@@ -214,10 +219,10 @@ private:
                        BMenuItem*                      fBackMenuItem;
                        BMenuItem*                      fForwardMenuItem;
 
-                       IconButton*                     fBackButton;
-                       IconButton*                     fForwardButton;
-                       IconButton*                     fStopButton;
-                       IconButton*                     fHomeButton;
+                       BIconButton*            fBackButton;
+                       BIconButton*            fForwardButton;
+                       BIconButton*            fStopButton;
+                       BIconButton*            fHomeButton;
                        URLInputGroup*          fURLInputGroup;
                        BStringView*            fStatusText;
                        BStatusBar*                     fLoadingProgressBar;
diff --git a/src/apps/webpositive/Jamfile b/src/apps/webpositive/Jamfile
index a287626..584d377 100644
--- a/src/apps/webpositive/Jamfile
+++ b/src/apps/webpositive/Jamfile
@@ -26,11 +26,8 @@ local sources =
        # support
        BaseURL.cpp
        BitmapButton.cpp
-       DateTime.cpp
        FontSelectionView.cpp
-       IconButton.cpp
        SettingsMessage.cpp
-       StringForSize.cpp
 
        # tabview
        TabContainerView.cpp
@@ -46,7 +43,6 @@ local sources =
        DownloadWindow.cpp
        SettingsKeys.cpp
        SettingsWindow.cpp
-       svn_revision.cpp
        URLInputGroup.cpp
 ;
 
@@ -54,12 +50,11 @@ Includes [ FGristFiles $(sources) ] : 
$(HAIKU_WEBKIT_HEADERS_DEPENDENCY) ;
        # Dependency needed to trigger downloading/unzipping the package before
        # compiling the files.
 
-# SVN revision
-#local svnRevisionFile = [ FGristFiles svn_revision ] ;
-#MakeLocate $(svnRevisionFile) : $(LOCATE_TARGET) ;
-#CreateSVNRevisionFile $(svnRevisionFile) ;
+# private OS headers
+UseLibraryHeaders icon ;
+UsePrivateHeaders shared tracker ;
+SubDirHdrs $(HAIKU_TOP) src kits tracker ;
 
-UsePrivateHeaders shared ;
 
 Application WebPositive :
        $(sources)
diff --git a/src/apps/webpositive/support/AutoLocker.h 
b/src/apps/webpositive/support/AutoLocker.h
deleted file mode 100644
index 9baa7aa..0000000
--- a/src/apps/webpositive/support/AutoLocker.h
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright 2005-2007, Ingo Weinhold, bonefish@xxxxxxxxxxxx.
- * All rights reserved. Distributed under the terms of the MIT License.
- */
-#ifndef _AUTO_LOCKER_H
-#define _AUTO_LOCKER_H
-
-
-#include <stddef.h>
-
-
-namespace BPrivate {
-
-// AutoLockerStandardLocking
-template<typename Lockable>
-class AutoLockerStandardLocking {
-public:
-       inline bool Lock(Lockable* lockable)
-       {
-               return lockable->Lock();
-       }
-
-       inline void Unlock(Lockable* lockable)
-       {
-               lockable->Unlock();
-       }
-};
-
-// AutoLockerReadLocking
-template<typename Lockable>
-class AutoLockerReadLocking {
-public:
-       inline bool Lock(Lockable* lockable)
-       {
-               return lockable->ReadLock();
-       }
-
-       inline void Unlock(Lockable* lockable)
-       {
-               lockable->ReadUnlock();
-       }
-};
-
-// AutoLockerWriteLocking
-template<typename Lockable>
-class AutoLockerWriteLocking {
-public:
-       inline bool Lock(Lockable* lockable)
-       {
-               return lockable->WriteLock();
-       }
-
-       inline void Unlock(Lockable* lockable)
-       {
-               lockable->WriteUnlock();
-       }
-};
-
-// AutoLocker
-template<typename Lockable,
-                typename Locking = AutoLockerStandardLocking<Lockable> >
-class AutoLocker {
-private:
-       typedef AutoLocker<Lockable, Locking>   ThisClass;
-public:
-       inline AutoLocker()
-               :
-               fLockable(NULL),
-               fLocked(false)
-       {
-       }
-
-       inline AutoLocker(const Locking& locking)
-               :
-               fLockable(NULL),
-               fLocking(locking),
-               fLocked(false)
-       {
-       }
-
-       inline AutoLocker(Lockable* lockable, bool alreadyLocked = false,
-               bool lockIfNotLocked = true)
-               :
-               fLockable(lockable),
-               fLocked(fLockable && alreadyLocked)
-       {
-               if (!alreadyLocked && lockIfNotLocked)
-                       Lock();
-       }
-
-       inline AutoLocker(Lockable& lockable, bool alreadyLocked = false,
-               bool lockIfNotLocked = true)
-               :
-               fLockable(&lockable),
-               fLocked(fLockable && alreadyLocked)
-       {
-               if (!alreadyLocked && lockIfNotLocked)
-                       Lock();
-       }
-
-       inline ~AutoLocker()
-       {
-               Unlock();
-       }
-
-       inline void SetTo(Lockable* lockable, bool alreadyLocked,
-               bool lockIfNotLocked = true)
-       {
-               Unlock();
-               fLockable = lockable;
-               fLocked = (lockable && alreadyLocked);
-               if (!alreadyLocked && lockIfNotLocked)
-                       Lock();
-       }
-
-       inline void SetTo(Lockable& lockable, bool alreadyLocked,
-               bool lockIfNotLocked = true)
-       {
-               SetTo(&lockable, alreadyLocked, lockIfNotLocked);
-       }
-
-       inline void Unset()
-       {
-               Unlock();
-               Detach();
-       }
-
-       inline bool Lock()
-       {
-               if (fLockable && !fLocked)
-                       fLocked = fLocking.Lock(fLockable);
-               return fLocked;
-       }
-
-       inline void Unlock()
-       {
-               if (fLockable && fLocked) {
-                       fLocking.Unlock(fLockable);
-                       fLocked = false;
-               }
-       }
-
-       inline void Detach()
-       {
-               fLockable = NULL;
-               fLocked = false;
-       }
-
-       inline AutoLocker<Lockable, Locking>& operator=(Lockable* lockable)
-       {
-               SetTo(lockable);
-               return *this;
-       }
-
-       inline AutoLocker<Lockable, Locking>& operator=(Lockable& lockable)
-       {
-               SetTo(&lockable);
-               return *this;
-       }
-
-       inline bool IsLocked() const    { return fLocked; }
-
-       inline operator bool() const    { return fLocked; }
-
-protected:
-       Lockable*       fLockable;
-       Locking         fLocking;
-       bool            fLocked;
-};
-
-
-}      // namespace BPrivate
-
-using BPrivate::AutoLocker;
-using BPrivate::AutoLockerReadLocking;
-using BPrivate::AutoLockerWriteLocking;
-
-#endif // _AUTO_LOCKER_H
diff --git a/src/apps/webpositive/support/DateTime.cpp 
b/src/apps/webpositive/support/DateTime.cpp
deleted file mode 100644
index 19030db..0000000
--- a/src/apps/webpositive/support/DateTime.cpp
+++ /dev/null
@@ -1,1473 +0,0 @@
-/*
- * Copyright 2007-2010, Haiku, Inc. All Rights Reserved.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- *             Julun <host.haiku@xxxxxx>
- *             Stephan Aßmus <superstippi@xxxxxx>
- */
-
-#include "DateTime.h"
-
-
-#include <time.h>
-#include <sys/time.h>
-
-#include <Message.h>
-
-
-namespace BPrivate {
-
-
-const int32                    kSecondsPerMinute                       = 60;
-
-const int32                    kHoursPerDay                            = 24;
-const int32                    kMinutesPerDay                          = 1440;
-const int32                    kSecondsPerDay                          = 86400;
-const int32                    kMillisecondsPerDay                     = 
86400000;
-
-const bigtime_t                kMicrosecondsPerSecond          = 1000000LL;
-const bigtime_t                kMicrosecondsPerMinute          = 60000000LL;
-const bigtime_t                kMicrosecondsPerHour            = 3600000000LL;
-const bigtime_t                kMicrosecondsPerDay                     = 
86400000000LL;
-
-
-/*!
-       Constructs a new BTime object. Asked for its time representation, it 
will
-       return 0 for Hour(), Minute(), Second() etc. This can represent 
midnight,
-       but be aware IsValid() will return false.
-*/
-BTime::BTime()
-       :
-       fMicroseconds(-1)
-{
-}
-
-
-/*!
-       Constructs a new BTime object as a copy of \c other.
-*/
-BTime::BTime(const BTime& other)
-       :
-       fMicroseconds(other.fMicroseconds)
-{
-}
-
-
-/*!
-       Constructs a BTime object with \c hour \c minute, \c second, \c 
microsecond.
-
-       \c hour must be between 0 and 23, \c minute and \c second must be 
between
-       0 and 59 and \c microsecond should be in the range of 0 and 999999. If 
the
-       specified time is invalid, the time is not set and IsValid() returns 
false.
-*/
-BTime::BTime(int32 hour, int32 minute, int32 second, int32 microsecond)
-       :
-       fMicroseconds(-1)
-{
-       _SetTime(hour, minute, second, microsecond);
-}
-
-
-/*!
-       Constructs a new BTime object from the provided BMessage archive.
-*/
-BTime::BTime(const BMessage* archive)
-       :
-       fMicroseconds(-1)
-{
-       if (archive == NULL)
-               return;
-       archive->FindInt64("mircoseconds", &fMicroseconds);
-}
-
-
-/*!
-       Empty destructor.
-*/
-BTime::~BTime()
-{
-}
-
-
-/*!
-       Archives the BTime object into the provided BMessage object.
-       @returns        \c B_OK if all went well.
-                               \c B_BAD_VALUE, if the message is \c NULL.
-                               \c other error codes, depending on failure to 
append
-                               fields to the message.
-*/
-status_t
-BTime::Archive(BMessage* into) const
-{
-       if (into == NULL)
-               return B_BAD_VALUE;
-       return into->AddInt64("mircoseconds", fMicroseconds);
-}
-
-
-/*!
-       Returns true if the time is valid, otherwise false. A valid time can be
-       BTime(23, 59, 59, 999999) while BTime(24, 00, 01) would be invalid.
-*/
-bool
-BTime::IsValid() const
-{
-       return fMicroseconds > -1 && fMicroseconds < kMicrosecondsPerDay;
-}
-
-
-/*!
-       This is an overloaded member function, provided for convenience.
-*/
-bool
-BTime::IsValid(const BTime& time) const
-{
-       return time.fMicroseconds > -1 && time.fMicroseconds < 
kMicrosecondsPerDay;
-}
-
-
-/*!
-       This is an overloaded member function, provided for convenience.
-*/
-bool
-BTime::IsValid(int32 hour, int32 minute, int32 second, int32 microsecond) const
-{
-       return BTime(hour, minute, second, microsecond).IsValid();
-}
-
-
-/*!
-       Returns the current time as reported by the system depending on the 
given
-       time_type \c type.
-*/
-BTime
-BTime::CurrentTime(time_type type)
-{
-       struct timeval tv;
-       if (gettimeofday(&tv, NULL) != 0) {
-               // gettimeofday failed?
-               time(&tv.tv_sec);
-       }
-
-       struct tm result;
-       struct tm* timeinfo;
-       if (type == B_GMT_TIME)
-               timeinfo = gmtime_r(&tv.tv_sec, &result);
-       else
-               timeinfo = localtime_r(&tv.tv_sec, &result);
-
-       int32 sec = timeinfo->tm_sec;
-       return BTime(timeinfo->tm_hour, timeinfo->tm_min, (sec > 59) ? 59 : sec,
-               tv.tv_usec);
-}
-
-
-/*!
-       Returns a copy of the current BTime object.
-*/
-BTime
-BTime::Time() const
-{
-       return *this;
-}
-
-
-/*!
-       This is an overloaded member function, provided for convenience. Set the
-       current BTime object to the passed BTime \c time object.
-*/
-bool
-BTime::SetTime(const BTime& time)
-{
-       fMicroseconds = time.fMicroseconds;
-       return IsValid();
-}
-
-
-/*!
-       Set the time to \c hour \c minute, \c second and \c microsecond.
-
-       \c hour must be between 0 and 23, \c minute and \c second must be 
between
-       0 and 59 and \c microsecond should be in the range of 0 and 999999. 
Returns
-       true if the time is valid; otherwise false. If the specified time is
-       invalid, the time is not set and the function returns false.
-*/
-bool
-BTime::SetTime(int32 hour, int32 minute, int32 second, int32 microsecond)
-{
-       return _SetTime(hour, minute, second, microsecond);
-}
-
-
-
-/*!
-       Adds \c hours to the current time. If the passed value is negativ it 
will
-       become earlier. Note: The time will wrap if it passes midnight.
-*/
-BTime&
-BTime::AddHours(int32 hours)
-{
-       return _AddMicroseconds(bigtime_t(hours % kHoursPerDay)
-               * kMicrosecondsPerHour);
-}
-
-
-/*!
-       Adds \c minutes to the current time. If the passed value is negativ it 
will
-       become earlier. Note: The time will wrap if it passes midnight.
-*/
-BTime&
-BTime::AddMinutes(int32 minutes)
-{
-       return _AddMicroseconds(bigtime_t(minutes % kMinutesPerDay)
-               * kMicrosecondsPerMinute);
-}
-
-
-/*!
-       Adds \c seconds to the current time. If the passed value is negativ it 
will
-       become earlier. Note: The time will wrap if it passes midnight.
-*/
-BTime&
-BTime::AddSeconds(int32 seconds)
-{
-       return _AddMicroseconds(bigtime_t(seconds % kSecondsPerDay)
-               * kMicrosecondsPerSecond);
-}
-
-
-/*!
-       Adds \c milliseconds to the current time. If the passed value is 
negativ it
-       will become earlier. Note: The time will wrap if it passes midnight.
-*/
-BTime&
-BTime::AddMilliseconds(int32 milliseconds)
-{
-       return _AddMicroseconds(bigtime_t(milliseconds % kMillisecondsPerDay)
-               * 1000);
-}
-
-
-/*!
-       Adds \c microseconds to the current time. If the passed value is 
negativ it
-       will become earlier. Note: The time will wrap if it passes midnight.
-*/
-BTime&
-BTime::AddMicroseconds(int32 microseconds)
-{
-       return _AddMicroseconds(microseconds);
-}
-
-
-/*!
-       Returns the hour fragment of the time.
-*/
-int32
-BTime::Hour() const
-{
-       return int32(_Microseconds() / kMicrosecondsPerHour);
-}
-
-
-/*!
-       Returns the minute fragment of the time.
-*/
-int32
-BTime::Minute() const
-{
-       return int32(((_Microseconds() % kMicrosecondsPerHour)) / 
kMicrosecondsPerMinute);
-}
-
-
-/*!
-       Returns the second fragment of the time.
-*/
-int32
-BTime::Second() const
-{
-       return int32(_Microseconds() / kMicrosecondsPerSecond) % 
kSecondsPerMinute;
-}
-
-
-/*!
-       Returns the millisecond fragment of the time.
-*/
-int32
-BTime::Millisecond() const
-{
-
-       return Microsecond() / 1000;
-}
-
-
-/*!
-       Returns the microsecond fragment of the time.
-*/
-int32
-BTime::Microsecond() const
-{
-       return int32(_Microseconds() % 1000000);
-}
-
-
-bigtime_t
-BTime::_Microseconds() const
-{
-       return fMicroseconds == -1 ? 0 : fMicroseconds;
-}
-
-
-/*!
-       Returns the difference between this time and the given BTime \c time 
based
-       on the passed diff_type \c type. If \c time is earlier the return value 
will
-       be negativ.
-
-       The return value then can be hours, minutes, seconds, milliseconds or
-       microseconds while its range will always be between -86400000000 and
-       86400000000 depending on diff_type \c type.
-*/
-bigtime_t
-BTime::Difference(const BTime& time, diff_type type) const
-{
-       bigtime_t diff = time._Microseconds() - _Microseconds();
-       switch (type) {
-               case B_HOURS_DIFF: {
-                       diff /= kMicrosecondsPerHour;
-               }       break;
-               case B_MINUTES_DIFF: {
-                       diff /= kMicrosecondsPerMinute;
-               }       break;
-               case B_SECONDS_DIFF: {
-                       diff /= kMicrosecondsPerSecond;
-               }       break;
-               case B_MILLISECONDS_DIFF: {
-                       diff /= 1000;
-               }       break;
-               case B_MICROSECONDS_DIFF:
-               default:        break;
-       }
-       return diff;
-}
-
-
-/*!
-       Returns true if this time is different from \c time, otherwise false.
-*/
-bool
-BTime::operator!=(const BTime& time) const
-{
-       return fMicroseconds != time.fMicroseconds;
-}
-
-
-/*!
-       Returns true if this time is equal to \c time, otherwise false.
-*/
-bool
-BTime::operator==(const BTime& time) const
-{
-       return fMicroseconds == time.fMicroseconds;
-}
-
-
-/*!
-       Returns true if this time is earlier than \c time, otherwise false.
-*/
-bool
-BTime::operator<(const BTime& time) const
-{
-       return fMicroseconds < time.fMicroseconds;
-}
-
-
-/*!
-       Returns true if this time is earlier than or equal to \c time, 
otherwise false.
-*/
-bool
-BTime::operator<=(const BTime& time) const
-{
-       return fMicroseconds <= time.fMicroseconds;
-}
-
-
-/*!
-       Returns true if this time is later than \c time, otherwise false.
-*/
-bool
-BTime::operator>(const BTime& time) const
-{
-       return fMicroseconds > time.fMicroseconds;
-}
-
-
-/*!
-       Returns true if this time is later than or equal to \c time, otherwise 
false.
-*/
-bool
-BTime::operator>=(const BTime& time) const
-{
-       return fMicroseconds >= time.fMicroseconds;
-}
-
-
-BTime&
-BTime::_AddMicroseconds(bigtime_t microseconds)
-{
-       bigtime_t count = 0;
-       if (microseconds < 0) {
-               count = ((kMicrosecondsPerDay - microseconds) / 
kMicrosecondsPerDay) *
-                       kMicrosecondsPerDay;
-       }
-       fMicroseconds = (_Microseconds() + microseconds + count) % 
kMicrosecondsPerDay;
-       return *this;
-}
-
-
-bool
-BTime::_SetTime(bigtime_t hour, bigtime_t minute, bigtime_t second,
-       bigtime_t microsecond)
-{
-       fMicroseconds = hour * kMicrosecondsPerHour +
-                                       minute * kMicrosecondsPerMinute +
-                                       second * kMicrosecondsPerSecond +
-                                       microsecond;
-
-       bool isValid = IsValid();
-       if (!isValid)
-               fMicroseconds = -1;
-
-       return isValid;
-}
-
-
-//     #pragma mark - BDate
-
-
-/*!
-       Constructs a new BDate object. IsValid() will return false.
-*/
-BDate::BDate()
-       :
-       fDay(-1),
-       fYear(0),
-       fMonth(-1)
-{
-}
-
-
-/*!
-       Constructs a new BDate object as a copy of \c other.
-*/
-BDate::BDate(const BDate& other)
-       :
-       fDay(other.fDay),
-       fYear(other.fYear),
-       fMonth(other.fMonth)
-{
-}
-
-
-/*!
-       Constructs a BDate object with \c year \c month and \c day.
-
-       Please note that a date before 1.1.4713 BC, a date with year 0 and a 
date
-       between 4.10.1582 and 15.10.1582 are considered invalid. If the 
specified
-       date is invalid, the date is not set and IsValid() returns false. Also 
note
-       that every passed year will be interpreted as is.
-
-*/
-BDate::BDate(int32 year, int32 month, int32 day)
-{
-       _SetDate(year, month, day);
-}
-
-
-/*!
-       Constructs a new BDate object from the provided archive.
-*/
-BDate::BDate(const BMessage* archive)
-       :
-       fDay(-1),
-       fYear(0),
-       fMonth(-1)
-{
-       if (archive == NULL)
-               return;
-       archive->FindInt32("day", &fDay);
-       archive->FindInt32("year", &fYear);
-       archive->FindInt32("month", &fMonth);
-}
-
-
-/*!
-       Empty destructor.
-*/
-BDate::~BDate()
-{
-}
-
-
-/*!
-       Archives the BDate object into the provided BMessage object.
-       @returns        \c B_OK if all went well.
-                               \c B_BAD_VALUE, if the message is \c NULL.
-                               \c other error codes, depending on failure to 
append
-                               fields to the message.
-*/
-status_t
-BDate::Archive(BMessage* into) const
-{
-       if (into == NULL)
-               return B_BAD_VALUE;
-       status_t ret = into->AddInt32("day", fDay);
-       if (ret == B_OK)
-               ret = into->AddInt32("year", fYear);
-       if (ret == B_OK)
-               ret = into->AddInt32("month", fMonth);
-       return ret;
-}
-
-
-/*!
-       Returns true if the date is valid, otherwise false.
-
-       Please note that a date before 1.1.4713 BC, a date with year 0 and a 
date
-       between 4.10.1582 and 15.10.1582 are considered invalid.
-*/
-bool
-BDate::IsValid() const
-{
-       return IsValid(fYear, fMonth, fDay);
-}
-
-
-/*!
-       This is an overloaded member function, provided for convenience.
-*/
-bool
-BDate::IsValid(const BDate& date) const
-{
-       return IsValid(date.fYear, date.fMonth, date.fDay);
-}
-
-
-/*!
-       This is an overloaded member function, provided for convenience.
-*/
-bool
-BDate::IsValid(int32 year, int32 month, int32 day) const
-{
-       // no year 0 in Julian and nothing before 1.1.4713 BC
-       if (year == 0 || year < -4713)
-               return false;
-
-       if (month < 1 || month > 12)
-               return false;
-
-       if (day < 1 || day > _DaysInMonth(year, month))
-               return false;
-
-       // 'missing' days between switch julian - gregorian
-       if (year == 1582 && month == 10 && day > 4 && day < 15)
-               return false;
-
-       return true;
-}
-
-
-/*!
-       Returns the current date as reported by the system depending on the 
given
-       time_type \c type.
-*/
-BDate
-BDate::CurrentDate(time_type type)
-{
-       time_t timer;
-       struct tm result;
-       struct tm* timeinfo;
-
-       time(&timer);
-
-       if (type == B_GMT_TIME)
-               timeinfo = gmtime_r(&timer, &result);
-       else
-               timeinfo = localtime_r(&timer, &result);
-
-       return BDate(timeinfo->tm_year + 1900, timeinfo->tm_mon +1, 
timeinfo->tm_mday);
-}
-
-
-/*!
-       Returns a copy of the current BTime object.
-*/
-BDate
-BDate::Date() const
-{
-       return *this;
-}
-
-
-/*!
-       This is an overloaded member function, provided for convenience.
-*/
-bool
-BDate::SetDate(const BDate& date)
-{
-       return _SetDate(date.fYear, date.fMonth, date.fDay);
-}
-
-
-/*!
-       Set the date to \c year \c month and \c day.
-
-       Returns true if the date is valid; otherwise false. If the specified 
date is
-       invalid, the date is not set and the function returns false.
-*/
-bool
-BDate::SetDate(int32 year, int32 month, int32 day)
-{
-       return _SetDate(year, month, day);
-}
-
-
-/*!
-       This function sets the given \c year, \c month and \c day to the
-       representative values of this date. The pointers can be NULL. If the 
date is
-       invalid, the values will be set to -1 for \c month and \c day, the \c 
year
-       will be set to 0.
-*/
-void
-BDate::GetDate(int32* year, int32* month, int32* day)
-{
-       if (year)
-               *year = fYear;
-
-       if (month)
-               *month = fMonth;
-
-       if (day)
-               *day = fDay;
-}
-
-
-/*!
-       Adds \c days to the current date. If the passed value is negativ it will
-       become earlier. If the current date is invalid, the \c days are not 
added.
-*/
-void
-BDate::AddDays(int32 days)
-{
-       if (IsValid())
-               *this = JulianDayToDate(DateToJulianDay() + days);
-}
-
-
-/*!
-       Adds \c years to the current date. If the passed value is negativ it 
will
-       become earlier. If the current date is invalid, the \c years are not 
added.
-       The day/ month combination will be adjusted if it does not exist in the
-       resulting year, so this function will then return the latest valid date.
-*/
-void
-BDate::AddYears(int32 years)
-{
-       if (IsValid()) {
-               const int32 tmp = fYear;
-               fYear += years;
-
-               if ((tmp > 0 && fYear <= 0) || (tmp < 0 && fYear >= 0))
-                       fYear += (years > 0) ? +1 : -1;
-
-               fDay = min_c(fDay, _DaysInMonth(fYear, fMonth));
-       }
-}
-
-
-/*!
-       Adds \c months to the current date. If the passed value is negativ it 
will
-       become earlier. If the current date is invalid, the \c months are not 
added.
-       The day/ month combination will be adjusted if it does not exist in the
-       resulting year, so this function will then return the latest valid date.
-*/
-void
-BDate::AddMonths(int32 months)
-{
-       if (IsValid()) {
-               const int32 tmp = fYear;
-               fYear += months / 12;
-               fMonth +=  months % 12;
-
-               if (fMonth > 12) {
-                       fYear++;
-                       fMonth -= 12;
-               } else if (fMonth < 1) {
-                       fYear--;
-                       fMonth += 12;
-               }
-
-               if ((tmp > 0 && fYear <= 0) || (tmp < 0 && fYear >= 0))
-                       fYear += (months > 0) ? +1 : -1;
-
-               // 'missing' days between switch julian - gregorian
-               if (fYear == 1582 && fMonth == 10 && fDay > 4 && fDay < 15)
-                       fDay = (months > 0) ? 15 : 4;
-
-               fDay = min_c(fDay, DaysInMonth());
-       }
-}
-
-
-/*!
-       Returns the day fragment of the date. The return value will be in the 
range
-       of 1 to 31, in case the date is invalid it will be -1.
-*/
-int32
-BDate::Day() const
-{
-       return fDay;
-}
-
-
-/*!
-       Returns the year fragment of the date. If the date is invalid, the 
function
-       returns 0.
-*/
-int32
-BDate::Year() const
-{
-       return fYear;
-}
-
-
-/*!
-       Returns the month fragment of the date. The return value will be in the
-       range of 1 to 12, in case the date is invalid it will be -1.
-*/
-int32
-BDate::Month() const
-{
-       return fMonth;
-}
-
-
-/*!
-       Returns the difference in days between this date and the given BDate \c 
date.
-       If \c date is earlier the return value will be negativ. If the 
calculation
-       is done with an invalid date, the result is undefined.
-*/
-int32
-BDate::Difference(const BDate& date) const
-{
-       return date.DateToJulianDay() - DateToJulianDay();
-}
-
-
-/*!
-       Returns the week number of the date, if the date is invalid it will 
return
-       B_ERROR. Please note that this function does only work within the 
Gregorian
-       calendar, thus a date before 15.10.1582 will return B_ERROR.
-*/
-int32
-BDate::WeekNumber() const
-{
-       /*
-               This algorithm is taken from:
-               Frequently Asked Questions about Calendars
-               Version 2.8 Claus Tøndering 15 December 2005
-
-               Note: it will work only within the Gregorian Calendar
-       */
-
-       if (!IsValid() || fYear < 1582
-               || (fYear == 1582 && fMonth < 10)
-               || (fYear == 1582 && fMonth == 10 && fDay < 15))
-               return int32(B_ERROR);
-
-       int32 a;
-       int32 b;
-       int32 s;
-       int32 e;
-       int32 f;
-
-       if (fMonth > 0 && fMonth < 3) {
-               a = fYear - 1;
-               b = (a / 4) - (a / 100) + (a / 400);
-               int32 c = ((a - 1) / 4) - ((a - 1) / 100) + ((a -1) / 400);
-               s = b - c;
-               e = 0;
-               f = fDay - 1 + 31 * (fMonth - 1);
-       } else if (fMonth >= 3 && fMonth <= 12) {
-               a = fYear;
-               b = (a / 4) - (a / 100) + (a / 400);
-               int32 c = ((a - 1) / 4) - ((a - 1) / 100) + ((a -1) / 400);
-               s = b - c;
-               e = s + 1;
-               f = fDay + ((153 * (fMonth - 3) + 2) / 5) + 58 + s;
-       } else
-               return int32(B_ERROR);
-
-       int32 g = (a + b) % 7;
-       int32 d = (f + g - e) % 7;
-       int32 n = f + 3 - d;
-
-       int32 weekNumber;
-       if (n < 0)
-               weekNumber = 53 - (g -s) / 5;
-       else if (n > 364 + s)
-               weekNumber = 1;
-       else
-               weekNumber = n / 7 + 1;
-
-       return weekNumber;
-}
-
-
-/*!
-       Returns the day of the week in the range of 1 to 7, while 1 stands for
-       monday. If the date is invalid, the function will return B_ERROR.
-*/
-int32
-BDate::DayOfWeek() const
-{
-       // http://en.wikipedia.org/wiki/Julian_day#Calculation
-       return IsValid() ? (DateToJulianDay() % 7) + 1 : int32(B_ERROR);
-}
-
-
-/*!
-       Returns the day of the year in the range of 1 to 365 (366 in leap 
years). If
-       the date is invalid, the function will return B_ERROR.
-*/
-int32
-BDate::DayOfYear() const
-{
-       if (!IsValid())
-               return int32(B_ERROR);
-
-       return DateToJulianDay() - _DateToJulianDay(fYear, 1, 1) + 1;
-}
-
-
-/*!
-       Returns true if the passed \c year is a leap year, otherwise false. If 
the
-       \c year passed is before 4713 BC, the result is undefined.
-*/
-bool
-BDate::IsLeapYear(int32 year) const
-{
-       if (year < 1582) {
-               if (year < 0)
-                       year++;
-               return (year % 4) == 0;
-       }
-       return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
-}
-
-
-/*!
-       Returns the number of days in the year of the current date. If the date 
is
-       valid it will return 365 or 366, otherwise B_ERROR;
-*/
-int32
-BDate::DaysInYear() const
-{
-       if (!IsValid())
-               return int32(B_ERROR);
-
-       return IsLeapYear(fYear) ? 366 : 365;
-}
-
-
-/*!
-       Returns the number of days in the month of the current date. If the 
date is
-       valid it will return 28 up to 31, otherwise B_ERROR;
-*/
-int32
-BDate::DaysInMonth() const
-{
-       if (!IsValid())
-               return int32(B_ERROR);
-
-       return _DaysInMonth(fYear, fMonth);
-}
-
-
-/*!
-       Returns the short day name of this object.
-*/
-BString
-BDate::ShortDayName() const
-{
-       return ShortDayName(DayOfWeek());
-}
-
-
-/*!
-       Returns the short day name in case of an valid day, otherwise an empty
-       string. The passed \c day must be in the range of 1 to 7 while 1 stands 
for
-       monday.
-*/
-/*static*/ BString
-BDate::ShortDayName(int32 day)
-{
-       if (day < 1 || day > 7)
-               return BString();
-
-       tm tm_struct;
-       memset(&tm_struct, 0, sizeof(tm));
-       tm_struct.tm_wday = day == 7 ? 0 : day;
-
-       char buffer[256];
-       strftime(buffer, sizeof(buffer), "%a", &tm_struct);
-
-       return BString(buffer);
-}
-
-
-/*!
-       Returns the short month name of this object.
-*/
-BString
-BDate::ShortMonthName() const
-{
-       return ShortMonthName(Month());
-}
-
-
-/*!
-       Returns the short month name in case of an valid month, otherwise an 
empty
-       string. The passed \c month must be in the range of 1 to 12.
-*/
-/*static*/ BString
-BDate::ShortMonthName(int32 month)
-{
-       if (month < 1 || month > 12)
-               return BString();
-
-       tm tm_struct;
-       memset(&tm_struct, 0, sizeof(tm));
-       tm_struct.tm_mon = month - 1;
-
-       char buffer[256];
-       strftime(buffer, sizeof(buffer), "%b", &tm_struct);
-
-       return BString(buffer);
-}
-
-
-/*!
-       Returns the long day name of this object's week day.
-*/
-BString
-BDate::LongDayName() const
-{
-       return LongDayName(DayOfWeek());
-}
-
-
-/*!
-       Returns the long day name in case of an valid day, otherwise an empty
-       string. The passed \c day must be in the range of 1 to 7 while 1 stands 
for
-       monday.
-*/
-/*static*/ BString
-BDate::LongDayName(int32 day)
-{
-       if (day < 1 || day > 7)
-               return BString();
-
-       tm tm_struct;
-       memset(&tm_struct, 0, sizeof(tm));
-       tm_struct.tm_wday = day == 7 ? 0 : day;
-
-       char buffer[256];
-       strftime(buffer, sizeof(buffer), "%A", &tm_struct);
-
-       return BString(buffer);
-}
-
-
-/*!
-       Returns the long month name of this object's month.
-*/
-BString
-BDate::LongMonthName() const
-{
-       return LongMonthName(Month());
-}
-
-
-/*!
-       Returns the long month name in case of an valid month, otherwise an 
empty
-       string. The passed \c month must be in the range of 1 to 12.
-*/
-/*static*/ BString
-BDate::LongMonthName(int32 month)
-{
-       if (month < 1 || month > 12)
-               return BString();
-
-       tm tm_struct;
-       memset(&tm_struct, 0, sizeof(tm));
-       tm_struct.tm_mon = month - 1;
-
-       char buffer[256];
-       strftime(buffer, sizeof(buffer), "%B", &tm_struct);
-
-       return BString(buffer);
-}
-
-
-/*!
-       Converts the date to Julian day. If your date is invalid, the function 
will
-       return B_ERROR.
-*/
-int32
-BDate::DateToJulianDay() const
-{
-       return _DateToJulianDay(fYear, fMonth, fDay);
-}
-
-
-/*
-       Converts the passed \c julianDay to an BDate. If the \c julianDay is 
negativ,
-       the function will return an invalid date. Because of the switch from 
Julian
-       calendar to Gregorian calendar the 4.10.1582 is followed by the 
15.10.1582.
-*/
-BDate
-BDate::JulianDayToDate(int32 julianDay)
-{
-       BDate date;
-       const int32 kGregorianCalendarStart = 2299161;
-       if (julianDay >= kGregorianCalendarStart) {
-               // 
http://en.wikipedia.org/wiki/Julian_day#Gregorian_calendar_from_Julian_day_number
-               int32 j = julianDay + 32044;
-               int32 dg = j % 146097;
-               int32 c = (dg / 36524 + 1) * 3 / 4;
-               int32 dc = dg - c * 36524;
-               int32 db = dc % 1461;
-               int32 a = (db / 365 + 1) * 3 / 4;
-               int32 da = db - a * 365;
-               int32 m = (da * 5 + 308) / 153 - 2;
-               date.fYear = ((j / 146097) * 400 + c * 100 + (dc / 1461) * 4 + 
a) - 4800 +
-                       (m + 2) / 12;
-               date.fMonth = (m + 2) % 12 + 1;
-               date.fDay = int32((da - (m + 4) * 153 / 5 + 122) + 1.5);
-       } else if (julianDay >= 0) {
-               // http://en.wikipedia.org/wiki/Julian_day#Calculation
-               julianDay += 32082;
-               int32 d = (4 * julianDay + 3) / 1461;
-               int32 e = julianDay - (1461 * d) / 4;
-               int32 m = ((5 * e) + 2) / 153;
-               date.fDay = e - (153 * m + 2) / 5 + 1;
-               date.fMonth = m + 3 - 12 * (m / 10);
-               int32 year = d - 4800 + (m / 10);
-               if (year <= 0)
-                       year--;
-               date.fYear = year;
-       }
-       return date;
-}
-
-
-/*!
-       Returns true if this date is different from \c date, otherwise false.
-*/
-bool
-BDate::operator!=(const BDate& date) const
-{
-       return DateToJulianDay() != date.DateToJulianDay();
-}
-
-
-/*!
-       Returns true if this date is equal to \c date, otherwise false.
-*/
-bool
-BDate::operator==(const BDate& date) const
-{
-       return DateToJulianDay() == date.DateToJulianDay();
-}
-
-
-/*!
-       Returns true if this date is earlier than \c date, otherwise false.
-*/
-bool
-BDate::operator<(const BDate& date) const
-{
-       return DateToJulianDay() < date.DateToJulianDay();
-}
-
-
-/*!
-       Returns true if this date is earlier than or equal to \c date, 
otherwise false.
-*/
-bool
-BDate::operator<=(const BDate& date) const
-{
-       return DateToJulianDay() <= date.DateToJulianDay();
-}
-
-
-/*!
-       Returns true if this date is later than \c date, otherwise false.
-*/
-bool
-BDate::operator>(const BDate& date) const
-{
-       return DateToJulianDay() > date.DateToJulianDay();
-}
-
-
-/*!
-       Returns true if this date is later than or equal to \c date, otherwise 
false.
-*/
-bool
-BDate::operator>=(const BDate& date) const
-{
-       return DateToJulianDay() >= date.DateToJulianDay();
-}
-
-
-bool
-BDate::_SetDate(int32 year, int32 month, int32 day)
-{
-       fDay = -1;
-       fYear = 0;
-       fMonth = -1;
-
-       bool valid = IsValid(year, month, day);
-       if (valid) {
-               fDay = day;
-               fYear = year;
-               fMonth = month;
-       }
-
-       return valid;
-}
-
-
-int32
-BDate::_DaysInMonth(int32 year, int32 month) const
-{
-       if (month == 2 && IsLeapYear(year))
-               return 29;
-
-       const int32 daysInMonth[12] =
-               {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
-
-       return daysInMonth[month -1];
-}
-
-
-int32
-BDate::_DateToJulianDay(int32 _year, int32 month, int32 day) const
-{
-       if (IsValid(_year, month, day)) {
-               int32 year = _year;
-               if (year < 0) year++;
-
-               int32 a = (14 - month) / 12;
-               int32 y = year + 4800 - a;
-               int32 m = month + (12 * a) - 3;
-
-               // http://en.wikipedia.org/wiki/Julian_day#Calculation
-               if (year > 1582
-                       || (year == 1582 && month > 10)
-                       || (year == 1582 && month == 10 && day >= 15)) {
-                       return day + (((153 * m) + 2) / 5) + (365 * y) + (y / 
4) -
-                               (y / 100) + (y / 400) - 32045;
-               } else if (year < 1582
-                       || (year == 1582 && month < 10)
-                       || (year == 1582 && month == 10 && day <= 4)) {
-                       return day + (((153 * m) + 2) / 5) + (365 * y) + (y / 
4) - 32083;
-               }
-       }
-
-       // http://en.wikipedia.org/wiki/Gregorian_calendar:
-       //              The last day of the Julian calendar was Thursday 
October 4, 1582
-       //              and this was followed by the first day of the Gregorian 
calendar,
-       //              Friday October 15, 1582 (the cycle of weekdays was not 
affected).
-       return int32(B_ERROR);
-}
-
-
-//     #pragma mark - BDateTime
-
-
-/*!
-       Constructs a new BDateTime object. IsValid() will return false.
-*/
-BDateTime::BDateTime()
-       : fDate(),
-         fTime()
-{
-}
-
-
-/*!
-       Constructs a BDateTime object with \c date and \c time. The return value
-       of IsValid() depends on the validity of the passed objects.
-*/
-BDateTime::BDateTime(const BDate& date, const BTime& time)
-       : fDate(date),
-         fTime(time)
-{
-}
-
-
-/*!
-       Constructs a new BDateTime object. IsValid() will return false.
-*/
-BDateTime::BDateTime(const BMessage* archive)
-       : fDate(archive),
-         fTime(archive)
-{
-}
-
-
-/*!
-       Empty destructor.
-*/
-BDateTime::~BDateTime()
-{
-}
-
-
-/*!
-       Archives the BDateTime object into the provided BMessage object.
-       @returns        \c B_OK if all went well.
-                               \c B_BAD_VALUE, if the message is \c NULL.
-                               \c other error codes, depending on failure to 
append
-                               fields to the message.
-*/
-status_t
-BDateTime::Archive(BMessage* into) const
-{
-       status_t ret = fDate.Archive(into);
-       if (ret == B_OK)
-               ret = fTime.Archive(into);
-       return ret;
-}
-
-
-/*!
-       Returns true if the date time is valid, otherwise false.
-*/
-bool
-BDateTime::IsValid() const
-{
-       return fDate.IsValid() && fTime.IsValid();
-}
-
-
-/*!
-       Returns the current date and time as reported by the system depending 
on the
-       given time_type \c type.
-*/
-BDateTime
-BDateTime::CurrentDateTime(time_type type)
-{
-       return BDateTime(BDate::CurrentDate(type), BTime::CurrentTime(type));
-}
-
-
-/*!
-       Sets the current date and time of this object to \c date and \c time.
-*/
-void
-BDateTime::SetDateTime(const BDate& date, const BTime& time)
-{
-       fDate = date;
-       fTime = time;
-}
-
-
-/*!
-       Returns the current date of this object.
-*/
-BDate&
-BDateTime::Date()
-{
-       return fDate;
-}
-
-
-/*!
-       Returns the current date of this object.
-*/
-const BDate&
-BDateTime::Date() const
-{
-       return fDate;
-}
-
-
-/*!
-       Set the current date of this object to \c date.
-*/
-void
-BDateTime::SetDate(const BDate& date)
-{
-       fDate = date;
-}
-
-
-/*!
-       Returns the current time of this object.
-*/
-BTime&
-BDateTime::Time()
-{
-       return fTime;
-}
-
-
-/*!
-       Returns the current time of this object.
-*/
-const BTime&
-BDateTime::Time() const
-{
-       return fTime;
-}
-
-
-/*!
-       Sets the current time of this object to \c time.
-*/
-void
-BDateTime::SetTime(const BTime& time)
-{
-       fTime = time;
-}
-
-
-/*!
-       Returns the current date and time converted to seconds since
-       1.1.1970 - 00:00:00. If the current date is before 1.1.1970 the function
-       returns -1;
-*/
-int32
-BDateTime::Time_t() const
-{
-       BDate date(1970, 1, 1);
-       if (date.Difference(fDate) < 0)
-               return -1;
-
-       tm tm_struct;
-
-       tm_struct.tm_hour = fTime.Hour();
-       tm_struct.tm_min = fTime.Minute();
-       tm_struct.tm_sec = fTime.Second();
-
-       tm_struct.tm_year = fDate.Year() - 1900;
-       tm_struct.tm_mon = fDate.Month() - 1;
-       tm_struct.tm_mday = fDate.Day();
-
-       // set less 0 as we wan't use it
-       tm_struct.tm_isdst = -1;
-
-       // return secs_since_jan1_1970 or -1 on error
-       return int32(mktime(&tm_struct));
-}
-
-
-/*!
-       Sets the current date and time converted from seconds since
-       1.1.1970 - 00:00:00.
-*/
-void
-BDateTime::SetTime_t(uint32 seconds)
-{
-       BTime time;
-       time.AddSeconds(seconds % kSecondsPerDay);
-       fTime.SetTime(time);
-       
-       BDate date(1970, 1, 1);
-       date.AddDays(seconds / kSecondsPerDay);
-       fDate.SetDate(date);
-}
-
-
-/*!
-       Returns true if this datetime is different from \c dateTime, otherwise 
false.
-*/
-bool
-BDateTime::operator!=(const BDateTime& dateTime) const
-{
-       return fTime != dateTime.fTime && fDate != dateTime.fDate;
-}
-
-
-/*!
-       Returns true if this datetime is equal to \c dateTime, otherwise false.
-*/
-bool
-BDateTime::operator==(const BDateTime& dateTime) const
-{
-       return fTime == dateTime.fTime && fDate == dateTime.fDate;
-}
-
-
-/*!
-       Returns true if this datetime is earlier than \c dateTime, otherwise 
false.
-*/
-bool
-BDateTime::operator<(const BDateTime& dateTime) const
-{
-       if (fDate < dateTime.fDate)
-               return true;
-       if (fDate == dateTime.fDate)
-               return fTime < dateTime.fTime;
-       return false;
-}
-
-
-/*!
-       Returns true if this datetime is earlier than or equal to \c dateTime,
-       otherwise false.
-*/
-bool
-BDateTime::operator<=(const BDateTime& dateTime) const
-{
-       if (fDate < dateTime.fDate)
-               return true;
-       if (fDate == dateTime.fDate)
-               return fTime <= dateTime.fTime;
-       return false;
-}
-
-
-/*!
-       Returns true if this datetime is later than \c dateTime, otherwise 
false.
-*/
-bool
-BDateTime::operator>(const BDateTime& dateTime) const
-{
-       if (fDate > dateTime.fDate)
-               return true;
-       if (fDate == dateTime.fDate)
-               return fTime > dateTime.fTime;
-       return false;
-}
-
-
-/*!
-       Returns true if this datetime is later than or equal to \c dateTime,
-       otherwise false.
-*/
-bool
-BDateTime::operator>=(const BDateTime& dateTime) const
-{
-       if (fDate > dateTime.fDate)
-               return true;
-       if (fDate == dateTime.fDate)
-               return fTime >= dateTime.fTime;
-       return false;
-}
-
-
-}      //namespace BPrivate
diff --git a/src/apps/webpositive/support/DateTime.h 
b/src/apps/webpositive/support/DateTime.h
deleted file mode 100644
index 93f7639..0000000
--- a/src/apps/webpositive/support/DateTime.h
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright 2007-2010, Haiku, Inc. All Rights Reserved.
- * Distributed under the terms of the MIT License.
- */
-#ifndef _DATE_TIME_H_
-#define _DATE_TIME_H_
-
-
-#include <String.h>
-
-
-class BMessage;
-
-
-namespace BPrivate {
-
-
-enum time_type {
-       B_GMT_TIME,
-       B_LOCAL_TIME
-};
-
-
-enum diff_type {
-       B_HOURS_DIFF,
-       B_MINUTES_DIFF,
-       B_SECONDS_DIFF,
-       B_MILLISECONDS_DIFF,
-       B_MICROSECONDS_DIFF
-};
-
-
-class BTime {
-public:
-                                                               BTime();
-                                                               BTime(const 
BTime& other);
-                                                               BTime(int32 
hour, int32 minute, int32 second,
-                                                                       int32 
microsecond = 0);
-                                                               BTime(const 
BMessage* archive);
-                                                               ~BTime();
-
-                       status_t                        Archive(BMessage* into) 
const;
-
-                       bool                            IsValid() const;
-                       bool                            IsValid(const BTime& 
time) const;
-                       bool                            IsValid(int32 hour, 
int32 minute, int32 second,
-                                                                       int32 
microsecond = 0) const;
-
-       static  BTime                           CurrentTime(time_type type);
-
-                       BTime                           Time() const;
-                       bool                            SetTime(const BTime& 
time);
-                       bool                            SetTime(int32 hour, 
int32 minute, int32 second,
-                                                                       int32 
microsecond = 0);
-
-                       BTime&                          AddHours(int32 hours);
-                       BTime&                          AddMinutes(int32 
minutes);
-                       BTime&                          AddSeconds(int32 
seconds);
-                       BTime&                          AddMilliseconds(int32 
milliseconds);
-                       BTime&                          AddMicroseconds(int32 
microseconds);
-
-                       int32                           Hour() const;
-                       int32                           Minute() const;
-                       int32                           Second() const;
-                       int32                           Millisecond() const;
-                       int32                           Microsecond() const;
-                       bigtime_t                       Difference(const BTime& 
time,
-                                                                       
diff_type type) const;
-
-                       bool                            operator!=(const BTime& 
time) const;
-                       bool                            operator==(const BTime& 
time) const;
-
-                       bool                            operator<(const BTime& 
time) const;
-                       bool                            operator<=(const BTime& 
time) const;
-
-                       bool                            operator>(const BTime& 
time) const;
-                       bool                            operator>=(const BTime& 
time) const;
-
-private:
-                       bigtime_t                       _Microseconds() const;
-                       BTime&                          
_AddMicroseconds(bigtime_t microseconds);
-                       bool                            _SetTime(bigtime_t 
hour, bigtime_t minute,
-                                                                       
bigtime_t second, bigtime_t microsecond);
-
-private:
-                       bigtime_t                       fMicroseconds;
-};
-
-
-class BDate {
-public:
-                                                               BDate();
-                                                               BDate(const 
BDate& other);
-                                                               BDate(int32 
year, int32 month, int32 day);
-                                                               BDate(const 
BMessage* archive);
-                                                               ~BDate();
-
-                       status_t                        Archive(BMessage* into) 
const;
-
-                       bool                            IsValid() const;
-                       bool                            IsValid(const BDate& 
date) const;
-                       bool                            IsValid(int32 year, 
int32 month,
-                                                                       int32 
day) const;
-
-       static  BDate                           CurrentDate(time_type type);
-
-                       BDate                           Date() const;
-                       bool                            SetDate(const BDate& 
date);
-
-                       bool                            SetDate(int32 year, 
int32 month, int32 day);
-                       void                            GetDate(int32* year, 
int32* month, int32* day);
-
-                       void                            AddDays(int32 days);
-                       void                            AddYears(int32 years);
-                       void                            AddMonths(int32 months);
-
-                       int32                           Day() const;
-                       int32                           Year() const;
-                       int32                           Month() const;
-                       int32                           Difference(const BDate& 
date) const;
-
-                       int32                           DayOfWeek() const;
-                       int32                           DayOfYear() const;
-
-                       int32                           WeekNumber() const;
-                       bool                            IsLeapYear(int32 year) 
const;
-
-                       int32                           DaysInYear() const;
-                       int32                           DaysInMonth() const;
-
-                       BString                         ShortDayName() const;
-       static  BString                         ShortDayName(int32 day);
-
-                       BString                         ShortMonthName() const;
-       static  BString                         ShortMonthName(int32 month);
-
-                       BString                         LongDayName() const;
-       static  BString                         LongDayName(int32 day);
-
-                       BString                         LongMonthName() const;
-       static  BString                         LongMonthName(int32 month);
-
-                       int32                           DateToJulianDay() const;
-       static  BDate                           JulianDayToDate(int32 
julianDay);
-
-                       bool                            operator!=(const BDate& 
date) const;
-                       bool                            operator==(const BDate& 
date) const;
-
-                       bool                            operator<(const BDate& 
date) const;
-                       bool                            operator<=(const BDate& 
date) const;
-
-                       bool                            operator>(const BDate& 
date) const;
-                       bool                            operator>=(const BDate& 
date) const;
-
-private:
-                       int32                           _DaysInMonth(int32 
year, int32 month) const;
-                       bool                            _SetDate(int32 year, 
int32 month, int32 day);
-                       int32                           _DateToJulianDay(int32 
year, int32 month,
-                                                                       int32 
day) const;
-
-private:
-                       int32                           fDay;
-                       int32                           fYear;
-                       int32                           fMonth;
-};
-
-
-class BDateTime {
-public:
-                                                               BDateTime();
-                                                               BDateTime(const 
BDate &date, const BTime &time);
-                                                               BDateTime(const 
BMessage* archive);
-                                                               ~BDateTime();
-
-                       status_t                        Archive(BMessage* into) 
const;
-
-                       bool                            IsValid() const;
-
-       static  BDateTime                       CurrentDateTime(time_type type);
-                       void                            SetDateTime(const BDate 
&date, const BTime &time);
-
-                       BDate&                          Date();
-                       const BDate&            Date() const;
-                       void                            SetDate(const BDate 
&date);
-
-                       BTime&                          Time();
-                       const BTime&            Time() const;
-                       void                            SetTime(const BTime 
&time);
-
-                       int32                           Time_t() const;
-                       void                            SetTime_t(uint32 
seconds);
-
-                       bool                            operator!=(const 
BDateTime& dateTime) const;
-                       bool                            operator==(const 
BDateTime& dateTime) const;
-
-                       bool                            operator<(const 
BDateTime& dateTime) const;
-                       bool                            operator<=(const 
BDateTime& dateTime) const;
-
-                       bool                            operator>(const 
BDateTime& dateTime) const;
-                       bool                            operator>=(const 
BDateTime& dateTime) const;
-
-private:
-                       BDate                           fDate;
-                       BTime                           fTime;
-};
-
-
-}      // namespace BPrivate
-
-
-using BPrivate::time_type;
-using BPrivate::B_GMT_TIME;
-using BPrivate::B_LOCAL_TIME;
-using BPrivate::diff_type;
-using BPrivate::B_HOURS_DIFF;
-using BPrivate::B_MINUTES_DIFF;
-using BPrivate::B_SECONDS_DIFF;
-using BPrivate::B_MILLISECONDS_DIFF;
-using BPrivate::B_MICROSECONDS_DIFF;
-using BPrivate::BTime;
-using BPrivate::BDate;
-using BPrivate::BDateTime;
-
-
-#endif // _DATE_TIME_H_
diff --git a/src/apps/webpositive/support/HashMap.h 
b/src/apps/webpositive/support/HashMap.h
deleted file mode 100644
index 36b321f..0000000
--- a/src/apps/webpositive/support/HashMap.h
+++ /dev/null
@@ -1,481 +0,0 @@
-// HashMap.h
-//
-// Copyright (c) 2004-2007, Ingo Weinhold (bonefish@xxxxxxxxxxxxxxx)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-// DEALINGS IN THE SOFTWARE.
-//
-// Except as contained in this notice, the name of a copyright holder shall
-// not be used in advertising or otherwise to promote the sale, use or other
-// dealings in this Software without prior written authorization of the
-// copyright holder.
-
-#ifndef HASH_MAP_H
-#define HASH_MAP_H
-
-
-#include <Locker.h>
-
-#include "AutoLocker.h"
-#include "OpenHashTable.h"
-
-
-namespace BPrivate {
-
-// HashMapElement
-template<typename Key, typename Value>
-class HashMapElement : public OpenHashElement {
-private:
-       typedef HashMapElement<Key, Value> Element;
-public:
-
-       HashMapElement() : OpenHashElement(), fKey(), fValue()
-       {
-               fNext = -1;
-       }
-
-       inline uint32 Hash() const
-       {
-               return fKey.GetHashCode();
-       }
-
-       inline bool operator==(const OpenHashElement &_element) const
-       {
-               const Element &element = static_cast<const Element&>(_element);
-               return (fKey == element.fKey);
-       }
-
-       inline void Adopt(Element &element)
-       {
-               fKey = element.fKey;
-               fValue = element.fValue;
-       }
-
-       Key             fKey;
-       Value   fValue;
-};
-
-// HashMap
-template<typename Key, typename Value>
-class HashMap {
-public:
-       class Entry {
-       public:
-               Entry() {}
-               Entry(const Key& key, Value value) : key(key), value(value) {}
-
-               Key             key;
-               Value   value;
-       };
-
-       class Iterator {
-       private:
-               typedef HashMapElement<Key, Value>      Element;
-       public:
-               Iterator(const Iterator& other)
-                       :
-                       fMap(other.fMap),
-                       fIndex(other.fIndex),
-                       fElement(other.fElement),
-                       fLastElement(other.fElement)
-               {
-               }
-
-               bool HasNext() const
-               {
-                       return fElement;
-               }
-
-               Entry Next()
-               {
-                       if (!fElement)
-                               return Entry();
-                       Entry result(fElement->fKey, fElement->fValue);
-                       _FindNext();
-                       return result;
-               }
-
-               Value* NextValue()
-               {
-                       if (fElement == NULL)
-                               return NULL;
-
-                       Value* value = &fElement->fValue;
-                       _FindNext();
-                       return value;
-               }
-
-               Entry Remove()
-               {
-                       if (!fLastElement)
-                               return Entry();
-                       Entry result(fLastElement->fKey, fLastElement->fValue);
-                       fMap->fTable.Remove(fLastElement, true);
-                       fLastElement = NULL;
-                       return result;
-               }
-
-               Iterator& operator=(const Iterator& other)
-               {
-                       fMap = other.fMap;
-                       fIndex = other.fIndex;
-                       fElement = other.fElement;
-                       fLastElement = other.fLastElement;
-                       return *this;
-               }
-
-       private:
-               Iterator(const HashMap<Key, Value>* map)
-                       :
-                       fMap(const_cast<HashMap<Key, Value>*>(map)),
-                       fIndex(0),
-                       fElement(NULL),
-                       fLastElement(NULL)
-               {
-                       // find first
-                       _FindNext();
-               }
-
-               void _FindNext()
-               {
-                       fLastElement = fElement;
-                       if (fElement && fElement->fNext >= 0) {
-                               fElement = 
fMap->fTable.ElementAt(fElement->fNext);
-                               return;
-                       }
-                       fElement = NULL;
-                       int32 arraySize = fMap->fTable.ArraySize();
-                       for (; !fElement && fIndex < arraySize; fIndex++)
-                               fElement = fMap->fTable.FindFirst(fIndex);
-               }
-
-       private:
-               friend class HashMap<Key, Value>;
-
-               HashMap<Key, Value>*    fMap;
-               int32                                   fIndex;
-               Element*                                fElement;
-               Element*                                fLastElement;
-       };
-
-       HashMap();
-       ~HashMap();
-
-       status_t InitCheck() const;
-
-       status_t Put(const Key& key, Value value);
-       Value Remove(const Key& key);
-       void Clear();
-       Value Get(const Key& key) const;
-       bool Get(const Key& key, Value*& _value) const;
-
-       bool ContainsKey(const Key& key) const;
-
-       int32 Size() const;
-
-       Iterator GetIterator() const;
-
-protected:
-       typedef HashMapElement<Key, Value>      Element;
-       friend class Iterator;
-
-private:
-       Element *_FindElement(const Key& key) const;
-
-protected:
-       OpenHashElementArray<Element>                                           
        fElementArray;
-       OpenHashTable<Element, OpenHashElementArray<Element> >  fTable;
-};
-
-// SynchronizedHashMap
-template<typename Key, typename Value>
-class SynchronizedHashMap : public BLocker {
-public:
-       typedef struct HashMap<Key, Value>::Entry Entry;
-       typedef struct HashMap<Key, Value>::Iterator Iterator;
-
-       SynchronizedHashMap() : BLocker("synchronized hash map")        {}
-       ~SynchronizedHashMap()  { Lock(); }
-
-       status_t InitCheck() const
-       {
-               return fMap.InitCheck();
-       }
-
-       status_t Put(const Key& key, Value value)
-       {
-               MapLocker locker(this);
-               if (!locker.IsLocked())
-                       return B_ERROR;
-               return fMap.Put(key, value);
-       }
-
-       Value Remove(const Key& key)
-       {
-               MapLocker locker(this);
-               if (!locker.IsLocked())
-                       return Value();
-               return fMap.Remove(key);
-       }
-
-       void Clear()
-       {
-               MapLocker locker(this);
-               return fMap.Clear();
-       }
-
-       Value Get(const Key& key) const
-       {
-               const BLocker* lock = this;
-               MapLocker locker(const_cast<BLocker*>(lock));
-               if (!locker.IsLocked())
-                       return Value();
-               return fMap.Get(key);
-       }
-
-       bool ContainsKey(const Key& key) const
-       {
-               const BLocker* lock = this;
-               MapLocker locker(const_cast<BLocker*>(lock));
-               if (!locker.IsLocked())
-                       return false;
-               return fMap.ContainsKey(key);
-       }
-
-       int32 Size() const
-       {
-               const BLocker* lock = this;
-               MapLocker locker(const_cast<BLocker*>(lock));
-               return fMap.Size();
-       }
-
-       Iterator GetIterator()
-       {
-               return fMap.GetIterator();
-       }
-
-       // for debugging only
-       const HashMap<Key, Value>& GetUnsynchronizedMap() const { return fMap; }
-       HashMap<Key, Value>& GetUnsynchronizedMap()                             
{ return fMap; }
-
-protected:
-       typedef AutoLocker<BLocker> MapLocker;
-
-       HashMap<Key, Value>     fMap;
-};
-
-// HashKey32
-template<typename Value>
-struct HashKey32 {
-       HashKey32() {}
-       HashKey32(const Value& value) : value(value) {}
-
-       uint32 GetHashCode() const
-       {
-               return (uint32)value;
-       }
-
-       HashKey32<Value> operator=(const HashKey32<Value>& other)
-       {
-               value = other.value;
-               return *this;
-       }
-
-       bool operator==(const HashKey32<Value>& other) const
-       {
-               return (value == other.value);
-       }
-
-       bool operator!=(const HashKey32<Value>& other) const
-       {
-               return (value != other.value);
-       }
-
-       Value   value;
-};
-
-
-// HashKey64
-template<typename Value>
-struct HashKey64 {
-       HashKey64() {}
-       HashKey64(const Value& value) : value(value) {}
-
-       uint32 GetHashCode() const
-       {
-               uint64 v = (uint64)value;
-               return (uint32)(v >> 32) ^ (uint32)v;
-       }
-
-       HashKey64<Value> operator=(const HashKey64<Value>& other)
-       {
-               value = other.value;
-               return *this;
-       }
-
-       bool operator==(const HashKey64<Value>& other) const
-       {
-               return (value == other.value);
-       }
-
-       bool operator!=(const HashKey64<Value>& other) const
-       {
-               return (value != other.value);
-       }
-
-       Value   value;
-};
-
-
-// HashMap
-
-// constructor
-template<typename Key, typename Value>
-HashMap<Key, Value>::HashMap()
-       :
-       fElementArray(1000),
-       fTable(1000, &fElementArray)
-{
-}
-
-// destructor
-template<typename Key, typename Value>
-HashMap<Key, Value>::~HashMap()
-{
-}
-
-// InitCheck
-template<typename Key, typename Value>
-status_t
-HashMap<Key, Value>::InitCheck() const
-{
-       return (fTable.InitCheck() && fElementArray.InitCheck()
-                       ? B_OK : B_NO_MEMORY);
-}
-
-// Put
-template<typename Key, typename Value>
-status_t
-HashMap<Key, Value>::Put(const Key& key, Value value)
-{
-       Element* element = _FindElement(key);
-       if (element) {
-               // already contains the key: just set the new value
-               element->fValue = value;
-               return B_OK;
-       }
-       // does not contain the key yet: add an element
-       element = fTable.Add(key.GetHashCode());
-       if (!element)
-               return B_NO_MEMORY;
-       element->fKey = key;
-       element->fValue = value;
-       return B_OK;
-}
-
-// Remove
-template<typename Key, typename Value>
-Value
-HashMap<Key, Value>::Remove(const Key& key)
-{
-       Value value = Value();
-       if (Element* element = _FindElement(key)) {
-               value = element->fValue;
-               fTable.Remove(element);
-       }
-       return value;
-}
-
-// Clear
-template<typename Key, typename Value>
-void
-HashMap<Key, Value>::Clear()
-{
-       fTable.RemoveAll();
-}
-
-// Get
-template<typename Key, typename Value>
-Value
-HashMap<Key, Value>::Get(const Key& key) const
-{
-       if (Element* element = _FindElement(key))
-               return element->fValue;
-       return Value();
-}
-
-// Get
-template<typename Key, typename Value>
-bool
-HashMap<Key, Value>::Get(const Key& key, Value*& _value) const
-{
-       if (Element* element = _FindElement(key)) {
-               _value = &element->fValue;
-               return true;
-       }
-
-       return false;
-}
-
-// ContainsKey
-template<typename Key, typename Value>
-bool
-HashMap<Key, Value>::ContainsKey(const Key& key) const
-{
-       return _FindElement(key);
-}
-
-// Size
-template<typename Key, typename Value>
-int32
-HashMap<Key, Value>::Size() const
-{
-       return fTable.CountElements();
-}
-
-// GetIterator
-template<typename Key, typename Value>
-struct HashMap<Key, Value>::Iterator
-HashMap<Key, Value>::GetIterator() const
-{
-       return Iterator(this);
-}
-
-// _FindElement
-template<typename Key, typename Value>
-struct HashMap<Key, Value>::Element *
-HashMap<Key, Value>::_FindElement(const Key& key) const
-{
-       Element* element = fTable.FindFirst(key.GetHashCode());
-       while (element && element->fKey != key) {
-               if (element->fNext >= 0)
-                       element = fTable.ElementAt(element->fNext);
-               else
-                       element = NULL;
-       }
-       return element;
-}
-
-}      // namespace BPrivate
-
-using BPrivate::HashMap;
-using BPrivate::HashKey32;
-using BPrivate::HashKey64;
-using BPrivate::SynchronizedHashMap;
-
-#endif // HASH_MAP_H
diff --git a/src/apps/webpositive/support/HashSet.h 
b/src/apps/webpositive/support/HashSet.h

[ *** diff truncated: 2399 lines dropped *** ]



Other related posts:

  • » [haiku-commits] haiku: hrev45766 - src/apps/webpositive/support - superstippi