Esempio n. 1
0
	XGuiLogApplication() :
		CGuiApplication(_T("XGuiLog")),
		m_bAnyOption(false),
		m_bHelp(false),
		m_bMDITest(false)
	{
		COptionCallback<XGuiLogApplication> cb(this, &XGuiLogApplication::handleHelp);

		addOption(COption(_T("Help"))
			.shortName(_T("h"))
			.description(_T("Show Help."))
			.callBack(cb));
		addOption(COption(_T("TestMDI"))
			.shortName(_T("mdi"))
			.category(_T("Test"))
			.description(_T("Test MDI.")));
	}
Esempio n. 2
0
 void AddOption( int opt, const string& longopt, EArg arg, EConfigSection section, const string& help, const string& valhlp = "" ) {
     if( m_optchar.count( opt ) || m_optchar.count( char( opt ) ) ) 
         THROW( logic_error, "Internal configuration error: duplicate option for long option " << longopt );
     if( m_longopt.count( longopt ) )
         THROW( logic_error, "Internal configuration error: duplicate option long option " << longopt );
     m_optchar.insert( opt ); m_optchar.insert( char( opt ) );
     m_longopt.insert( longopt );
     m_optionList.push_back( COption( opt, longopt, arg, section, help, valhlp ) ); 
 }
Esempio n. 3
0
	XZipApplication():
		CApplication(CStringBuffer(__FILE__LINE__ _T("XZip"))),
		m_AnyZipOption(false),
	    m_help(false),
		m_bAddFiles(false),
		m_bFreshenFiles(false),
		m_bUpdateFiles(false),
		m_bViewFiles(false),
		m_sViewFiles(),
		m_bRecurseFolders(false),
		m_bExclude(false),
		m_sExclude(__FILE__LINE__ 16, 16, VectorEmptyDeleteFunc),
		m_bZipArchive(false),
		m_sZipArchive(),
		m_bZipFileSpec(false),
		m_sZipFileSpec(__FILE__LINE__ 16, 16, VectorEmptyDeleteFunc),
		m_bInputDir(false),
		m_sInputDir(),
		m_bOutputFile(false),
		m_sOutputFile()
	{
        COptionCallback<XZipApplication> cb(this,&XZipApplication::handleHelp);
                
		addOption(COption(_T("Help"))
			.shortName(_T("h"))
			.description(_T("Show Help."))
			.callBack(cb));
		addOption(COption(_T("AddFiles"))
			.shortName(_T("a"))
			.group(_T("ZipOption"))
			.category(_T("Zip"))
			.description(_T("Adds files to zip archive.")));
		addOption(COption(_T("FreshenFiles"))
			.shortName(_T("f"))
			.group(_T("ZipOption"))
			.category(_T("Zip"))
			.description(_T("Freshen files in zip archive.")));
		addOption(COption(_T("UpdateFiles"))
			.shortName(_T("u"))
			.group(_T("ZipOption"))
			.category(_T("Zip"))
			.description(_T("Updates files in zip archive.")));
		addOption(COption(_T("ViewFiles"))
			.shortName(_T("v"))
			.group(_T("ZipOption"))
			.argument(_T("mode"), false)
			.category(_T("Zip"))
			.description(_T("View zip file files. Argument can be 'verbose', 'full' or 'delta'.")));
		addOption(COption(_T("RecurseFolders"))
			.shortName(_T("r"))
			.category(_T("Zip"))
			.description(_T("Recurse Folders.")));
		addOption(COption(_T("Exclude"))
			.shortName(_T("x"))
			.argument(_T("path"))
			.repeatable(true)
			.category(_T("Zip"))
			.description(_T("Exclude files and directories from archiving. Wildcards allowed.")));
		addOption(COption(_T("ZipArchive"))
			.shortName(_T("z"))
			.required(true)
			.argument(_T("path"), true, 1)
			.category(_T("Zip"))
			.description(_T("Specifies the zip archive file.")));
		addOption(COption(_T("FileSpec"))
			.shortName(_T("s"))
			.argument(_T("spec"))
			.repeatable(true)
			.category(_T("Zip"))
			.description(_T("Specifies the files to be zipped.")));
		addOption(COption(_T("InputDir"))
			.shortName(_T("d"))
			.argument(_T("path"))
			.category(_T("Zip"))
			.description(_T("From this directory files will be taken, to be added, updated or freshened to the archive (default: <current directory>).")));
		addOption(COption(_T("OutputFile"))
			.shortName(_T("o"))
			.argument(_T("path"))
			.category(_T("Zip"))
			.description(_T("In this file stdout will be redirected.")));
	}
Esempio n. 4
0
//-- Load a design from a file, loaded design will be selected
BOOL CTinyCadDoc::ReadFile(CStream &theArchive, BOOL Details, drawingCollection &drawing)
{
  try
  {
	// Save the old layer setting
	CDrawingObject*	obj		= NULL;
	BYTE			tp		= xNULL;
	CHeaderStamp	oHeader;

	LONG pos = theArchive.GetPos();

	oHeader.Read( theArchive );

	if( ! oHeader.IsChecked(false) )
	{
		// Perhaps this is XML?
		theArchive.Seek(pos);
		CXMLReader xml( &theArchive );
		return ReadFileXML( xml, Details, drawing, FALSE );
	}

	while (tp!=xEndFile) {
		theArchive >> tp;

		switch (tp) {
			case xDesignInformation:
				GetDetails().Read( theArchive );
				break;
			case xDesignInformation2:
				GetDetails().ReadEx( theArchive );
				m_snap.Load( theArchive, Details );
				break;
			case xOptions:
				if( Details )
				{
					theOptions.ReadNative( theArchive );
				}
				else
				{
					COption().ReadNative( theArchive );
				}
				obj = NULL;
				break;
			case xFont:
				theOptions.LoadFonts(theArchive);
				obj = NULL;
				break;
			case xLineStyle:
				theOptions.LoadStyles(theArchive);
				obj = NULL;
				break;
			case xFillStyle:
				theOptions.LoadFillStyles(theArchive);
				obj = NULL;
				break;
			case xMetaFiles:
				theOptions.LoadMetaFiles(theArchive);
				obj = NULL;
				break;
			case xSymbols:
				theOptions.LoadSymbols(theArchive);
				obj = NULL;
				break;
			case xLayerTable:
				{
					// Read in the number of Layers in this list
					CString theNewName;
					WORD NumberOfResources;
					theArchive >> NumberOfResources;

					hRESOURCE OldResourceNumber = 0;

					while (NumberOfResources > 0) {
						theArchive >> OldResourceNumber;
						theArchive >> theNewName;
						NumberOfResources--;
					}
					obj = NULL;
				}
				break;
			case xRuler:
				obj = new CDrawRuler(this,FALSE);
				break;
			case xBus:
				obj = new CDrawLine(this,xBus);
				break;
			case xWire:
				obj = new CDrawLine(this,xWire);
				break;
			case xBusName:
				obj = new CDrawText(this,xBusName);
				break;
			case xBusNameEx:
				obj = new CDrawText(this,xBusNameEx);
				break;
			case xLabel:  	
				obj = new CDrawLabel(this);
				break;
			case xLabelEx:
				obj = new CDrawLabel(this);
				break;
			case xLabelEx2:
				obj = new CDrawLabel(this);
				break;
			case xJunction:
				obj = new CDrawJunction(this);
				break;
			case xNoConnect:
				obj = new CDrawNoConnect(this);
				break;
			case xBusSlash:
				obj = new CDrawBusSlash(this);
				break;
			case xPower:
				obj = new CDrawPower(this);
				break;
			case xPin:
			case xPinEx:
				obj = new CDrawPin(this);
				break;
			case xLine:
				obj = new CDrawPolygon(this,xLine);
				break;
			case xLineEx:
				obj = new CDrawPolygon(this,xLineEx);
				break;
			case xLineEx2:
				obj = new CDrawPolygon(this,xLineEx2);
				break;
			case xPolygon:
				obj = new CDrawPolygon(this,xPolygon);
				break;
			case xDash:
				obj = new CDrawPolygon(this,xDash);
				break;
			case xText:		// The old text type
				obj = new CDrawText(this,xText);
				break;
			case xTextEx:
				obj = new CDrawText(this,xTextEx);
				break;
			case xTextEx2:
				obj = new CDrawText(this,xTextEx2);
				break;
			case xCircle:
			case xCircleEx:
			case xCircleEx2:
			case xCircleEx3:
				obj = new CDrawSquare(this,xCircleEx3);
				break;
			case xSquare:
			case xSquareEx:
			case xSquareEx2:
			case xSquareEx3:
				obj = new CDrawSquare(this,xSquareEx3);
				break;
			case xArc:
			case xArcEx:
			case xArcEx2:
				obj = new CDrawPolygon(this,static_cast<ObjType>(tp));
				break;
			case xMethod:		// The old method type
			case xMethodEx:
			case xMethodEx2:
			case xMethodEx3:
				obj = new CDrawMethod(this);
				break;
			case xTag:
				obj = new CDrawTag(this);
				break;
			case xMetaFile:
				obj = new CDrawMetaFile(this);
				break;
			default:
				obj = NULL;
				break;
		}
		
		if (obj!=NULL) 
		{
			// Provide special handling for old objects
			switch (tp) {
				case xSquare:
				case xSquareEx:
				case xCircle:
				case xCircleEx:
					((CDrawSquare *)obj)->OldLoad(theArchive,tp);
					break;
				case xCircleEx2:
				case xSquareEx2:
					((CDrawSquare *)obj)->OldLoad2(theArchive);
					break;
				case xMethod:
					((CDrawMethod *)obj)->OldLoad(theArchive);
					break;
				case xMethodEx:
					((CDrawMethod *)obj)->OldLoad2(theArchive);
					break;
				case xMethodEx2:
					((CDrawMethod *)obj)->OldLoad3(theArchive);
					break;
				case xPin:
					((CDrawPin *)obj)->OldLoad(theArchive);
					break;
				case xLabel:
				case xLabelEx:
				case xLabelEx2:
					((CDrawLabel *)obj)->Load(theArchive,(ObjType)tp);
					break;
				default:
					obj->Load(theArchive);
					break;
			}

			// Now add object to linked list
			drawing.insert( drawing.end(), obj );
		}
  	}

  }

  catch( CException *e) 
  {
		CString s;
		CString msg;
		e->GetErrorMessage( msg.GetBuffer(256), 256, NULL );
		msg.ReleaseBuffer();
		s.Format(_T("Cannot load file.\r\n%s"),
			msg );
		AfxMessageBox( s );
		e->Delete();
  }


  return drawing.size() > 0;
}