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