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

📄 line.cpp

📁 基于单片机的 snmp协议解析的一些原代码 给有用的 同行
💻 CPP
字号:
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop

#include <stdlib.h>
#include "Line.h"
//---------------------------------------------------------------------------
Line::Line()
{
	numIndices=0;
    type = 0;
    numIndents=0;
}

Line::Line(char *inString)
{
	char *temp;
    char *temp2;
//    const char endline=0x0A;

    temp = strtok(inString, " ");
    OID = temp;                     // OID support
    temp = strtok(NULL, " ");       // OID support
    node = temp;
    temp2 = strtok(NULL, " ");
    temp = strtok(NULL, " ");     // type

    if (!strncmp("Root", temp, 4))
    {
    	type = TYPE_ROOT;
        numIndices=0;
    }
    else if (!strncmp("Node", temp, 4))
    {
    	type = TYPE_NODE;
        numIndices=0;
    }
    else if (!strncmp("seq", temp, 3))
    {
    	type = TYPE_SEQUENCE;
    	temp = strtok(NULL, " "); // read name
	    temp = strtok(NULL, " "); // read num indices
    	numIndices = atoi(temp);
      if ((numIndices > 9) || (numIndices < 1))
        numIndices = 1;
    }
    else if (!strncmp("Table", temp, 5))
    {
    	type = TYPE_TABLE;
        numIndices=0;
    }
    else if (!strncmp("Row", temp, 3))
    {
    	type = TYPE_TABLE;          // only temporary
        numIndices=0;
    }
    else
    {
    	type = TYPE_LEAF;
        numIndices=0;
    }
    numIndents=0;
    parent = strtok(temp2,".");
}

void Line::GetInfo(short *indices, short *theType)
{
	*indices = numIndices;
    *theType = type;
}
void Line::SetIndices(short indices)
{
	numIndices = indices;
}
short Line::GetIndices()
{
	return numIndices;
}
void Line::SetIndent(short indents)
{
	numIndents = indents;
}
short Line::GetIndent()
{
	return numIndents;
}

AnsiString Line::GetParent ()
{
	return parent;
}
void Line::GetNameInfo(AnsiString nodeName, AnsiString parentName)
{
	nodeName = node;
    parentName = parent;
}

Line::~Line()
{
}
AnsiString Line::GetName()
{
	if (type != TYPE_LEAF)
		return node;
    else
    {
    	AnsiString temp=node;
        temp+=".";
        if (numIndices==0)
        	temp+="0";
        else
        	temp+="X";
        return temp;
    }
}
AnsiString Line::GetOID()
{
    return(OID);
}
short Line::GetType()
{
	return(type);
}
 

⌨️ 快捷键说明

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