diff options
-rw-r--r-- | chrome/browser/sync/syncable/syncable-inl.h | 3 | ||||
-rw-r--r-- | chrome/browser/sync/syncable/syncable.h | 3 | ||||
-rw-r--r-- | chrome/browser/sync/util/row_iterator.h | 122 | ||||
-rw-r--r-- | chrome/chrome.gyp | 1 |
4 files changed, 2 insertions, 127 deletions
diff --git a/chrome/browser/sync/syncable/syncable-inl.h b/chrome/browser/sync/syncable/syncable-inl.h index 5094561..1a34325 100644 --- a/chrome/browser/sync/syncable/syncable-inl.h +++ b/chrome/browser/sync/syncable/syncable-inl.h @@ -1,11 +1,10 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_INL_H_ #define CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_INL_H_ -#include "chrome/browser/sync/util/row_iterator.h" #include "chrome/common/sqlite_utils.h" namespace syncable { diff --git a/chrome/browser/sync/syncable/syncable.h b/chrome/browser/sync/syncable/syncable.h index 8114f00..3793a2c 100644 --- a/chrome/browser/sync/syncable/syncable.h +++ b/chrome/browser/sync/syncable/syncable.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -29,7 +29,6 @@ #include "chrome/browser/sync/syncable/model_type.h" #include "chrome/browser/sync/util/channel.h" #include "chrome/browser/sync/util/dbgq.h" -#include "chrome/browser/sync/util/row_iterator.h" #include "chrome/browser/sync/util/sync_types.h" #include "chrome/common/deprecated/event_sys.h" diff --git a/chrome/browser/sync/util/row_iterator.h b/chrome/browser/sync/util/row_iterator.h deleted file mode 100644 index 73748ee..0000000 --- a/chrome/browser/sync/util/row_iterator.h +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A handy type for iterating through query results. -// -// Just define your Traits type with -// -// RowType -// Extract(statement*, RowType); -// -// and then pass an sqlite3_stmt into the constructor for begin, -// and use the no-arg constructor for an end iterator. Ex: -// -// for (RowIterator<SomeTraits> i(statement), end; i != end; ++i) -// ... - -#ifndef CHROME_BROWSER_SYNC_UTIL_ROW_ITERATOR_H_ -#define CHROME_BROWSER_SYNC_UTIL_ROW_ITERATOR_H_ - -#include "base/logging.h" -#include "third_party/sqlite/preprocessed/sqlite3.h" - -template <typename ColumnType, int index = 0> -struct SingleColumnTraits { - typedef ColumnType RowType; - inline void Extract(sqlite3_stmt* statement, ColumnType* x) const { - GetColumn(statement, index, x); - } -}; - -template <typename RowTraits> -class RowIterator : public std::iterator<std::input_iterator_tag, - const typename RowTraits::RowType> { - public: - typedef typename RowTraits::RowType RowType; - // Statement must have been prepared, but not yet stepped: - RowIterator(sqlite3_stmt* statement, RowTraits traits = RowTraits()) { - kernel_ = new Kernel; - kernel_->done = false; - kernel_->refcount = 1; - kernel_->statement = statement; - kernel_->row_traits = traits; - ++(*this); - } - RowIterator() : kernel_(NULL) { } // creates end iterator - - RowIterator(const RowIterator& i) - : kernel_(NULL) { - *this = i; - } - - ~RowIterator() { - if (kernel_ && 0 == --(kernel_->refcount)) { - sqlite3_finalize(kernel_->statement); - delete kernel_; - } - } - - RowIterator& operator = (const RowIterator& i) { - if (kernel_ && (0 == --(kernel_->refcount))) { - sqlite3_finalize(kernel_->statement); - delete kernel_; - } - kernel_ = i.kernel_; - if (kernel_) - kernel_->refcount += 1; - return *this; - } - - RowIterator operator ++(int) { - RowIterator i(*this); - return ++i; - } - - RowIterator& operator ++() { - DCHECK(NULL != kernel_); - if (SQLITE_ROW == sqlite3_step(kernel_->statement)) { - kernel_->row_traits.Extract(kernel_->statement, &kernel_->row); - } else { - kernel_->done = true; - } - return *this; - } - - const RowType& operator *() const { - return *(operator -> ()); - } - - const RowType* operator ->() const { - DCHECK(NULL != kernel_); - DCHECK(!kernel_->done); - return &(kernel_->row); - } - - bool operator == (const RowIterator& i) const { - if (kernel_ == i.kernel_) - return true; - if (NULL == kernel_ && i.kernel_->done) - return true; - if (NULL == i.kernel_ && kernel_->done) - return true; - return false; - } - - bool operator != (const RowIterator& i) const { - return !(*this == i); - } - - protected: - struct Kernel { - int refcount; - bool done; - RowType row; - sqlite3_stmt* statement; - RowTraits row_traits; - }; - - Kernel* kernel_; -}; - -#endif // CHROME_BROWSER_SYNC_UTIL_ROW_ITERATOR_H_ diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index e1bff39..ebd8304 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -933,7 +933,6 @@ 'browser/sync/util/fast_dump.h', 'browser/sync/util/nigori.cc', 'browser/sync/util/nigori.h', - 'browser/sync/util/row_iterator.h', 'browser/sync/util/sync_types.h', 'browser/sync/util/user_settings.cc', 'browser/sync/util/user_settings.h', |