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

📄 resptxt.cpp

📁 ISO 8583 with c++ for financial transaction standard
💻 CPP
字号:
//
// IT24 Sistemas S.A.
// Proyecto Sistema OnLine de Atencion de Tarjetas
// Texto de Respuesta de Codigos de Errores 
//
//
// Tarea        Fecha           Autor   Observaciones
// (Inicial)    1998.08.07      mdc     Base
//


// Headers propios
#include <qusrinc/alias.h>
#include <qusrinc/typedefs.h>
#include <qusrinc/resptxt.h>

// Standard I/O memory functions
#include <memory.h>
#include <string.h>


// Clase Lista de BitMapStr
// Constructor por default
RESPTXTLIST::RESPTXTLIST() 
	{
	// Contador a cero
	iCounter = 0;	
	}

// Constructor opcional
RESPTXTLIST::RESPTXTLIST(PSTR pszRespCde, PSTR pszText) 
	{
	// Contador a cero
	iCounter = 0;
	// Insercion de string de texto y codigo
	Insert(pszRespCde, pszText);	
	}

// Destructor
RESPTXTLIST::~RESPTXTLIST() 
	{	
	// Iteracion para la busqueda
	for (INT i = 0; i < iCounter; i++)
		{
		// Precondicion de desalocacion
		if(strlTexts[i].pszRespCde == NULL)
			continue;
		// Desalocacion de espacio
		try
			{
			delete[] strlTexts[i].pszRespCde;
			delete[] strlTexts[i].pszTxt;
			}//end-try
		catch(int iError)
			{
			throw (iError); // Error o Excepcion arrojada 
			}//end-throw
		// Punteros en Nulo
		strlTexts[i].pszRespCde = NULL;
		strlTexts[i].pszTxt     = NULL;
		}//end-for
	// Contador a cero
	iCounter = 0;	
	}

// Insercion
BOOL RESPTXTLIST::Insert(PSTR pszRespCde, PSTR pszText) 
	{
	// Precondicion
	if((pszRespCde == NULL) || (pszText == NULL))
		return FALSE;
	
	// Longitud de strings
	INT iLenCde = strlen(pszRespCde),
		iLenTxt = strlen(pszText);
	// Chequear longitudes...
	if( (iLenCde < MAX_RESPTXT_LEN && iLenCde > 0) 
		&&
		(iLenTxt < MAX_RESPTXT_LEN && iLenTxt > 0) 
		&&
		// y maximo de contador
		(iCounter < MAX_RESPTXTS)
		&&
		// y no existe previamente
		(Find(pszRespCde) == FALSE)
		)
		{
		// Alocacion de espacio
		try
			{
			strlTexts[iCounter].pszRespCde = new CHAR[iLenCde+1];
			strlTexts[iCounter].pszTxt     = new CHAR[iLenTxt+1];
			}//end-try
		catch(int iError)
			{
			strlTexts[iCounter].pszRespCde = NULL;
			strlTexts[iCounter].pszTxt     = NULL;
			throw (iError); // Error o Excepcion arrojada 
			}//end-throw
		// Copia interna al final de la lista
		strcpy(strlTexts[iCounter].pszRespCde, pszRespCde); 
		strcpy(strlTexts[iCounter].pszTxt    , pszText   ); 
		// e incremento a posteriori del contador
		iCounter++;
		// Ok
		return (TRUE);
		}
	else
		return (FALSE);
	}

// Buscador
BOOL RESPTXTLIST::Find(PSTR pszRespCde) 
	{
	// Precondicion
	if(pszRespCde == NULL)
		return FALSE;
	// Precondicion
	if(iCounter == 0)
		return (FALSE);	

	// Iteracion para la busqueda
	for (INT i = 0; i < iCounter; i++)
			// Es el codigo buscado?						
			if ( strcmp(strlTexts[i].pszRespCde, pszRespCde) == 0 )
				// Hallado
				return (TRUE);
	// No hallado
	return (FALSE);
	}

// Cargador
PSTR RESPTXTLIST::Get(PSTR pszRespCde) 
	{
	// Precondicion
	if(pszRespCde == NULL)
		return FALSE;
	// Precondicion
	if(iCounter == 0)
		return (FALSE);	

	// Iteracion para la busqueda
	for (INT i = 0; i < iCounter; i++)
			// Es el codigo buscado?						
			if ( strcmp(strlTexts[i].pszRespCde, pszRespCde) == 0 )
				// Hallado, retornar el texto
				return (PSTR)strlTexts[i].pszTxt;
	// No hallado
	return (PSTR)NULL;
	}

⌨️ 快捷键说明

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