main() { int hid=1,istat=0,icycle=0; int i,i1,j; int nvar; float r[3]; char chtag_in[3][6]={"X","Y","Z"}; char chtag_out[5][8],chtitl[80]; float rmin[5],rmax[5]; int record_size=1024; HLIMIT(PAWC_SIZE); HROPEN(1,"example","ntuple-example.hbook","N",record_size,istat); HBOOKN(hid," An Ntuple",3," ",5000,chtag_in); for (i=0;i<10000;i++){ for(i1=0;i1<3;i1++) for (j=0,r[i1]=0.;j<10;r[i1] += rand()/32768. -0.5 ,j++); HFN(hid,r); } nvar=5; HGIVEN(hid,chtitl,nvar,chtag_out,rmin,rmax); printf(" title obtained:%s\n variables %d\ntags:>%s< >%s< >%s<\n", chtitl,nvar,chtag_out[0],chtag_out[1],chtag_out[2]); printf(" rmin: %e %e %e\n",rmin[0],rmin[1],rmin[2]); printf(" rmax: %e %e %e\n",rmax[0],rmax[1],rmax[2]); HROUT(0,icycle," "); HREND("example"); KUCLOS(1," ",1); }
bool wxsItemRes::CreateNewResource(NewResourceParams& Params) { wxFileName HFN(GetProjectPath()+Params.Hdr); SetLanguage(wxsCodeMarks::IdFromExt(HFN.GetExt())); switch ( GetLanguage() ) { case wxsCPP: { SetResourceName(Params.Class); // Building arguments for constructor wxString CallArgs; wxString CtorArgs; wxString CtorArgsD; if ( Params.CtorParent ) { CallArgs << _T("parent"); CtorArgs << _T("wxWindow* parent"); CtorArgsD << _T("wxWindow* parent"); if ( Params.CtorParentDef ) { CtorArgsD << _T("=0"); } } if ( Params.CtorId ) { if ( !CtorArgs.IsEmpty() ) { CallArgs << _T(","); CtorArgs << _T(","); CtorArgsD << _T(","); } CallArgs << _T("id"); CtorArgs << _T("wxWindowID id"); CtorArgsD << _T("wxWindowID id"); if ( Params.CtorIdDef ) { CtorArgsD << _T("=wxID_ANY"); } } if ( Params.CtorPos ) { if ( !CtorArgs.IsEmpty() ) { CallArgs << _T(","); CtorArgs << _T(","); CtorArgsD << _T(","); } CallArgs << _T("pos"); CtorArgs << _T("const wxPoint& pos"); CtorArgsD << _T("const wxPoint& pos"); if ( Params.CtorPosDef ) { CtorArgsD << _T("=wxDefaultPosition"); } } if ( Params.CtorSize ) { if ( !CtorArgs.IsEmpty() ) { CallArgs << _T(","); CtorArgs << _T(","); CtorArgsD << _T(","); } CallArgs << _T("size"); CtorArgs << _T("const wxSize& size"); CtorArgsD << _T("const wxSize& size"); if ( Params.CtorSizeDef ) { CtorArgsD << _T("=wxDefaultSize"); } } wxString CtorArgsF = CtorArgs; if ( !Params.CustomCtorArgs.IsEmpty() ) { if ( !CtorArgs.IsEmpty() ) { CtorArgs << _T(","); CtorArgsD << _T(","); } CtorArgs << Params.CustomCtorArgs; CtorArgsD << Params.CustomCtorArgs; } // Generating code m_HdrFileName = Params.Hdr; if ( Params.GenHdr ) { wxString Name = GetProjectPath()+Params.Hdr; wxFileName::Mkdir(wxFileName(Name).GetPath(),0777,wxPATH_MKDIR_FULL); wxFile File(Name,wxFile::write); wxString Guard = HFN.GetName().Upper() + _T("_H"); wxString Header = CppEmptyHeader; wxString InitFuncDecl; wxString HeadersPch; if ( Params.UseInitFunc ) { InitFuncDecl << _T("\tprotected:\n\n") _T("\t\tvoid ") << Params.InitFunc << _T("(") << CtorArgsF << _T(");\n\n"); } if ( Params.UsePch && !Params.PchGuard.IsEmpty() ) { HeadersPch << _T("#ifndef ") + Params.PchGuard + _T("\n") _T("\t") + wxsCodeMarks::Beg(wxsCPP,_T("HeadersPCH"),Params.Class) + _T("\n") _T("\t") + wxsCodeMarks::End(wxsCPP) + _T("\n") _T("#endif\n"); } Header.Replace(_T("$(CtorArgs)"),CtorArgsD); Header.Replace(_T("$(Guard)"),Guard); Header.Replace(_T("$(ClassName)"),Params.Class); Header.Replace(_T("$(BaseClassName)"),Params.BaseClass); Header.Replace(_T("$(InitFuncDecl)"),InitFuncDecl); Header.Replace(_T("$(HeadersPch)"),HeadersPch); wxString Scope = _T(""); switch ( Params.ScopeMembers ) { case NewResourceParams::Private: Scope = _T("\tprivate:\n\n"); break; case NewResourceParams::Protected: Scope = _T("\tprotected:\n\n"); break; default:; } Header.Replace(_T("$(MembersScope)"),Scope); Scope = _T(""); if ( Params.ScopeIds != Params.ScopeMembers ) { switch ( Params.ScopeIds ) { case NewResourceParams::Public: Scope = _T("\tpublic:\n\n"); break; case NewResourceParams::Private: Scope = _T("\tprivate:\n\n"); break; case NewResourceParams::Protected: Scope = _T("\tprotected:\n\n"); break; } } Header.Replace(_T("$(IdsScope)"),Scope); Scope = _T(""); if ( Params.ScopeHandlers != Params.ScopeIds ) { switch ( Params.ScopeHandlers ) { case NewResourceParams::Public: Scope = _T("\tpublic:\n\n"); break; case NewResourceParams::Private: Scope = _T("\tprivate:\n\n"); break; case NewResourceParams::Protected: Scope = _T("\tprotected:\n\n"); break; } } Header.Replace(_T("$(HandlersScope)"),Scope); // TODO: Use wxsCoder to save file's content, so it will // have proper encoding and EOL stuff if ( !File.Write(Header) ) return false; } m_SrcFileName = Params.Src; if ( Params.GenSrc ) { wxString Name = GetProjectPath()+Params.Src; wxFileName::Mkdir(wxFileName(Name).GetPath(),0777,wxPATH_MKDIR_FULL); wxFile File(Name,wxFile::write); HFN.MakeRelativeTo(wxFileName(Name).GetPath()); wxString Include = HFN.GetFullPath(wxPATH_UNIX); wxString PchCode; if ( Params.UsePch ) { wxFileName PCH(GetProjectPath()+Params.Pch); PCH.MakeRelativeTo(wxFileName(Name).GetPath()); PchCode << _T("#include \"") << PCH.GetFullPath(wxPATH_UNIX) << _T("\"\n"); } wxString CtorInitCode; if ( Params.UseInitFunc ) { CtorInitCode << _T("\t") << Params.InitFunc << _T("(") << CallArgs << _T(");\n"); CtorInitCode << _T("}\n\n"); CtorInitCode << _T("void ") << Params.Class << _T("::") << Params.InitFunc << _T("(") << CtorArgsF << _T(")\n"); CtorInitCode << _T("{\n"); } wxString IntHeadersPch; if ( Params.UsePch && !Params.PchGuard.IsEmpty() ) { IntHeadersPch << _T("#ifndef ") + Params.PchGuard + _T("\n") _T("\t") + wxsCodeMarks::Beg(wxsCPP,_T("InternalHeadersPCH"),Params.Class) + _T("\n") _T("\t") + wxsCodeMarks::End(wxsCPP) + _T("\n") _T("#endif\n"); } wxString Source = CppEmptySource; Source.Replace(_T("$(PchCode)"),PchCode); Source.Replace(_T("$(CtorArgs)"),CtorArgs); Source.Replace(_T("$(Include)"),Include); Source.Replace(_T("$(ClassName)"),Params.Class); Source.Replace(_T("$(BaseClassName)"),Params.BaseClass); Source.Replace(_T("$(CtorInit)"),CtorInitCode); Source.Replace(_T("$(InternalHeadersPch)"),IntHeadersPch); // TODO: Use wxsCoder to save file's content, so it will // have proper encoding and EOL stuff if ( !File.Write(Source) ) return false; } m_XrcFileName = Params.Xrc; if ( !Params.Xrc.IsEmpty() && Params.GenXrc ) { wxString Name = GetProjectPath()+Params.Xrc; wxFileName::Mkdir(wxFileName(Name).GetPath(),0777,wxPATH_MKDIR_FULL); wxFile File(Name,wxFile::write); if ( !File.Write(EmptyXrc) ) return false; } if ( Params.Wxs.IsEmpty() ) { // Searching for new wxs file name // TODO: Do not use constant folder name wxString WxsNameBase = _T("wxsmith"); wxString WxsName; if ( !wxFileName::DirExists(GetProjectPath()+WxsNameBase) ) { if ( !wxFileName::Mkdir(GetProjectPath()+WxsNameBase,0777,wxPATH_MKDIR_FULL) ) { return false; } } WxsNameBase += _T("/") + Params.Class; WxsName = WxsNameBase + _T(".wxs"); int Cnt = 0; for(;;) { if ( !wxFileName::FileExists(GetProjectPath()+WxsName) && !wxFileName::DirExists(GetProjectPath()+WxsName) ) { break; } Cnt++; WxsName = wxString::Format(_T("%s%d.wxs"),WxsNameBase.wx_str(),Cnt); } m_WxsFileName = WxsName; Params.Wxs = WxsName; { wxString Name = GetProjectPath()+m_WxsFileName; wxFile File(Name,wxFile::write); wxString Content = EmptyWxs; Content.Replace(_T("$(ClassName)"),Params.Class); Content.Replace(_T("$(BaseClassName)"),GetResourceType()); if ( !File.Write(Content) ) { return false; } } } else { m_WxsFileName = Params.Wxs; } m_UseForwardDeclarations = Params.UseFwdDecl; m_UseI18n = Params.UseI18n; return true; } default:; } SetLanguage(wxsUnknownLanguage); return false; }