void*能接受那些类型?
inline int EG::ByteLocator::Locate(void* identifier,int i_length)
{
while(curIndex<dataSize)
{
if(memcmp(identifier,&srcBuffer[curIndex],i_length)==0)
{
curIndex+=i_length;
return curIndex;
}
curIndex+=step;
}
return -1;
}
int end=locator.Locate((void*)0x00,1);
#ifndef EG_MEMORY_H
#define EG_MEMORY_H
#include"EG/EGDef.h"
#include<memory.h>
#ifdef __cplusplus
extern "C"{//声明为C编译,连接方式为外部函数
#endif
namespace EG{
typedef EG::byte dataType;
class EG_API ByteLocator
//字节定位器
{
private:
dataType* srcBuffer;
int curIndex;
int step;
int dataSize;
ByteLocator(const ByteLocator&);
ByteLocator& operator=(const ByteLocator&);
public:
ByteLocator(dataType* srcBuffer,int srcSize,int curIndex=0,int step=1);
int Locate(dataType* identifier,int i_length);
int Locate(void* identifier,int i_length);
int Locate(byte4 identifier,int i_length=4);
/*
*如果找到标识数据,则返回数据末端的索引
*如果没有找到标识数据,返回负值
*/
void operator+(int val);
void operator-(int val);
int setIndex(int Index);
int setStep(int step);
int GetIndex();
int GetStep();
};
};
inline void EG::ByteLocator::operator+(int val)
{
this->curIndex=curIndex+val;
}
inline void EG::ByteLocator::operator-(int val)
{
this->curIndex=curIndex-val;
}
inline int EG::ByteLocator::setIndex(int Index)
{
if((Index>=dataSize)||(Index<0))
return EXCEPTION;
this->curIndex=Index;
return OK;
}
inline int EG::ByteLocator::setStep(int step)
{
if(step==0)
return EXCEPTION;
this->step=step;
return OK;
}
inline int EG::ByteLocator::GetIndex(){ return curIndex;}
inline int EG::ByteLocator::GetStep() { return step;}
inline int EG::ByteLocator::Locate(void* identifier,int i_length)
{
while(curIndex<dataSize)
{
if(memcmp(identifier,&srcBuffer[curIndex],i_length)==0)
{
curIndex+=i_length;
return curIndex;
}
curIndex+=step;
}
return -1;
}
#ifdef __cplusplus
}
#endif
#endif
3,都属于二进制文件 可以使用
[解决办法]
内联要求在每一个编译单元存在定义,你把定义放在 cpp 里面,其他地方没有了,可不是出错吗。
[解决办法]