当前位置: 首页>>代码示例>>C++>>正文


C++ ReadField函数代码示例

本文整理汇总了C++中ReadField函数的典型用法代码示例。如果您正苦于以下问题:C++ ReadField函数的具体用法?C++ ReadField怎么用?C++ ReadField使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ReadField函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReadField

int IDialPacket::LoadPacket(BYTE* pBuffer, DWORD nLength)
{
	CHAR xCommandId[10];
	
	DWORD nRead = ReadField( pBuffer, xCommandId, 10 );
	if ( ! IsCommandId( xCommandId ) ) return -1;
	BYTE* ptr = pBuffer + nRead;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	int nField = ReadField( ptr, RemoteId, 21 );
	nRead += nField; ptr += nField;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	nField = ReadField( ptr, LocalId, 21 );
	nRead += nField; ptr += nField;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	nField = ReadField( ptr, CallerId, 21 );
	nRead += nField; ptr += nField;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	nField = ReadField( ptr, FeeNumber, 21 );
	nRead += nField; ptr += nField;

	if ( *( ptr ) != '\r' ) return -1;

	return nRead + 1;
}
开发者ID:pics860,项目名称:callcenter,代码行数:28,代码来源:ipacket.cpp

示例2: CargarInvent

void CargarInvent(int NpcIndex) {
	/* '*************************************************** */
	/* 'Author: Unknown */
	/* 'Last Modification: - */
	/* ' */
	/* '*************************************************** */

	/* 'Vuelve a cargar el inventario del npc NpcIndex */
	int LoopC;
	std::string ln;
	std::string npcfile;

	npcfile = GetDatPath(DATPATH::NPCs);

	Npclist[NpcIndex].Invent.NroItems = vb6::val(
			GetVar(npcfile, "NPC" + vb6::CStr(Npclist[NpcIndex].Numero), "NROITEMS"));
	Npclist[NpcIndex].Invent.NroItems = vb6::Constrain(Npclist[NpcIndex].Invent.NroItems, 0, MAX_INVENTORY_SLOTS);

	for (LoopC = (1); LoopC <= (Npclist[NpcIndex].Invent.NroItems); LoopC++) {
		ln = GetVar(npcfile, "NPC" + vb6::CStr(Npclist[NpcIndex].Numero), "Obj" + vb6::CStr(LoopC));
		Npclist[NpcIndex].Invent.Object[LoopC].ObjIndex = vb6::val(ReadField(1, ln, 45));
		Npclist[NpcIndex].Invent.Object[LoopC].Amount = vb6::val(ReadField(2, ln, 45));

	}

}
开发者ID:Chaitooler,项目名称:dakara-server,代码行数:26,代码来源:InvNpcs.cpp

示例3: EncontrarCant

/* ' @remarks This function reads the Npc.dat file */
int EncontrarCant(int NpcIndex, int ObjIndex) {
	int retval;
	/* '*************************************************** */
	/* 'Author: Unknown */
	/* 'Last Modification: 03/09/08 */
	/* 'Last Modification By: Marco Vanotti (Marco) */
	/* ' - 03/09/08 EncontrarCant now returns 0 if the npc doesn't have it (Marco) */
	/* '*************************************************** */

	/* 'Devuelve la cantidad original del obj de un npc */

	std::string ln;
	std::string npcfile;
	int i;

	npcfile = GetDatPath(DATPATH::NPCs);

	for (i = (1); i <= (MAX_INVENTORY_SLOTS); i++) {
		ln = GetVar(npcfile, "NPC" + vb6::CStr(Npclist[NpcIndex].Numero), "Obj" + vb6::CStr(i));
		if (ObjIndex == vb6::val(ReadField(1, ln, 45))) {
			retval = (int) vb6::val(ReadField(2, ln, 45));
			return retval;
		}
	}

	retval = 0;

	return retval;
}
开发者ID:Chaitooler,项目名称:dakara-server,代码行数:30,代码来源:InvNpcs.cpp

示例4: ReadField

int CPacketBase::LoadPacket(BYTE* pBuffer, DWORD nLength)
{
	DWORD nRead = CPacket::LoadPacket( pBuffer, nLength );
	if ( nRead == -1 ) return -1;
	
	CHAR szTemp[16];
	BYTE* ptr = pBuffer + nRead;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	int nField = ReadField( ptr, szTemp, 16 );
	nRead += nField; ptr += nField;
	
	ASSERT( m_pXML == NULL );
	DWORD nXMLLength = _ttoi( szTemp );
	
	if ( nLength - nRead < 2 + nXMLLength )
	{
		return BufferSize = 0;
	}
	
	CXMLElement* pXML = CXMLElement::FromBytes( pBuffer + nRead + 2, nXMLLength, FALSE );
	m_pXML = ( pXML ) ? LoadBody( pXML ) : NULL;
	
	if ( ! m_pXML && pXML ) delete pXML;

	BufferSize = nRead + 2 + nXMLLength;
	return BufferSize;
}
开发者ID:pics860,项目名称:callcenter,代码行数:28,代码来源:PacketBase.cpp

示例5: memset

bool CDBF::Locate(bool bLoca)
{	
	unsigned int uiHave,i,j;
	unsigned long ulPrevious=m_ulCurRecLine;
	char cResult[MAX_CHAR_LENGTH+1];
	memset(cResult,0,MAX_CHAR_LENGTH+1);
	for (i=0;i<m_ulRecCount;i++)
	{
		uiHave=0;
		m_ulCurRecLine=i;
		for (j=0;j<m_uiCond;j++)
		{
			ReadField(m_pszCondition[j][0],cResult,MAX_CHAR_LENGTH);
			AllTrim(cResult);
			if (strnicmp(cResult,m_pszCondition[j][1],MAX_CHAR_LENGTH)==0)
			{
				uiHave++;
			}
		}
		if (uiHave==m_uiCond)
		{
			if (bLoca)
				m_ulCurRecLine=i;
			else
				m_ulCurRecLine=ulPrevious;
			return true;
		}
	}
	m_ulCurRecLine=ulPrevious;
	return false;
}
开发者ID:wuweiFrank,项目名称:useful,代码行数:31,代码来源:ReadDBF.cpp

示例6: variables

/*
==============
ReadLevelLocals
 
All pointer variables(except function pointers) must be handled specially.
==============
*/
void ReadLevelLocals(FILE *f){
	field_t	*field;
	
	fread(&level, sizeof(level), 1, f);
	
	for(field = levelfields; field->name; field++){
		ReadField(f, field,(byte *)&level);
	}
}
开发者ID:luaman,项目名称:qforge-2,代码行数:16,代码来源:g_save.c

示例7: ParseSub

static void ParseSub( const string & s, char & cmd, vector <string> & fields ) {

	unsigned int i = 0;
	cmd = MustGet( s, i++ );
	if ( cmd != SUB_CMD ) {
		CSVTHROW( "Invalid value for " << FLAG_EDIT << ": " << s );
	}
	char sep = MustGet( s, i++ );
	if (  sep == '\\' ) {
		CSVTHROW( "Invalid value for " << FLAG_EDIT << ": " << s );
	}

	string f = ReadField( s, i, sep );
	fields.push_back( f );
	f = ReadField( s, i, sep );
	fields.push_back( f );
	f = s.substr( i );
	fields.push_back( f );
}
开发者ID:bminossi,项目名称:csvfix,代码行数:19,代码来源:csved_edit.cpp

示例8: SendCommand

void* ShineImpl::RequestRepeatedField(int8 index, int32 offset) {
    SendCommand('r');
    transport_->SendByte(index);
    transport_->SendUInt32(offset);

    // Read back the value.
    int8 field_index = transport_->ReadByte(); // Ignored
    FieldTypes field_type = input_->type(index);

    // TODO(jmcgill): Work out how this value survives on the stack. Might need
    // a RequestRepeatedField for each type (or size) of repeated field?
    return ReadField(field_type);
}
开发者ID:broady,项目名称:shine,代码行数:13,代码来源:shine.cpp

示例9: variables

/*
==============
ReadClient

All pointer variables (except function pointers) must be handled specially.
==============
*/
void ReadClient (FILE *f, gclient_t *client)
{
	field_t		*field;

	fread (client, sizeof(*client), 1, f);

	client->pers.spawn_landmark = false;
	client->pers.spawn_levelchange = false;
	for (field=clientfields ; field->name ; field++)
	{		
		ReadField (f, field, (byte *)client);
	}
}
开发者ID:AimHere,项目名称:thirty-flights-of-linux,代码行数:20,代码来源:g_save.c

示例10: variables

/*
==============
ReadLevelLocals

All pointer variables (except function pointers) must be handled specially.
==============
*/
void ReadLevelLocals (FILE *f)
{
	field_t		*field;

	if (fread(&level, sizeof(level), 1, f) == 0) {
        Com_Printf("ReadLevelLocals failed fread");
    }

	for (field=levelfields ; field->name ; field++)
	{
		ReadField (f, field, (byte *)&level);
	}
}
开发者ID:ajbonner,项目名称:yet-another-quake2-fork,代码行数:20,代码来源:g_save.c

示例11: ReadField

void ShineImpl::HandleReceivedField() {
    int8 field_index = transport_->ReadByte();

    if (input_->repeated(field_index)) {
        // Only the size of repeated fields is sent in advance.
        int32 size = transport_->ReadUInt32();
        input_->set_size(field_index, size);
    } else {
        // The actual value is sent for scalar fields.
        FieldTypes field_type = input_->type(field_index);
        void* value = ReadField(field_type);
        input_->set_value(field_index, value);
    }
}
开发者ID:broady,项目名称:shine,代码行数:14,代码来源:shine.cpp

示例12: ReadTag

bool
ConfigManager::ReadObjectHelper(std::istream &in, DataNode *parentNode, bool &te)
{
    bool keepReading = true;
    bool tagIsEndTag = false;
    std::string  tagName;
    NodeTypeEnum tagType = INTERNAL_NODE;
    int          tagLength = 0;

    // Read the opening tag.
    keepReading = ReadTag(in, tagName, tagType, tagLength, tagIsEndTag);

    if(tagIsEndTag && keepReading)
    {
        te = true;
        return keepReading;
    }

    if(tagType == INTERNAL_NODE)
    {
        DataNode *node = new DataNode(tagName);
        parentNode->AddNode(node);

        while(keepReading && !tagIsEndTag)
        {
            keepReading = ReadObjectHelper(in, node, tagIsEndTag);
        }

        if(tagIsEndTag)
            return keepReading;
    }
    else
        keepReading = ReadField(in, parentNode, tagName, tagType, tagLength);

    // Read the ending tag.
    stringVector sv = ReadStringVector(in,'>');
    keepReading = sv.size() > 0;

    te = false;
    return keepReading;
}
开发者ID:burlen,项目名称:visit_vtk_7_src,代码行数:41,代码来源:ConfigManager.C

示例13: GetObject

bool FObjectReplicator::ReceivedBunch( FInBunch& Bunch, const FReplicationFlags& RepFlags, bool& bOutHasUnmapped )
{
	UObject* Object = GetObject();

	if ( Object == NULL )
	{
		UE_LOG(LogNet, Verbose, TEXT("ReceivedBunch: Object == NULL"));
		return false;
	}

	UPackageMap * PackageMap = OwningChannel->Connection->PackageMap;

	const bool bIsServer = ( OwningChannel->Connection->Driver->ServerConnection == NULL );

	const FClassNetCache * ClassCache = OwningChannel->Connection->Driver->NetCache->GetClassNetCache( ObjectClass );

	if ( ClassCache == NULL )
	{
		UE_LOG(LogNet, Error, TEXT("ReceivedBunch: ClassCache == NULL: %s"), *Object->GetFullName());
		return false;
	}

	bool bThisBunchReplicatedProperties = false;

	// Read first field
	const FFieldNetCache * FieldCache = ReadField( ClassCache, Bunch );

	if ( Bunch.IsError() )
	{
		UE_LOG(LogNet, Error, TEXT("ReceivedBunch: Error reading field 1: %s"), *Object->GetFullName());
		return false;
	}

	if ( FieldCache == NULL )
	{
		// There are no actual replicated properties or functions in this bunch. That is ok - we may have gotten this
		// actor/sub-object because we want the client to spawn one (but we aren't actually replicating properties on it)
		return true;
	}

	while ( FieldCache )
	{
		// Receive properties from the net.
		UProperty* ReplicatedProp = NULL;

		while ( FieldCache && ( ReplicatedProp = Cast< UProperty >( FieldCache->Field ) ) != NULL )
		{
			NET_CHECKSUM( Bunch );

			// Server shouldn't receive properties.
			if ( bIsServer )
			{
				UE_LOG(LogNet, Error, TEXT("Server received unwanted property value %s in %s"), *ReplicatedProp->GetName(), *Object->GetFullName());
				return false;
			}
		
			bThisBunchReplicatedProperties = true;

			if ( !bHasReplicatedProperties )
			{
				bHasReplicatedProperties = true;		// Persistent, not reset until PostNetReceive is called
				PreNetReceive();
			}

			bool DebugProperty = false;
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
			{
				static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("net.Replication.DebugProperty"));
				if (CVar && !CVar->GetString().IsEmpty() && ReplicatedProp->GetName().Contains(CVar->GetString()) )
				{
					UE_LOG(LogRep, Log, TEXT("Replicating Property[%d] %s on %s"), ReplicatedProp->RepIndex, *ReplicatedProp->GetName(), *Object->GetName());
					DebugProperty = true;
				}
			}
#endif
			if ( !Retirement[ ReplicatedProp->RepIndex ].CustomDelta )
			{
				bool bLocalHasUnmapped = false;
				// We hijack a non custom delta property to signify we are using FRepLayout to read the entire property block
				if ( !RepLayout->ReceiveProperties( ObjectClass, RepState, (void*)Object, Bunch, bLocalHasUnmapped ) )
				{
					UE_LOG(LogRep, Error, TEXT("ReceiveProperties FAILED %s in %s"), *ReplicatedProp->GetName(), *Object->GetFullName());
					return false;
				}

				if ( bLocalHasUnmapped )
				{
					bOutHasUnmapped = true;
				}
			}
			else
			{
				// Receive array index.
				uint32 Element = 0;
				if ( ReplicatedProp->ArrayDim != 1 )
				{
					check( ReplicatedProp->ArrayDim >= 2 );

					Bunch.SerializeIntPacked( Element );

//.........这里部分代码省略.........
开发者ID:frobro98,项目名称:UnrealSource,代码行数:101,代码来源:DataReplication.cpp

示例14: THROW

void SimpleGeometryCreator::Run(const std::vector<String>& arguments)
{
	if(arguments.size() < 3)
		THROW("Must be 3 auguments for command");

	ptr<FileSystem> fileSystem = FolderFileSystem::GetNativeFileSystem();
	//открыть исходный файл
	_wfreopen(Strings::UTF82Unicode(arguments[0]).c_str(), L"rb", stdin);

	//размеры текстуры
	textureWidth = 1;
	textureHeight = 1;
	//размер вершины
	size_t vertexStride = 0;
	//считать поля
	char str[1024];
	while(gets_s(str))
	{
		Field field;
		//считать тип и размеры
		char typeStr[32];
		size_t i;
		for(i = 0; str[i] && isalpha(str[i]); ++i)
			typeStr[i] = str[i];
		typeStr[i] = 0;
		sscanf(str + i, "%dx%d", &field.size1, &field.size2);
		for(; str[i] && !isspace(str[i]); ++i);
		for(; str[i] && isspace(str[i]); ++i);
		field.divider = str[i];

		//получить тип
		size_t fieldSize;
		if(strcmp(typeStr, "float") == 0)
		{
			field.type = Field::typeFloat;
			fieldSize = sizeof(float);
		}
		else if(strcmp(typeStr, "int") == 0)
		{
			field.type = Field::typeInt;
			fieldSize = sizeof(int);
		}
		else if(strcmp(typeStr, "uint") == 0)
		{
			field.type = Field::typeUInt;
			fieldSize = sizeof(unsigned);
		}
		else if(strcmp(typeStr, "end") == 0)
			break;
		else if(strcmp(typeStr, "width") == 0)
		{
			textureWidth = field.size1;
			continue;
		}
		else if(strcmp(typeStr, "height") == 0)
		{
			textureHeight = field.size1;
			continue;
		}
		else
			THROW(String("Unknown field type: ") + typeStr);

		vertexStride += fieldSize * field.size1 * field.size2;

		//добавить поле
		fields.push_back(field);
	}

	//создать поток вывода в памяти
	stream = new MemoryStream();

	//цикл считывания вершин
	bool stop = false, indexed = false;
	while(!stop)
	{
		//проверить, может там начинается слово indexes
		char c;
		scanf(" %c", &c);
		if(c == 'i')
		{
			indexed = true;
			char s[10];
			scanf("%s", s);
			break;
		}
		else
			ungetc(c, stdin);
		//цикл считывания полей в вершине
		for(size_t i = 0; i < fields.size(); ++i)
			//если поле не считалось
			if(!ReadField(fields[i]))
				//если оно не первое в вершине, то это плохо
				if(i)
					THROW("Can't read field");
				//иначе это нормально, просто завершить цикл
				else
				{
					stop = true;
					break;
				}
//.........这里部分代码省略.........
开发者ID:grumpy-bot,项目名称:inanity,代码行数:101,代码来源:SimpleGeometryCreator.cpp

示例15: main

int main (int argc, char* argv[])
{
   VString        inname;            /* name of input images      */
   VString        outname;           /* name of output images     */
   VString        fieldname;         /* name of deformation field */
   VBoolean       verbose = TRUE;    /* verbose flag              */
   VOptionDescRec options[] =        /* options of program        */
   {
      {"in",      VStringRepn,  1, &inname,    VRequiredOpt, NULL, "Input image"},
      {"out",     VStringRepn,  1, &outname,   VRequiredOpt, NULL, "Deformed output image"},
      {"field",   VStringRepn,  1, &fieldname, VRequiredOpt, NULL, "3D deformation field"},
      {"verbose", VBooleanRepn, 1, &verbose,   VOptionalOpt, NULL, "Show status messages. Optional"}
   };

   VAttrList in_history=NULL;      /* history of input images      */
   VAttrList field_history=NULL;   /* history of deformation field */

   VAttrList In;           /* input images  */
   VImage    Dx, Dy, Dz;   /* field images  */

   VAttrListPosn pos;   /* position in list */
   VImage        in;    /* image in list    */

   float  fx, fy, fz;   /* scaling factors          */
   VImage dx, dy, dz;   /* scaled deformation field */

   VAttrListPosn rider;                         /* functional data rider   */
   int           bands, rows, columns, steps;   /* size of functional data */
   VImage        data;                          /* functional data         */
   VShort        *src, *dest;                   /* functional data pointer */

   VBoolean success;   /* success flag */

   int n, t, z;   /* indices */


   /* print information */
   char prg_name[100];
	char ver[100];
	getLipsiaVersion(ver, sizeof(ver));
	sprintf(prg_name, "vdeform V%s", ver);
  
   fprintf (stderr, "%s\n", prg_name); fflush (stderr);

   /* parse command line */
   if (!VParseCommand (VNumber (options), options, &argc, argv))
   {
      if (argc > 1) VReportBadArgs (argc, argv);
      VReportUsage (argv[0], VNumber (options), options, NULL);
      exit (1);
   }

   /* read input images */
   if (verbose) {fprintf (stderr, "Reading input image '%s' ...\n", inname); fflush (stderr);}
   ReadImages (inname, In, in_history);
   if (!In) exit (2);

   /* read deformation field */
   if (verbose) {fprintf (stderr, "Reading 3D deformation field '%s' ...\n", fieldname); fflush (stderr);}
   ReadField (fieldname, Dx, Dy, Dz, field_history);
   if (!Dx || !Dy || !Dz) exit (3);


   /* deform anatomical images */
   for (VFirstAttr (In, &pos); VAttrExists (&pos); VNextAttr (&pos))
   {
      /* get image */
      VGetAttrValue (&pos, NULL, VImageRepn, &in);
      if (VPixelRepn (in) != VUByteRepn) break;

      /* compare image and field */
      if (verbose) {fprintf (stderr, "Comparing anatomical image and deformation field ...\n"); fflush (stderr);}
      if (!Compatible (in, Dx)) exit (4);
      if (!Compatible (in, Dy)) exit (4);
      if (!Compatible (in, Dz)) exit (4);

      /* deform image */
      if (verbose) {fprintf (stderr, "Deforming anatomical image ...\n"); fflush (stderr);}
      RTTI (in, TrilinearInverseDeform, (in, Dx, Dy, Dz));
      VSetAttrValue (&pos, NULL, VImageRepn, in);
   }


   /* deform map images */
   for (; VAttrExists (&pos); VNextAttr (&pos))
   {
      /* get image */
      VGetAttrValue (&pos, NULL, VImageRepn, &in);
      if (VPixelRepn (in) != VFloatRepn) break;

      /* scale field */
      if (verbose) {fprintf (stderr, "Scaling deformation field ...\n"); fflush (stderr);}
      fx = (float) VImageNColumns (in) / (float) VImageNColumns (Dx);
      fy = (float) VImageNRows    (in) / (float) VImageNRows    (Dy);
      fz = (float) VImageNBands   (in) / (float) VImageNBands   (Dz);
      TrilinearScale<VFloat> (Dx, fx, fy, fz, dx); Multiply<VFloat> (dx, fx);
      TrilinearScale<VFloat> (Dy, fx, fy, fz, dy); Multiply<VFloat> (dy, fy);
      TrilinearScale<VFloat> (Dz, fx, fy, fz, dz); Multiply<VFloat> (dz, fz);

      /* compare image and field */
//.........这里部分代码省略.........
开发者ID:Rollmops,项目名称:lipsia,代码行数:101,代码来源:vdeform.C


注:本文中的ReadField函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。