static void
AnnotateClsidRegistrationForHive(JSONWriter& aJson, HKEY aHive,
                                 const nsAString& aClsid,
                                 const JSONWriter::CollectionStyle aStyle)
{
  nsAutoString clsidSubkey;
  clsidSubkey.AppendLiteral(kSoftwareClasses);
  clsidSubkey.AppendLiteral(kClsid);
  clsidSubkey.Append(aClsid);

  nsAutoString className;
  if (GetStringValue(aHive, clsidSubkey, kDefaultValue, className)) {
    aJson.StringProperty("ClassName",
                         NS_ConvertUTF16toUTF8(className).get());
  }

  nsAutoString inprocServerSubkey(clsidSubkey);
  inprocServerSubkey.AppendLiteral(kInprocServer32);

  nsAutoString pathToServerDll;
  if (GetStringValue(aHive, inprocServerSubkey, kDefaultValue, pathToServerDll)) {
    aJson.StringProperty("Path", NS_ConvertUTF16toUTF8(pathToServerDll).get());
    if (GetLoadedPath(pathToServerDll)) {
      aJson.StringProperty("LoadedPath",
                           NS_ConvertUTF16toUTF8(pathToServerDll).get());
    }
  }

  nsAutoString apartment;
  if (GetStringValue(aHive, inprocServerSubkey, kThreadingModel, apartment)) {
    aJson.StringProperty("ThreadingModel", NS_ConvertUTF16toUTF8(apartment).get());
  }
}
static void
AnnotateInterfaceRegistrationForHive(JSONWriter& aJson, HKEY aHive, REFIID aIid,
                                     const JSONWriter::CollectionStyle aStyle)
{
  nsAutoString interfaceSubKey;
  interfaceSubKey.AppendLiteral(kSoftwareClasses);
  interfaceSubKey.AppendLiteral(kInterface);
  nsAutoString iid;
  GUIDToString(aIid, iid);
  interfaceSubKey.Append(iid);

  nsAutoString interfaceName;
  if (GetStringValue(aHive, interfaceSubKey, kDefaultValue, interfaceName)) {
    aJson.StringProperty("InterfaceName",
                         NS_ConvertUTF16toUTF8(interfaceName).get());
  }

  nsAutoString psSubKey(interfaceSubKey);
  psSubKey.AppendLiteral(kProxyStubClsid32);

  nsAutoString psClsid;
  if (GetStringValue(aHive, psSubKey, kDefaultValue, psClsid)) {
    aJson.StartObjectProperty("ProxyStub", aStyle);
    aJson.StringProperty("CLSID", NS_ConvertUTF16toUTF8(psClsid).get());
    AnnotateClsidRegistrationForHive(aJson, aHive, psClsid, aStyle);
    aJson.EndObject();
  }

  nsAutoString typelibSubKey(interfaceSubKey);
  typelibSubKey.AppendLiteral(kTypeLib);

  nsAutoString typelibId;
  bool haveTypelibId = GetStringValue(aHive, typelibSubKey, kDefaultValue,
                                      typelibId);

  nsAutoString typelibVersion;
  bool haveTypelibVersion = GetStringValue(aHive, typelibSubKey, kVersion,
                                           typelibVersion);

  if (haveTypelibId || haveTypelibVersion) {
    aJson.StartObjectProperty("TypeLib", aStyle);
  }

  if (haveTypelibId) {
    aJson.StringProperty("ID", NS_ConvertUTF16toUTF8(typelibId).get());
  }

  if (haveTypelibVersion) {
    aJson.StringProperty("Version", NS_ConvertUTF16toUTF8(typelibVersion).get());
  }

  if (haveTypelibId && haveTypelibVersion) {
    AnnotateTypelibRegistrationForHive(aJson, aHive, typelibId, typelibVersion,
                                       aStyle);
  }

  if (haveTypelibId || haveTypelibVersion) {
    aJson.EndObject();
  }
}
static void
AnnotateTypelibRegistrationForHive(JSONWriter& aJson, HKEY aHive,
                                   const nsAString& aTypelibId,
                                   const nsAString& aTypelibVersion,
                                   const JSONWriter::CollectionStyle aStyle)
{
  nsAutoString typelibSubKey;
  typelibSubKey.AppendLiteral(kSoftwareClasses);
  typelibSubKey.AppendLiteral(kTypeLib);
  typelibSubKey.AppendLiteral(kBackslash);
  typelibSubKey.Append(aTypelibId);
  typelibSubKey.AppendLiteral(kBackslash);
  typelibSubKey.Append(aTypelibVersion);

  nsAutoString typelibDesc;
  if (GetStringValue(aHive, typelibSubKey, kDefaultValue, typelibDesc)) {
    aJson.StringProperty("Description",
                         NS_ConvertUTF16toUTF8(typelibDesc).get());
  }

  nsAutoString flagsSubKey(typelibSubKey);
  flagsSubKey.AppendLiteral(kBackslash);
  flagsSubKey.AppendLiteral(kFlags);

  nsAutoString typelibFlags;
  if (GetStringValue(aHive, flagsSubKey, kDefaultValue, typelibFlags)) {
    aJson.StringProperty("Flags", NS_ConvertUTF16toUTF8(typelibFlags).get());
  }

  HKEY rawTypelibKey;
  LONG result = RegOpenKeyEx(aHive, typelibSubKey.get(), 0, KEY_READ,
                             &rawTypelibKey);
  if (result != ERROR_SUCCESS) {
    return;
  }
  nsAutoRegKey typelibKey(rawTypelibKey);

  const size_t kMaxLcidCharLen = 9;
  WCHAR keyName[kMaxLcidCharLen];

  for (DWORD index = 0; result == ERROR_SUCCESS; ++index) {
    DWORD keyNameLength = ArrayLength(keyName);
    result = RegEnumKeyEx(typelibKey, index, keyName, &keyNameLength, nullptr,
                          nullptr, nullptr, nullptr);

    unsigned long lcid;
    if (result == ERROR_SUCCESS && ConvertLCID(keyName, WrapNotNull(&lcid))) {
      nsDependentString strLcid(keyName, keyNameLength);
      aJson.StartObjectProperty(NS_ConvertUTF16toUTF8(strLcid).get(), aStyle);
      AnnotateTypelibPlatform(aJson, typelibKey, strLcid, kWin32, aStyle);
#if defined(HAVE_64BIT_BUILD)
      AnnotateTypelibPlatform(aJson, typelibKey, strLcid, kWin64, aStyle);
#endif
      aJson.EndObject();
    }
  }
}
void QProcessResultThread::ParseSpResult( QByteArray& byJson, bool& bSuccess, QString& strUUID )
{
    strUUID = "";
    bSuccess = false;
    QJsonParseError jsonError;
    QJsonDocument jsonDoc = QJsonDocument::fromJson( byJson, &jsonError );

    if ( QJsonParseError::NoError != jsonError.error ) {
        qDebug( ) << jsonError.errorString( ) << endl;
        return;
    }

    if ( jsonDoc.isNull( ) || jsonDoc.isEmpty( ) ) {
        return;
    }

    QJsonObject jsonObj = jsonDoc.object( );
    if ( jsonObj.isEmpty( ) ) {
        return;
    }

    QJsonValue jsonVal = jsonObj.value( "Flag" );
    if ( jsonVal.isDouble( ) ) {
        bSuccess = jsonVal.toInt( );
    }

    GetStringValue( strUUID, "UUID",  jsonObj );

    if ( !bSuccess ) {
        return;
    }

    QString strDateTime = "";
    GetStringValue( strDateTime, "DateTime",  jsonObj );

    QString strPlate = "";
    GetStringValue( strPlate, "Plate",  jsonObj );

    QString strMobile = "";
    GetStringValue( strMobile, "MobilePhone",  jsonObj );

    QString strName = "";
    GetStringValue( strName, "Name",  jsonObj );

    if ( strMobile.isEmpty( ) ) {
        return;
    }

    SendShortMessage( strPlate, strDateTime, strName, strMobile );
}
示例#5
0
RDLog::LinkState RDLog::linkState(RDLog::Source src) const
{
  if(linkQuantity(src)==0) {
    return RDLog::LinkNotPresent;
  }
  switch(src) {
      case RDLog::SourceMusic:
	return (RDLog::LinkState)RDBool(GetStringValue("MUSIC_LINKED"));

      case RDLog::SourceTraffic:
	return (RDLog::LinkState)RDBool(GetStringValue("TRAFFIC_LINKED"));
  }
  return RDLog::LinkNotPresent;
}
NS_IMETHODIMP nsAbDirProperty::GetDirName(nsAString &aDirName)
{
  if (m_DirPrefId.IsEmpty())
  {
    aDirName = m_ListDirName;
    return NS_OK;
  }

  nsCString dirName;
  nsresult rv = GetLocalizedStringValue("description", EmptyCString(), dirName);
  NS_ENSURE_SUCCESS(rv, rv);

  // In TB 2 only some prefs had chrome:// URIs. We had code in place that would
  // only get the localized string pref for the particular address books that
  // were built-in.
  // Additionally, nsIPrefBranch::getComplexValue will only get a non-user-set,
  // non-locked pref value if it is a chrome:// URI and will get the string
  // value at that chrome URI. This breaks extensions/autoconfig that want to
  // set default pref values and allow users to change directory names.
  //
  // Now we have to support this, and so if for whatever reason we fail to get
  // the localized version, then we try and get the non-localized version
  // instead. If the string value is empty, then we'll just get the empty value
  // back here.
  if (dirName.IsEmpty())
  {
    rv = GetStringValue("description", EmptyCString(), dirName);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  CopyUTF8toUTF16(dirName, aDirName);
  return NS_OK;
}
示例#7
0
// Load/Save
BOOL COptionsMisc::Load()
{
	m_bParentFolder = GetBoolValue	("ParentFolder", TRUE) ? true : false;

	// Load Icons Info
	m_bShowIcons = GetBoolValue ("ShowIcons", TRUE) ? true : false;

	// Load Thumbnails Info
	m_bShowThumbnails = GetBoolValue ("ShowThumbnails", TRUE) ? true : false;

	SetAutoExtractIcons(GetBoolValue("AutoExtractIcons", TRUE) ? true : false);
	SetAutoExtractClassHelp(GetBoolValue("AutoExtractClassHelp", TRUE) ? true : false);

	m_bShowUndoWarnings = GetBoolValue ("ShowUndoWarnings", TRUE) ? true : false;

	m_bShowFullPath = GetBoolValue("ShowFullPathInTitle", FALSE) ? true : false;

	m_bAutoLoadProj = GetBoolValue("AutoLoadProj", TRUE) ? true : false;

	m_bDefaultCompressed = GetBoolValue("DefaultCompressed", TRUE) ? true : false;
	m_bLoadLYTFile = GetBoolValue("LoadLYTFile", TRUE) ? true : false;
	m_bUndoFreezeHide = GetBoolValue("UndoFreezeHide", FALSE) ? true : false;

	// Load undo data
	m_dwUndos			= GetDWordValue("NumUndos", 40);

	SetVectorEditIncrement(atof(GetStringValue("VectorEditIncrement", "0.1")));
	SetVectorEditAutoApply(GetBoolValue("VectorEditAutoApply", TRUE) ? true : false);
	SetRotationEditAutoApply(GetBoolValue("RotationEditAutoApply", TRUE) ? true : false);

	return TRUE;
}
示例#8
0
/**
 * Funcao para adicionar o aspas no caso de data e strings
 */
CString	CField::GetQueryFormatValue()
{
	CString s;

	if(m_type == FIELD_TYPE_STRING ||
	   m_type == FIELD_TYPE_DATE   ||
	   m_type == FIELD_TYPE_BOOLCHAR )
	{
		s.Format(_T("'%s'"), m_sValue);
		return s;
	}

	m_sValue.TrimLeft();
	m_sValue.TrimRight();

	if(m_sValue.IsEmpty() && 
		( m_type == FIELD_TYPE_NUMBER || 
		  m_type == FIELD_TYPE_CURRENCY)
	   )
	{
		return _T("");
	}

	return GetStringValue();
}
示例#9
0
bool Var::Equals(Var* rvalue) {
	switch(type) {
		case vtInt: {
			return GetIntValue() == rvalue->GetIntValue();
		}
		case vtFloat: {
			return GetFloatValue() == rvalue->GetFloatValue();
		}
		case vtString: {
			char* lvaluetext = GetStringValue();
			char* rvaluetext = rvalue->GetStringValue();
			bool result = !strcmp(lvaluetext,rvaluetext);
			delete[] lvaluetext;
			delete[] rvaluetext;
			return result;
		}
		case vtFloat3: {
			return float3value == rvalue->float3value;
		}
		case vtObject: {
			return objectvalue == rvalue->objectvalue; // compare pointers...
		}
		default: {
			return false;
		}
	}
}
示例#10
0
CString	CTableBase::GetStringValueNoNULL(LPCTSTR _szLabel)
{
	CString s = GetStringValue(_szLabel);
	if(s.CompareNoCase(_T("NULL")) == 0)
		return _T("");
	return s;
}
PRBool
nsAttrValue::GetColorValue(nscolor& aColor) const
{
  NS_PRECONDITION(Type() == eColor || Type() == eString, "wrong type");
  switch (BaseType()) {
    case eString:
    {
      return GetPtr() && NS_ColorNameToRGB(GetStringValue(), &aColor);
    }
    case eOtherBase:
    {
      aColor = GetMiscContainer()->mColor;
      
      break;
    }
    case eIntegerBase:
    {
      aColor = static_cast<nscolor>(GetIntInternal());
      
      break;
    }
    default:
    {
      NS_NOTREACHED("unexpected basetype");
      
      break;
    }
  }

  return PR_TRUE;
}
示例#12
0
	/**
	@brief Get a parsed value from the config file
	@param cName The name of the variable in the config file
	@param n The position of the value in a multivalue field.
	For "MyArray 10 56 38 52 46;",  GetValue<int>("MyArray", 3) will return 52. (the first value is at n=0)
	**/
    T GetValue(const char* cName, int n=0)const
	{
		std::string sValue(GetStringValue(cName)+" ");
		std::string sCurrValue;

		int nPos=0;
		for(unsigned int i=0 ; i<sValue.size() ; i++)
		{
			if(sValue[i]!=' ' && sValue[i]!='\t')
			{
				sCurrValue+=sValue[i];
			}
			else
			{
				if(nPos==n)
				{
					std::stringstream ss(sCurrValue);
					T a;
					ss>>a;
					return a;
				}
				else
				{
					sCurrValue="";
					nPos++;
				}
			}
NS_IMETHODIMP nsAbMDBDirectory::GetDatabaseFile(nsILocalFile **aResult)
{
  NS_ENSURE_ARG_POINTER(aResult);

  nsCString fileName;
  nsresult rv = GetStringValue("filename", EmptyCString(), fileName);
  NS_ENSURE_SUCCESS(rv, rv);

  if (fileName.IsEmpty())
    return NS_ERROR_NOT_INITIALIZED;

  nsCOMPtr<nsIFile> profileDir;
  rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
                              getter_AddRefs(profileDir));
  NS_ENSURE_SUCCESS(rv, rv);

  rv = profileDir->AppendNative(fileName);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsILocalFile> dbFile = do_QueryInterface(profileDir, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  NS_ADDREF(*aResult = dbFile);

  return NS_OK;
}
int wxTextWidgetImpl::GetLineLength(long lineNo) const
{
    // TODO: change this if possible to reflect real lines
    wxString content = GetStringValue() ;

    // Find line first
    int count = 0;
    for (size_t i = 0; i < content.length() ; i++)
    {
        if (count == lineNo)
        {
            // Count chars in line then
            count = 0;
            for (size_t j = i; j < content.length(); j++)
            {
                if (content[j] == '\n')
                    return count;

                count++;
            }

            return count;
        }

        if (content[i] == '\n')
            count++;
    }

    return 0 ;
}
示例#15
0
void wxTreeViewComboPopup::OnSelectionChanged(wxGxSelectionEvent& event)
{
	if(event.GetInitiator() == GetId())
		return;

    long nSelID = m_pSelection->GetLastSelectedObjectId();
	wxTreeItemId ItemId = m_TreeMap[nSelID];
	if(ItemId.IsOk())
	{
		SelectItem(ItemId);
	}
	else
	{
        wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(nSelID);
		wxGxObject* pParentGxObj = pGxObject->GetParent();
		while(pParentGxObj)
		{
			wxTreeItemId ItemId = m_TreeMap[pParentGxObj->GetId()];
			if(ItemId.IsOk())
			{
				Expand(ItemId);
				break;
			}
			else
				pParentGxObj = pParentGxObj->GetParent();
		}
		OnSelectionChanged(event);
	}
    //set combo text
    wxString sText = GetStringValue();
    m_combo->SetText(sText);
}
wxString wxTextWidgetImpl::GetLineText(long lineNo) const
{
    // TODO: change this if possible to reflect real lines
    wxString content = GetStringValue() ;

    // Find line first
    int count = 0;
    for (size_t i = 0; i < content.length() ; i++)
    {
        if (count == lineNo)
        {
            // Add chars in line then
            wxString tmp;

            for (size_t j = i; j < content.length(); j++)
            {
                if (content[j] == '\n')
                    return tmp;

                tmp += content[j];
            }

            return tmp;
        }

        if (content[i] == '\n')
            count++;
    }

    return wxEmptyString ;
}
示例#17
0
NS_IMETHODIMP
nsSampleImpl::WriteValue(const char* aPrefix)
{
    NS_PRECONDITION(aPrefix != nsnull, "null ptr");
    if (! aPrefix)
        return NS_ERROR_NULL_POINTER;

    printf("%s %s\n", aPrefix, mValue);

    // This next part illustrates the nsEmbedString:
    nsEmbedString foopy;
    foopy.Append(PRUnichar('f'));
    foopy.Append(PRUnichar('o'));
    foopy.Append(PRUnichar('o'));
    foopy.Append(PRUnichar('p'));
    foopy.Append(PRUnichar('y'));
    
    const PRUnichar* f = foopy.get();
    PRUint32 l = foopy.Length();
    printf("%c%c%c%c%c %d\n", char(f[0]), char(f[1]), char(f[2]), char(f[3]), char(f[4]), l);
    
    nsEmbedCString foopy2;
    GetStringValue(foopy2);

    //foopy2.AppendLiteral("foopy");
    const char* f2 = foopy2.get();
    PRUint32 l2 = foopy2.Length();

    printf("%s %d\n", f2, l2);

    return NS_OK;
}
示例#18
0
/*
** Executes OnChangeAction if action is set.
** If execute parameter is set to false, only updates old value with current value.
**
*/
void Measure::DoChangeAction(bool execute)
{
	if (!m_OnChangeAction.empty() && m_ValueAssigned)
	{
		double newValue = GetValue();
		const WCHAR* newStringValue = GetStringValue();
		if (!newStringValue)
		{
			newStringValue = L"";
		}

		if (!m_OldValue)
		{
			m_OldValue = new MeasureValueSet(newValue, newStringValue);
		}
		else if (execute)
		{
			if (m_OldValue->IsChanged(newValue, newStringValue))
			{
				GetRainmeter().ExecuteCommand(m_OnChangeAction.c_str(), m_Skin);
			}
		}
		else
		{
			m_OldValue->Set(newValue, newStringValue);
		}
	}
}
示例#19
0
float Universal::GetFloat() const
{
	switch (GetType())
	{
	case TypeString:
		{
			register const char * str = GetStringValue();
			if (str[0] == '0' && str[1] == 'x')
			{
				register float ret = 0;
				sscanf(str+2, "%x", &ret);
				return (float)ret;
			}
			else
			{
				register float ret = 0.f;
				sscanf(str, "%f", &ret);
				return ret;
			}
		}
	case TypeDecimal: return (float)value.l;
	case TypeUnsigned: return (float)value.ul;
	case TypeFloat: return value.f;
	case TypeBool: return value.b ? 1.f:0.f;
	//case TypeFloatVector: return vec_GetFloat(0);
	};
	return 0;
}
示例#20
0
            void Configuration::FillFromConnectString(const char* str, size_t len)
            {
                // Initializing map.
                arguments.clear();

                // Initializing DSN to empty string.
                arguments[Key::dsn].clear();

                // Ignoring terminating zero byte if present.
                // Some Driver Managers pass zero-terminated connection string
                // while others don't.
                if (len && !str[len - 1])
                    --len;

                ParseAttributeList(str, len, ';', arguments);

                ArgumentMap::const_iterator it = arguments.find(Key::address);
                if (it != arguments.end())
                {
                    // Parsing address.
                    ParseAddress(it->second, endPoint);
                }
                else
                {
                    endPoint.host = GetStringValue(Key::server, DefaultValue::server);
                    endPoint.port = static_cast<uint16_t>(GetIntValue(Key::port, DefaultValue::port));
                }
            }
示例#21
0
            void Configuration::FillFromConfigAttributes(const char * attributes)
            {
                // Initializing map.
                arguments.clear();

                size_t len = 0;

                // Getting list length. List is terminated by two '\0'.
                while (attributes[len] || attributes[len + 1])
                    ++len;

                ++len;

                ParseAttributeList(attributes, len, '\0', arguments);

                ArgumentMap::const_iterator it = arguments.find(Key::address);
                if (it != arguments.end())
                {
                    // Parsing address.
                    ParseAddress(it->second, endPoint);
                }
                else
                {
                    endPoint.host = GetStringValue(Key::server, DefaultValue::server);
                    endPoint.port = static_cast<uint16_t>(GetIntValue(Key::port, DefaultValue::port));
                }
            }
inline static bool
GetStringValue(HKEY aBaseKey, const nsAString& aStrSubKey,
               const char16_t (&aValueName)[N], nsAString& aOutput)
{
  return GetStringValue(aBaseKey, aStrSubKey,
                        nsLiteralString(aValueName),
                        aOutput);
}
示例#23
0
IINField LoggingHandler::ProcessHeader(const RangeHeader& header, const ICollection<Indexed<Binary>>& values)
{
	auto stringify = [](bool value) -> const char*
	{
		return GetStringValue(value);
	};
	return this->PrintVQTStringify(header.enumeration, values, stringify);
}
示例#24
0
/* 获取section段第一个键为key的string值,成功返回获取的值,否则返回默认值 */
void IniFile::GetStringValueOrDefault(const string &section, const string &key,
                                      string *value, const string &defaultValue)
{
    if (GetStringValue(section, key, value) != 0) {
        *value = defaultValue;
    }

    return;
}
示例#25
0
void PersonnelResourceGetFamilyName (IAAFObject * pObj,
							 aafCharacter * buf,
							 aafUInt32 buflen)
{
  assert (pObj);
  assert (buf);
  GetStringValue (pObj, kPropID_PersonnelResource_FamilyName,
		          buf,buflen);
}
示例#26
0
文件: db.c 项目: yangchenzhong/im
float GetFloatValue(MYSQL_RES *pResult, char *pField)
{
	char *pValue = GetStringValue(pResult, pField);
	if (pValue)
	{
		return (float)atof(pValue);
	}

	return 0;
}
示例#27
0
文件: db.c 项目: yangchenzhong/im
double GetDoubleValue(MYSQL_RES *pResult, char *pField)
{
	char *pValue = GetStringValue(pResult, pField);
	if (pValue)
	{
		return atof(pValue);
	}

	return 0;
}
示例#28
0
文件: db.c 项目: yangchenzhong/im
int GetIntValue(MYSQL_RES *pResult, char *pField)
{
	char *pValue = GetStringValue(pResult, pField);
	if (pValue)
	{
		return atoi(pValue);
	}

	return 0;
}
示例#29
0
QColor RDEvent::color() const
{
  bool ok;
  QColor color;
  color=QColor(GetStringValue("COLOR",&ok));
  if(!ok) {
    color=QColor();
  }
  return color;
}
示例#30
0
bool nsCSSValue::IsNonTransparentColor() const
{
  // We have the value in the form it was specified in at this point, so we
  // have to look for both the keyword 'transparent' and its equivalent in
  // rgba notation.
  nsDependentString buf;
  return
    (mUnit == eCSSUnit_Color && NS_GET_A(GetColorValue()) > 0) ||
    (mUnit == eCSSUnit_Ident &&
     !nsGkAtoms::transparent->Equals(GetStringValue(buf))) ||
    (mUnit == eCSSUnit_EnumColor);
}