variable_set.cc
//parses the variable set in the binary policy (from offset)
parses the variable set in the binary policy (from offset)
parses the variable set in the binary policy ( from offset )
void VariableSet::parse(uint64_t variableSetOffset, uint64_t numberOfVariables)  {
    policyBinary.setPosition(variableSetOffset);
    variables.clear(); 
    for(uint64_t varId = 0; varId < numberOfVariables; varId++)  {
        Variable var;
        var.type = getType(); 
        getVariableValueFromBinary(var);
        variables.push_back(var);
    }
    #if DEBUG_POLICY_EVALUATION
        cout << "Variables: " << endl;
        for(int i = 0; i < variables.size(); i++) {
            Variable var = variables.at(i);
            cout << uintToString(variableTypeToInt[var.type], bitsForVariableSetType) << " ";
            if(var.type == VariableSetType::BOOLEAN)  {
                cout << " Boolean " << var.value.asBoolean << endl;
            }
            else if(var.type == VariableSetType::STRING) {
                cout << " String " << *(var.value.asString) << endl;
            }
            else if(var.type == VariableSetType::ID)  {
                throw "Should now be replaced by the actual type and value!";
            }
            else if(var.type == VariableSetType::FUNCTION)  {
                throw "Should now be replaced by the actual type and value!";
            }
            else if(var.type == VariableSetType::INT64)
                cout << " Int64 " << var.value.asInt64 << endl;
            else if(var.type == VariableSetType::INT32)
                cout << " Int32 " << var.value.asInt32 << endl;
            else if(var.type == VariableSetType::INT16)
                cout << " Int16 " << var.value.asInt16 << endl;
            else if(var.type == VariableSetType::INT8)
                cout << " Int8 " << (int16_t) var.value.asInt8 << endl;
            else if(var.type == VariableSetType::UINT32)
                cout << " UInt32 " << var.value.asUInt32 << endl;
            else if(var.type == VariableSetType::UINT16)
                cout << " UInt16 " << var.value.asUInt16 << endl;
            else if(var.type == VariableSetType::UINT8)
                cout << " UInt8 " << (uint16_t) var.value.asUInt8 << endl;
            else if(var.type == VariableSetType::DOUBLE)
                cout << " Double " << var.value.asDouble << endl;
        }
    #endif
}
void VariableSet :: parse ( uint64_t variableSetOffset , uint64_t numberOfVariables ) { policyBinary . setPosition ( variableSetOffset ) ; variables . clear ( ) ; for ( uint64_t varId = 0 ; varId < numberOfVariables ; varId ++ ) { Variable var ; var . type = getType ( ) ; getVariableValueFromBinary ( var ) ; variables . push_back ( var ) ; } #if DEBUG_POLICY_EVALUATION cout << " " << endl ; for ( int i = 0 ; i < variables . size ( ) ; i ++ ) { Variable var = variables . at ( i ) ; cout << uintToString ( variableTypeToInt [ var . type ] , bitsForVariableSetType ) << " " ; if ( var . type == VariableSetType :: BOOLEAN ) { cout << " " << var . value . asBoolean << endl ; } else if ( var . type == VariableSetType :: STRING ) { cout << " " << * ( var . value . asString ) << endl ; } else if ( var . type == VariableSetType :: ID ) { throw " " ; } else if ( var . type == VariableSetType :: FUNCTION ) { throw " " ; } else if ( var . type == VariableSetType :: INT64 ) cout << " " << var . value . asInt64 << endl ; else if ( var . type == VariableSetType :: INT32 ) cout << " " << var . value . asInt32 << endl ; else if ( var . type == VariableSetType :: INT16 ) cout << " " << var . value . asInt16 << endl ; else if ( var . type == VariableSetType :: INT8 ) cout << " " << ( int16_t ) var . value . asInt8 << endl ; else if ( var . type == VariableSetType :: UINT32 ) cout << " " << var . value . asUInt32 << endl ; else if ( var . type == VariableSetType :: UINT16 ) cout << " " << var . value . asUInt16 << endl ; else if ( var . type == VariableSetType :: UINT8 ) cout << " " << ( uint16_t ) var . value . asUInt8 << endl ; else if ( var . type == VariableSetType :: DOUBLE ) cout << " " << var . value . asDouble << endl ; } #endif }
parses the variable set in the binary policy (from offset)
parses the variable set in the binary policy ( from offset )
//go to the right position in the binary policy //ensures that the variable set is empty //get the variable type //signed integers //unsigned integers //double