|
Oracle CLOB holds upto 4 gigabytes data. I tried retrieving the data out using StreamIn to a CRichEditCtrl control. I am able to StreamIn and StreamOut when data is upto 1 MB (I guess). I believe there are some tricks with large data in CLOB fields. I also checked Oracle DBMS_LOB package. It is not very clear how data can be retrieved to an program interface. CLOB data is stored and retrieved in the database by using locator ids. Have you successfully implemented an interface to work with large text data?
|
|
|
|
|
I am trying to implement a class for matrix multiplication:
Here is my header file:
******************************************************8
#include <stdlib.h>
class matrix
{
private:
double **m;
int nRows, nCols;
public:
matrix( int n1 = 0, int n2 = 0 );
~matrix( );
matrix& operator = ( const matrix& m1 );
matrix operator * ( const matrix& m1 );
int GetRows( ) { return nRows; }
int GetCols( ) { return nCols; }
void SetElement( int nRow, int nCol, double fValue );
double GetElement( int nRow, int nCol );
};
*********************************************************8
Here is my implementation file:
*****************************************************
#include "stdafx.h"
#include "matrix.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
matrix::matrix( int n1, int n2 ) {
if( n1 >= 0 && n2 >= 0 ) {
printf("Constructor ...\n");
nRows = n1;
nCols = n2;
if( nRows > 0 ) {
register int nRow;
m = ( double ** ) malloc( nRows * sizeof( double * ) );
for( nRow = 0; nRow < nRows; nRow++ ) {
m[nRow] = ( double * ) malloc( nCols * sizeof( double ) );
}
}
} else {
nRows = 0;
nCols = 0;
}
}
matrix::~matrix( ) {
if( nRows > 0 ) {
while( --nRows > -1 ) {
free( m[nRows] );
}
free( m );
}
}
matrix& matrix::operator = ( const matrix& m1 ) {
printf("Assignment operator ...\n");
// If the dimensions of the matrix are not the same, redefine the matrix
if( nRows != m1.nRows || nCols != m1.nCols ) {
printf("Reshaping!");
if( nRows > 0 ) {
while( --nRows > -1 ) {
free( m[nRows] );
}
free( m );
}
nRows = m1.nRows;
nCols = m1.nCols;
if( nRows > 0 ) {
register int nRow;
m = ( double ** ) malloc( nRows * sizeof( double * ) );
for( nRow = 0; nRow < nRows; nRow++ ) {
m[nRow] = ( double * ) malloc( nCols * sizeof( double ) );
}
}
}
// Copy the elements of the matrix
register int n1, n2;
for( n1 = 0; n1 < nRows; n1++ ) {
for( n2 = 0; n2 < nCols; n2++ ) {
***********************************
* THIS IS WHERE IT FAILS !!!!
***********************************
m[n1][n2] = m1.m[n1][n2];
}
}
return *this;
}
matrix matrix::operator * ( const matrix& m1 ) {
if( nCols == m1.nRows ) {
double fValue;
register int n1, n2, n3;
matrix mResult( nRows, m1.nCols );
for( n1 = 0; n1 < nRows; n1++ ) {
for ( n2 = 0; n2 < m1.nCols; n2++ ) {
fValue = 0.0;
for ( n3 = 0; n3 < nCols; n3++ ) {
fValue += m[n1][n3] * m1.m[n3][n2];
}
mResult.m[n1][n2] = fValue;
}
}
printf("Finished multiplying ...\n");
return mResult;
} else {
printf("ERROR");
// Multiplication is impossible
}
}
void matrix::SetElement( int nRow, int nCol, double fValue ) {
if( nRow >= 0 && nRow <= nRows && nCol >= 0 && nCol <= nCols) {
m[nRow][nCol] = fValue;
}
}
double matrix::GetElement( int nRow, int nCol ) {
if( nRow >= 0 && nRow <= nRows && nCol >= 0 && nCol <= nCols) {
return m[nRow][nCol];
} else {
return 0.0;
}
}
********************************************
Here is my code:
*************************
matrix m1( 3, 2 );
m1.SetElement (0, 0, 5.0);
m1.SetElement (0, 1, 4.0);
m1.SetElement (1, 0, 3.0);
m1.SetElement (1, 1, 2.0);
m1.SetElement (2, 0, 1.0);
m1.SetElement (2, 1, 0.0);
matrix m2( 2, 2 );
m2.SetElement (0, 0, 2.3);
m2.SetElement (0, 1, 3.7);
m2.SetElement (1, 0, 4.5);
m2.SetElement (1, 1, 6.9);
printf("Before multiplication ...\n");
matrix m3( 3, 2 );
m3 = m1 * m2;
printf("After multiplication ...\n");
printf("Element: %12.10f ", m3.GetElement (0, 0));
***********************
I marked the place where it fails above. I can't figure out why. Please help!!
Many thanks
|
|
|
|
|
Hi Anton,
Your class lacks a suitable copy constructor. The problem lies here:
m3 = m1 * m2; The expression m1 * m2 invokes matrix::operator * , which correctly builds the resulting matrix and returns it. But what m3 is being assigned is not that matrix, but a copy of it. As you haven't provided a copy constructor, the compiler uses the default one, which simply copies the object memberwise: so, the copied result member m really points to the same memory block as the matrix calculated in matrix::operator * ; by the time matrix::operator = enters into play, the internally calculated matrix has been destroyed, and the copied result points to non-valid memory.
More generally, when any function returns an object of whatever type, what the caller of the function gets is not the internal object, but rather a copy of it. The copy constructor is always implicitly called.
The morale is: copy constructors and assignment operators come in pairs, you cannot write one without writing the other. Keep this in mind and you'll save yourself a lot of trouble.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquin:
This makes perfect sense! Thank you for pointing me in the right direction.
|
|
|
|
|
|
World-class C++ advice! Muy bien.
|
|
|
|
|
Can any body help me figure out whats wrong with this code? All i'm trying to do is make a list of structs and then having the data in the lists printed. I havn't coded in C++ in a while so i'm assuming its the syntax
#include <fstream>
#include <iostream>
#include <iomanip> // format manipulation
#include <list> // list class library
using namespace std;
struct server
{
int server_ID;
int server_speed;
int operator==(const server&);
server& operator=(const server&);
}
int main()
{
ifstream myFile ("Request.dat", ios::in); // Don't mind this two lines
int Reqid, Artime, Cputime, server_num;
cout << "How many servers ur bitch ass wants?\n"; //Asking the user how many servers the list will consist of
cin >> server_num;
server IBM; // declare and instance of my struct
for (int i=0; i >= server_num; i++) // for each server the user requests
{ // an ID and server speed will be placed in the list
IBM.server_ID = i; // accessing the data member "ID"
IBM.server_speed = rand()% 700+100; // generating a random number for the server speed
list<server> servers;
servers.push_back (server_ID); // inputting data into list
servers.push_back (server_speed);
while (!servers.empty())
{
cout << servers.front() << " "; //printing the contents of my list
servers.pop_front();
}
cout << "\n";
/*while (!myFile.eof())
{
myFile >> Reqid >> Artime >> Cputime;
list<int> list1;
list1.push_back (Reqid);
list1.push_back (Artime);
list1.push_back (Cputime);
while (!list1.empty())
{
cout << list1.front() << ' ';
list1.pop_front();
}
*/
// Output the list values, by repeatedly getting the item from
// the "front" of the list, outputting it, and removing it
// from the front of the list.
}
return 0;
}
Sal. R
|
|
|
|
|
struct server
{
int server_ID;
int server_speed;
int operator==(const server&);
server& operator=(const server&);
}
Why the operators ?
for (int i=0; i >= server_num; i++)
Don't you mean <= ???
servers.push_back (server_ID); // inputting data into list
servers.push_back (server_speed);
Shouldn't you put this info into an instance of your struct and push that back ? How can you tell what in your list is an ID and what is a speed ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
Hello all,
I've wrote simple C++ program for Ms-Dos mode.
I wanna know, is there any way to run this program at startup ?
When the computer boots, and after the system checked the RAM and BIOS and CMOS, like Setup supervizer password.
I don't mean windows start up
Regards,
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
If you are talking about Windows 95,98,Me, you can still put things in Autoexec.bat, I believe.
You can pick your friends, and you can pick your nose, but you can't pick your friend's nose.
|
|
|
|
|
Hello Navin, thanks for reply.
But i wanna run exactly after RAM testing !
as i said, like Supervizer password in Setup.
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hahahahahhaha. This just shows me how old-skewl I am.
Put it in the autoexec.bat file.
|
|
|
|
|
Hello Scorp1us, thanks for reply.
But i wanna run exactly after RAM testing !
as i said, like Supervizer password in Setup.
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Can't do it uh-uh no way in hell. You'd have to write your own BIOS. Maybe the [Open|Linux]BIOS project may be of help?
Short of that, you could write your own boot loader to take over the PC as soon as it comes out of BIOS code. There you have LILO or GRUB (Both opensource linux boot loaders) as options.
|
|
|
|
|
OK, Thanks for information
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
on NT/2000 u can run it as an NT Service using the srvany utility. on 9x/me u can put it in the startup group
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
No. You can't get it to be executed by the bios, unless you can burn your own bios. You are asking to run a program off disk, before the system knows how to access the disk. It needs to boot first.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
OK
Thanks alot !
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
CBitmapButton seems to be wired to use bitmaps which are resources within the application.
My question is if I have those bitmaps on the disk , can I do a LoadImage
and use the HBITMAP's on the CBitmapButton ?
Amit
|
|
|
|
|
Is there any free library or code available that can be used to burn CDs on Windows earlier than XP.
If you know any such resource then mail me.
-----------------------------
In my dream, I was dorwning my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
NERO has a burning SDK.
Go search their homepage!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Tili wrote:
Is there any free library or code available that can be used to burn CDs on Windows earlier than XP.
Please Google for CDRecord (or cdrtools).
|
|
|
|
|
I am getting an Illegal Instruction error during StreamIn to a RichEdit control when the formatted text data is about two pages. I know that this has something to do with the size of data because I did not get any error messages when StreamIn a smaller size data. Below is the code snippet. The error was caught at catch(...).
//initialize m_dwSizeDescr
m_dwSizeDescr = 0;
es.pfnCallback = StreamInCallbackDescr;
try
{
m_ctrlDescription.StreamIn(SF_RTF, es);
}
catch (CDBException* e)
{
AfxMessageBox("Database problem " + e->m_strError);
}
catch (...)
{
AfxMessageBox("DoDataExchange StreamInCallbackDescr");
}
Eilzabeth
|
|
|
|
|
I have a dialog with some controls on it. I wish to make member variables for these controls. The problem is that in the ClassWizard, not all the IDC_* values show up, and some show up that aren't (but were) there.
In trying to fix this problem, I've re-numbered my resource.h file, and checked the .rc file - both are 'correct' - the .rc has all the proper IDC_* values, and no dupes exist in resource.h.
I've saved and reloaded, reverified everything. To this day ClassWizard instists that there is no IDC_WITH control but there is a IDC_LASTNAME control. (I had renamed IDC_LASTNAME to IDC_SO_LASTNAME, now BOTH show up, but only the IDC_SO_ one is in the .rc file.
Please help!
|
|
|
|
|
Recently I had a similar problem and workedaround it like follows:- Make a backup of your project just in case the thing fails.
- Copy your
.rc , resource.h and res directory to some new directory. Delete all these from your project.
- Open your project, then open the
.rc and drag and drop all resources to the project.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|