epoc32/include/bacell.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100 (2010-03-31)
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@4
     4
// under the terms of "Eclipse Public License v1.0"
williamr@2
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
//
williamr@2
    15
williamr@2
    16
// Written by DanH, Sept 1995
williamr@2
    17
#if !defined(__BACELL_H__)
williamr@2
    18
#define __BACELL_H__
williamr@2
    19
williamr@2
    20
#if !defined(__E32DEF_H_)
williamr@2
    21
#include <e32def.h>
williamr@2
    22
#endif
williamr@2
    23
williamr@2
    24
#if !defined(__S32STRM_H__)
williamr@2
    25
#include <s32strm.h>
williamr@2
    26
#endif
williamr@2
    27
williamr@2
    28
//class RReadStream;
williamr@2
    29
//class RWriteStream;
williamr@2
    30
williamr@2
    31
class TCellRef
williamr@2
    32
/** 
williamr@2
    33
Identifies a cell by row and column number. 
williamr@2
    34
@publishedAll
williamr@2
    35
@released
williamr@2
    36
*/
williamr@2
    37
	{
williamr@2
    38
public:
williamr@2
    39
	inline TCellRef();
williamr@2
    40
	inline TCellRef(TInt aRow,TInt aCol);
williamr@2
    41
williamr@2
    42
	inline TBool operator==(const TCellRef& aCell) const;
williamr@2
    43
	inline TBool operator!=(const TCellRef& aCell) const;
williamr@2
    44
williamr@2
    45
	inline TCellRef& operator+=(const TCellRef& aCell);
williamr@2
    46
	inline TCellRef& operator-=(const TCellRef& aCell);
williamr@2
    47
williamr@2
    48
	IMPORT_C void Offset(TInt aRowOffset,TInt aColOffset);
williamr@2
    49
//
williamr@2
    50
	IMPORT_C void InternalizeL(RReadStream& aStream);
williamr@2
    51
	inline void ExternalizeL(RWriteStream& aStream) const;
williamr@2
    52
public:
williamr@2
    53
	/** The row number. */
williamr@2
    54
	TInt iRow;
williamr@2
    55
	/** The column number. */
williamr@2
    56
	TInt iCol;
williamr@2
    57
	};
williamr@2
    58
williamr@2
    59
/** 
williamr@2
    60
@publishedAll
williamr@2
    61
@released
williamr@2
    62
*/
williamr@2
    63
IMPORT_C TCellRef operator+(const TCellRef& aLeft,const TCellRef& aRight);
williamr@2
    64
IMPORT_C TCellRef operator-(const TCellRef& aLeft,const TCellRef& aRight);
williamr@2
    65
williamr@2
    66
inline TCellRef::TCellRef()
williamr@2
    67
	/** Default constructor.
williamr@2
    68
	
williamr@2
    69
	The object's row and column number are undefined. */
williamr@2
    70
	{}
williamr@2
    71
inline TCellRef::TCellRef(TInt aRow,TInt aCol)
williamr@2
    72
    : iRow(aRow),iCol(aCol)
williamr@2
    73
	/** Constructor taking a row and column number.
williamr@2
    74
	
williamr@2
    75
	@param aRow The row number.
williamr@2
    76
	@param aCol The column number. */
williamr@2
    77
	{}
williamr@2
    78
inline TBool TCellRef::operator==(const TCellRef& aCell) const
williamr@2
    79
	/** Compares this cell with the specified cell for equality.
williamr@2
    80
	
williamr@2
    81
	@param aCell The cell to be compared.
williamr@2
    82
	@return ETrue, if the row numbers are the same and column numbers are 
williamr@2
    83
	the same. */
williamr@2
    84
	{return aCell.iRow==iRow && aCell.iCol==iCol;}
williamr@2
    85
inline TBool TCellRef::operator!=(const TCellRef& aCell) const
williamr@2
    86
	/** Compares this cell with the specified cell for inequality.
williamr@2
    87
	
williamr@2
    88
	@param aCell The cell to be compared.
williamr@2
    89
	@return ETrue, if the row numbers are different or the column numbers are 
williamr@2
    90
	different. */
williamr@2
    91
	{return aCell.iRow!=iRow || aCell.iCol!=iCol;}
williamr@2
    92
inline TCellRef& TCellRef::operator+=(const TCellRef& aCell)
williamr@2
    93
	/** Adds the specified cell to this cell.
williamr@2
    94
	
williamr@2
    95
	Addition is the process of adding the specified cell's row and column 
williamr@2
    96
	numbers to this cell's row and column numbers respectively.
williamr@2
    97
	
williamr@2
    98
	@param aCell The cell to be added.
williamr@2
    99
	@return A reference to this cell object. */
williamr@2
   100
	{Offset(aCell.iRow,aCell.iCol);return *this;}
williamr@2
   101
inline TCellRef& TCellRef::operator-=(const TCellRef& aCell)
williamr@2
   102
	/** Subtracts the specified cell from this cell.
williamr@2
   103
	
williamr@2
   104
	Subtraction is the process of subtracting the specified cell's row and 
williamr@2
   105
	column numbers from this cell's row and column numbers respectively.
williamr@2
   106
	
williamr@2
   107
	@param aCell The cell to be subtracted.
williamr@2
   108
	@return A reference to this cell object. */
williamr@2
   109
	{Offset(-aCell.iRow,-aCell.iCol);return *this;}
williamr@2
   110
inline void TCellRef::ExternalizeL(RWriteStream& aStream) const
williamr@2
   111
	/** Externalises an object of this class to a write stream.
williamr@2
   112
	
williamr@2
   113
	The presence of this function means that the standard templated operator<<() 
williamr@2
   114
	can be used to externalise objects of this class. 
williamr@2
   115
	
williamr@2
   116
	@param aStream Stream to which the object should be externalised. */
williamr@2
   117
	{aStream.WriteInt32L(iRow);aStream.WriteInt32L(iCol);}
williamr@2
   118
williamr@2
   119
williamr@2
   120
class TRangeRef
williamr@2
   121
/** 
williamr@2
   122
Identifies a range of cells by start and end cell references.
williamr@2
   123
The range is inclusive of both the start and end cells.
williamr@2
   124
@see TCellRef
williamr@2
   125
@publishedAll
williamr@2
   126
@released
williamr@2
   127
*/
williamr@2
   128
	{
williamr@2
   129
public:
williamr@2
   130
	inline TRangeRef();
williamr@2
   131
	inline TRangeRef(const TCellRef& aFrom,const TCellRef& aTo);
williamr@2
   132
	inline TRangeRef(TInt aFromRow,TInt aFromCol,TInt aToRow,TInt aToCol);
williamr@2
   133
williamr@2
   134
	IMPORT_C TBool operator==(const TRangeRef& aRange) const;
williamr@2
   135
	inline TBool operator!=(const TRangeRef& aRange) const;
williamr@2
   136
williamr@2
   137
	inline void SetRange(const TCellRef& aFrom,const TCellRef& aTo);
williamr@2
   138
	inline void SetRange(TInt aFromRow,TInt aFromCol,TInt aToRow,TInt aToCol);
williamr@2
   139
	inline TInt NoRows() const;
williamr@2
   140
	inline TInt NoCols() const;
williamr@2
   141
	IMPORT_C TInt NoCells() const;
williamr@2
   142
	IMPORT_C TBool Contains(const TCellRef& aCell) const;
williamr@2
   143
	IMPORT_C void InternalizeL(RReadStream& aStream);
williamr@2
   144
	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
williamr@2
   145
public:
williamr@2
   146
	/** The start cell. */
williamr@2
   147
	TCellRef	iFrom;
williamr@2
   148
	/** The end cell. */
williamr@2
   149
	TCellRef	iTo;
williamr@2
   150
public:
williamr@2
   151
	class TIter;	// defined outside TRangeRef class as contains TRangeRef
williamr@2
   152
	};
williamr@2
   153
class TRangeRef::TIter
williamr@2
   154
/**
williamr@2
   155
@publishedAll
williamr@2
   156
@released
williamr@2
   157
*/
williamr@2
   158
	{
williamr@2
   159
public:
williamr@2
   160
	IMPORT_C TIter(const TRangeRef& aRangeRef);
williamr@2
   161
	IMPORT_C TBool operator++();
williamr@2
   162
	inline TBool InRange() const;
williamr@2
   163
public:
williamr@2
   164
	TCellRef	iCurrent;
williamr@2
   165
private:
williamr@2
   166
	TRangeRef	iRange;
williamr@2
   167
	};
williamr@2
   168
williamr@2
   169
williamr@2
   170
inline TRangeRef::TRangeRef()
williamr@2
   171
	/** Default constructor.
williamr@2
   172
	
williamr@2
   173
	The object's start cell and end cell are undefined. */
williamr@2
   174
	{}
williamr@2
   175
inline TRangeRef::TRangeRef(const TCellRef& aFrom,const TCellRef& aTo)
williamr@2
   176
	: iFrom(aFrom),iTo(aTo)
williamr@2
   177
	/** Constructor taking a start and end cell.
williamr@2
   178
	
williamr@2
   179
	@param aFrom The start cell.
williamr@2
   180
	@param aTo The end cell. */
williamr@2
   181
	{}
williamr@2
   182
inline TRangeRef::TRangeRef(TInt aFromRow,TInt aFromCol,TInt aToRow,TInt aToCol)
williamr@2
   183
	: iFrom(aFromRow,aFromCol),iTo(aToRow,aToCol)
williamr@2
   184
	/** Constructor taking a start row and start column number, and an end row and 
williamr@2
   185
	end column number.
williamr@2
   186
	
williamr@2
   187
	@param aFromRow The start row number.
williamr@2
   188
	@param aFromCol The start column number.
williamr@2
   189
	@param aToRow The end row number.
williamr@2
   190
	@param aToCol The end column number. */
williamr@2
   191
	{}
williamr@2
   192
inline void TRangeRef::SetRange(const TCellRef& aFrom,const TCellRef& aTo)
williamr@2
   193
	/** Sets the cell range to the specified cells.
williamr@2
   194
	
williamr@2
   195
	@param aFrom The start cell for the range.
williamr@2
   196
	@param aTo The end cell for the range. */
williamr@2
   197
	{iFrom=aFrom;iTo=aTo;}
williamr@2
   198
inline void TRangeRef::SetRange(TInt aFromRow,TInt aFromCol,TInt aToRow,TInt aToCol)
williamr@2
   199
	/** Sets the cell range to the specified start row and column, and end row 
williamr@2
   200
	and column.
williamr@2
   201
	
williamr@2
   202
	@param aFromRow The start row number.
williamr@2
   203
	@param aFromCol The start column number.
williamr@2
   204
	@param aToRow The end row number.
williamr@2
   205
	@param aToCol The end column number. */
williamr@2
   206
	{iFrom.iRow=aFromRow;iFrom.iCol=aFromCol;iTo.iRow=aToRow;iTo.iCol=aToCol;}
williamr@2
   207
inline TBool TRangeRef::operator!=(const TRangeRef& aRange) const
williamr@2
   208
	/** Compares this cell range with the specified cell range for inequality.
williamr@2
   209
	
williamr@2
   210
	@param aRange The cell to be compared.
williamr@2
   211
	@return ETrue, if the start cells are different or the end cells are 
williamr@2
   212
	different. */
williamr@2
   213
	{return !operator==(aRange);}
williamr@2
   214
inline TInt TRangeRef::NoRows() const
williamr@2
   215
	/** Gets the number of rows represented by the range.
williamr@2
   216
	
williamr@2
   217
	@return The number of rows. */
williamr@2
   218
	{return iTo.iRow - iFrom.iRow + 1;}
williamr@2
   219
inline TInt TRangeRef::NoCols() const
williamr@2
   220
	/** Gets the number of columns represented by the range.
williamr@2
   221
	
williamr@2
   222
	@return The number of columns. */
williamr@2
   223
	{return iTo.iCol - iFrom.iCol + 1;}
williamr@2
   224
inline TBool TRangeRef::TIter::InRange() const
williamr@2
   225
	{return iRange.Contains(iCurrent);}
williamr@2
   226
williamr@2
   227
#endif