Ejemplo n.º 1
0
	static std::pair<std::string, strus::NumericVariant> get( value const &v )
	{
		std::pair<std::string, strus::NumericVariant> p;
		
		if( v.type( ) != is_object) {
			throw bad_value_cast( );
		}
		
		p.first = v.get<std::string>( "key" );
		value val = v["value"];
		switch( val.type( ) ) {
			case is_boolean:
				// TODO: really? Do we allow this?
				p.second = ( v.get<bool>( "value" ) ) ? 1 : 0;
				break;
			
			case is_string:
				// TODO: really? Do we allow this?
			case is_number:
				if( is_of_type( val, p.second.variant.Int ) ) {
					p.second = v.get<BOOST_TYPEOF( p.second.variant.Int )>( "value" );
				} else if( is_of_type( val, p.second.variant.UInt ) ) {
					p.second = v.get<BOOST_TYPEOF( p.second.variant.UInt )>( "value" );
				} else if( is_of_type( val, p.second.variant.Float ) ) {
					p.second = v.get<BOOST_TYPEOF( p.second.variant.Float )>( "value" );
				} else {
					throw bad_value_cast( );
				}
				break;
				
			case is_undefined:
			case is_null:
				// TODO: how do we map absence
			case is_object:
			case is_array:	
			default:
				throw bad_value_cast( );
		}
				
		return p;
	}
Ejemplo n.º 2
0
ACI_TAG_NODE AgilorUtils::parse(const TAGNODE& info)
{



	ACI_TAG_NODE node;
	aci::init(node);

	node.alarmhihi = info.alarmHiHi;
	node.alarmlolo = info.alarmLolo;
	node.alarmstate = info.alarmState;
	node.alarmtype = info.alarmType;
	node.compmax = info.compressMax;
	node.compmin = info.compressMin;
	node.creationdate = info.creationDate;
	memcpy(node.descriptor, info.desc.data(), boost::extent<BOOST_TYPEOF(node.descriptor)>::value);
	memcpy(node.engunits, info.engUnit.data(), boost::extent<BOOST_TYPEOF(node.engunits)>::value);
	memcpy(node.enumdesc, info.enumDesc.data(), boost::extent<BOOST_TYPEOF(node.enumdesc)>::value);
	node.excdev = info.exceptionDev;
	node.excmax = info.exceptionMax;
	node.excmin = info.exceptionMin;
	node.hihipriority = info.hihiPriority;
	node.hipriority = info.hiPriority;
	node.hisidx = info.hisIndex;
	node.istat = info.state;
	node.pointtype = info.type;
	node.scan = info.IOState;

	switch (info.type)
	{
	case 'R':node.rval = boost::lexical_cast<float>(info.value); break;
	case 'S':memcpy(node.sval, info.value.data(), sizeof(node.sval)); break;
	case 'B':node.bval = boost::lexical_cast<bool>(info.value); break;
	case 'L':node.lval = boost::lexical_cast<long>(info.value); break;
	default:
		break;
	}
	memcpy(node.name, info.name.data(), boost::extent<BOOST_TYPEOF(node.name)>::value);
	memcpy(node.sourceserver, info.deviceName.data(), boost::extent<BOOST_TYPEOF(node.sourceserver)>::value);
	memcpy(node.sourcegroup, info.groupName.data(), boost::extent<BOOST_TYPEOF(node.sourcegroup)>::value);
	memcpy(node.sourcetag, info.sourceTag.data(), boost::extent<BOOST_TYPEOF(node.sourcetag)>::value);
	return node;
}
Ejemplo n.º 3
0
void test() {
    {
    boost::detail::winapi::LARGE_INTEGER_ a;
    LARGE_INTEGER b;
    BOOST_CHRONO_STATIC_ASSERT((
            sizeof(boost::detail::winapi::LARGE_INTEGER_)==sizeof(LARGE_INTEGER)
        ), NOTHING, (boost::detail::winapi::LARGE_INTEGER_, LARGE_INTEGER));
    BOOST_TEST((
            sizeof(a.QuadPart)==sizeof(b.QuadPart)
            ));
    BOOST_CHRONO_STATIC_ASSERT((
            offsetof(boost::detail::winapi::LARGE_INTEGER_, QuadPart)==offsetof(LARGE_INTEGER, QuadPart)
        ), NOTHING, (boost::detail::winapi::LARGE_INTEGER_, LARGE_INTEGER));
    BOOST_CHRONO_STATIC_ASSERT((
            boost::is_same<
                    BOOST_TYPEOF(a.QuadPart),
                    BOOST_TYPEOF(b.QuadPart)
                >::value
        ), NOTHING, (boost::detail::winapi::LARGE_INTEGER_, LARGE_INTEGER));
    }

    BOOST_CHRONO_STATIC_ASSERT((
            sizeof(boost::detail::winapi::BOOL_)==sizeof(BOOL)
        ), NOTHING, (boost::detail::winapi::BOOL_, BOOL));
    BOOST_CHRONO_STATIC_ASSERT((
            boost::is_same<boost::detail::winapi::BOOL_,BOOL>::value
        ), NOTHING, (boost::detail::winapi::BOOL_, BOOL));

    BOOST_CHRONO_STATIC_ASSERT((
            sizeof(boost::detail::winapi::DWORD_)==sizeof(DWORD)
        ), NOTHING, (boost::detail::winapi::DWORD_, DWORD));
    BOOST_CHRONO_STATIC_ASSERT((
            boost::is_same<boost::detail::winapi::DWORD_,DWORD>::value
        ), NOTHING, (boost::detail::winapi::DWORD_, DWORD));

    BOOST_CHRONO_STATIC_ASSERT((
            sizeof(boost::detail::winapi::HANDLE_)==sizeof(HANDLE)
        ), NOTHING, (boost::detail::winapi::HANDLE_, HANDLE));
    BOOST_CHRONO_STATIC_ASSERT((
            boost::is_same<boost::detail::winapi::HANDLE_,HANDLE>::value
        ), NOTHING, (boost::detail::winapi::HANDLE_, HANDLE));

    BOOST_CHRONO_STATIC_ASSERT((
            sizeof(boost::detail::winapi::LONG_)==sizeof(LONG)
        ), NOTHING, (boost::detail::winapi::LONG_, LONG));
    BOOST_CHRONO_STATIC_ASSERT((
            boost::is_same<boost::detail::winapi::LONG_,LONG>::value
        ), NOTHING, (boost::detail::winapi::LONG_, LONG));

    BOOST_CHRONO_STATIC_ASSERT((
            sizeof(boost::detail::winapi::LONGLONG_)==sizeof(LONGLONG)
        ), NOTHING, (boost::detail::winapi::LONGLONG_, LONGLONG));
    BOOST_CHRONO_STATIC_ASSERT((
            boost::is_same<boost::detail::winapi::LONGLONG_,LONGLONG>::value
        ), NOTHING, (boost::detail::winapi::LONGLONG_, LONGLONG));

    BOOST_CHRONO_STATIC_ASSERT((
            sizeof(boost::detail::winapi::ULONG_PTR_)==sizeof(ULONG_PTR)
        ), NOTHING, (boost::detail::winapi::ULONG_PTR_, ULONG_PTR));
    BOOST_CHRONO_STATIC_ASSERT((
            boost::is_same<boost::detail::winapi::ULONG_PTR_,ULONG_PTR>::value
        ), NOTHING, (boost::detail::winapi::ULONG_PTR_, ULONG_PTR));
        
    BOOST_CHRONO_STATIC_ASSERT((
            sizeof(boost::detail::winapi::PLARGE_INTEGER_)==sizeof(PLARGE_INTEGER)
        ), NOTHING, (boost::detail::winapi::PLARGE_INTEGER_, PLARGE_INTEGER));
    //~ BOOST_CHRONO_STATIC_ASSERT((
            //~ boost::is_same<boost::detail::winapi::PLARGE_INTEGER_,PLARGE_INTEGER>::value
        //~ ), NOTHING, (boost::detail::winapi::PLARGE_INTEGER_, PLARGE_INTEGER));
        
    {
        BOOST_CHRONO_STATIC_ASSERT((
                sizeof(boost::detail::winapi::FILETIME_)==sizeof(FILETIME)
            ), NOTHING, (boost::detail::winapi::FILETIME_, FILETIME));
        
        BOOST_CHRONO_STATIC_ASSERT((
                sizeof(boost::detail::winapi::PFILETIME_)==sizeof(PFILETIME)
            ), NOTHING, (boost::detail::winapi::PFILETIME_, PFILETIME));
        

        boost::detail::winapi::FILETIME_ a;
        FILETIME b;
        BOOST_TEST((
                sizeof(a.dwLowDateTime)==sizeof(b.dwLowDateTime)
                ));
        BOOST_TEST((
                sizeof(a.dwHighDateTime)==sizeof(b.dwHighDateTime)
                ));
        BOOST_CHRONO_STATIC_ASSERT((
                offsetof(boost::detail::winapi::FILETIME_, dwLowDateTime)==offsetof(FILETIME, dwLowDateTime)
            ), NOTHING, (boost::detail::winapi::FILETIME_, FILETIME));
        BOOST_CHRONO_STATIC_ASSERT((
                offsetof(boost::detail::winapi::FILETIME_, dwHighDateTime)==offsetof(FILETIME, dwHighDateTime)
            ), NOTHING, (boost::detail::winapi::FILETIME_, FILETIME));
        BOOST_CHRONO_STATIC_ASSERT((
            boost::is_same<
                    BOOST_TYPEOF(a.dwLowDateTime),
                    BOOST_TYPEOF(b.dwLowDateTime)
                >::value
        ), NOTHING, (boost::detail::winapi::FILETIME_, FILETIME));
        BOOST_CHRONO_STATIC_ASSERT((
            boost::is_same<
                    BOOST_TYPEOF(a.dwHighDateTime),
                    BOOST_TYPEOF(b.dwHighDateTime)
                >::value
        ), NOTHING, (boost::detail::winapi::FILETIME_, FILETIME));

    }

//    BOOST_CHRONO_STATIC_ASSERT((
//            GetLastError==boost::detail::winapi::::GetLastError
//        ), NOTHING, ());

}