Click here to Skip to main content
15,891,136 members
Articles / Desktop Programming / MFC

The Ultimate Grid Home Page

,
Rate me:
Please Sign up or sign in to vote.
5.00/5 (122 votes)
14 Sep 2013CPOL10 min read 4.6M   81.9K   418  
The Ultimate Grid is now Open Source
// ===================================================================
//     Class: CUGCBArrayDataSource
//      File: UGCBADSC.h
//   Created: September 19, 1998
//   Revised: 
//   Purpose: Example of simple CByteArray dump datasource
//				Shows how a simple datasource can
//				reduce memory overhead by working directly
//				from data in memory
// ===================================================================
// This software along with its related components, documentation and files ("The Libraries")
// is � 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
// governed by a software license agreement ("Agreement").  Copies of the Agreement are
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
// to obtain this file, or directly from our office.  For a copy of the license governing
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
// ===================================================================
#ifndef _UGCBADSC_H_
#define _UGCBADSC_H_

#include "ugctrl.h"

// we can control the number of bytes dumped in a cell
#define UGCBA_OPT_BLOCKSIZE 99
// ... and whether we want decimal or hex or...
#define UGCBA_OPT_RADIX	98		
// ... and what to display for non-printing ascii chars
#define UGCBA_OPT_REPCHAR 97	

// radi supported
#define UGCBA_RADIX_HEX 1
#define UGCBA_RADIX_DECIMAL 2

class CUGCBArrayDataSource : public CUGDataSource {
private:
	// private member declarations


protected:
	// protected member declarations
	int				m_nBlockSize;		// how many bytes to format in a cell
	int				m_extra;			// leftover bytes for last row...
	int				m_radix;			// hex or what...
	CString			m_strTemp;			// for formatting block (cell) data
	char			m_cNonPrintable;	// can change from the traditional '.'
	long			m_lastRow;			// set in GetNumRows;
public:
	// public member declarations
	CByteArray		*m_byteArray;		// array in question - possibly 
										// the result of loading a file 
										// in serialize...

	CUGCBArrayDataSource();

	virtual ~CUGCBArrayDataSource();
	CUGCBArrayDataSource(const CUGCBArrayDataSource& );
	CUGCBArrayDataSource operator=(const CUGCBArrayDataSource&);
	
	/////////////////////////////////////////////////////////////////////
	// CUGDataSource overrides - this is a read-only datasource, so only
	// a few basics needed...
	virtual long GetNumRows();
	virtual int GetNumCols();
	virtual int	GetCell(int col,long row,CUGCell *cell);
	virtual int FindNext(CString *string,int *col,long *row,int flags);
	//options
	virtual int SetOption(int option,long param1,long param2);
	virtual int GetOption(int option,long& param1,long& param2);

	// new for dumper app
	void FormatHexString(long row);
    void FormatDecimalString(long row);
	void FormatAsciiString(long row);


};
	bool operator==(const CUGCBArrayDataSource&, const CUGCBArrayDataSource&);
	bool operator!=(const CUGCBArrayDataSource&, const CUGCBArrayDataSource&);

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Canada Canada
In January 2005, David Cunningham and Chris Maunder created TheUltimateToolbox.com, a new group dedicated to the continued development, support and growth of Dundas Software’s award winning line of MFC, C++ and ActiveX control products.

Ultimate Grid for MFC, Ultimate Toolbox for MFC, and Ultimate TCP/IP have been stalwarts of C++/MFC development for a decade. Thousands of developers have used these products to speed their time to market, improve the quality of their finished products, and enhance the reliability and flexibility of their software.
This is a Organisation

476 members

Written By
Software Developer (Senior)
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions