Warning, /pim/akregator/src/storage/metakit/include/mk4.inl is written in an unsupported language. File is not indexed.
0001 // mk4.inl --
0002 // This is part of Metakit, the homepage is http://www.equi4.com/metakit/
0003
0004 /** @file
0005 * Public definitions which are usually inlined
0006 */
0007
0008 /////////////////////////////////////////////////////////////////////////////
0009 // Reordered inlines so they are always defined before their first use
0010
0011 d4_inline c4_Cursor c4_RowRef::operator& () const
0012 {
0013 return _cursor;
0014 }
0015
0016 /** Return a unique id for this property
0017 *
0018 * A property object in fact merely represents an entry in a globally
0019 * maintained symbol table. Each property is assigned a unique id,
0020 * which remains valid as long as some reference to that property
0021 * exists. In general, property id's remain unique as long as the
0022 * application runs. Do not store id's on file, since they are
0023 * not guaranteed to remain the same across program invocations.
0024 * All properties with the same name are given the same id.
0025 */
0026 d4_inline int c4_Property::GetId() const
0027 {
0028 return _id;
0029 }
0030
0031 //////////////////////////////////////////////////////////////////////////////////
0032
0033 #if !defined(q4_LONG64) && !defined (LONG_LONG) && !defined(HAVE_LONG_LONG)
0034
0035 d4_inline bool operator== (const t4_i64 a_, const t4_i64 b_)
0036 {
0037 return a_.l1 == b_.l1 && a_.l2 == b_.l2;
0038 }
0039
0040 d4_inline bool operator< (const t4_i64 a_, const t4_i64 b_)
0041 {
0042 return a_.l2 < b_.l2 || a_.l2 == b_.l2 && a_.l2 < b_.l2;
0043 }
0044
0045 #endif
0046
0047 //////////////////////////////////////////////////////////////////////////////////
0048 // c4_View
0049
0050 /// Returns the number of entries in this view.
0051 d4_inline int c4_View::GetSize() const
0052 {
0053 return _seq->NumRows();
0054 }
0055
0056 /** Change the size of this view
0057 * Since views act like dynamic arrays, you can quickly
0058 * change their size. Increasing the size will append rows
0059 * with zero/empty values, while decreasing it will delete
0060 * the last rows. The growBy_ parameter is currently unused.
0061 */
0062 d4_inline void c4_View::SetSize(int newSize_, int growBy_)
0063 {
0064 _seq->Resize(newSize_, growBy_);
0065 }
0066
0067 /// Removes all entries (sets size to zero).
0068 d4_inline void c4_View::RemoveAll()
0069 {
0070 SetSize(0);
0071 }
0072
0073 /// Return a pointer to the persistence handler, or zero
0074 d4_inline c4_Persist* c4_View::Persist() const
0075 {
0076 return _seq->Persist();
0077 }
0078
0079 /**
0080 * Change the value of the specified entry. If the new value has
0081 * other properties, these will be added to the underlying view.
0082 *
0083 * @param index_ the zero-based row index
0084 * @param newElem_ the row to copy to this view
0085 */
0086 d4_inline void c4_View::SetAt(int index_, const c4_RowRef& newElem_)
0087 {
0088 _seq->SetAt(index_, &newElem_);
0089 }
0090
0091 /**
0092 * Insert a copy of the contents of another view. This is identical to
0093 * inserting the specified number of default entries and then setting
0094 * each of them to the new element value passed as argument.
0095 */
0096 d4_inline void c4_View::InsertAt(
0097 int index_, ///< zero-based row index
0098 const c4_RowRef& newElem_, ///< the value to insert
0099 int count_ ///< number of copies to insert, must be > 0
0100 )
0101 {
0102 _seq->InsertAt(index_, &newElem_, count_);
0103 }
0104
0105 /**
0106 * Remove entries starting at the given index. Entries which have
0107 * other view references may cause these views to be deleted if their
0108 * reference counts drop to zero because of this removal.
0109 *
0110 * @param index_ the zero-based row index
0111 * @param count_ the number of entries to remove
0112 */
0113 d4_inline void c4_View::RemoveAt(int index_, int count_)
0114 {
0115 _seq->RemoveAt(index_, count_);
0116 }
0117
0118 /** Return the number of properties present in this view.
0119 * @return A non-negative integer
0120 */
0121 d4_inline int c4_View::NumProperties() const
0122 {
0123 return _seq->NumHandlers();
0124 }
0125
0126 /** Find the index of a property, given its id
0127 * @param propId_ Unique id associated to a specific propoerty
0128 * @return The index of the property, or -1 of it was not found
0129 */
0130 d4_inline int c4_View::FindProperty(int propId_)
0131 {
0132 return _seq->PropIndex(propId_);
0133 }
0134
0135 /// Return a decription if there is a fixed structure, else zero
0136 d4_inline const char* c4_View::Description() const
0137 {
0138 return _seq->Description();
0139 }
0140
0141 /// Increase the reference count of the associated sequence
0142 d4_inline void c4_View::_IncSeqRef()
0143 {
0144 _seq->IncRef();
0145 }
0146
0147 /// Decrease the reference count of the associated sequence
0148 d4_inline void c4_View::_DecSeqRef()
0149 {
0150 _seq->DecRef();
0151 }
0152
0153 /// Destructor, decrements reference count
0154 d4_inline c4_View::~c4_View ()
0155 {
0156 _DecSeqRef();
0157 }
0158
0159 /// Return true if the contents of both views are equal
0160 d4_inline bool operator== (const c4_View& a_, const c4_View& b_)
0161 {
0162 return a_.GetSize() == b_.GetSize() && a_.Compare(b_) == 0;
0163 }
0164
0165 /// Return true if the contents of both views are not equal
0166 d4_inline bool operator!= (const c4_View& a_, const c4_View& b_)
0167 {
0168 return !(a_ == b_);
0169 }
0170
0171 /// True if first view is less than second view
0172 d4_inline bool operator< (const c4_View& a_, const c4_View& b_)
0173 {
0174 return a_.Compare(b_) < 0;
0175 }
0176
0177 /// True if first view is greater than second view
0178 d4_inline bool operator> (const c4_View& a_, const c4_View& b_)
0179 {
0180 return b_ < a_;
0181 }
0182
0183 /// True if first view is less or equal to second view
0184 d4_inline bool operator<= (const c4_View& a_, const c4_View& b_)
0185 {
0186 return !(b_ < a_);
0187 }
0188
0189 /// True if first view is greater or equal to second view
0190 d4_inline bool operator>= (const c4_View& a_, const c4_View& b_)
0191 {
0192 return !(a_ < b_);
0193 }
0194
0195 /////////////////////////////////////////////////////////////////////////////
0196 // c4_Cursor
0197
0198 /** Constructs a new cursor.
0199 *
0200 * Cursor cannot be created without an underlying view, but you could
0201 * define a global "nullView" object and then initialize the cursor with
0202 * "&nullView[0]". This works because cursors need not point to a valid row.
0203 */
0204 d4_inline c4_Cursor::c4_Cursor (c4_Sequence& seq_, int index_)
0205 : _seq (&seq_), _index (index_)
0206 {
0207 }
0208
0209 /// Pre-increments the cursor.
0210 d4_inline c4_Cursor& c4_Cursor::operator++ ()
0211 {
0212 ++_index;
0213 return *this;
0214 }
0215
0216 /// Post-increments the cursor.
0217 d4_inline c4_Cursor c4_Cursor::operator++ (int)
0218 {
0219 return c4_Cursor (*_seq, _index++);
0220 }
0221
0222 /// Pre-decrements the cursor.
0223 d4_inline c4_Cursor& c4_Cursor::operator-- ()
0224 {
0225 --_index;
0226 return *this;
0227 }
0228
0229 /// Post-decrements the cursor.
0230 d4_inline c4_Cursor c4_Cursor::operator-- (int)
0231 {
0232 return c4_Cursor (*_seq, _index--);
0233 }
0234
0235 /// Advances by a given offset.
0236 d4_inline c4_Cursor& c4_Cursor::operator+= (int offset_)
0237 {
0238 _index += offset_;
0239 return *this;
0240 }
0241
0242 /// Backs up by a given offset.
0243 d4_inline c4_Cursor& c4_Cursor::operator-= (int offset_)
0244 {
0245 _index -= offset_;
0246 return *this;
0247 }
0248
0249 /// Subtracts a specified offset.
0250 d4_inline c4_Cursor c4_Cursor::operator- (int offset_) const
0251 {
0252 return c4_Cursor (*_seq, _index - offset_);
0253 }
0254
0255 /// Returns the distance between two cursors.
0256 d4_inline int c4_Cursor::operator- (c4_Cursor cursor_) const
0257 {
0258 return _index - cursor_._index;
0259 }
0260
0261 /// Add a specified offset.
0262 d4_inline c4_Cursor operator+ (c4_Cursor cursor_, int offset_)
0263 {
0264 return c4_Cursor (*cursor_._seq, cursor_._index + offset_);
0265 }
0266
0267 /// Adds specified offset to cursor.
0268 d4_inline c4_Cursor operator+ (int offset_, c4_Cursor cursor_)
0269 {
0270 return cursor_ + offset_;
0271 }
0272
0273 d4_inline bool operator== (c4_Cursor a_, c4_Cursor b_)
0274 {
0275 return a_._seq == b_._seq && a_._index == b_._index;
0276 }
0277
0278 d4_inline bool operator!= (c4_Cursor a_, c4_Cursor b_)
0279 {
0280 return !(a_ == b_);
0281 }
0282
0283 d4_inline bool operator< (c4_Cursor a_, c4_Cursor b_)
0284 {
0285 return a_._seq < b_._seq ||
0286 ( a_._seq == b_._seq && a_._index < b_._index );
0287 }
0288
0289 d4_inline bool operator> (c4_Cursor a_, c4_Cursor b_)
0290 {
0291 return b_ < a_;
0292 }
0293
0294 d4_inline bool operator<= (c4_Cursor a_, c4_Cursor b_)
0295 {
0296 return !(b_ < a_);
0297 }
0298
0299 d4_inline bool operator>= (c4_Cursor a_, c4_Cursor b_)
0300 {
0301 return !(a_ < b_);
0302 }
0303
0304 /////////////////////////////////////////////////////////////////////////////
0305 // c4_RowRef
0306
0307 d4_inline c4_RowRef::c4_RowRef (c4_Cursor cursor_)
0308 : _cursor (cursor_)
0309 {
0310 }
0311
0312 d4_inline c4_RowRef c4_RowRef::operator= (const c4_RowRef& rowRef_)
0313 {
0314 if (_cursor != rowRef_._cursor)
0315 _cursor._seq->SetAt(_cursor._index, &rowRef_);
0316
0317 return *this;
0318 }
0319
0320 d4_inline c4_View c4_RowRef::Container() const
0321 {
0322 return _cursor._seq;
0323 }
0324
0325 d4_inline bool operator== (const c4_RowRef& a_, const c4_RowRef& b_)
0326 {
0327 return (&a_)._seq->Compare((&a_)._index, &b_) == 0;
0328 }
0329
0330 d4_inline bool operator!= (const c4_RowRef& a_, const c4_RowRef& b_)
0331 {
0332 return !(a_ == b_);
0333 }
0334
0335 d4_inline bool operator< (const c4_RowRef& a_, const c4_RowRef& b_)
0336 {
0337 // 25-5-1998: don't exchange a and b, this comparison is -not- symmetric
0338 return (&a_)._seq->Compare((&a_)._index, &b_) < 0;
0339 }
0340
0341 d4_inline bool operator> (const c4_RowRef& a_, const c4_RowRef& b_)
0342 {
0343 // 25-5-1998: don't exchange a and b, this comparison is -not- symmetric
0344 return (&a_)._seq->Compare((&a_)._index, &b_) > 0;
0345 }
0346
0347 d4_inline bool operator<= (const c4_RowRef& a_, const c4_RowRef& b_)
0348 {
0349 return !(a_ > b_);
0350 }
0351
0352 d4_inline bool operator>= (const c4_RowRef& a_, const c4_RowRef& b_)
0353 {
0354 return !(a_ < b_);
0355 }
0356
0357 /////////////////////////////////////////////////////////////////////////////
0358 // c4_Bytes
0359
0360 /// Construct an empty binary object
0361 d4_inline c4_Bytes::c4_Bytes ()
0362 : _size (0), _copy (false)
0363 {
0364 _contents = nullptr; // moved out of intializers for DEC CXX 5.7
0365 }
0366
0367 /// Construct an object with contents, no copy
0368 d4_inline c4_Bytes::c4_Bytes (const void* buf_, int len_)
0369 : _size (len_), _copy (false)
0370 {
0371 _contents = (t4_byte*) buf_; // moved out of intializers for DEC CXX 5.7
0372 }
0373
0374 /// Returns a pointer to the contents.
0375 d4_inline const t4_byte* c4_Bytes::Contents() const
0376 {
0377 return _contents;
0378 }
0379
0380 /// Returns the number of bytes of its contents.
0381 d4_inline int c4_Bytes::Size() const
0382 {
0383 return _size;
0384 }
0385
0386 d4_inline void c4_Bytes::_LoseCopy()
0387 {
0388 if (_copy)
0389 delete [] (char*) _contents;
0390 }
0391
0392 /// Returns true if the contents of both objects is not equal.
0393 d4_inline bool operator!= (const c4_Bytes& a_, const c4_Bytes& b_)
0394 {
0395 return !(a_ == b_);
0396 }
0397
0398 /// Destructor, if a copy was made, it will be released here.
0399 d4_inline c4_Bytes::~c4_Bytes ()
0400 {
0401 _LoseCopy();
0402 }
0403
0404 /////////////////////////////////////////////////////////////////////////////
0405 // c4_Reference
0406
0407 d4_inline c4_Reference::c4_Reference (const c4_RowRef& rowRef_,
0408 const c4_Property& prop_)
0409 : _cursor (&rowRef_), _property (prop_)
0410 {
0411 }
0412
0413 d4_inline int c4_Reference::GetSize() const
0414 {
0415 return _cursor._seq->ItemSize(_cursor._index, _property.GetId());
0416 }
0417
0418 d4_inline bool c4_Reference::GetData(c4_Bytes& buf_) const
0419 {
0420 return _cursor._seq->Get(_cursor._index, _property.GetId(), buf_);
0421 }
0422
0423 d4_inline void c4_Reference::SetData(const c4_Bytes& buf_) const
0424 {
0425 _cursor._seq->Set(_cursor._index, _property, buf_);
0426 }
0427
0428 d4_inline bool operator!= (const c4_Reference& a_, const c4_Reference& b_)
0429 {
0430 return !(a_ == b_);
0431 }
0432
0433 /////////////////////////////////////////////////////////////////////////////
0434 // c4_IntRef
0435
0436 d4_inline c4_IntRef::c4_IntRef (const c4_Reference& value_)
0437 : c4_Reference (value_)
0438 {
0439 }
0440
0441 /////////////////////////////////////////////////////////////////////////////
0442 #if !defined(q4_TINY)
0443 /////////////////////////////////////////////////////////////////////////////
0444 // c4_LongRef
0445
0446 d4_inline c4_LongRef::c4_LongRef (const c4_Reference& value_)
0447 : c4_Reference (value_)
0448 {
0449 }
0450
0451 /////////////////////////////////////////////////////////////////////////////
0452 // c4_FloatRef
0453
0454 d4_inline c4_FloatRef::c4_FloatRef (const c4_Reference& value_)
0455 : c4_Reference (value_)
0456 {
0457 }
0458
0459 /////////////////////////////////////////////////////////////////////////////
0460 // c4_DoubleRef
0461
0462 d4_inline c4_DoubleRef::c4_DoubleRef (const c4_Reference& value_)
0463 : c4_Reference (value_)
0464 {
0465 }
0466
0467 /////////////////////////////////////////////////////////////////////////////
0468 #endif // !q4_TINY
0469 /////////////////////////////////////////////////////////////////////////////
0470 // c4_BytesRef
0471
0472 d4_inline c4_BytesRef::c4_BytesRef (const c4_Reference& value_)
0473 : c4_Reference (value_)
0474 {
0475 }
0476
0477 /////////////////////////////////////////////////////////////////////////////
0478 // c4_StringRef
0479
0480 d4_inline c4_StringRef::c4_StringRef (const c4_Reference& value_)
0481 : c4_Reference (value_)
0482 {
0483 }
0484
0485 /////////////////////////////////////////////////////////////////////////////
0486 // c4_ViewRef
0487
0488 d4_inline c4_ViewRef::c4_ViewRef (const c4_Reference& value_)
0489 : c4_Reference (value_)
0490 {
0491 }
0492
0493 /////////////////////////////////////////////////////////////////////////////
0494 // c4_Property
0495
0496 d4_inline c4_Property::c4_Property (char type_, int id_)
0497 : _id ((short) id_), _type (type_)
0498 {
0499 }
0500
0501 /// Get or set this untyped property in a row
0502 d4_inline c4_Reference c4_Property::operator() (const c4_RowRef& rowRef_) const
0503 {
0504 return c4_Reference (rowRef_, *this);
0505 }
0506
0507 /// Return a view like the first, with a property appended to it
0508 d4_inline c4_View c4_Property::operator, (const c4_Property& prop_) const
0509 {
0510 return c4_View (*this), prop_;
0511 }
0512
0513 /// Return the type of this property
0514 d4_inline char c4_Property::Type() const
0515 {
0516 return _type;
0517 }
0518
0519 /////////////////////////////////////////////////////////////////////////////
0520 // c4_IntProp
0521
0522 d4_inline c4_IntProp::c4_IntProp (const char* name_)
0523 : c4_Property ('I', name_)
0524 {
0525 }
0526
0527 d4_inline c4_IntProp::~c4_IntProp ()
0528 = default;
0529
0530 d4_inline c4_IntRef c4_IntProp::operator() (const c4_RowRef& rowRef_) const
0531 {
0532 return c4_Reference (rowRef_, *this);
0533 }
0534
0535 d4_inline t4_i32 c4_IntProp::Get(const c4_RowRef& rowRef_) const
0536 {
0537 return operator() (rowRef_);
0538 }
0539
0540 d4_inline void c4_IntProp::Set(const c4_RowRef& rowRef_, t4_i32 value_) const
0541 {
0542 operator() (rowRef_) = value_;
0543 }
0544
0545 d4_inline c4_Row c4_IntProp::AsRow(t4_i32 value_) const
0546 {
0547 c4_Row row;
0548 operator() (row) = value_;
0549 return row;
0550 }
0551
0552 d4_inline c4_Row c4_IntProp::operator[] (t4_i32 value_) const
0553 {
0554 return AsRow(value_);
0555 }
0556
0557 /////////////////////////////////////////////////////////////////////////////
0558 #if !defined(q4_TINY)
0559 /////////////////////////////////////////////////////////////////////////////
0560 // c4_LongProp
0561
0562 d4_inline c4_LongProp::c4_LongProp (const char* name_)
0563 : c4_Property ('L', name_)
0564 {
0565 }
0566
0567 d4_inline c4_LongProp::~c4_LongProp ()
0568 = default;
0569
0570 d4_inline c4_LongRef c4_LongProp::operator() (const c4_RowRef& rowRef_) const
0571 {
0572 return c4_Reference (rowRef_, *this);
0573 }
0574
0575 d4_inline t4_i64 c4_LongProp::Get(const c4_RowRef& rowRef_) const
0576 {
0577 return operator() (rowRef_);
0578 }
0579
0580 d4_inline void c4_LongProp::Set(const c4_RowRef& rowRef_, t4_i64 value_) const
0581 {
0582 operator() (rowRef_) = value_;
0583 }
0584
0585 d4_inline c4_Row c4_LongProp::AsRow(t4_i64 value_) const
0586 {
0587 c4_Row row;
0588 operator() (row) = value_;
0589 return row;
0590 }
0591
0592 d4_inline c4_Row c4_LongProp::operator[] (t4_i64 value_) const
0593 {
0594 return AsRow(value_);
0595 }
0596
0597 /////////////////////////////////////////////////////////////////////////////
0598 // c4_FloatProp
0599
0600 d4_inline c4_FloatProp::c4_FloatProp (const char* name_)
0601 : c4_Property ('F', name_)
0602 {
0603 }
0604
0605 d4_inline c4_FloatProp::~c4_FloatProp ()
0606 = default;
0607
0608 d4_inline c4_FloatRef c4_FloatProp::operator() (const c4_RowRef& rowRef_) const
0609 {
0610 return c4_Reference (rowRef_, *this);
0611 }
0612
0613 d4_inline double c4_FloatProp::Get(const c4_RowRef& rowRef_) const
0614 {
0615 return operator() (rowRef_);
0616 }
0617
0618 d4_inline void c4_FloatProp::Set(const c4_RowRef& rowRef_, double value_) const
0619 {
0620 operator() (rowRef_) = value_;
0621 }
0622
0623 d4_inline c4_Row c4_FloatProp::AsRow(double value_) const
0624 {
0625 c4_Row row;
0626 operator() (row) = value_;
0627 return row;
0628 }
0629
0630 d4_inline c4_Row c4_FloatProp::operator[] (double value_) const
0631 {
0632 return AsRow(value_);
0633 }
0634
0635 /////////////////////////////////////////////////////////////////////////////
0636 // c4_DoubleProp
0637
0638 d4_inline c4_DoubleProp::c4_DoubleProp (const char* name_)
0639 : c4_Property ('D', name_)
0640 {
0641 }
0642
0643 d4_inline c4_DoubleProp::~c4_DoubleProp ()
0644 = default;
0645
0646 d4_inline c4_DoubleRef c4_DoubleProp::operator() (const c4_RowRef& rowRef_) const
0647 {
0648 return c4_Reference (rowRef_, *this);
0649 }
0650
0651 d4_inline double c4_DoubleProp::Get(const c4_RowRef& rowRef_) const
0652 {
0653 return operator() (rowRef_);
0654 }
0655
0656 d4_inline void c4_DoubleProp::Set(const c4_RowRef& rowRef_, double value_) const
0657 {
0658 operator() (rowRef_) = value_;
0659 }
0660
0661 d4_inline c4_Row c4_DoubleProp::AsRow(double value_) const
0662 {
0663 c4_Row row;
0664 operator() (row) = value_;
0665 return row;
0666 }
0667
0668 d4_inline c4_Row c4_DoubleProp::operator[] (double value_) const
0669 {
0670 return AsRow(value_);
0671 }
0672
0673 /////////////////////////////////////////////////////////////////////////////
0674 #endif // !q4_TINY
0675 /////////////////////////////////////////////////////////////////////////////
0676 // c4_BytesProp
0677
0678 d4_inline c4_BytesProp::c4_BytesProp (const char* name_)
0679 : c4_Property ('B', name_)
0680 {
0681 }
0682
0683 d4_inline c4_BytesProp::~c4_BytesProp ()
0684 = default;
0685
0686 d4_inline c4_BytesRef c4_BytesProp::operator() (const c4_RowRef& rowRef_) const
0687 {
0688 return c4_Reference (rowRef_, *this);
0689 }
0690
0691 d4_inline c4_Bytes c4_BytesProp::Get(const c4_RowRef& rowRef_) const
0692 {
0693 return operator() (rowRef_);
0694 }
0695
0696 d4_inline void c4_BytesProp::Set(const c4_RowRef& rowRef_, const c4_Bytes& value_) const
0697 {
0698 operator() (rowRef_) = value_;
0699 }
0700
0701 d4_inline c4_Row c4_BytesProp::AsRow(const c4_Bytes& value_) const
0702 {
0703 c4_Row row;
0704 operator() (row) = value_;
0705 return row;
0706 }
0707
0708 d4_inline c4_Row c4_BytesProp::operator[] (const c4_Bytes& value_) const
0709 {
0710 return AsRow(value_);
0711 }
0712
0713 /////////////////////////////////////////////////////////////////////////////
0714 // c4_StringProp
0715
0716 d4_inline c4_StringProp::c4_StringProp (const char* name_)
0717 : c4_Property ('S', name_)
0718 {
0719 }
0720
0721 d4_inline c4_StringProp::~c4_StringProp ()
0722 = default;
0723
0724 d4_inline c4_StringRef c4_StringProp::operator() (const c4_RowRef& rowRef_) const
0725 {
0726 return c4_Reference (rowRef_, *this);
0727 }
0728
0729 d4_inline const char* c4_StringProp::Get(const c4_RowRef& rowRef_) const
0730 {
0731 return operator() (rowRef_);
0732 }
0733
0734 d4_inline void c4_StringProp::Set(const c4_RowRef& rowRef_, const char* value_) const
0735 {
0736 operator() (rowRef_) = value_;
0737 }
0738
0739 d4_inline c4_Row c4_StringProp::AsRow(const char* value_) const
0740 {
0741 c4_Row row;
0742 operator() (row) = value_;
0743 return row;
0744 }
0745
0746 d4_inline c4_Row c4_StringProp::operator[] (const char* value_) const
0747 {
0748 return AsRow(value_);
0749 }
0750
0751 /////////////////////////////////////////////////////////////////////////////
0752 // c4_ViewProp
0753
0754 d4_inline c4_ViewProp::c4_ViewProp (const char* name_)
0755 : c4_Property ('V', name_)
0756 {
0757 }
0758
0759 d4_inline c4_ViewProp::~c4_ViewProp ()
0760 = default;
0761
0762 d4_inline c4_ViewRef c4_ViewProp::operator() (const c4_RowRef& rowRef_) const
0763 {
0764 return c4_Reference (rowRef_, *this);
0765 }
0766
0767 d4_inline c4_View c4_ViewProp::Get(const c4_RowRef& rowRef_) const
0768 {
0769 return operator() (rowRef_);
0770 }
0771
0772 d4_inline void c4_ViewProp::Set(const c4_RowRef& rowRef_, const c4_View& value_) const
0773 {
0774 operator() (rowRef_) = value_;
0775 }
0776
0777 d4_inline c4_Row c4_ViewProp::AsRow(const c4_View& value_) const
0778 {
0779 c4_Row row;
0780 operator() (row) = value_;
0781 return row;
0782 }
0783
0784 d4_inline c4_Row c4_ViewProp::operator[] (const c4_View& value_) const
0785 {
0786 return AsRow(value_);
0787 }
0788
0789 /////////////////////////////////////////////////////////////////////////////
0790 // c4_Strategy
0791
0792 /// True if we can do I/O with this object
0793 d4_inline bool c4_Strategy::IsValid() const
0794 {
0795 return false;
0796 }
0797
0798 /////////////////////////////////////////////////////////////////////////////
0799 // c4_CustomViewer
0800
0801 d4_inline c4_CustomViewer::c4_CustomViewer()
0802 = default;
0803
0804 d4_inline int c4_CustomViewer::Lookup(const c4_RowRef& r_, int& n_)
0805 {
0806 return Lookup(&r_, n_); // c4_Cursor
0807 }
0808
0809 d4_inline bool c4_CustomViewer::InsertRows(int p_, const c4_RowRef& r_, int n_)
0810 {
0811 return InsertRows(p_, &r_, n_); // c4_Cursor
0812 }
0813
0814 /////////////////////////////////////////////////////////////////////////////
0815 // c4_Sequence
0816
0817 d4_inline c4_Dependencies* c4_Sequence::GetDependencies() const
0818 {
0819 return _dependencies;
0820 }
0821
0822 /////////////////////////////////////////////////////////////////////////////
0823 // Reordered inlines so they are always used after their definition
0824
0825 /// Dereferences this cursor to "almost" a row.
0826 d4_inline c4_RowRef c4_Cursor::operator* () const
0827 {
0828 return *(c4_Cursor*) this; // cast avoids a const problem with BCPP 4.52
0829 }
0830
0831 /// This is the same as *(cursor + offset).
0832 d4_inline c4_RowRef c4_Cursor::operator[] (int offset_) const
0833 {
0834 return *(*this + offset_);
0835 }
0836
0837 /// Returns a reference to specified entry, for use as RHS or LHS
0838 d4_inline c4_RowRef c4_View::GetAt(int index_) const
0839 {
0840 return * c4_Cursor (*_seq, index_);
0841 }
0842
0843 /** Element access, shorthand for GetAt
0844 * @return A reference to the specified row in the view.
0845 * This reference can be used on either side of the assignment operator.
0846 */
0847 d4_inline c4_RowRef c4_View::operator[] (
0848 int index_ ///< zero-based row index
0849 ) const
0850 {
0851 return GetAt(index_);
0852 }
0853
0854 /** Element access, shorthand for GetAt
0855 * @return A reference to the specified row in the view.
0856 * This reference can be used on either side of the assignment operator.
0857 */
0858 d4_inline c4_RowRef c4_View::ElementAt(
0859 int index_ ///< zero-based row index
0860 )
0861 {
0862 return GetAt(index_);
0863 }
0864
0865 /////////////////////////////////////////////////////////////////////////////