예제 #1
0
// ----------------------------------------------------------------------------
//
bool ActorSelectField::setValue( LPCSTR value ) {
    CString key( value );
    ActorList actors;

    int curPos = 0;
    while ( true ) {
        CString resToken = key.Tokenize( _T(" ,"), curPos );
        if ( resToken.IsEmpty() )
            break;

        resToken.MakeUpper();

        ActorSelectField::EntryMap::iterator it = m_entries.find( resToken );
        if ( it == m_entries.end() )
            throw FieldException( "Invalid fixture number %s", (LPCSTR)resToken );

        actors.push_back( (*it).second.m_actor );
    }

    if ( actors.size() == 0 )
        throw FieldException( "Select at least one fixture" );

    if ( actors.size() > 1 && !m_allow_multiple )
        throw FieldException( "Select a single fixture" );

    m_selected_actors = actors;

    return InputField::setValue( value );
}
예제 #2
0
    T GetData(SQLSMALLINT type) const
    {
      T Storage = T();
      SQLINTEGER Needed = 0;
		  RETCODE Ret = SQLGetData(Stmt.GetHolder().GetHandle(), static_cast<SQLUSMALLINT>(Index),
        type, &Storage, sizeof(Storage),
        //reinterpret_cast for x64
        reinterpret_cast<SQLLEN *>(&Needed));
		  if (Ret != SQL_SUCCESS)
			  throw FieldException("Error get field", feErrorGetField);
      if (Needed <= 0)
        throw FieldException("Empty field", feErrorGetField);
      return Storage;
	  }
예제 #3
0
    std::string GetAsString() const
    {
      SQLINTEGER Needed = 0;
      const unsigned BufSize = 256;
      char SmallBuff[BufSize] = { 0 };
      RETCODE Ret = SQLGetData(Stmt.GetHolder().GetHandle(), static_cast<SQLUSMALLINT>(Index), SQL_C_CHAR,
        SmallBuff, BufSize,
        //reinterpret_cast for x64
        reinterpret_cast<SQLLEN *>(&Needed));
      if (TIODBC_SUCCESS_CODE(Ret))
        return std::string(SmallBuff);
		  if (Needed > 0)
      {
        SQLINTEGER Buff = Needed + 1;
        std::vector<char> Data(Buff, 0);
        Ret = SQLGetData(Stmt.GetHolder().GetHandle(), static_cast<SQLUSMALLINT>(Index), SQL_C_CHAR,
          reinterpret_cast<SQLTCHAR *>(&Data.front()), Buff,
          //reinterpret_cast for x64
          reinterpret_cast<SQLLEN *>(&Needed));
        if (TIODBC_SUCCESS_CODE(Ret))
          return std::string(&Data[0], Data.size());
        throw FieldException("Error get field", feErrorGetField);
		  }
      return std::string();
    }
예제 #4
0
// ----------------------------------------------------------------------------
//
bool ColorSelectField::setValue( LPCSTR value ) {
    CString key( value );
    RGBWAArray colors;

    int curPos = 0;
    while ( true ) {
        CString resToken = key.Tokenize( _T(","), curPos );
        if ( resToken.IsEmpty() )
            break;

        resToken.Trim();
        if ( resToken.GetLength() == 0 )
            continue;

        bool found = false;
        RGBWA rgb;
        ULONG value;
        unsigned red, green, blue;

        if ( sscanf_s( resToken, "#%lx", &value ) == 1 ) {
            found = true;
            rgb = RGBWA( value );
        }
        else if ( sscanf_s( resToken, "rgb(%u %u %u)", &red, &green, &blue ) == 3 ) {
            found = true;
            rgb = RGBWA( red, green, blue );
        }
        else 
            found = RGBWA::getColorByName( (LPCSTR)resToken, rgb );

        if ( ! found )
            throw FieldException( "Unknown color value '%s'", (LPCSTR)resToken );

        colors.push_back( rgb );
    }

    if ( colors.size() > 1 && !m_allow_multiple )
        throw FieldException( "Select a single color" );

    m_colors = colors;

    return InputField::setValue( value );
}
예제 #5
0
// ----------------------------------------------------------------------------
//
bool DmxAddressField::setValue( LPCSTR value ) 
{
    long result;

    if ( !IntegerField::parse( value, result ) )
        throw FieldException( "'%s' is not a valid DMX address" );

    channel_t end_address = (channel_t)result+m_num_channels-1;

    if ( !m_allow_address_overlap ) {
        UID current = m_venue->whoIsAddressRange( 1, (channel_t)result, end_address );
        if ( current != 0 && current != m_uid )
            throw FieldException( "DMX address %d already in use", result );
        if ( end_address > DMX_PACKET_SIZE )
        throw FieldException( "Channel range past end of addressable DMX addresses (%d > %d)", end_address, DMX_PACKET_SIZE );
    }

    return IntegerField::setValue( value );
}
예제 #6
0
// ----------------------------------------------------------------------------
//
bool UniqueGroupNumberField::setValue( LPCSTR value ) {
    long result;

    if ( !IntegerField::parse( value, result ) )
        return false;

    if ( m_venue->getFixtureGroupByNumber( (GroupNumber)result ) != NULL )
        throw FieldException( "Group number %lu is already in use", result );

    return IntegerField::setValue( value );
}
예제 #7
0
// ----------------------------------------------------------------------------
//
bool ChannelValueListField::setValue( LPCSTR value ) {
    CString key( value );
    ChannelValueArray channel_value_list;

    int curPos = 0;
    while ( true ) {
        CString resToken = key.Tokenize( _T(" ,"), curPos );
        if ( resToken.IsEmpty() )
            break;
            
        long channel_value = strtoul( resToken, NULL, 10 );
        if ( channel_value < 0 || channel_value > 255 ) 
            throw FieldException( "Value %lu is out of range (value values 0-255)", channel_value );

        channel_value_list.push_back( (BYTE)channel_value );
    }

    if ( channel_value_list.size() == 0 )
        throw FieldException( "Need at least one channel value" );

    m_channel_values = channel_value_list;

    return InputField::setValue( value );
}
예제 #8
0
 std::tm GetAsTimestamp() const
 {
   SQL_TIMESTAMP_STRUCT Timestamp = GetData<TIMESTAMP_STRUCT>(SQL_C_TIMESTAMP);
   std::tm Tm = { 0 };
   Tm.tm_year = Timestamp.year - 1900;
   Tm.tm_mon = Timestamp.month;
   Tm.tm_mday = Timestamp.day;
   Tm.tm_hour = Timestamp.hour;
   Tm.tm_min = Timestamp.minute;
   Tm.tm_sec = Timestamp.second;
   Tm.tm_isdst = -1;
   std::time_t Seconds = std::mktime(&Tm);
   if (Seconds == -1)
     throw FieldException("Bad date format", feBadFormat);
   return *std::localtime(&Seconds);
 }
예제 #9
0
// ----------------------------------------------------------------------------
//
bool CoordinatesField::setValue( LPCSTR value ) {
    CString key( value );
    CoordinateArray coordinates_list;

    int curPos = 0;
    while ( true ) {
        CString resToken = key.Tokenize( _T(";"), curPos );
        if ( resToken.IsEmpty() )
            break;

        UINT pan, tilt;

        resToken.Trim();

        if ( sscanf_s( resToken, "%u,%u", &pan, &tilt ) != 2 )
            throw FieldException( "Enter coordinates in the form: pan,tilt;pan,tilt;..." );

        coordinates_list.push_back( FixtureCoordinate(pan,tilt) );
    }

    m_coordinates = coordinates_list;

    return InputField::setValue( value );
}