⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nsf_dpp.cpp

📁 IBM Lotus C++ API 7.0a for IBM Lotus Notes/Domino Directory Release --------- ------------------
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// Name:
//		QueryArguments
//
// Description:
//		Querys the user to change any of the input parameters.
//		a carriage return on any of the prompts leaves it alone.
//---------------------------------------------------------------------------
void QueryArguments()
{
	cout << endl;
	cout << "Enter the following parameters (Enter by itself takes the default):" << endl;
	cout << endl;

	// Prompt for strings....
	cout << PromptString1 << ParamString1 << "]> ";
	cin >> CommandBuf;
	if( (CommandBuf) != (const char *)"" )
		ParamString1 = CommandBuf;

	cout << PromptString2 << ParamString2 << "]> ";
	cin >> CommandBuf;
	if( (CommandBuf) != (const char *)"" )
		ParamString2 = CommandBuf;

	cout << PromptString3 << ParamString3 << "]> ";
	cin >> CommandBuf;
	if( (CommandBuf) != (const char *)"" )
		ParamString3 = CommandBuf;

	cout << PromptString4 << ParamString4 << "]> ";
	cin >> CommandBuf;
	if( (CommandBuf) != (const char *)"" )
		ParamString4 = CommandBuf;

} // END QueryArguments()


//---------------------------------------------------------------------------
//
// Rich Text Parser Error Handling functions
//
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
//
// Name:
//		ProcessError
//
// Description:
//		Prints out error status. Used by ProcessRichText
//---------------------------------------------------------------------------
void ProcessError( LNSTATUS error )
{
char        msgbuf[LNERROR_MESSAGE_LENGTH];
LNString    errormessage;

    // Display the error message and increment the error count.

    LNGetErrorMessage(error, msgbuf);

    errormessage = "Rich Text Parsor Error! Count: [";
    errormessage << ErrorCount;
    errormessage << "] Message: ";
    errormessage << msgbuf;

    if ( pLog != 0 )
        pLog->LogMainHeading(errormessage);
    else
        cout << endl << errormessage << endl;

    ErrorCount++;
}

//---------------------------------------------------------------------------
//
// Name:
//      ProcessRichText
//
// Description:
//      Error handler for Rich Text Parser hangups.
//
// Remarks:
//
//      Definition of the LNPARSERERRORDATA from lnrt.hpp
//
//      struct LNRTPARSERERRORDATA
//      {
//          const LNItem *Item; // Rich text item, not fully initialized
//          LNINT       Offset; // From the beginning of the rich text, excluding the initial type word
//          WORD        CDSig;  // The signature of the cd record at the given offset
//          LNINT       CDSize; // The size of the cd record at the given offset
//          LNSTATUS    Status; // Error status found
//     };
//
//      Global defs from above...
//
//          NOTEID   PrevID;
//          LNString PrevName;
//          DWORD    PrevOffset;
//          WORD     PrevCDSig;
//          DWORD    PrevCDSize;
//
//---------------------------------------------------------------------------
LNSTATUS ProcessRichText( const LNRTPARSERERRORDATA &data )
{
LNNote doc = data.Item->GetNote();
NOTEID id = doc.GetNoteID();

    // If we've seen this problem before - go on without printing more
    // info

    if ( (id != PrevID)                     ||
         (data.Item->GetName() != PrevName) ||
         (data.Offset != PrevOffset)        ||
         (data.CDSig != PrevCDSig)          ||
         (data.CDSize != PrevCDSize)  )
    {
    LNString tempstring;

        PrevID     = id;
        PrevName   = data.Item->GetName();
        PrevOffset = data.Offset;
        PrevCDSig  = data.CDSig;
        PrevCDSize = data.CDSize;

        ProcessError(data.Status);

        // Dont log if pointer is no longer valid.

        if ( pLog == 0 )
            return data.Status;

        // log information about the problem rich text item but don't allow 
        // the parser to continue.

	    // Append the current Note ID to the log.
	    pLog->LogLabel( "Note ID            ", PrevID, 10 );

	    // Append the current Item name to the log.
	    pLog->LogLabel( "Item Name          ", PrevName );

        tempstring = pLog->GetCDSignatureString ( PrevCDSig );

	    // Append the currnet CD Sig to the log.
	    pLog->LogLabel( "CD Signature       ", PrevName );
    }

    return data.Status;

}// END ProcessRichText()


//===========================================================================
//
// IOPARAMETER Class Implementation
//
// Description:	
//		Implementation for a simple generic string buffer class.
//		to hold user input and output prompts.
//===========================================================================

//===========================================================================
// Constructors
//===========================================================================
IOParameter::IOParameter() // Default Constructor.
{
	size =1; // Null Terminator.
	
	if(! (pBuf = new char[size]) )
	{
		cout << "IOParameter:  Allocation Error!!!" << endl;
		exit(1);
	}

	pBuf[0] = '\0';
}

//===========================================================================
IOParameter::IOParameter( const char *Str ) // Init with const string.
{
	size = strlen(Str) + 1;					// Size of string + null term.

	if(! (pBuf = new char[size]) )
	{
		cout << "IOParameter:  Allocation Error!!!" << endl;
		exit(1);
	}

	strcpy(pBuf, Str);
}


//===========================================================================
// Constructs a decmal radix string representation in of an integer.
IOParameter::IOParameter( const int Number )
{
char	buf[16];						// Temporary Buffer for characters.

	sprintf(buf, "%d", Number);

	size = strlen(buf) + 1;				// Size of string + null term.

	if(! (pBuf = new char[size]) )
	{
		cout << "IOParameter:  Allocation Error!!!" << endl;
		exit(1);
	}

	strcpy(pBuf, buf);
}


//===========================================================================
IOParameter::IOParameter( const IOParameter &Other ) // copy constructor
{
	size = Other.size;

	if(! (pBuf = new char[size]) )
	{
		cout << "IOParameter:  Allocation Error!!!" << endl;
		exit(1);
	}

	strcpy(pBuf, Other.pBuf);
}

//===========================================================================
// Constructor using 2 IOParameter objects as input.
IOParameter::IOParameter( const IOParameter& Prefix, const IOParameter& Postfix)
{
	size = Prefix.size + Postfix.size - 1;

	if(! (pBuf = new char[size]) )
	{
		cout << "IOParameter:  Allocation Error!!!" << endl;
		exit(1);
	}

	strcpy(pBuf, Prefix.pBuf);
	strcat(pBuf, Postfix.pBuf);
}

//===========================================================================
// Subscript etc...
//===========================================================================
char IOParameter::operator [] (int index)
{
char c;

	if (index > size)
		c = '\0';
	else
		c = pBuf[index];

	return c;
}

//===========================================================================
// Assignment...
//===========================================================================
IOParameter IOParameter::operator = ( const IOParameter &Other )
{
	if(pBuf)
		delete [] pBuf;

	size = Other.size;
	
	if(! (pBuf = new char[size]) )
	{
		cout << "IOParameter:  Allocation Error!!!" << endl;
		exit(1);
	}

	strcpy(pBuf, Other.pBuf);

	return *this;
}

//===========================================================================
IOParameter IOParameter::operator = ( const char *Str )
{
	size = strlen(Str) +1;

	if (pBuf)
		delete [] pBuf;
	
	if(! (pBuf = new char[size]) )
	{
		cout << "IOParameter:  Allocation Error!!!" << endl;
		exit(1);
	}

	strcpy(pBuf, Str);
	return *this;
}

//===========================================================================
// I/O operators...
//===========================================================================
ostream &operator << ( ostream &Stream, const IOParameter &Other )
{
	Stream << Other.pBuf;
	return Stream;
}

//===========================================================================
istream &operator >> ( istream &Stream, IOParameter &Other )
{
const int buflen = 255;					// Arbitrary size change if needed...
char t[buflen];						// temp string... 
int len;

	for (len=0; len<buflen; len++)
	{
		Stream.get(t[len]);
		if (t[len] == '\n')  // New line character
			break;
		if (t[len] == '\b')  // Backspace character
		{
			if(len)
			{
				len--;
				// cout << "'\b'";  // for debug only...
			}
		}
	}

	t[len] = '\0';
	len++;

	if(Other.pBuf)
		delete [] Other.pBuf;

	if (! (Other.pBuf = new char[len]) )
	{
		cout << "IOParameter:  Allocation Error!!!" << endl;
		exit(1);
	}

	Other.size = len;

	strcpy(Other.pBuf, t);
	return Stream;

} // END istream &operator >>

//===========================================================================
// Concatenate...
//===========================================================================
IOParameter IOParameter::operator + ( const IOParameter &Other ) // Cat 2 IOParameter objects
{
	return IOParameter( *this, Other );
}

//===========================================================================
IOParameter IOParameter::operator + ( const char *str ) // Cat IOParameter and String.
{
	return IOParameter( *this, IOParameter(str) );
}

//===========================================================================
IOParameter operator + ( char *str, const IOParameter &Other ) // Cat string with IOParameter
{
	return IOParameter( IOParameter(str), Other );
}

//===========================================================================
IOParameter& IOParameter::operator << ( const IOParameter &Other ) // Cat 2 IOParameter objects
{
	IOParameter TempString(*this);

	size = TempString.size + Other.size - 1;

	if (pBuf)
		delete [] pBuf;

	if(! (pBuf = new char[size]) )
	{
		cout << "IOParameter:  Allocation Error!!!" << endl;
		exit(1);
	}

	strcpy(pBuf, TempString.pBuf);
	strcat(pBuf, Other.pBuf);

	return *this;
}

//===========================================================================
IOParameter& IOParameter::operator << ( const char *str ) // Cat IOParameter and String.
{
	IOParameter TempString(*this);
	IOParameter Other(str);

	size = TempString.size + Other.size - 1;

	if (pBuf)
		delete [] pBuf;

	if(! (pBuf = new char[size]) )
	{
		cout << "IOParameter:  Allocation Error!!!" << endl;
		exit(1);
	}

	strcpy(pBuf, TempString.pBuf);
	strcat(pBuf, Other.pBuf);

	return *this;	
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -