Exemple #1
0
size_t CIniFile::ReadSection(const tchar* pszSection, CStrArray& astrKeys, CStrArray& astrValues)
{
	ASSERT(pszSection);

	CStrArray astrEntries;

	// Read all the entries...
	if (ReadSection(pszSection, astrEntries))
	{
		// Split all entries.
		for (size_t i = 0; i < astrEntries.Size(); ++i)
		{
			// Split into key and value.
			CString strEntry = astrEntries[i];
			size_t  nLength  = strEntry.Length();
			size_t  nSepPos  = strEntry.Find(TXT('='));

			// Key set AND value set?
			if ( (nSepPos > 0) && ((nLength-nSepPos-1) > 0) )
			{
				astrKeys.Add(strEntry.Left(nSepPos));
				astrValues.Add(strEntry.Right(nLength-nSepPos-1));
			}
		}
	}

	ASSERT(astrKeys.Size() == astrValues.Size());

	return astrKeys.Size();
}
Exemple #2
0
bool CBratSettings::LoadConfig()
{
	return
	base_t::LoadConfig()
	&&
	ReadSection( GROUP_COMMON, 

		k_v( ENTRY_LAST_DATA_PATH,			&m_lastDataPath ),
		k_v( ENTRY_LAST_PAGE_REACHED,		&m_lastPageReached ),
		k_v( ENTRY_ADVANCED_OPERATIONS,		&mAdvancedOperations, false ),

		k_v( ENTRY_LOAD_WKSPC_AT_STARTUP,	&mLoadLastWorkspaceAtStartUp ),
        k_v( ENTRY_MAIN_LAYER_BASE_TYPE,	(int*)&mMainLayerBaseType, (int)smDefaultLayerBaseType ),
        k_v( ENTRY_VIEWS_LAYER_BASE_TYPE,	(int*)&mViewsLayerBaseType, (int)smDefaultLayerBaseType ),
		k_v( ENTRY_VECTOR_SIMPLIFY_METHOD,	&mVectorSimplifyMethod, true ),
		k_v( ENTRY_DESKTOP_MANAGER_SDI,		&mDesktopManagerSdi, true ),
		k_v( ENTRY_CHECK_OPENGL,			&mCheckOpenGL, true )
	)
	&&
	ReadValues( GROUP_WKS, 
	{ 
		{ ENTRY_LAST, m_lastWksPath },
	} 
	)
	&&
	ReadValues( GROUP_COLORTABLE, 
	{ 
		{ ENTRY_LAST, m_lastColorTable },
	}
	)
	&&
	LoadPaths();
}
Exemple #3
0
bool CBratSettings::LoadPaths()
{
	return
		ReadSection( GROUP_PATHS,

			k_v( ENTRY_USER_DATA_PATH,			&mBratPaths.mUserDataDirectory ),
            k_v( ENTRY_WORKSPACES_DIR,			&mBratPaths.mWorkspacesDirectory ),
            k_v( ENTRY_URL_RASTER_LAYER_PATH,   &mBratPaths.mURLRasterLayerPath, mBratPaths.smDefaultURLRasterLayerPath ),

            k_v( ENTRY_PORTABLE_PATHS,			&mBratPaths.mUsePortablePaths )
		)
		&&
        mBratPaths.SetUserPaths();
}
Exemple #4
0
void ObjReadSections (FILE* F, unsigned long Pos, ObjData* O)
/* Read the section data from a file at the given position */
{
    unsigned I;

    /* Seek to the correct position */
    FileSetPos (F, Pos);

    /* Read the data */
    O->SectionCount = ReadVar (F);
    O->Sections     = xmalloc (O->SectionCount * sizeof (O->Sections[0]));
    for (I = 0; I < O->SectionCount; ++I) {
        O->Sections [I] = ReadSection (F, O);
    }
}
Exemple #5
0
int umd_readdata(char **pf, buffer ** buf)
{
	u_short hdType = 0;
	u_short hdUmdMode = 0;
	int nRet = -1;
	p_umd_chapter *pchapter = NULL;

	if (!pf || !(*pf) || !buf || !(*buf))
		return -1;

	while (**pf == '#') {
		if ((nRet = ReadSection(pf, buf, &hdUmdMode, &hdType)) < 0)
			break;
		while (**pf == '$') {
			if ((nRet = ReadAdditionalSession(pf, buf, pchapter, hdType, false)) < 0)
				return nRet;
		}
	}
	return nRet;
}
Exemple #6
0
vtLULCFile::vtLULCFile(const char *fname)
{
	char buf[80];
	uint i;

	m_pNext = NULL;
	m_iError = 0;

	FILE *fp = vtFileOpen(fname, "rb");
	if (!fp)
	{
		m_iError = LULC_ERR_FILE;
		return;
	}

	// subfile A - header
	if (!GetRecord(fp, buf)) return;
	geti10(buf+0);		// iNumArcs
	geti10(buf+10);		// iNumCoords
	geti10(buf+20);		// iNumPolys
	m_iNumSections = geti5(buf+40);
	geti5(buf+45);		// iMapType, 1 = LULC
	geti5(buf+50);		// iSubfileLength
	geti5(buf+55);		// iProjectionCode
	geti10(buf+60);		// iScaleDenominator
	geti10(buf+70);		// iMapDate

	// extent of control points, in local coordinates
	if (!GetRecord(fp, buf)) return;
	m_cMin.x = (short) geti5(buf+0);
	m_cMin.y = (short) geti5(buf+5);
	m_cMax.x = (short) geti5(buf+10);
	m_cMax.y = (short) geti5(buf+15);

	// local coordinates of control points
	for (i = 0; i < 6; i++)
	{
		m_cCorners[i].x = (short) geti5(buf+20+i*10);
		m_cCorners[i].y = (short) geti5(buf+20+i*10+5);
	}

	// latitude and longitude of control points
	if (!GetRecord(fp, buf)) return;
	m_Corners[0].y = getdegree(buf+0);
	m_Corners[0].x = getdegree(buf+10);
	m_Corners[1].y = getdegree(buf+20);
	m_Corners[1].x = getdegree(buf+30);
	m_Corners[2].y = getdegree(buf+40);
	m_Corners[2].x = getdegree(buf+50);
	m_Corners[3].y = getdegree(buf+60);
	m_Corners[3].x = getdegree(buf+70);
	if (!GetRecord(fp, buf)) return;
	m_Corners[4].y = getdegree(buf+0);
	m_Corners[4].x = getdegree(buf+10);
	m_Corners[5].y = getdegree(buf+20);
	m_Corners[5].x = getdegree(buf+30);

	// try to determine the mapping from local to latlon
	SetupMapping();

	geti5(buf+40);		// iNad
	int iNumCharTitle  = geti5(buf+45);
	if (iNumCharTitle > 64) iNumCharTitle = 64;
	geti5(buf+50);		// iLengthOfFAP
	geti10(buf+60);	// CreationDate

	if (!GetRecord(fp, buf)) return;
	char title[65];
	strncpy(title, buf, iNumCharTitle);

	// allocate sections
	m_pSection = new LULCSection[m_iNumSections];

	for (i = 0; i < m_iNumSections; i++)
		ReadSection(m_pSection + i, fp);

	fclose(fp);
}
Exemple #7
0
int qimageReadSectionFloat(ImodImageFile *inFile, char *buf, int inSection)
{ 
  return(ReadSection(inFile, buf, 2));
}
Exemple #8
0
int qimageReadSectionByte(ImodImageFile *inFile, char *buf, int inSection)
{ 
  return(ReadSection(inFile, buf, 1));
}