Esempio n. 1
0
// Constructor
Firnplayer::Player::Player()
{
  ConfigDir = cleanpath(HomePath() + "/.firnplayer");
  ConfigFile = cleanpath(ConfigDir + "/Configuration.json");
  TrackInfoFile = cleanpath(ConfigDir + "/TrackInfo.json");
  
  ThePlayer = this;

  // Check if Config path exists and make if not.
  if(!FileExists(ConfigDir))
  {
    std::printf("Config folder %s does not exist, creating.\n", ConfigDir.c_str());
    boost::filesystem::create_directory(ConfigDir);
    if(!FileExists(ConfigDir))
    {
      FatalErrorString = StringPrintf("Could not create directory %s, aborting\n", ConfigDir.c_str());
    }
  }

  // Load and sanitize config file.
  if(FileExists(ConfigFile))
  {
    std::printf("Reading Config\n");
    LoadJson(ConfigFile, Options);
  }
  SanitizeConfig();

  ActiveViewPort = ACTIVE_ARTISTS;

  // Set the frame colours
  ArtistView.SetFrameColPair(COLPAIR_FRAME);
  TrackView.SetFrameColPair(COLPAIR_FRAME);
  QueueView.SetFrameColPair(COLPAIR_FRAME);
  PlaylistView.SetFrameColPair(COLPAIR_FRAME);

  // Load track info if it exists.
  std::string TrackDBPath = cleanpath(ConfigDir + "/TrackInfo.Json");
  if(FileExists(TrackDBPath))
  {
    std::printf("Loading Track Info\n");
    if(!LoadJson(TrackDBPath, TrackList))  // No queue lock.  No other threads should be running.
    {
      std::printf("Stored track info file corrupt, starting empty.\n");
    }
    else
    {
      Threads["Sorter"] = std::thread(Sortfunction, std::ref(Artists), std::ref(ArtistsQueue), 
                                      std::ref(TrackList), std::ref(TrackListQueue));
    }
  }
  Running = 1;
}
Esempio n. 2
0
Cjson& Cjson::operator[] (int num){
	//如果是个空的CTypeValue,那么需要先初始化,判断时必须用pJson来判断,因为只有pJson是透传的
	if(pJson == NULL){
		//说明还未初始化
		LoadJson("{}");
	}
	//不论是什么类型先把数字存进去,因为在存的时候最初定义的类型都是CjsonA
	pJson->vecField.push_back(CFieldType("",num));
	//把本层的地址传入pvec并带下去,方便后面取之前的地址和清空vector
	pJson->vecCjson.push_back(this);

	if(type == "class CstrValue"){
		
	}
	else if(type == "class CszValue"){
		//如果数组中有这么长再返回
		if(((CszValue*)pClass)->vecszValue.size() > (unsigned int)num){
			((CszValue*)pClass)->vecszValue.at(num).pJson = this->pJson;
			return ((CszValue*)pClass)->vecszValue.at(num);
		}
	}
	else if(type == "class CjsonA"){
		
	}
	else{
		;//AfxMessageBox("重载[num]时本身类型出错,类型为:" + type);
	}
	return *this;
}
Esempio n. 3
0
Cjson& Cjson::operator[] (string field){
	//如果是个空的CTypeValue,那么需要先初始化,判断时必须用pJson来判断,因为只有pJson是透传的
	if(pJson == NULL){
		//说明还未初始化
		LoadJson("{}");
	}
	//不论当前是什么类型都先把字段存进去,因为存的时候之前的类型是没有意义的
	pJson->vecField.push_back(CFieldType(field,-1));
	//把本层的地址传入pvec并带下去,方便后面取之前的地址和清空vector
	pJson->vecCjson.push_back(this);
	

	if(type == "class CstrValue"){
		
	}
	else if(type == "class CszValue"){
		
	}
	else if(type == "class CjsonA"){
		//如果有这个字段再返回
		auto it = ((CjsonA*)pClass)->mapdata.begin();
		for(;it != ((CjsonA*)pClass)->mapdata.end();it++){
			if(it->first.c_str() == field){
				//返回之前先把pJson的值带下去,因为如果出现不存在的情况,return *this能保证pJson肯定有值
				((CjsonA*)pClass)->mapdata[field].pJson = this->pJson;
				return ((CjsonA*)pClass)->mapdata[field];
			}
		}
	}
	else{
		;//AfxMessageBox("重载[field]时本身类型出错,类型为:" + type);
	}
	return *this;
}
void WindowManager::CreateFromJson(WindowPtr spWindow, IFileSystem& fileSystem, const CString& cszRelativeFilename)
{
   CString cszJsonText = LoadJson(fileSystem, cszRelativeFilename);

   JsonWindowLoader loader;
   loader.Load(spWindow, cszJsonText);
}
Esempio n. 5
0
bool cMotion::Load(const std::string& file)
{
	Clear();
	
	std::ifstream f_stream(file);
	Json::Value root;
	Json::Reader reader;
	bool succ = reader.parse(f_stream, root);
	f_stream.close();

	if (succ)
	{
		succ = LoadJson(root);
		if (succ)
		{
			PostProcessFrames(mFrames);
		}
		else
		{
			printf("Failed to load motion from file %s\n", file.c_str());
			assert(false);
		}
	}
	else
	{
		printf("Failed to parse Json from %s\n", file.c_str());
		assert(false);
	}
	return succ;
}
Esempio n. 6
0
string Cjson::tostring(string NewLineSign,string FormatSign,int FormatLength){
	//如果是个空的CTypeValue,那么需要先初始化,判断时必须用pJson来判断,因为只有pJson是透传的
	if(pJson == NULL){
		//说明还未初始化
		LoadJson("{}");
	}
	if(type == "class CjsonA") return pJsonA->tostring(NewLineSign,FormatSign,FormatLength);
	else return "";
}
Esempio n. 7
0
void CFilterDlg::OnLoad(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wndCtl*/)
{
	CFileDialog dlg(true, L".xml", m_name.c_str(), OFN_FILEMUSTEXIST | OFN_HIDEREADONLY,
		L"XML Files (*.xml)\0*.xml\0"
		L"JSON Files (*.json)\0*.json\0"
		L"All Files\0*.*\0"
		L"\0", 0);
	dlg.m_ofn.nFilterIndex = 0;
	dlg.m_ofn.lpstrTitle = L"Load DebugView Filter";

	// notice subtle behaviour, see http://msdn.microsoft.com/en-us/library/ms646839 at lpstrInitialDir 
	std::wstring path;
	wchar_t szPath[MAX_PATH];
	if (SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_PERSONAL, nullptr, 0, szPath)))
	{
		path = szPath;
		path += L"\\DebugView++ Filters";
		dlg.m_ofn.lpstrInitialDir = path.c_str();
	}

	if (dlg.DoModal() != IDOK)
		return;

	auto ext = GetFileNameExt(dlg.m_szFileName);
	auto fileName = Str(dlg.m_szFileName).str();
	FilterData data;
	if (boost::iequals(ext, L"json"))
		data = LoadJson(fileName);
	else /* if (boost::iequals(ext, L"xml")) */
		data = LoadXml(fileName);

	SetDlgItemTextA(*this, IDC_NAME, data.name.c_str());

	auto msgFilters = m_messagePage.GetFilters();
	msgFilters.insert(msgFilters.end(), data.filter.messageFilters.begin(), data.filter.messageFilters.end());
	m_messagePage.SetFilters(msgFilters);

	auto procFilters = m_processPage.GetFilters();
	procFilters.insert(procFilters.end(), data.filter.processFilters.begin(), data.filter.processFilters.end());
	m_processPage.SetFilters(procFilters);
}