Views act like pointers to the actual collections, setting a view to a new value does not alter the collection to which this view pointed previously.

The protocol used for this class mimics the way many other collection classes are defined. For example, when used with MFC, you will see member definitions such as c4_View::GetSize, c4_View::GetAt, c4_View::InsertAt.

The elements of views can be referred to by their 0-based index, which produces a row-reference of type c4_RowRef. These row references can be copied, used to get or set properties, or dereferenced (in which case an object of class c4_Row is returned). Taking the address of a row reference produces a c4_Cursor, which acts very much like a pointer.

The following code creates a view with 1 row and 2 properties:

        c4_StringProp pName ("Name");
        c4_IntProp pAge ("Age");

        c4_Row data;
        pName (data) = "John Williams";
        pAge (data) = 43;

        c4_View myView;
        myView.Add(row);

<if !private>
int Add (const c4_RowRef& row_);
  Add a new entry, same as "SetAtGrow(GetSize(), ...)".

  <if !private>

int AddProperty (const c4_Property& property_);
  Adds a property column to a view if not already present

  <if !private>

c4_View Clone () const;
  Construct a new view with the same structure but no data

  <if !private>

int Compare (const c4_View& view_) const;

  <if !private>

c4_View Concat (const c4_View& view_) const;
  Constructs a view which has all rows of this view, and all rows of the second view appended. The structure of the second view is assumed to be identical to this one. This operation is a bit similar to appending all rows from the second view, but it does not actually store the result anywhere, it just looks like it.

  <if !private>

c4_View Counts (const c4_View& keys_, const c4_IntProp& name_) const;

  keys_ |  | the properties in this view determine the grouping
  name_ |  | name of the new count property defined in result

  This is similar to c4_View::GroupBy, but it determines only the number of rows in each group and does not create a nested view.

  <if !private>

const char* Describe () const;
  Return a description of the structure

  <if !private>

static const char* Description (const c4_View& view_);
  Return a homogenized description of this view

  <if !private>

c4_View Different (const c4_View& view_) const;
  Calculates the "XOR" of two sets. This will only work if both input views are sets, i.e. they have no duplicate rows in them.

  <if !private>

c4_View Duplicate (bool deepCopy_ =false) const;
  Construct a new view with a copy of the data

  <if !private>

c4_RowRef ElementAt (int index_);
  Element access, for use as RHS or LHS

  <if !private>

int Find (const c4_RowRef& key_, int start_ =0) const;
  Find index of the the next entry matching the specified key

  <if !private>

int FindPropIndexByName (const char* name_) const;
  Find the index of a property, given its name

  <if !private>

int FindProperty (int id_);
  Find the index of a property, given its id

  <if !private>

c4_RowRef GetAt (int index_) const;
  Return a reference to specified entry

  <if !private>

int GetIndexOf (const c4_RowRef& row_) const;
  Return the index of the specified row in this view (or -1)

  <if !private>

bool GetItem (int row_, int col_, c4_Bytes& buf_) const;

  row_ |  | row index, range [0 .. GetSize())
  col_ |  | property index, range [0 .. NumProperties())
  buf_ |  | buffer for the result

  This can be used to access view data in a generalized way. Useful for c4_CustomViewers which are based on other views.

  <if !private>

int GetSize () const;
  Return the number of entries

  <if !private>

int GetUpperBound () const;
  Return highest index (size - 1)

  <if !private>

c4_View GroupBy (const c4_View& keys_, const c4_ViewProp& name_) const;

  keys_ |  | the properties in this view determine the grouping
  name_ |  | name of the new subview defined in result

  This operation is similar to the SQL 'GROUP BY', but it takes advantage of the fact that MetaKit supports nested views. The view returned from this member has one row per distinct group, with an extra view property holding the remaining properties. If there are N rows in the original view matching key X, then the result is a row for key X, with a subview of N rows. The properties of the subview are all the properties not in the key.

  <if !private>

void InsertAt (int index_, const c4_View& view_);
  Insert a copy of the contents of another view

  <if !private>

void InsertAt (int index_, const c4_RowRef& row_, int count_ =1);
  Insert one or more copies of an entry

  <if !private>

c4_View Intersect (const c4_View& view_) const;
  Calculates the set intersection. This will only work if both input views are sets, i.e. they have no duplicate rows in them.

  <if !private>

c4_View Join (const c4_View& keys_, const c4_View& view_, bool outer_ =false) const;

  keys_ |  | the properties in this view determine the join
  view_ |  | second view participating in the join
  outer_ |  | true: keep rows with no match in second view

  <if !private>

c4_View JoinProp (const c4_ViewProp& sub_, bool outer_ =false) const;

  sub_ |  | name of the subview to expand
  outer_ |  | true: keep rows with empty subviews

  This operation is the inverse of c4_View::GroupBy, expanding all rows in specified subview and returning a view which looks as if the rows in each subview were "expanded in place".

  <if !private>

c4_View Minus (const c4_View& view_) const;
  Calculates set-difference of this view minus arg view. Result is a subset, unlike c4_View::Different. Will only work if both input views are sets, i.e. they have no duplicate rows in them.

  <if !private>

const c4_Property& NthProperty (int column_) const;
  Return the id of the N-th property

  <if !private>

int NumProperties () const;
  Return the number of properties

  <if !private>

c4_View Pair (const c4_View& view_) const;
  This is like a row-by-row concatenation. Both views must have the same number of rows, the result has all properties from this view plus any other properties from the other view.

  <if !private>

c4_View Product (const c4_View& view_) const;
  The cartesian product is defined as every combination of rows in both views. The number of entries is the product of the number of entries in the two views, properties which are present in both views will use the values defined in this view.

  <if !private>

c4_View Project (const c4_View& order_) const;
  Create view with the specified property arrangement

  <if !private>

c4_View ProjectWithout (const c4_View& order_) const;
  Create derived view with some properties omitted

  <if !private>

bool RelocateRows (int from_, int count_, c4_View& dest_, int pos_);
  Move attached rows to somewhere else in same storage

  <if !private>

c4_View RemapWith (const c4_View& order_) const;
  Remapping constructs a view with the rows indicated by another view. The first property in the order_ view must be an int property with index values referring to this one. The size of the resulting view is determined by the order_ view and can differ, for example to act as a subset selection (if smaller).

  <if !private>

void RemoveAll ();
  Remove all entries (sets size to zero)

  <if !private>

void RemoveAt (int index_, int count_ =1);
  Remove entries starting at the given index

  <if !private>

c4_View Rename (const c4_Property& old_, const c4_Property& new_) const;
  Create view with one property renamed (must be of same type)

  <if !private>

int Search (const c4_RowRef& key_) const;
  Search for a key, using the native sort order of the view

  <if !private>

c4_View Select (const c4_RowRef& criterium_) const;
  Create view with rows matching the specified value

  <if !private>

c4_View SelectRange (const c4_RowRef& rowLow_, const c4_RowRef& rowHigh_) const;
  Create view with row values within the specified range

  <if !private>

void SetAt (int index_, const c4_RowRef& row_);
  Replace an entry with the contents of another row. If the row contains subviews, they will be replaced as well, but there are two cases: if this is an attached view, all the subview rows will be copied (deep copy), whereas for an unattached view the new subviews will be shared with the original (shallow copy).

  <if !private>

void SetAtGrow (int index_, const c4_RowRef& row_);
  Set an entry, growing the view if needed

  <if !private>

void SetSize (int newSize_, int growBy_ =-1);
  Since views act like dynamic arrays, you can quickly change their size. Increasing the size will append rows with zero/empty values, while decreasing it will delete the last rows. The growBy_ parameter is currently unused.

  <if !private>

c4_View Slice (int start_, int limit_ =-1, int step_ =1) const;
  Returns a view which is a subset, either a contiguous range, or a "slice" with element taken from every step_ entries. If the step is negative, the same entries are returned, but in reverse order (start_ is still lower index, it'll then be returned last).

  <if !private>

c4_View Sort () const;
  Create view with all rows in natural (property-wise) order

  <if !private>

c4_View SortOn (const c4_View& order_) const;
  Create view sorted according to the specified properties

  <if !private>

c4_View SortOnReverse (const c4_View& order_, const c4_View& orderDown_) const;
  Create sorted view, with some properties sorted in reverse

  <if !private>

c4_View Structure () const;
  Return a view which describes the structure of this view

  <if !private>

c4_View Union (const c4_View& view_) const;
  Calculates the set union. This will only work if both input views are sets, i.e. they have no duplicate rows in them.

  <if !private>

c4_View Unique () const;
  Returns a subset which does not contain any duplicate rows.

  <if !private>

void _DecSeqRef ();

  <if !private>

void _IncSeqRef ();

  <if !private>

c4_Sequence* _seq;

  <if !private>

c4_View (c4_CustomViewer* viewer_);
  Construct a view based on a custom viewer

  <if !private>

c4_View (c4_Sequence* implementation_ =0);
  Construct a view based on a sequence

  <if !private>

c4_View (const c4_View& view_);
  Construct an empty view with one propertyConstruct a view from another one

  <if !private>

c4_View (const c4_View& view_);
  Construct an empty view with one propertyConstruct a view from another one

  <if !private>

c4_View operator, (const c4_Property& property_) const;
  Return a view like the first, with a property appended to it

  <if !private>

c4_View& operator= (const c4_View& source_);
  Make this view the same as another one

  <if !private>

c4_RowRef operator[] (int index_) const;
  Shorthand for c4_View::GetAt

  <if !private>

~c4_View ();
  Destructor, decrements reference count

class c4_View