Esempio n. 1
0
    /* read a wstring from the UnMarshal object  
    */
    void UnMarshal::Read(wstring& ws)
    {
        MarshalDataType dt = readDataType();

        // check for stream read error 
        CHECK_READ_ERROR(m_strm);
        
        if (dt != MTYPE_WSTRING)
        {
            throw SCXMarshalFormatException(MTYPE_WSTRING, dt, SCXSRCLOCATION);
        }

        int strSize = readInteger();

        CHECK_READ_ERROR(m_strm);

        // Read in the wstring as a list of bytes
        vector<char> buf(strSize, '\0');
        m_strm.read(&buf[0], strSize);

        CHECK_READ_ERROR(m_strm);

        // Create a real wstring of the appropriate size
        size_t nr = strSize / sizeof(wchar_t);
        vector<wchar_t> wbuf(nr + 1 /* Null byte */, L'\0');
        memcpy(&wbuf[0], (void*) &buf[0], strSize);

        // Return the final wstring
        ws = wstring(&wbuf[0]);
    }
Esempio n. 2
0
    /* read a vector of SCXRegexWithIndex objects from the UnMarshal object  
    */
    void UnMarshal::Read(vector<SCXRegexWithIndex>& vri)
    {
        MarshalDataType dt = readDataType();

        // check for stream read error 
        CHECK_READ_ERROR(m_strm);
        
        if (dt != MTYPE_VECTOR_REGEX_INDEX)
        {
            throw SCXMarshalFormatException(MTYPE_VECTOR_REGEX_INDEX, dt, SCXSRCLOCATION);
        }

        int vecSize = readInteger();

        CHECK_READ_ERROR(m_strm);

        vri.clear();

        for(int i = 0; i < vecSize; i++)
        {
           SCXRegexWithIndex ri;
           Read(ri);
           vri.push_back(ri);
        }
    }
Esempio n. 3
0
    /* read a vector of wstring objects from the UnMarshal object  
    */
    void UnMarshal::Read(vector<wstring>& vws)
    {
        MarshalDataType dt = readDataType();

        // check for stream read error 
        CHECK_READ_ERROR(m_strm);

        if (dt != MTYPE_VECTOR_WSTRING)
        {
            throw SCXMarshalFormatException(MTYPE_VECTOR_WSTRING, dt, SCXSRCLOCATION);
        }

        int vecSize = readInteger();

        CHECK_READ_ERROR(m_strm);

        vws.clear();

        for(int i = 0; i < vecSize; i++)
        {
            wstring ws;
            Read(ws);
            vws.push_back(ws);
        }
    }
Esempio n. 4
0
/* Read and add all the elements (integers) */
void readAdd(typeList *lis) {
    int temp;
    if (readDataType(&temp) == EOF)
        *lis = NULL;
    else {
        readAdd(lis);
        addNode(lis, temp);
    }
}
Esempio n. 5
0
/// Load events from given banks into event lists.
void load(const Communicator &comm, const std::string &filename,
          const std::string &groupName,
          const std::vector<std::string> &bankNames,
          const std::vector<int32_t> &bankOffsets,
          std::vector<std::vector<Types::Event::TofEvent> *> eventLists) {
  H5::H5File file(filename, H5F_ACC_RDONLY);
  H5::Group group = file.openGroup(groupName);
  load(readDataType(group, bankNames, "event_time_offset"), comm, group,
       bankNames, bankOffsets, std::move(eventLists));
}
Esempio n. 6
0
/* Read LLS from each node */
void readNode(typeList *lis) {
    int temp;
    if (readDataType(&temp) == EOF)
        *lis = NULL;
    else {
        *lis = (typeList)malloc(sizeof(typeNodeList));
        (*lis)->data = temp;
        readNode(&((*lis)->next));
    }
}
Esempio n. 7
0
    /* read an integer from the UnMarshal object  
    */
    void UnMarshal::Read(int& val)
    {
        MarshalDataType dt = readDataType();

        // check for stream read error 
        CHECK_READ_ERROR(m_strm);

        if (dt != MTYPE_INT)
        {
            throw SCXMarshalFormatException(MTYPE_INT, dt, SCXSRCLOCATION);
        }

        val = readInteger();
        
        CHECK_READ_ERROR(m_strm);
    }
Esempio n. 8
0
    /* read a SCXRegexWithIndex object from the UnMarshal object  
    */
    void UnMarshal::Read(SCXRegexWithIndex& ri)
    {
        MarshalDataType dt = readDataType();

        // check for stream read error 
        CHECK_READ_ERROR(m_strm);
        
        if (dt != MTYPE_REGEX_INDEX)
        {
            throw SCXMarshalFormatException(MTYPE_REGEX_INDEX, dt, SCXSRCLOCATION);
        }

        int index = readInteger();
        
        CHECK_READ_ERROR(m_strm);

        ri.index = (size_t) index;

        wstring ws;
        Read(ws);
        ri.regex = new SCXRegex(ws);
    }
Esempio n. 9
0
DataType Program::compute(ExecutionData *eD)
{
	int ret;
	DataType op1, op2;
	DataType *p_op;
	byte op;

	switch (data[eD->currentOp++])
	{
	case 0: // Constant
		readDataType(eD, &p_op);
#ifdef _VERBOSE
		Serial.print(*p_op);
#endif
		return *p_op;
	
	case 1: // Operation
		op = data[eD->currentOp++];
#ifdef _VERBOSE
		Serial.print(F("( "));
#endif
		op1 = compute(eD);
#ifdef _VERBOSE
		switch (op)
		{
		case 0: Serial.print(F(" + ")); break;
		case 1: Serial.print(F(" - ")); break;
		case 2: Serial.print(F(" * ")); break;
		case 3: Serial.print(F(" / ")); break;
		case 4: Serial.print(F(" ^ ")); break;
		}
#endif
		op2 = compute(eD);
#ifdef _VERBOSE
		Serial.print(F(" )"));
#endif

		switch (op)
		{
		case 0: // Add
			return op1 + op2;

		case 1: // Subtract
			return op1 - op2;

		case 2: // Multiply
			return (DataType)(op1 * op2);

		case 3: // Divide
			return (DataType)((float)op1 / (float)op2);

		case 4: // Power
			return (DataType)(pow(op1, op2));
		}
		break;

	case 2: // Read Variable
		op = data[eD->currentOp++];
#ifdef _VERBOSE
		Serial.print(F("v"));
		Serial.print(op);
		if (VERBOSE > 1)
		{
			Serial.print(F("["));
			Serial.print(variables[op]);
			Serial.print(F("]"));
		}
#endif
		return variables[op];



	default:
		Serial.println(F("Operacion desconocida"));
	}
}