示例#1
0
    void DiMotionSerializerImpl::ReadAttachNodes( DiDataStreamPtr& stream,DiAttachSet* attachset )
    {
        uint16 numAttaches;

        ReadShorts(stream,&numAttaches,1);

        for (size_t i = 0; i < numAttaches; ++i)
        {
            DiString name = ReadString(stream);

            DiVec3 position;
            ReadObject(stream,position);

            DiQuat quat;
            ReadObject(stream,quat);

            bool hasscale;
            ReadBools(stream,&hasscale,1);

            DiVec3 scale = DiVec3::UNIT_SCALE;
            if (hasscale)
            {
                ReadObject(stream,scale);
            }

            DiAttachNode * pkAttachNode = attachset->CreateAttachNode(name);
            pkAttachNode->SetPosition(position);
            pkAttachNode->SetOrientation(quat);
            
            if (hasscale)
            {
                pkAttachNode->SetScale(scale);
            }
        }
    }
示例#2
0
    void DiMotionSerializerImpl::ReadAttachClips( DiDataStreamPtr& stream, DiAnimation* motion )
    {
        DiString strName = ReadString(stream);

        DiNodeClip* nodeClip = motion->CreateAttachClip(strName);

        uint16 keyFrameNum = 0;
        ReadShorts(stream,&keyFrameNum,1);

        for (uint16 i = 0; i < keyFrameNum; ++i)
        {
            float time = 0;
            ReadFloats(stream,&time, 1);

            DiVec3 pos;
            ReadObject(stream,pos);

            DiQuat quat;
            ReadObject(stream,quat);

            bool hasScale = false;
            ReadBools(stream,&hasScale,1);

            DiVec3 scale = DiVec3::UNIT_SCALE;
            if (hasScale)
            {
                ReadObject(stream,scale);
            }

            DiTransformKeyFrame* key = nodeClip->CreateNodeKeyFrame(time);
            key->SetTranslate(pos);
            key->SetRotation(quat);
            key->SetScale(scale);
        }
    }
示例#3
0
// Parses the entire contents of an XNB file.
void ContentReader::ReadXnb()
{
    // Read the XNB header.
    uint32_t endPosition = ReadHeader();

    ReadTypeManifest();

    uint32_t sharedResourceCount = Read7BitEncodedInt();

    // Read the primary asset data.
    Log.WriteLine("Asset:");

    ReadObject();

    // Read any shared resource instances.
    for (uint32_t i = 0 ; i < sharedResourceCount; i++)
    {
        Log.WriteLine("Shared resource %d:", i);
        
        ReadObject();
    }

    // Make sure we read the amount of data that the file header said we should.
    if (FilePosition() != endPosition)
    {
        throw app_exception("End position does not match XNB header: unexpected amount of data was read.");
    }
}
   shared_ptr<SecurityRange>
   PersistentSecurityRange::ReadMatchingIP(const IPAddress &ipaddress)
   {
      shared_ptr<SecurityRange> empty;

      IPAddressSQLHelper helper;
      String sSQL;

      if (ipaddress.GetType() == IPAddress::IPV4)
      {
         shared_ptr<SecurityRange> pSR = shared_ptr<SecurityRange>(new SecurityRange());

         sSQL.Format(_T("select * from hm_securityranges where %s >= rangelowerip1 and %s <= rangeupperip1 and rangelowerip2 IS NULL and rangeupperip2 IS NULL order by rangepriorityid desc"), 
            String(helper.GetAddress1String(ipaddress)), String(helper.GetAddress1String(ipaddress)));

         if (!ReadObject(pSR, SQLCommand(sSQL)))
            return empty;

         return pSR;
      }
      else
      {
         // Read all IPv6 items.
         shared_ptr<SecurityRange> bestMatch;

         SQLCommand command(_T("select * from hm_securityranges where rangelowerip2 is not null order by rangepriorityid desc"));
         
         shared_ptr<DALRecordset> recordset = Application::Instance()->GetDBManager()->OpenRecordset(command);
         if (!recordset)
            return empty;

         while (!recordset->IsEOF())
         {
            shared_ptr<SecurityRange> securityRange = shared_ptr<SecurityRange>(new SecurityRange());

            if (ReadObject(securityRange, recordset) == false)
               return empty;

            if (ipaddress.WithinRange(securityRange->GetLowerIP(), securityRange->GetUpperIP()))
            {
               // This IP range matches the client. Does it have higher prio than the currently
               // matching?

               if (!bestMatch || securityRange->GetPriority() > bestMatch->GetPriority())
                  bestMatch = securityRange;
            }

            recordset->MoveNext();
         }

         return bestMatch;
      }


      
   }
示例#5
0
         /// <summary>Reads all objects in the file</summary>
         /// <returns></returns>
         /// <exception cref="Logic::FileFormatException">File contains a syntax error</exception>
         /// <exception cref="Logic::IOException">An I/O error occurred</exception>
         TFilePtr  ReadFile(MainType t, GameVersion v)
         {
            // Skip comments
            while (ReadComment())
            {}

            // Parse header
            int  ver   = ReadInt(L"File version");
            int  count = ReadInt(L"Number of objects");

            // TODO: Validate version

            // Create file
            TFile<OBJ>* file = new TFile<OBJ>(count);
            TFilePtr output(file);

            // Parse objects
            for (int i = 0; i < count; ++i)
            {
               OBJ obj(t);

               // Read header/contents/footer
               ReadHeader(obj);
               ReadObject(obj, v);
               ReadFooter(obj);

               // Add to file
               file->Objects.push_back(obj);
            }

            // Return non-generic file
            return output;
         }
示例#6
0
static ZS_status_t
io()
{
	ZS_status_t ret;

	uint32_t wr_flags = 0;
	uint32_t i = 0;

	char key[256] = {'\0'};
	char value[256] = {'\0'};

	char *data = NULL;
	uint64_t len = 0;

	fprintf(fp,"****** io started ******\n");

	fprintf(fp,"****** Writing objects *******\n");
	for (i = 0; i < MAX_ITERATION; i++) {
		snprintf(key, 255, "%s_%d", "key", i);
		snprintf(value, 255, "%s_%d", "value", i);
		if(ZS_SUCCESS == (ret = WriteObject(cguid, key, value, wr_flags)))
		{
			fprintf(fp,"write sucessful: key%s\n", key);
		} else {
			fprintf(fp,"write failed: key=%s error=%s\n", key, ZSStrError(ret));
			goto exit_io;
		}

		/*
		 * Flush few object
		 */
		if (0 == (i % 2)) {
			if(ZS_SUCCESS == (ret = FlushObject(cguid, key)))
			{
				fprintf(fp,"flush sucessful: key%s\n", key);
			} else {
				fprintf(fp,"flush failed: key=%s error=%s\n", key, ZSStrError(ret));
				goto exit_io;
			}
		}
	}

	/*
	 * Issue read
	 */
	fprintf(fp,"****** Reading objects *******\n");

	for (i = 0; i < MAX_ITERATION; i++) {
		snprintf(key, 255, "%s_%d", "key", i);
		if(ZS_SUCCESS == (ret = ReadObject(cguid, key, &data, &len)))
		{
			fprintf(fp,"read successful: key=%s data=%s\n", key, data);
		} else {
			fprintf(fp,"read failed: read key= %s error=%s\n", key, ZSStrError(ret));
			goto exit_io;
		}
	}
exit_io:
	return ret;
}
示例#7
0
bool JsonString::ReadValue()  
{  
	Token token;  
	ReadToken(token);  
	bool successful = true;  

	switch(token.type_)  
	{  
	case tokenObjectBegin:  
		objnum++;  
		successful = ReadObject(token);  
		break;  
	case tokenArrayBegin:  
		successful = ReadArray(token);  
		break;  
	case tokenNumber:  
	case tokenString:  
	case tokenTrue:  
	case tokenFalse:  
	case tokenNull:  
		break;  
	default:  
		return false;  
	}  
	return successful;  
}  
示例#8
0
void Stream::ReadMember(uint8* object, Type* pType)
{
	Type_type kind = pType->get_Kind();

	if (kind == type_class)
	{
		ReadMembers(object, static_cast<ClassType*>(pType));
	}
	else if (kind == type_pointer)
	{
		Type* pPointerTo = pType->GetPointerTo()->GetStripped();

		if (pPointerTo->get_Kind() == type_class)
		{
			*(void**)object = ReadObject();
		}
		else
		{
			ASSERT(0);
		}
	}
	else
	{
		Read(object, pType->get_sizeof());
	}
}
示例#9
0
    void Deserialize(T& t, const char* key)
    {
        Document& doc = m_jsutil.GetDocument();
        Value& jsonval = doc[key];

        ReadObject(t, jsonval);
    }
示例#10
0
void
PersistentRule::DeleteByAccountID(__int64 iAccountID)
{
    SQLCommand selectCommand("select * from hm_rules where ruleaccountid = @ACCOUNTID");
    selectCommand.AddParameter("@ACCOUNTID", iAccountID);

    shared_ptr<DALRecordset> pRS = Application::Instance()->GetDBManager()->OpenRecordset(selectCommand);
    if (!pRS)
        return ;

    bool bRetVal = false;
    while (!pRS->IsEOF())
    {
        // Create and read the fetch account.
        shared_ptr<Rule> oRule = shared_ptr<Rule>(new Rule);

        if (ReadObject(oRule, pRS))
        {
            // Delete this fetch account and all the
            // UID's connected to it.
            DeleteObject(oRule);
        }

        pRS->MoveNext();
    }

    // All the fetch accounts have been deleted.

}
  bool
  PersistentDistributionList::ReadObject(std::shared_ptr<DistributionList> pDistList, __int64 iID)
  {
     SQLCommand selectCommand("select * from hm_distributionlists where distributionlistid = @LISTID");
     selectCommand.AddParameter("@LISTID", iID);
 
     return ReadObject(pDistList, selectCommand);
  }
   bool
   PersistentSecurityRange::ReadObject(shared_ptr<SecurityRange> pSR, __int64 lDBID)
   {
      SQLCommand command(_T("select * from hm_securityranges where rangeid = @RANGEID"));
      command.AddParameter("@RANGEID", lDBID);

      return ReadObject(pSR, command);
   }
示例#13
0
bool EditorConfig::GetLongValue(const wxString& name, long& value)
{
    SimpleLongValue data;
    if(ReadObject(name, &data)) {
        value = data.GetValue();
        return true;
    }
    return false;
}
示例#14
0
bool SQFunctionProto::Load(SQVM *v,SQUserPointer up,SQREADFUNC read)
{
	SQInteger i, nsize = _literals.size();
	SQObjectPtr o;
	_CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART));
	_CHECK_IO(ReadObject(v, up, read, _sourcename));
	_CHECK_IO(ReadObject(v, up, read, _name));
	_CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART));
	_CHECK_IO(SafeRead(v,read,up, &nsize, sizeof(nsize)));
	for(i = 0;i < nsize; i++){
		_CHECK_IO(ReadObject(v, up, read, o));
		_literals.push_back(o);
	}
	_CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART));
	_CHECK_IO(SafeRead(v,read,up, &nsize, sizeof(nsize)));
	for(i = 0; i < nsize; i++){
		_CHECK_IO(ReadObject(v, up, read, o));
		_parameters.push_back(o);
	}
	_CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART));
	_CHECK_IO(SafeRead(v,read,up,&nsize,sizeof(nsize)));
	for(i = 0; i < nsize; i++){
		SQUnsignedInteger type;
		SQObjectPtr name;
		_CHECK_IO(SafeRead(v,read,up, &type, sizeof(SQUnsignedInteger)));
		_CHECK_IO(ReadObject(v, up, read, o));
		_CHECK_IO(ReadObject(v, up, read, name));
		_outervalues.push_back(SQOuterVar(name,o, (SQOuterType)type));
	}
	_CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART));
	_CHECK_IO(SafeRead(v,read,up,&nsize, sizeof(nsize)));
	for(i = 0; i < nsize; i++){
		SQLocalVarInfo lvi;
		_CHECK_IO(ReadObject(v, up, read, lvi._name));
		_CHECK_IO(SafeRead(v,read,up, &lvi._pos, sizeof(SQUnsignedInteger)));
		_CHECK_IO(SafeRead(v,read,up, &lvi._start_op, sizeof(SQUnsignedInteger)));
		_CHECK_IO(SafeRead(v,read,up, &lvi._end_op, sizeof(SQUnsignedInteger)));
		_localvarinfos.push_back(lvi);
	}
	_CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART));
	_CHECK_IO(SafeRead(v,read,up, &nsize,sizeof(nsize)));
	_lineinfos.resize(nsize);
	_CHECK_IO(SafeRead(v,read,up, &_lineinfos[0], sizeof(SQLineInfo)*nsize));
	_CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART));
	_CHECK_IO(SafeRead(v,read,up, &nsize, sizeof(nsize)));
	_instructions.resize(nsize);
	_CHECK_IO(SafeRead(v,read,up, &_instructions[0], sizeof(SQInstruction)*nsize));
	_CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART));
	_CHECK_IO(SafeRead(v,read,up, &nsize, sizeof(nsize)));
	for(i = 0; i < nsize; i++){
		o = SQFunctionProto::Create();
		_CHECK_IO(_funcproto(o)->Load(v, up, read));
		_functions.push_back(o);
	}
	_CHECK_IO(SafeRead(v,read,up, &_stacksize, sizeof(_stacksize)));
	_CHECK_IO(SafeRead(v,read,up, &_bgenerator, sizeof(_bgenerator)));
	_CHECK_IO(SafeRead(v,read,up, &_varparams, sizeof(_varparams)));
	return true;
}
   bool
   PersistentAlias::ReadObject(std::shared_ptr<Alias> pAccount, __int64 ObjectID)
   {
      SQLCommand command("select * from hm_aliases where aliasid = @ALIASID");
      command.AddParameter("@ALIASID", ObjectID);

      bool bResult = ReadObject(pAccount, command);

      return bResult;
   }
   bool
   PersistentIncomingRelay::ReadObject(boost::shared_ptr<IncomingRelay> pSR, int lDBID)
   {
      SQLCommand command("select * from hm_incoming_relays where relayid = @RELAYID");
      command.AddParameter("@RELAYID", lDBID);

      bool bResult = ReadObject(pSR, command);

      return bResult;
   }
示例#17
0
bool
PersistentAccount::ReadObject(boost::shared_ptr<Account> pAccount, __int64 ObjectID)
{
    String sSQL = "select * from hm_accounts where accountid = @ACCOUNTID";

    SQLCommand command(sSQL);
    command.AddParameter("@ACCOUNTID", ObjectID);

    return ReadObject(pAccount, command);
}
示例#18
0
    void DiMotionSerializerImpl::ReadBones( DiDataStreamPtr& stream,DiSkeleton* skeleton )
    {
        uint16 numBones;

        ReadShorts(stream,&numBones,1);

        for (size_t i = 0; i < numBones; ++i)
        {
            // name
            DiString name = ReadString(stream);

            // handle
            uint16 handle;
            ReadShorts(stream,&handle,1);

            // position
            DiVec3 position;
            ReadObject(stream,position);

            // orientation
            DiQuat quat;
            ReadObject(stream,quat);

            // scale
            bool hasscale;
            ReadBools(stream,&hasscale,1);

            DiVec3 scale = DiVec3::UNIT_SCALE;
            if (hasscale)
            {
                // scale
                ReadObject(stream,scale);
            }

            DiBone* bone = skeleton->CreateBone(name,handle);
            bone->SetPosition(position);
            bone->SetOrientation(quat);
            if (hasscale)
            {
                bone->SetScale(scale);
            }
        }
    }
// ****************************************************************************
// Method: AccessViewerSession::ReadConfigFile
//
// Purpose: 
//   Reads the session file and stores it internally.
//
// Arguments:
//   filename : The name of the session file to open.
//
// Returns:    A pointer to the root data node or 0.
//
// Programmer: Brad Whitlock
// Creation:   Mon Nov 13 15:44:26 PST 2006
//
// Modifications:
//   Brad Whitlock, Tue Apr 22 12:19:30 PDT 2008
//   Skip the XML tag.
//
// ****************************************************************************
DataNode *
AccessViewerSession::ReadConfigFile(std::istream& in)
{
    // Skip the XML tag
    FinishTag(in);

    root = new DataNode("root");
    ReadObject(in, root);

    return GetRootNode();
}
   bool
   PersistentDistributionList::ReadObject(std::shared_ptr<DistributionList> pDistList, const String &sAddress)
   {
      SQLStatement statement;

      statement.SetStatementType(SQLStatement::STSelect);
      statement.SetTable("hm_distributionlists");
      statement.AddWhereClauseColumn("distributionlistaddress", sAddress);

      return ReadObject(pDistList, statement.GetCommand());
   }  
   bool
   PersistentAlias::ReadObject(std::shared_ptr<Alias> pAlias, const String & sName)
   {
      SQLStatement statement;

      statement.SetStatementType(SQLStatement::STSelect);
      statement.SetTable("hm_aliases");
      statement.AddWhereClauseColumn("aliasname", sName);

      return ReadObject(pAlias, statement.GetCommand());
   }
示例#22
0
wxString EditorConfig::GetString(const wxString& key, const wxString& defaultValue)
{
    // Check the cache first
    std::map<wxString, wxString>::iterator iter = m_cacheStringValues.find(key);
    if(iter != m_cacheStringValues.end()) return iter->second;

    SimpleStringValue data;
    if(!ReadObject(key, &data)) { return defaultValue; }

    m_cacheStringValues[key] = data.GetValue();
    return data.GetValue();
}
示例#23
0
bool
PersistentAccount::ReadObject(boost::shared_ptr<Account> pAccount, const String & sAddress)
{
    SQLStatement statement;
    statement.SetStatementType(SQLStatement::STSelect);
    statement.SetTable("hm_accounts");
    statement.AddWhereClauseColumn("accountaddress", sAddress);

    bool bResult = ReadObject(pAccount, statement.GetCommand());

    return bResult;

}
示例#24
0
long EditorConfig::GetInteger(const wxString& name, long defaultValue)
{
    // Check the cache first
    std::map<wxString, long>::iterator iter = m_cacheLongValues.find(name);
    if(iter != m_cacheLongValues.end()) return iter->second;

    SimpleLongValue data;
    if(!ReadObject(name, &data)) { return defaultValue; }

    // update the cache
    m_cacheLongValues[name] = data.GetValue();
    return data.GetValue();
}
示例#25
0
// ****************************************************************************
// Method: ColorTableManager::ReadConfigFile
//
// Purpose: 
//   Reads a color table from a file.
//
// Arguments:
//   filename : The name of the file to open.
//
// Programmer: Brad Whitlock
// Creation:   Thu Jul 3 18:27:57 PST 2003
//
// Modifications:
//   
// ****************************************************************************
DataNode *
ColorTableManager::ReadConfigFile(std::istream& in)
{
    DataNode *node = 0;

    // Read the XML tag and ignore it.
    FinishTag(in);

    // Create a root node and use it to read the visit tree.
    node = new DataNode("FileRoot");
    ReadObject(in, node);
    return node;
}
示例#26
0
	JsonValue * JsonParser::ReadValue(JsonValue * parent)
	{
		if (*cur_ == '"')
		{
			return ReadString(parent);
		}
		else if (IsDigit(*cur_) || *cur_ == '-')
		{
			return ReadNumber(parent);
		}
		else if (IsAlpha(*cur_))
		{
			std::string keyword;
			ParseIdentifier(keyword);

			if (keyword == "null")
			{
				return 0;
			}
			if (keyword == "true")
			{
				return new JsonBooleanValue(parent, true);
			}
			else if (keyword == "false")
			{
				return new JsonBooleanValue(parent, false);
			}
			else
			{
				throw Error(
					row_,
					column_ - keyword.length(),
					FormatString("Invalid bareword \"%s\", while value expected", keyword.c_str())
				);
			}
		}
		else if (*cur_ == '[')
		{
			return ReadArray(parent);
		}
		else if (*cur_ == '{')
		{
			return ReadObject(parent);
		}
		else
		{
			RaiseError("Invalid symbol, while value expected");
			return 0;
		}
	}
示例#27
0
int InitGLObjects()										// Initialize Objects
{
	if (!ReadObject("Data/Object2.txt", &obj))			// Read Object2 Into obj
	{
		return FALSE;									// If Failed Return False
	}

	SetConnectivity(&obj);								// Set Face To Face Connectivity

	for (unsigned int i=0;i<obj.nPlanes;i++)			// Loop Through All Object Planes
		CalcPlane(obj, &(obj.planes[i]));				// Compute Plane Equations For All Faces

	return TRUE;										// Return True
}
示例#28
0
///////////////////////////////////////////////////////////////////////////////
// ReadReport
///////////////////////////////////////////////////////////////////////////////
void cTWUtil::ReadReport(const TCHAR*                reportFileName,
                         cFCOReportHeader&           reportHeader,
                         cFCOReport&                 r,
                         const cElGamalSigPublicKey* pPublicKey,
                         bool                        silent,
                         bool&                       bEncrypted)
{
    iUserNotify::GetInstance()->Notify(iUserNotify::V_VERBOSE,
                                       _T("%s%s\n"),
                                       TSS_GetString(cTW, tw::STR_OPEN_REPORT_FILE).c_str(),
                                       cDisplayEncoder::EncodeInline(reportFileName).c_str());

    ReadObject(reportFileName, &reportHeader, r, cFCOReport::GetFileHeaderID(), pPublicKey, bEncrypted);
}
示例#29
0
bool
PersistentAccount::ReadObject(boost::shared_ptr<Account> pAccount, const SQLCommand &command)
{
    boost::shared_ptr<DALRecordset> pRS = Application::Instance()->GetDBManager()->OpenRecordset(command);
    if (!pRS)
        return false;

    bool bRetVal = false;
    if (!pRS->IsEOF())
    {
        bRetVal = ReadObject(pAccount, pRS);
    }

    return bRetVal;
}
   bool
   PersistentDomainAlias::ReadObject(shared_ptr<DomainAlias> oDA, const SQLCommand & command)
   {
      shared_ptr<DALRecordset> pRS = Application::Instance()->GetDBManager()->OpenRecordset(command);
      if (!pRS)
         return false;

      bool bRetVal = false;
      if (!pRS->IsEOF())
      {
         bRetVal = ReadObject(oDA, pRS);
      }

      return bRetVal;
   }