OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 class SQLiteStatement; | 37 class SQLiteStatement; |
38 | 38 |
39 // FIXME: Add dates. | 39 // FIXME: Add dates. |
40 class IDBKey : public ThreadSafeShared<IDBKey> { | 40 class IDBKey : public ThreadSafeShared<IDBKey> { |
41 public: | 41 public: |
42 static PassRefPtr<IDBKey> create() | 42 static PassRefPtr<IDBKey> create() |
43 { | 43 { |
44 return adoptRef(new IDBKey()); | 44 return adoptRef(new IDBKey()); |
45 } | 45 } |
46 static PassRefPtr<IDBKey> create(int32_t number) | 46 static PassRefPtr<IDBKey> create(double number) |
47 { | 47 { |
48 return adoptRef(new IDBKey(number)); | 48 return adoptRef(new IDBKey(number)); |
49 } | 49 } |
50 static PassRefPtr<IDBKey> create(const String& string) | 50 static PassRefPtr<IDBKey> create(const String& string) |
51 { | 51 { |
52 return adoptRef(new IDBKey(string)); | 52 return adoptRef(new IDBKey(string)); |
53 } | 53 } |
54 ~IDBKey(); | 54 ~IDBKey(); |
55 | 55 |
56 // In order of the least to the highest precedent in terms of sort order. | 56 // In order of the least to the highest precedent in terms of sort order. |
57 enum Type { | 57 enum Type { |
58 NullType = 0, // FIXME: Phase out support for null keys. | 58 NullType = 0, // FIXME: Phase out support for null keys. |
59 StringType, | 59 StringType, |
60 NumberType | 60 NumberType |
61 }; | 61 }; |
62 | 62 |
63 Type type() const { return m_type; } | 63 Type type() const { return m_type; } |
64 | 64 |
65 const String& string() const | 65 const String& string() const |
66 { | 66 { |
67 ASSERT(m_type == StringType); | 67 ASSERT(m_type == StringType); |
68 return m_string; | 68 return m_string; |
69 } | 69 } |
70 | 70 |
71 int32_t number() const | 71 double number() const |
72 { | 72 { |
73 ASSERT(m_type == NumberType); | 73 ASSERT(m_type == NumberType); |
74 return m_number; | 74 return m_number; |
75 } | 75 } |
76 | 76 |
77 static PassRefPtr<IDBKey> fromQuery(SQLiteStatement& query, int baseColumn); | 77 static PassRefPtr<IDBKey> fromQuery(SQLiteStatement& query, int baseColumn); |
78 | 78 |
79 bool isEqual(IDBKey* other); | 79 bool isEqual(IDBKey* other); |
80 String whereSyntax(String qualifiedTableName = "") const; | 80 String whereSyntax(String qualifiedTableName = "") const; |
81 String lowerCursorWhereFragment(String comparisonOperator, String qualifiedT
ableName = ""); | 81 String lowerCursorWhereFragment(String comparisonOperator, String qualifiedT
ableName = ""); |
82 String upperCursorWhereFragment(String comparisonOperator, String qualifiedT
ableName = ""); | 82 String upperCursorWhereFragment(String comparisonOperator, String qualifiedT
ableName = ""); |
83 int bind(SQLiteStatement& query, int column) const; | 83 int bind(SQLiteStatement& query, int column) const; |
84 void bindWithNulls(SQLiteStatement& query, int baseColumn) const; | 84 void bindWithNulls(SQLiteStatement& query, int baseColumn) const; |
85 | 85 |
86 using ThreadSafeShared<IDBKey>::ref; | 86 using ThreadSafeShared<IDBKey>::ref; |
87 using ThreadSafeShared<IDBKey>::deref; | 87 using ThreadSafeShared<IDBKey>::deref; |
88 | 88 |
89 private: | 89 private: |
90 IDBKey(); | 90 IDBKey(); |
91 explicit IDBKey(int32_t); | 91 explicit IDBKey(double); |
92 explicit IDBKey(const String&); | 92 explicit IDBKey(const String&); |
93 | 93 |
94 Type m_type; | 94 Type m_type; |
95 String m_string; | 95 String m_string; |
96 int32_t m_number; | 96 double m_number; |
97 }; | 97 }; |
98 | 98 |
99 } | 99 } |
100 | 100 |
101 #endif // ENABLE(INDEXED_DATABASE) | 101 #endif // ENABLE(INDEXED_DATABASE) |
102 | 102 |
103 #endif // IDBKey_h | 103 #endif // IDBKey_h |
OLD | NEW |