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

📄 vparseline.cpp

📁 otl简单包装实现类,对数据库进行操作的,简单易用.
💻 CPP
字号:
/***************************************************************************                          vparseline.cpp -  description                             -------------------    begin                : 2004-12-25    copyright            : (C) 2004 by LiuZhong    email                : easeliu@vip.sina.com.cn ***************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************/#include <stdio.h>#include <memory.h>#include <stdlib.h>#include "vparseline.h"VParseLine::VParseLine(int LineSize){	m_LineSize = LineSize;	m_pLine = NULL;	m_pName = NULL;	m_pValue = NULL;}	VParseLine::~VParseLine(){	if(m_pLine) delete []m_pLine;	if(m_pName) delete []m_pName;	if(m_pValue) delete []m_pValue;}	int VParseLine::ParseLine(const char* Line){	if(strlen(Line)>1024) return -1;	if(strlen(Line)>m_LineSize){		if(m_pLine){			delete []m_pLine;			m_pLine = NULL;		}		if(m_pName){			delete []m_pName;			m_pName = NULL;		}		if(m_pValue){			delete []m_pValue;			m_pValue = NULL;		}		m_LineSize = strlen(Line)+1;	}	if(!m_pLine){		m_pLine = new char[m_LineSize];		m_pName = new char[m_LineSize];		m_pValue = new char[m_LineSize];	}	memset(m_pLine,0,m_LineSize);	memset(m_pName,0,m_LineSize);	memset(m_pValue,0,m_LineSize);	    char  *index,*index1,*index2;    int   rval = 0,pos;    strcpy(m_pLine,Line);    index = m_pLine;    while(*index==' ' || *index=='\t') index++;    if ((*index != '#') && (*index != '\n') && strncmp(index,"//",2)         && (*index != ';') && (index != NULL)) {		 index1=strchr(index,'=');		 if(index1!=NULL){             pos = index1-index-1;			 index1++;             *(index+pos+1) = 0;             while(pos>0 && (*(index+pos)==' ' || *(index+pos)=='\t')) *(index+pos--)=0;		     while(*index1==' ' || *index1=='\t')index1++;		     index2 = index1+strlen(index1)-1;             while(index2>=index1 &&(*index2=='\r' || *index2=='\n' || *index2==' '||*index2=='\t')) *index2-- = 0;		     strcpy(m_pName,index);		     strcpy(m_pValue,index1);		     rval = 2;		 }		 else{		 	 index1 = index+strlen(index)-1;			 while(index1>=index &&( *index1=='\r' || *index1=='\n' || *index1==' '||*index1=='\t')) *index1-- = 0;			 strcpy(m_pName,index);	              rval = 1;         }		        }    return rval;}const char* VParseLine::Line(){	return m_pLine;}const char* VParseLine::Name(){	return m_pName;}const char* VParseLine::Value(){	return m_pValue;}

⌨️ 快捷键说明

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