Esempio n. 1
0
bool XMLPreferences::isPreference(const QString& inName, 
				  const QString& inSection,
				  Persistence pers)
{
  // try to retrieve the preference
  QVariant* preference = getPref(inName, inSection, pers);

  return (preference != NULL);
}
Esempio n. 2
0
QVariant XMLPreferences::getPrefVariant(const QString& inName, 
					const QString& inSection,
					const QVariant& outDefault,
					Persistence pers)
{
  // try to retrieve the preference
  QVariant* preference = getPref(inName, inSection, pers);

  // if preference was retrieved, return it as a string
  if (preference)
    return *preference;

  // return the default value
  return outDefault;
}
Esempio n. 3
0
uint64_t XMLPreferences::getPrefUInt64(const QString& inName, 
				       const QString& inSection, 
				       uint64_t def, 
				       Persistence pers)
{
  // try to retrieve the preference
  QVariant* preference = getPref(inName, inSection, pers);

  // if preference was retrieved, return it as a string
  if (preference != NULL)
  {
    uint64_t value = def;

    switch(preference->type())
    {
    case QVariant::String:
      // convert it to a uint64_t (in base 16)
      value = strtoull(preference->toString(), 0, 16);
      break;
    case QVariant::Int:
    case QVariant::UInt:
      value = preference->toInt();
      break;
    case QVariant::Double:
      value = uint64_t(preference->toDouble());
      break;
    case QVariant::ByteArray:
      {
	QByteArray& ba = preference->asByteArray();
	if (ba.size() == sizeof(uint64_t))
	  value = *(uint64_t*)ba.data();
	break;
      }
    default:
      qWarning("XMLPreferences::getPrefUInt64(%s, %s, %llu): preference found,\n"
	       "\tbut type %s is not convertable to type uint64_t!",
	       (const char*)inName, (const char*)inSection, 
	       (unsigned long long)def,
	       preference->typeName());
    }

    // return the key
    return value;
  }

  // return the default value
  return def;
}
Esempio n. 4
0
int XMLPreferences::getPrefKey(const QString& inName, 
			       const QString& inSection, 
			       int def, 
			       Persistence pers)
{
  // try to retrieve the preference
  QVariant* preference = getPref(inName, inSection, pers);

  // if preference was retrieved, return it as a string
  if (preference != NULL)
  {
    int key = def;

    switch(preference->type())
    {
    case QVariant::KeySequence:
      key = preference->toInt();
      break;
    case QVariant::String:
      // convert it to a key
      key = QAccel::stringToKey(preference->toString());
      break;
    case QVariant::Int:
    case QVariant::UInt:
    case QVariant::Double:
      key = preference->toInt();
      break;
    default:
      qWarning("XMLPreferences::getPrefKey(%s, %s, %d): preference found,\n"
	       "\tbut type %s is not convertable to type key!",
	       (const char*)inName, (const char*)inSection, def,
	       preference->typeName());
    }

    // fix the key code (deal with Qt brain death)
    key &= ~Qt::UNICODE_ACCEL;

    // return the key
    return key;
  }

  // return the default value
  return def;
}
Esempio n. 5
0
// DW name      (ポインタデータの生成)
void vmDwName(int idx) {
  printf("\tDW\t%c%s\n",
	 getPref(topAux), ntGetName(topAux));   //    DW  _name
}
Esempio n. 6
0
// スタックトップの値を大域変数にストアする(POPはしない)
void vmStGlb(int idx) {                         // idx は名前表のインデクス
  if (topSta!=RVAR) loadStk(0);                 // レジスタにロードする
  printf("\tST\t%s,%c%s\n", regs[topAux],       // グローバル変数へストア
	 getPref(idx), ntGetName(idx));         //   ST Reg,_name
}
Esempio n. 7
0
                                                //   ローカル変数領域サイズ
// グローバルな名前をラベル欄に出力
void vmNam(int idx) {
  printf("%c%s",getPref(idx),ntGetName(idx));   // '_' or '.' と 名前の出力
}
Esempio n. 8
0
void PrefsDb::synchronizePlatformDefaults() {
	
	char* jsonStr = Utils::readFile(s_defaultPlatformPrefsFile);
	if (!jsonStr) {
		g_warning("PrefsDb::synchronizePlatformDefaults(): Failed to load default platform prefs file: %s", s_defaultPlatformPrefsFile);
		return;
	}

	json_object* root = 0;
	json_object* label = 0;
	std::string ccnumber;
	int ret;
	gchar* queryStr;

	root = json_tokener_parse(jsonStr);
	if (!root || is_error(root)) {
		g_warning("PrefsDb::synchronizePlatformDefaults(): Failed to parse file contents into json");
		return;
	}

	label = json_object_object_get(root, "preferences");
	if (!label || is_error(label)) {
		g_warning("PrefsDb::synchronizePlatformDefaults(): Failed to get preferences entry from file");
		json_object_put(root);
		return;
	}

	json_object_object_foreach(label, key, val) {

		if (val == NULL)
			continue;		//TODO: really should delete this key if it is in the database
		char * p_cDbv = json_object_to_json_string(val);
		if (p_cDbv == NULL)
			continue;
		//check the key to see if it exists in the db already
		
		std::string cv = getPref(key);
		std::string dbv(p_cDbv);
		
		if (cv.length() == 0) {
			queryStr = g_strdup_printf("INSERT INTO Preferences "
					"VALUES ('%s', '%s')",
					key, json_object_to_json_string(val));
			if (!queryStr) {
				g_warning("PrefsDb::synchronizePlatformDefaults(): Failed to allocate query string for key %s",key);
				continue;
			}

			ret = sqlite3_exec(m_prefsDb, queryStr, NULL, NULL, NULL);
			g_free(queryStr);

			if (ret) {
				g_warning("PrefsDb::synchronizePlatformDefaults(): Failed to execute query for key %s", key);
				continue;
			}
		}
		
	}
	
	json_object_put(root);
		
}