void UpdateFieldDumper::BuildUpdateFieldEnum(Enum& enumData, std::string const& name, std::vector<UpdateField> const& data, std::string const& end, std::string const& fieldBase)
{
    enumData.SetName(name);

    std::uint32_t i = 0;
    while (i < data.size())
    {
        UpdateField const* field = &data[i];
        std::string name = GetInputData()->GetString(data[i].NameAddress);
        if (name == "CGUnitData::npcFlags[UMNW0]")
        {
            name = "CGUnitData::npcFlags";
            field = &data[i + 1];
        }

        std::string oldName = GetOldName(name.c_str());
        if (!oldName.empty())
            name = oldName;

        enumData.AddMember(Enum::Member(i, FormatValue(i, fieldBase), name,
            static_cast<std::ostringstream&>(std::ostringstream() << "Size: " << field->Size << ", Flags: " << GetUpdateFieldFlagName(field->Flags)).str()));

        i += field->Size;
    }

    enumData.AddMember(Enum::Member(i, FormatValue(i, fieldBase), end, ""));
}
Exemple #2
0
 bool AssertEqual(const char* file, int line, const char* expr, T value, U expected, TestErrorMessage *msg)
 {
   if (static_cast<T>(expected) != value)
   {
     char buf1[1024];
     char buf2[1024];
     FormatValue(buf1, sizeof buf1, value);
     FormatValue(buf2, sizeof buf2, expected);
     return OnAssertFailure(file, line, msg, "value equality failed: %s: %s != %s", expr, buf1, buf2);
   }
   return true;
 }
Exemple #3
0
bool wxRegKey::DoExportValue(wxOutputStream& ostr, const wxString& name) const
{
    // first examine the value type: if it's unsupported, simply skip it
    // instead of aborting the entire export process because we failed to
    // export a single value
    wxString value = FormatValue(name);
    if ( value.empty() )
    {
        wxLogWarning(_("Ignoring value \"%s\" of the key \"%s\"."),
                     name.c_str(), GetName().c_str());
        return true;
    }

    // we do have the text representation of the value, now write everything
    // out

    // special case: unnamed/default value is represented as just "@"
    if ( name.empty() )
    {
        if ( !WriteAsciiChar(ostr, '@') )
            return false;
    }
    else // normal, named, value
    {
        if ( !WriteAsciiChar(ostr, '"') ||
                !WriteAsciiString(ostr, name) ||
                    !WriteAsciiChar(ostr, '"') )
            return false;
    }

    if ( !WriteAsciiChar(ostr, '=') )
        return false;

    return WriteAsciiString(ostr, value) && WriteAsciiEOL(ostr);
}
Exemple #4
0
void FormatValue(CFormat& format, const CECTag* tag)
{
	wxASSERT(tag->GetTagName() == EC_TAG_STAT_NODE_VALUE);

	wxString extra;
	const CECTag *tmp_tag = tag->GetTagByName(EC_TAG_STAT_NODE_VALUE);
	if (tmp_tag) {
		wxString tmp_fmt;
		const CECTag* tmp_vt = tmp_tag->GetTagByName(EC_TAG_STAT_VALUE_TYPE);
		EC_STATTREE_NODE_VALUE_TYPE tmp_valueType = tmp_vt != NULL ? (EC_STATTREE_NODE_VALUE_TYPE)tmp_vt->GetInt() : EC_VALUE_INTEGER;
		switch (tmp_valueType) {
			case EC_VALUE_INTEGER:
				tmp_fmt = wxT("%llu");
				break;
			case EC_VALUE_DOUBLE:
				tmp_fmt = wxT("%.2f%%");	// it's used for percentages
				break;
			default:
				tmp_fmt = wxT("%s");
		}
		CFormat tmp_format(wxT(" (") + tmp_fmt + wxT(")"));
		FormatValue(tmp_format, tmp_tag);
		extra = tmp_format.GetString();
	}

	const CECTag* vt = tag->GetTagByName(EC_TAG_STAT_VALUE_TYPE);
	EC_STATTREE_NODE_VALUE_TYPE valueType = vt != NULL ? (EC_STATTREE_NODE_VALUE_TYPE)vt->GetInt() : EC_VALUE_INTEGER;
	switch (valueType) {
		case EC_VALUE_INTEGER:
			format = format % tag->GetInt();
			break;
		case EC_VALUE_ISTRING:
			format = format % (CFormat(wxT("%u")) % tag->GetInt() + extra);
			break;
		case EC_VALUE_BYTES:
			format = format % (CastItoXBytes(tag->GetInt()) + extra);
			break;
		case EC_VALUE_ISHORT:
			format = format % (CastItoIShort(tag->GetInt()) + extra);
			break;
		case EC_VALUE_TIME:
			format = format % (CastSecondsToHM(tag->GetInt()) + extra);
			break;
		case EC_VALUE_SPEED:
			format = format % (CastItoSpeed(tag->GetInt()) + extra);
			break;
		case EC_VALUE_STRING:
			format = format % (wxGetTranslation(tag->GetStringData()) + extra);
			break;
		case EC_VALUE_DOUBLE:
			format = format % tag->GetDoubleData();
			break;
		default:
			wxFAIL;
	}
}
Exemple #5
0
    HRESULT FormatStruct( IValueBinder* binder, Address addr, Type* type, int radix, std::wstring& outStr )
    {
        HRESULT         hr = S_OK;

        _ASSERT( type->AsTypeStruct() );
        RefPtr<Declaration> decl = type->GetDeclaration();
        if ( decl == NULL )
            return E_INVALIDARG;

        RefPtr<IEnumDeclarationMembers> members;
        if ( !decl->EnumMembers( members.Ref() ) )
            return E_INVALIDARG;

        outStr.append( L"{" );
        for ( ; ; )
        {
            RefPtr<Declaration> member;
            if ( !members->Next( member.Ref() ) )
                break;
            if ( member->IsBaseClass() || member->IsStaticField() )
                continue;

            if ( outStr.length () > 64 )
            {
                outStr.append( L", ..." );
                break;
            }

            DataObject memberObj;
            member->GetType( memberObj._Type.Ref() );
            memberObj.Addr = addr;
            int offset;
            if ( member->GetOffset( offset ) )
                memberObj.Addr += offset;

            hr = binder->GetValue( memberObj.Addr, memberObj._Type, memberObj.Value );
            if ( FAILED( hr ) )
                return hr;

            std::wstring memberStr;
            hr = FormatValue( binder, memberObj, radix, memberStr );
            if ( FAILED( hr ) )
                return hr;

            if ( outStr.length() > 1 )
                outStr.append( L", " );
            outStr.append( member->GetName() );
            outStr.append( L"=" );
            outStr.append( memberStr );
        }
        outStr.append( L"}" );

        return hr;
    }
Exemple #6
0
/*------------------------------------------------------------------------------
*/
static char *FormatSupInfo(
  mh_eSupType SupType,
  mh_uSupInfo *sip
)
{
  static char Text[100];
  pwr_tString40	ActValue,LimitValue;

  Text[0] = '\0';

  if (SupType == mh_eSupType_Analog) {
    FormatValue(sip->mh_uSupInfo_u.A.ActualValue, ActValue);
    FormatValue(sip->mh_uSupInfo_u.A.CtrlLimit, LimitValue);
    sprintf(Text, " %s%s %s,  %s%s %s", _VALUE,	ActValue,
      sip->mh_uSupInfo_u.A.Unit, _LIMIT, LimitValue, sip->mh_uSupInfo_u.A.Unit
    );
  }

  return Text;
}
void UpdateFieldDumper::BuildDynamicUpdateFieldEnum(Enum& enumData, std::string const& name, std::vector<DynamicUpdateField> const& data, std::string const& end, std::string const& fieldBase)
{
    enumData.SetName(name);

    std::uint32_t i = 0;
    while (i < data.size())
    {
        DynamicUpdateField const* field = &data[i];
        std::string name = GetInputData()->GetString(data[i].NameAddress);
        std::string oldName = GetOldName(name.c_str());
        if (!oldName.empty())
            name = oldName;

        enumData.AddMember(Enum::Member(i, FormatValue(i, fieldBase), name,
            static_cast<std::ostringstream&>(std::ostringstream() << "Flags: " << GetUpdateFieldFlagName(field->Flags)).str()));
        ++i;
    }

    enumData.AddMember(Enum::Member(i, FormatValue(i, fieldBase), end, ""));
}
Exemple #8
0
void CFloatSpinCtrl::SetValueForBuddy(double val) {
    CWnd* pEdit = GetBuddy();
    if (pEdit) {
        CString str;
        if (m_strFormat.IsEmpty ()) {
            str = FormatValue (val);
        } else {
            str.Format (m_strFormat, val);
        }

        pEdit->SetWindowText(str);
    }
}
QString TransactionDesc::ValueMapToHTML(const std::map<int, int64_t> &valueMap)
{
    QString strHTML;
    std::map<int, int64_t>::const_iterator it;
    for (it = valueMap.begin(); it != valueMap.end(); ++it)
    {
        if (it != valueMap.begin())
        {
            strHTML += ", ";
        }
        strHTML += FormatValue(it->second, it->first);
    }
    return strHTML;
}
QString TransactionDesc::TxOutToHTML(const CTxOut &txout, const CWallet* wallet)
{
    // individual tx do not affect any representation
    static const bool fMultiSig = true;

    QString strHTML;
    if (wallet->IsMine(txout, fMultiSig) & ISMINE_ALL)
    {
        std::pair<int, int64_t> cred= wallet->GetCredit(txout, fMultiSig);
        if (CheckColor(cred.first))
        {
            strHTML += "<b>" + tr("Credit") + ":</b> " +
                         FormatValue(cred.second, cred.first) + "<br>";
        }
    }
    return strHTML;
}
QString TransactionDesc::TxInToHTML(const CTxIn &txin, const CWallet* wallet)
{
    // individual tx do not affect any balance calculation
    static const bool fMultiSig = true;

    QString strHTML;
    if (wallet->IsMine(txin, fMultiSig) & ISMINE_ALL)
    {
        std::pair<int, int64_t> deb = wallet->GetDebit(txin, fMultiSig);
        if (CheckColor(deb.first))
        {
            strHTML += "<b>" + tr("Debit") + ":</b> " +
                         FormatValue(-deb.second, deb.first) + "<br>";
        }
    }
    return strHTML;
}
Exemple #12
0
wxString CEC_StatTree_Node_Tag::GetDisplayString() const
{
	wxString en_label = GetStringData();
	wxString my_label = wxGetTranslation(en_label);
	// This is needed for client names, for example
	if (my_label == en_label) {
		if (en_label.Right(4) == wxT(": %s")) {
			my_label = wxGetTranslation(en_label.Mid(0, en_label.Length() - 4)) + wxString(wxT(": %s"));
		}
	}
	CFormat label(my_label);
	for (const_iterator it = begin(); it != end(); it++) {
		if (it->GetTagName() == EC_TAG_STAT_NODE_VALUE) {
			FormatValue(label, &*it);
		}
	}
	return label.GetString();
}
Exemple #13
0
MEDUSA_NAMESPACE_BEGIN

  bool Architecture::FormatCell(
  Document      const& rDoc,
  BinaryStream  const& rBinStrm,
  Address       const& rAddr,
  Cell          const& rCell,
  std::string        & rStrCell,
  Cell::Mark::List   & rMarks) const
{
  switch (rCell.GetType())
  {
  case Cell::InstructionType: return FormatInstruction(rDoc, rBinStrm, rAddr, static_cast<Instruction const&>(rCell), rStrCell, rMarks);
  case Cell::ValueType:       return FormatValue      (rDoc, rBinStrm, rAddr, static_cast<Value       const&>(rCell), rStrCell, rMarks);
  case Cell::CharacterType:   return FormatCharacter  (rDoc, rBinStrm, rAddr, static_cast<Character   const&>(rCell), rStrCell, rMarks);
  case Cell::StringType:      return FormatString     (rDoc, rBinStrm, rAddr, static_cast<String      const&>(rCell), rStrCell, rMarks);
  default:                    return false;
  }
}
Exemple #14
0
bool Architecture::FormatCell(
    Document      const& rDoc,
    Address       const& rAddr,
    Cell          const& rCell,
    PrintData          & rPrintData) const
{
    switch (rCell.GetType())
    {
    case Cell::InstructionType:
        return FormatInstruction(rDoc, rAddr, static_cast<Instruction const&>(rCell), rPrintData);
    case Cell::ValueType:
        return FormatValue      (rDoc, rAddr, static_cast<Value       const&>(rCell), rPrintData);
    case Cell::CharacterType:
        return FormatCharacter  (rDoc, rAddr, static_cast<Character   const&>(rCell), rPrintData);
    case Cell::StringType:
        return FormatString     (rDoc, rAddr, static_cast<String      const&>(rCell), rPrintData);
    default:
        return false;
    }
}
Exemple #15
0
/*
 * HIDParse(HIDParser_t* pParser, HIDData_t *pData)
 *
 * Analyse Report descriptor stored in HIDParser struct and store local and
 * global context. 
 * Return in pData the last object found.
 * Return -1 when there is no other Item to parse, 1 if a new object was found
 * or 0 if a continuation of a previous object was found.
 * -------------------------------------------------------------------------- */
static int HIDParse(HIDParser_t *pParser, HIDData_t *pData)
{
	int	Found = -1;

	while ((Found < 0) && (pParser->Pos < pParser->ReportDescSize)) {
		/* Get new pParser->Item if current pParser->Count is empty */
		if (pParser->Count == 0) {
			pParser->Item = pParser->ReportDesc[pParser->Pos++];
			pParser->Value = 0;
#if WORDS_BIGENDIAN
			{
				int	i;
				unsigned long	valTmp = 0;

				for (i = 0; i < ItemSize[pParser->Item & SIZE_MASK]; i++) {
					memcpy(&valTmp, &pParser->ReportDesc[(pParser->Pos)+i], 1);
					pParser->Value += valTmp >> ((3-i)*8);
					valTmp = 0;
				}
			}
#else
			memcpy(&pParser->Value, &pParser->ReportDesc[pParser->Pos], ItemSize[pParser->Item & SIZE_MASK]);
#endif
			/* Pos on next item */
      			pParser->Pos += ItemSize[pParser->Item & SIZE_MASK];
		}

		switch (pParser->Item & ITEM_MASK)
		{
		case ITEM_UPAGE:
			/* Copy UPage in Usage stack */
			pParser->UPage=(uint16_t)pParser->Value;
			break;

		case ITEM_USAGE:
			/* Copy global or local UPage if any, in Usage stack */
			if ((pParser->Item & SIZE_MASK) > 2) {
				pParser->UsageTab[pParser->UsageSize] = pParser->Value;
			} else {
				pParser->UsageTab[pParser->UsageSize] = (pParser->UPage << 16) | (pParser->Value & 0xFFFF);
			}

			/* Increment Usage stack size */
			pParser->UsageSize++;
			break;

		case ITEM_COLLECTION:
			/* Get UPage/Usage from UsageTab and store them in pParser->Data.Path */
			pParser->Data.Path.Node[pParser->Data.Path.Size] = pParser->UsageTab[0];
			pParser->Data.Path.Size++;

			/* Unstack UPage/Usage from UsageTab (never remove the last) */
			if (pParser->UsageSize > 0) {
				int	i;
			
				for (i = 0; i < pParser->UsageSize; i++) {
					pParser->UsageTab[i] = pParser->UsageTab[i+1];
				}

				/* Remove Usage */
				pParser->UsageSize--;
		        }

			/* Get Index if any */
			if (pParser->Value >= 0x80) {
				pParser->Data.Path.Node[pParser->Data.Path.Size] = 0x00ff0000 | (pParser->Value & 0x7F);
				pParser->Data.Path.Size++;
			}

			ResetLocalState(pParser);
			break;

		case ITEM_END_COLLECTION :
			pParser->Data.Path.Size--;
			
			/* Remove Index if any */
			if((pParser->Data.Path.Node[pParser->Data.Path.Size] & 0xffff0000) == 0x00ff0000) {
				pParser->Data.Path.Size--;
			}
			
			ResetLocalState(pParser);
			break;
			
		case ITEM_FEATURE:
		case ITEM_INPUT:
		case ITEM_OUTPUT:
			if (pParser->UsageTab[0] != 0x00000000) {
				/* An object was found if the path does not end with 0x00000000 */
				Found = 1;
			} else {
				/* It is a continuation of a previous object */
				Found = 0;
			}
			
			/* Get new pParser->Count from global value */
			if(pParser->Count == 0) {
				pParser->Count = pParser->ReportCount;
			}
			
			/* Get UPage/Usage from UsageTab and store them in pParser->Data.Path */
			pParser->Data.Path.Node[pParser->Data.Path.Size] = pParser->UsageTab[0];
			pParser->Data.Path.Size++;
			
			/* Unstack UPage/Usage from UsageTab (never remove the last) */
			if(pParser->UsageSize > 0) {
				int i;
				
				for (i = 0; i < pParser->UsageSize; i++) {
					pParser->UsageTab[i] = pParser->UsageTab[i+1];
				}
				/* Remove Usage */
				pParser->UsageSize--;
			}
			
			/* Copy data type */
			pParser->Data.Type = (uint8_t)(pParser->Item & ITEM_MASK);
			
			/* Copy data attribute */
			pParser->Data.Attribute = (uint8_t)pParser->Value;
			
			/* Store offset */
			pParser->Data.Offset = *GetReportOffset(pParser, pParser->Data.ReportID, (uint8_t)(pParser->Item & ITEM_MASK));
			
			/* Get Object in pData */
			/* -------------------------------------------------------------------------- */
			memcpy(pData, &pParser->Data, sizeof(HIDData_t));
			/* -------------------------------------------------------------------------- */
			
			/* Increment Report Offset */
			*GetReportOffset(pParser, pParser->Data.ReportID, (uint8_t)(pParser->Item & ITEM_MASK)) += pParser->Data.Size;
			
			/* Remove path last node */
			pParser->Data.Path.Size--;
			
			/* Decrement count */
			pParser->Count--;
			
			if (pParser->Count == 0) {
				ResetLocalState(pParser);
			}
			break;
			
		case ITEM_REP_ID :
			pParser->Data.ReportID = (uint8_t)pParser->Value;
			break;
			
		case ITEM_REP_SIZE :
			pParser->Data.Size = (uint8_t)pParser->Value;
			break;
			
		case ITEM_REP_COUNT :
			pParser->ReportCount = (uint8_t)pParser->Value;
			break;
			
		case ITEM_UNIT_EXP :
			pParser->Data.UnitExp = (int8_t)pParser->Value;
			if (pParser->Data.UnitExp > 7) {
				pParser->Data.UnitExp |= 0xF0;
			}
			break;
			
		case ITEM_UNIT :
			pParser->Data.Unit = pParser->Value;
			break;
			
		case ITEM_LOG_MIN :
			pParser->Data.LogMin = FormatValue(pParser->Value, ItemSize[pParser->Item & SIZE_MASK]);
			break;
			
		case ITEM_LOG_MAX :
			pParser->Data.LogMax = FormatValue(pParser->Value, ItemSize[pParser->Item & SIZE_MASK]);
			break;
			
		case ITEM_PHY_MIN :
			pParser->Data.PhyMin=FormatValue(pParser->Value, ItemSize[pParser->Item & SIZE_MASK]);
			pParser->Data.have_PhyMin = 1;
			break;
			
		case ITEM_PHY_MAX :
			pParser->Data.PhyMax=FormatValue(pParser->Value, ItemSize[pParser->Item & SIZE_MASK]);
			pParser->Data.have_PhyMax = 1;
			break;
			
		case ITEM_LONG :
			/* can't handle long items, but should at least skip them */
			pParser->Pos += (uint8_t)(pParser->Value & 0xff);
			break;
		}
	} /* while ((Found < 0) && (pParser->Pos < pParser->ReportDescSize)) */
Exemple #16
0
void UPnpDeviceDesc::OutputDevice( QTextStream &os,
                                   UPnpDevice *pDevice,
                                   const QString &sUserAgent )
{
    if (pDevice == NULL)
        return;

    QString sFriendlyName = QString( "%1: %2" )
                               .arg( GetHostName() )
                               .arg( pDevice->m_sFriendlyName );

    // ----------------------------------------------------------------------
    // Only override the root device
    // ----------------------------------------------------------------------

    if (pDevice == &m_rootDevice)
        sFriendlyName = UPnp::g_pConfig->GetValue( "UPnP/FriendlyName",
                                                   sFriendlyName  );

    os << "<device>\n";
    os << FormatValue( "deviceType"   , pDevice->m_sDeviceType );
    os << FormatValue( "friendlyName" , sFriendlyName          );

    // ----------------------------------------------------------------------
    // XBox 360 needs specific values in the Device Description.
    //
    // -=>TODO: This should be externalized in a more generic/extension
    //          kind of way.
    // ----------------------------------------------------------------------

    bool bIsXbox360 =
        sUserAgent.startsWith(QString("Xbox/2.0"), Qt::CaseInsensitive) ||
        sUserAgent.startsWith( QString("Mozilla/4.0"), Qt::CaseInsensitive);

    os << FormatValue( "manufacturer" , pDevice->m_sManufacturer    );
    os << FormatValue( "modelURL"     , pDevice->m_sModelURL        );

    if ( bIsXbox360 )
    {
        os << FormatValue( "modelName"    ,
                           "Windows Media Connect Compatible (MythTV)");
    }
    else
    {
        os << FormatValue( "modelName"    , pDevice->m_sModelName       );
    }

    os << FormatValue( "manufacturerURL"  , pDevice->m_sManufacturerURL );
    os << FormatValue( "modelDescription" , pDevice->m_sModelDescription);
    os << FormatValue( "modelNumber"      , pDevice->m_sModelNumber     );
    os << FormatValue( "serialNumber"     , pDevice->m_sSerialNumber    );
    os << FormatValue( "UPC"              , pDevice->m_sUPC             );
    os << FormatValue( "presentationURL"  , pDevice->m_sPresentationURL );

    // MythTV Custom information
    os << FormatValue( "mythtv:X_secure" , pDevice->m_securityPin ? "true" : "false");
    os << FormatValue( "mythtv:X_protocol", pDevice->m_protocolVersion );

    NameValues::const_iterator nit = pDevice->m_lstExtra.begin();
    for (; nit != pDevice->m_lstExtra.end(); ++nit)
    {
        // -=>TODO: Hack to handle one element with attributes... need to
        //          handle attributes in a more generic way.

        if ((*nit).sName == "dlna:X_DLNADOC")
        {
            os << QString("<dlna:X_DLNADOC xmlns:dlna=\"urn:"
                          "schemas-dlna-org:device-1-0\">%1"
                          "</dlna:X_DLNADOC>\n" ).arg((*nit).sValue);
        }
        else
            os << FormatValue( (*nit).sName, (*nit).sValue );
    }

    // ----------------------------------------------------------------------
    // Output Any Icons.
    // ----------------------------------------------------------------------

    if (pDevice->m_listIcons.count() > 0)
    {
        os << "<iconList>\n";

        UPnpIconList::const_iterator it = pDevice->m_listIcons.begin();
        for (; it != pDevice->m_listIcons.end(); ++it)
        {

            os << "<icon>\n";
            os << FormatValue( "mimetype", (*it)->m_sMimeType );
            os << FormatValue( "width"   , (*it)->m_nWidth    );
            os << FormatValue( "height"  , (*it)->m_nHeight   );
            os << FormatValue( "depth"   , (*it)->m_nDepth    );
            os << FormatValue( "url"     , (*it)->m_sURL      );
            os << "</icon>\n";
        }
        os << "</iconList>\n";
    }

    os << FormatValue( "UDN"          , pDevice->GetUDN()      );

    // ----------------------------------------------------------------------
    // Output any Services
    // ----------------------------------------------------------------------

    if (pDevice->m_listServices.count() > 0)
    {
        // ------------------------------------------------------------------
        // -=>TODO: As a temporary fix don't expose the MSRR service unless we
        //          as an XBox360 or Windows MediaPlayer.
        //
        //          There is a problem with a DSM-520 with firmware 1.04 and
        //          the Denon AVR-4306 receiver.
        //
        //          If the MSRR Service is exposed, it won't let us browse
        //          any media content.
        //
        //          Need to find out real fix and remove this code.
        // ------------------------------------------------------------------

        //bool bDSM = sUserAgent.startsWith( "INTEL_NMPR/2.1 DLNADOC/1.00", false );

        os << "<serviceList>\n";

        UPnpServiceList::const_iterator it = pDevice->m_listServices.begin();
        for (; it != pDevice->m_listServices.end(); ++it)
        {
            if (!bIsXbox360 && (*it)->m_sServiceType.startsWith(
                    "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar",
                    Qt::CaseInsensitive))
            {
                continue;
            }

            os << "<service>\n";
            os << FormatValue( "serviceType", (*it)->m_sServiceType );
            os << FormatValue( "serviceId"  , (*it)->m_sServiceId   );
            os << FormatValue( "SCPDURL"    , (*it)->m_sSCPDURL     );
            os << FormatValue( "controlURL" , (*it)->m_sControlURL  );
            os << FormatValue( "eventSubURL", (*it)->m_sEventSubURL );
            os << "</service>\n";
        }
        os << "</serviceList>\n";
    }

    // ----------------------------------------------------------------------
    // Output any Embedded Devices
    // ----------------------------------------------------------------------

    // -=>Note:  XBMC can't handle sub-devices, it's UserAgent is blank.
#if 0
    if (sUserAgent.length() > 0)
    {
        if (pDevice->m_listDevices.count() > 0)
        {
            os << "<deviceList>";

            for ( UPnpDevice *pEmbeddedDevice  = pDevice->m_listDevices.first();
                              pEmbeddedDevice != NULL;
                              pEmbeddedDevice  = pDevice->m_listDevices.next() )
            {
                OutputDevice( os, pEmbeddedDevice );
            }
            os << "</deviceList>";
        }
    }
#endif
    os << "</device>\n";
    os << flush;
}
Exemple #17
0
String FormatValue(const Single& value, const String& format)
{
    double d = value;
    return FormatValue(d, format);
}
Exemple #18
0
    HRESULT Property::GetPropertyInfo( 
        DEBUGPROP_INFO_FLAGS dwFields,
        DWORD dwRadix,
        DWORD dwTimeout,
        IDebugReference2** rgpArgs,
        DWORD dwArgCount,
        DEBUG_PROPERTY_INFO* pPropertyInfo )
    {
        if ( pPropertyInfo == NULL )
            return E_INVALIDARG;

        pPropertyInfo->dwFields = 0;

        if ( (dwFields & DEBUGPROP_INFO_NAME) != 0 )
        {
            std::wstring txt = mExprText;
            MagoEE::AppendFormatSpecifier( txt, mFormatOpts );
            pPropertyInfo->bstrName = SysAllocString( txt.c_str() );
            pPropertyInfo->dwFields |= DEBUGPROP_INFO_NAME;
        }

        if ( (dwFields & DEBUGPROP_INFO_FULLNAME) != 0 )
        {
            std::wstring txt = mFullExprText;
            MagoEE::AppendFormatSpecifier( txt, mFormatOpts );
            pPropertyInfo->bstrFullName = SysAllocString( txt.c_str() );
            pPropertyInfo->dwFields |= DEBUGPROP_INFO_FULLNAME;
        }

        if ( (dwFields & DEBUGPROP_INFO_VALUE) != 0 )
        {
            pPropertyInfo->bstrValue = FormatValue( dwRadix );
            pPropertyInfo->dwFields |= DEBUGPROP_INFO_VALUE;
        }

        if ( (dwFields & DEBUGPROP_INFO_TYPE) != 0 )
        {
            if ( mObjVal.ObjVal._Type != NULL )
            {
                std::wstring    typeStr;
                mObjVal.ObjVal._Type->ToString( typeStr );

                pPropertyInfo->bstrType = SysAllocString( typeStr.c_str() );
                pPropertyInfo->dwFields |= DEBUGPROP_INFO_TYPE;
            }
        }

        if ( (dwFields & DEBUGPROP_INFO_PROP) != 0 )
        {
            QueryInterface( __uuidof( IDebugProperty2 ), (void**) &pPropertyInfo->pProperty );
            pPropertyInfo->dwFields |= DEBUGPROP_INFO_PROP;
        }

        if ( (dwFields & DEBUGPROP_INFO_ATTRIB) != 0 )
        {
            pPropertyInfo->dwAttrib = 0;
            if ( mObjVal.HasString )
                pPropertyInfo->dwAttrib |= DBG_ATTRIB_VALUE_RAW_STRING;
            if ( mObjVal.ReadOnly )
                pPropertyInfo->dwAttrib |= DBG_ATTRIB_VALUE_READONLY;
            if ( mObjVal.HasChildren )
                pPropertyInfo->dwAttrib |= DBG_ATTRIB_OBJ_IS_EXPANDABLE;

            if ( mObjVal.ObjVal._Type != NULL )
            {
                if( !mObjVal.ObjVal._Type->IsMutable() )
                    pPropertyInfo->dwAttrib |= DBG_ATTRIB_TYPE_CONSTANT;
                if( mObjVal.ObjVal._Type->IsShared() )
                    pPropertyInfo->dwAttrib |= DBG_ATTRIB_TYPE_SYNCHRONIZED;

                if( auto fun = mObjVal.ObjVal._Type->AsTypeFunction() )
                {
                    if ( fun->IsProperty() )
                        pPropertyInfo->dwAttrib |= DBG_ATTRIB_PROPERTY;
                    else
                        pPropertyInfo->dwAttrib |= DBG_ATTRIB_METHOD;
                }
                else if( auto clss = mObjVal.ObjVal._Type->AsTypeStruct() )
                    pPropertyInfo->dwAttrib |= DBG_ATTRIB_CLASS;
                else
                    pPropertyInfo->dwAttrib |= DBG_ATTRIB_DATA;
            }
            pPropertyInfo->dwFields |= DEBUGPROP_INFO_ATTRIB;
        }

        return S_OK;
    }
Exemple #19
0
int HIDParse(HIDParser* pParser, HIDData* pData)
{
  int Found=0;

  while(!Found && pParser->Pos<pParser->ReportDescSize)
    {
      /* Get new pParser->Item if current pParser->Count is empty */
      if(pParser->Count==0)
	{
	  pParser->Item=pParser->ReportDesc[pParser->Pos++];
	  pParser->Value=0;
	  #ifdef WORDS_BIGENDIAN
	  {
	    int i;
	    unsigned long valTmp=0;
	    for (i=0;i<ItemSize[pParser->Item & SIZE_MASK];i++)
	      {
		memcpy(&valTmp, &pParser->ReportDesc[(pParser->Pos)+i], 1);
		pParser->Value+=valTmp>>((3-i)*8);
		valTmp=0;
	      }
	  }
	  #else
	  memcpy(&pParser->Value, &pParser->ReportDesc[pParser->Pos], ItemSize[pParser->Item & SIZE_MASK]);
	  #endif
	  /* Pos on next item */
	  pParser->Pos+=ItemSize[pParser->Item & SIZE_MASK];
	}

      switch(pParser->Item & ITEM_MASK)
	{
	case ITEM_UPAGE :
	  {
	    /* Copy UPage in Usage stack */
	    pParser->UPage=(ushort)pParser->Value;
	    break;
	  }
	case ITEM_USAGE :
	  {
	    /* Copy global or local UPage if any, in Usage stack */
	    if((pParser->Item & SIZE_MASK)>2)
	      pParser->UsageTab[pParser->UsageSize].UPage=(ushort)(pParser->Value>>16);
	    else
	      pParser->UsageTab[pParser->UsageSize].UPage=pParser->UPage;

	    /* Copy Usage in Usage stack */
	    pParser->UsageTab[pParser->UsageSize].Usage=(ushort)(pParser->Value & 0xFFFF);

	    /* Increment Usage stack size */
	    pParser->UsageSize++;

	    break;
	  }
	case ITEM_COLLECTION :
	  {
	    /* Get UPage/Usage from UsageTab and store them in pParser->Data.Path */
	    pParser->Data.Path.Node[pParser->Data.Path.Size].UPage=pParser->UsageTab[0].UPage;
	    pParser->Data.Path.Node[pParser->Data.Path.Size].Usage=pParser->UsageTab[0].Usage;
	    pParser->Data.Path.Size++;

	    /* Unstack UPage/Usage from UsageTab (never remove the last) */
	    if(pParser->UsageSize>0)
	      {
		uchar ii=0;
		while(ii<pParser->UsageSize)
		  {
		    pParser->UsageTab[ii].Usage=pParser->UsageTab[ii+1].Usage;
		    pParser->UsageTab[ii].UPage=pParser->UsageTab[ii+1].UPage;
		    ii++;
		  }
		/* Remove Usage */
		pParser->UsageSize--;
	      }

	    /* Get Index if any */
	    if(pParser->Value>=0x80)
	      {
		pParser->Data.Path.Node[pParser->Data.Path.Size].UPage=0xFF;
		pParser->Data.Path.Node[pParser->Data.Path.Size].Usage=pParser->Value & 0x7F;
		pParser->Data.Path.Size++;
	      }
	    ResetLocalState(pParser);
	    break;
	  }
	case ITEM_END_COLLECTION :
	  {
	    pParser->Data.Path.Size--;
	    /* Remove Index if any */
	    if(pParser->Data.Path.Node[pParser->Data.Path.Size].UPage==0xFF)
	      pParser->Data.Path.Size--;
	    ResetLocalState(pParser);
	    break;
	  }
	case ITEM_FEATURE :
	case ITEM_INPUT :
	case ITEM_OUTPUT :
	  {
	    /* An object was found */
	    Found=1;

	    /* Increment object count */
	    pParser->nObject++;

	    /* Get new pParser->Count from global value */
	    if(pParser->Count==0)
	      {
		pParser->Count=pParser->ReportCount;
	      }

	    /* Get UPage/Usage from UsageTab and store them in pParser->Data.Path */
	    pParser->Data.Path.Node[pParser->Data.Path.Size].UPage=pParser->UsageTab[0].UPage;
	    pParser->Data.Path.Node[pParser->Data.Path.Size].Usage=pParser->UsageTab[0].Usage;
	    pParser->Data.Path.Size++;

	    /* Unstack UPage/Usage from UsageTab (never remove the last) */
	    if(pParser->UsageSize>0)
	      {
		uchar ii=0;
		while(ii<pParser->UsageSize)
		  {
		    pParser->UsageTab[ii].UPage=pParser->UsageTab[ii+1].UPage;
		    pParser->UsageTab[ii].Usage=pParser->UsageTab[ii+1].Usage;
		    ii++;
		  }
		/* Remove Usage */
		pParser->UsageSize--;
	      }

	    /* Copy data type */
	    pParser->Data.Type=(uchar)(pParser->Item & ITEM_MASK);

	    /* Copy data attribute */
	    pParser->Data.Attribute=(uchar)pParser->Value;

	    /* Store offset */
	    pParser->Data.Offset=*GetReportOffset(pParser, pParser->Data.ReportID, (uchar)(pParser->Item & ITEM_MASK));

	    /* Get Object in pData */
	    /* -------------------------------------------------------------------------- */
	    memcpy(pData, &pParser->Data, sizeof(HIDData));
	    /* -------------------------------------------------------------------------- */

	    /* Increment Report Offset */
	    *GetReportOffset(pParser, pParser->Data.ReportID, (uchar)(pParser->Item & ITEM_MASK)) += pParser->Data.Size;

	    /* Remove path last node */
	    pParser->Data.Path.Size--;

	    /* Decrement count */
	    pParser->Count--;
	    if (pParser->Count == 0) {
	      ResetLocalState(pParser);
	    }
	    break;
	  }
	case ITEM_REP_ID :
	  {
	    pParser->Data.ReportID=(uchar)pParser->Value;
	    break;
	  }
	case ITEM_REP_SIZE :
	  {
	    pParser->Data.Size=(uchar)pParser->Value;
	    break;
	  }
	case ITEM_REP_COUNT :
	  {
	    pParser->ReportCount=(uchar)pParser->Value;
	    break;
	  }
	case ITEM_UNIT_EXP :
	  {
	    pParser->Data.UnitExp=(char)pParser->Value;
	    // Convert 4 bits signed value to 8 bits signed value
	    if (pParser->Data.UnitExp > 7)
	      pParser->Data.UnitExp|=0xF0;
	    break;
	  }
	case ITEM_UNIT :
	  {
	    pParser->Data.Unit=pParser->Value;
	    break;
	  }
	case ITEM_LOG_MIN :
	  {
	    pParser->Data.LogMin=FormatValue(pParser->Value, ItemSize[pParser->Item & SIZE_MASK]);
	    break;
	  }
	case ITEM_LOG_MAX :
	  {
	    pParser->Data.LogMax=FormatValue(pParser->Value, ItemSize[pParser->Item & SIZE_MASK]);
	    break;
	  }
	case ITEM_PHY_MIN :
	  {
	    pParser->Data.PhyMin=FormatValue(pParser->Value, ItemSize[pParser->Item & SIZE_MASK]);
	    break;
	  }
	case ITEM_PHY_MAX :
	  {
	    pParser->Data.PhyMax=FormatValue(pParser->Value, ItemSize[pParser->Item & SIZE_MASK]);
	    break;
	  }
	case ITEM_LONG :
	  {
	    /* can't handle long items, but should at least skip them */
	    pParser->Pos+=(u_char)(pParser->Value & 0xff);
	  }
	}
void ITxFormView::vOnSignalItemChanged(int nRow, int nColumn)
{
    if (nullptr == m_pouTxDataStore)
    {
        return;
    }

    CString omStrSigName = m_omLctrSigList.GetItemText(nRow, eSigColName);
    ITxMsgItem* pouMsgItem = nullptr;
    int nIndex = m_lstMsg.GetSelectionMark();
    if (-1 == nIndex)
    {
        return;
    }

    m_pouTxDataStore->GetMsgItem(nIndex, pouMsgItem);

    if (nullptr == pouMsgItem)
    {
        return;
    }
    SIG_DETAILS ouSignalDetails;
    pouMsgItem->GetSignal(m_pouIBMNetwork, m_bHexMode,std::string(omStrSigName), ouSignalDetails);

    // If it is a valid signal
    if (ouSignalDetails.Signal.first != nullptr)
    {
        // Get the Signal Raw Value
        CString omStr = m_omLctrSigList.GetItemText(nRow, nColumn);
        unsigned __int64 un64Min, un64Max;
        unsigned __int64 unI64RawValue = 0;
        __int64 nI64TempRawValue;
        double dwPhyVal = 0;
        int nBase = m_bHexMode ? defBASE_HEX : defBASE_DEC;


        switch (nColumn)
        {
            case eSigColPhyVal:
                dwPhyVal = atof(omStr);
                ouSignalDetails.Signal.first->GetRawValueFromEng(dwPhyVal, unI64RawValue);
                break;
            case eSigColRawVal:
                bConvertStringToInt64(omStr, nI64TempRawValue, nBase);
                unI64RawValue = nI64TempRawValue;
                break;
        }

        ouSignalDetails.Signal.first->GetMinMaxValue(un64Min, un64Max);

        eSignalDataType eDataType = eUnsigned;
        ouSignalDetails.Signal.first->GetDataType(eDataType);
        if (eUnsigned == eDataType)
        {
            GetRawValueInRange<unsigned __int64>(unI64RawValue, un64Min, un64Max);
        }
        else if (eSigned == eDataType)
        {
            unsigned int unSiglength = 0;
            ouSignalDetails.Signal.first->GetLength(unSiglength);
            __int64 nI64RawValue = static_cast<__int64>(FormatValue(eSigned,unSiglength,unI64RawValue));
            __int64 n64Min = static_cast<__int64>(un64Min);
            __int64 n64Max = static_cast<__int64>(un64Max);
            GetRawValueInRange<__int64>(nI64RawValue, n64Min, n64Max);
            unI64RawValue = static_cast<unsigned __int64>(nI64RawValue);
        }

        vGetDataBytesFromSignal(unI64RawValue, ouSignalDetails.Signal, pouMsgItem->MsgDetails.nDLC, pouMsgItem->MsgDetails.pchData);

        m_pouTxDataStore->SetMsgItem(nIndex, pouMsgItem);

        std::list<SIG_DETAILS> lstSignalDetails;
        pouMsgItem->GetSignalList(m_pouIBMNetwork, m_bHexMode,lstSignalDetails);
        UpdateDataAndSignalView(pouMsgItem->MsgDetails.pchData, pouMsgItem->MsgDetails.nDLC, lstSignalDetails);
    }
}