本文整理汇总了C++中ReportError函数的典型用法代码示例。如果您正苦于以下问题:C++ ReportError函数的具体用法?C++ ReportError怎么用?C++ ReportError使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReportError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gnutls_certificate_allocate_credentials
bool TlsSocket::Start()
{
#ifdef HAVE_LIBGNUTLS
gnutls_certificate_credentials_t cred;
m_retCode = gnutls_certificate_allocate_credentials(&cred);
if (m_retCode != 0)
{
ReportError("Could not create TLS context");
return false;
}
m_context = cred;
if (m_certFile && m_keyFile)
{
m_retCode = gnutls_certificate_set_x509_key_file((gnutls_certificate_credentials_t)m_context,
m_certFile, m_keyFile, GNUTLS_X509_FMT_PEM);
if (m_retCode != 0)
{
ReportError("Could not load certificate or key file");
Close();
return false;
}
}
gnutls_session_t sess;
m_retCode = gnutls_init(&sess, m_isClient ? GNUTLS_CLIENT : GNUTLS_SERVER);
if (m_retCode != 0)
{
ReportError("Could not create TLS session");
Close();
return false;
}
m_session = sess;
m_initialized = true;
const char* priority = !m_cipher.Empty() ? m_cipher.Str() : "NORMAL";
m_retCode = gnutls_priority_set_direct((gnutls_session_t)m_session, priority, nullptr);
if (m_retCode != 0)
{
ReportError("Could not select cipher for TLS");
Close();
return false;
}
if (m_host)
{
m_retCode = gnutls_server_name_set((gnutls_session_t)m_session, GNUTLS_NAME_DNS, m_host, m_host.Length());
if (m_retCode != 0)
{
ReportError("Could not set host name for TLS");
Close();
return false;
}
}
m_retCode = gnutls_credentials_set((gnutls_session_t)m_session, GNUTLS_CRD_CERTIFICATE,
(gnutls_certificate_credentials_t*)m_context);
if (m_retCode != 0)
{
ReportError("Could not initialize TLS session");
Close();
return false;
}
gnutls_transport_set_ptr((gnutls_session_t)m_session, (gnutls_transport_ptr_t)(size_t)m_socket);
m_retCode = gnutls_handshake((gnutls_session_t)m_session);
if (m_retCode != 0)
{
ReportError("TLS handshake failed");
Close();
return false;
}
m_connected = true;
return true;
#endif /* HAVE_LIBGNUTLS */
#ifdef HAVE_OPENSSL
m_context = SSL_CTX_new(SSLv23_method());
if (!m_context)
{
ReportError("Could not create TLS context");
return false;
}
if (m_certFile && m_keyFile)
{
if (SSL_CTX_use_certificate_chain_file((SSL_CTX*)m_context, m_certFile) != 1)
{
ReportError("Could not load certificate file");
Close();
return false;
}
if (SSL_CTX_use_PrivateKey_file((SSL_CTX*)m_context, m_keyFile, SSL_FILETYPE_PEM) != 1)
//.........这里部分代码省略.........
示例2: PrintItemName
HRESULT PrintItemName( IWiaItem *pWiaItem )
{
//
// Validate arguments
//
if (NULL == pWiaItem)
{
return E_INVALIDARG;
}
//
// Get the IWiaPropertyStorage interface
//
IWiaPropertyStorage *pWiaPropertyStorage = NULL;
HRESULT hr = pWiaItem->QueryInterface( IID_IWiaPropertyStorage, (void**)&pWiaPropertyStorage );
if (SUCCEEDED(hr))
{
//
// Declare PROPSPECs and PROPVARIANTs, and initialize them to zero.
//
PROPSPEC PropSpec[1] = {0};
PROPVARIANT PropVar[1] = {0};
//
// How many properties are we querying for?
//
const ULONG c_nPropertyCount = sizeof(PropSpec)/sizeof(PropSpec[0]);
//
// Define which properties we want to read:
// Device ID. This is what we'd use to create
// the device.
//
PropSpec[0].ulKind = PRSPEC_PROPID;
PropSpec[0].propid = WIA_IPA_FULL_ITEM_NAME;
//
// Ask for the property values
//
hr = pWiaPropertyStorage->ReadMultiple( c_nPropertyCount, PropSpec, PropVar );
if (SUCCEEDED(hr))
{
//
// IWiaPropertyStorage::ReadMultiple will return S_FALSE if some
// properties could not be read, so we have to check the return
// types for each requested item.
//
//
// Check the return type for the device ID
//
if (VT_BSTR == PropVar[0].vt)
{
//
// Do something with the device ID
//
_tprintf( TEXT("Item Name: %ws\n"), PropVar[0].bstrVal );
}
//
// Free the returned PROPVARIANTs
//
FreePropVariantArray( c_nPropertyCount, PropVar );
}
else
{
ReportError( TEXT("Error calling IWiaPropertyStorage::ReadMultiple"), hr );
}
//
// Release the IWiaPropertyStorage interface
//
pWiaPropertyStorage->Release();
pWiaPropertyStorage = NULL;
}
//
// Return the result of reading the properties
//
return hr;
}
示例3: EnumerateItems
HRESULT EnumerateItems( IWiaItem *pWiaItem )
{
//
// Validate arguments
//
if (NULL == pWiaItem)
{
return E_INVALIDARG;
}
//
// Get the item type for this item
//
LONG lItemType = 0;
HRESULT hr = pWiaItem->GetItemType( &lItemType );
//
// Do something with this item. Print the item name.
//
PrintItemName( pWiaItem );
//
// If this is an image, transfer it
//
if (lItemType & WiaItemTypeImage)
{
hr = TransferWiaItem( pWiaItem );
}
//
// If it is a folder, or it has attachments, enumerate its children
//
if (lItemType & WiaItemTypeFolder ||
lItemType & WiaItemTypeHasAttachments)
{
//
// Get the child item enumerator for this item
//
IEnumWiaItem *pEnumWiaItem = NULL;
hr = pWiaItem->EnumChildItems( &pEnumWiaItem );
if (SUCCEEDED(hr))
{
//
// We will loop until we get an error or pEnumWiaItem->Next returns
// S_FALSE to signal the end of the list.
//
while (S_OK == hr)
{
//
// Get the next child item
//
IWiaItem *pChildWiaItem = NULL;
hr = pEnumWiaItem->Next( 1, &pChildWiaItem, NULL );
//
// pEnumWiaItem->Next will return S_FALSE when the list is
// exhausted, so check for S_OK before using the returned
// value.
//
if (S_OK == hr)
{
//
// Recurse into this item
//
hr = EnumerateItems( pChildWiaItem );
//
// Release this item
//
pChildWiaItem->Release();
pChildWiaItem = NULL;
}
else if (FAILED(hr))
{
//
// Report that an error occurred during enumeration
//
ReportError( TEXT("Error calling pEnumWiaItem->Next"), hr );
}
}
//
// If the result of the enumeration is S_FALSE, since this
// is normal, we will change it to S_OK
//
if (S_FALSE == hr)
{
hr = S_OK;
}
//
// Release the enumerator
//
pEnumWiaItem->Release();
pEnumWiaItem = NULL;
}
}
return hr;
}
示例4: SetIcon
BOOL
SetupWizard::OnInitDialog ()
{
BOOL ret = CPropertySheet::OnInitDialog();
try
{
SetIcon (AfxGetApp()->LoadIcon(IDR_MAINFRAME), TRUE);
CStringW title;
if (theApp.isMiKTeXDirect)
{
title.Format (T_(_T("MiKTeX %s Setup (%d-bit)")),
static_cast<LPCTSTR>(UW_(MIKTEX_FULL_VERSION_STR)),
static_cast<int>(sizeof(void*)) * 8);
}
else if (theApp.pSetupService->GetOptions().IsPrefabricated)
{
PathName configFile (theApp.GetLocalPackageRepository());
configFile += "pr.ini";
SmartPointer<Cfg> pConfig (Cfg::Create());
pConfig->Read (configFile);
CString prefix;
CString version (MIKTEXTEXT(MIKTEX_SERIES_STR));
version += MIKTEXTEXT('.');
version += UT_(pConfig->GetValue("repository", "version").c_str());
switch (theApp.GetPackageLevel().Get())
{
case PackageLevel::Essential:
prefix = T_("Essential ");
break;
case PackageLevel::Basic:
prefix = T_("Basic ");
break;
case PackageLevel::Complete:
prefix = "";
break;
default:
MIKTEX_ASSERT (false);
__assume (false);
break;
}
title.Format (T_(_T("%sMiKTeX %s Installer (%d-bit)")),
static_cast<LPCTSTR>(prefix),
static_cast<LPCTSTR>(version),
static_cast<int>(sizeof(void*)) * 8);
}
else
{
title.Format (T_(_T("MiKTeX %s Net Installer (%d-bit)")),
static_cast<LPCTSTR>(UW_(MIKTEX_VERSION_STR)),
static_cast<int>(sizeof(void*)) * 8);
}
SetTitle (title);
SetActivePage (&m_License);
}
catch (const MiKTeXException & e)
{
ReportError (e);
}
catch (const exception & e)
{
ReportError (e);
}
return (ret);
}
示例5: calloc
long *GetSurfList( long surfnum, long numsurfs, long *numlistsurfs )
{
/*** Get a sequence of surface numbers. ***/
long i, numerror=0;
long *lsurflist = NULL;
int *surflist, nlistsurfs;
char instring[80], surfstring[100]="";
NumSeq surfseq;
/**********************************************************************/
/*** If we only have one surface, no need to ask. ***/
if ( numsurfs <= 1 )
{
nlistsurfs = 1;
lsurflist = (long *) calloc( (size_t) nlistsurfs, sizeof( long ));
lsurflist[0] = 0;
*numlistsurfs = nlistsurfs;
return( lsurflist );
}
/*** Now form the list the regular way, using Ted's routines. ***/
surfseq = NumSeqCreate();
if ( strlen( surfstring ) < 1 )
sprintf(surfstring,"%d", surfnum+1);
printf(" Enter the sequence of surfaces you want (e.g., 1,2,4-5,7)\n"
" ranging from (from 1-%d)\n"
" [def=%s] ? ", numsurfs, surfstring );
fgets(instring, 70, stdin );
if ( strlen( instring ) > 0 )
strcpy( surfstring,instring );
while (NumSeqParse(surfseq, surfstring) && numerror < 10)
{
printf("*** ? Illegal sequence\n");
printf(" Enter the desired range again [def= %s] > ", surfstring);
scanf("%s",instring);
if (Trulen((const char*) instring) >= 0)
strcpy( surfstring,instring );
numerror++;
}
if (numerror >= 10)
{
ReportError("GetSurflist", "Blow out trying to get legal string",
0, "");
return ( NULL );
}
/*** Now convert the string into an array of surface numbers. ***/
NumSeqArray( surfseq, &surflist, &nlistsurfs );
if ( surflist == NULL )
{
ReportError("GeturfList", "error converting sequence to list",
0, "");
return( NULL );
}
/*** Now scan the list and make sure it makes sense, and shift
values to start at 0. ***/
lsurflist = (long *) calloc( (size_t) nlistsurfs, sizeof( long ));
for (i=0; i<nlistsurfs; i++ )
{
if ( surflist[i] < 0 )
surflist[i] = 1;
if ( surflist[i] > numsurfs )
surflist[i] = numsurfs;
lsurflist[i] = surflist[i] - 1;
}
*numlistsurfs = nlistsurfs;
free( surflist );
NumSeqDestroy( surfseq );
return( lsurflist );
}
示例6: ReportError
void dng_info::PostParse (dng_host &host)
{
uint32 index;
fExif->PostParse (host, *fShared.Get ());
fShared->PostParse (host, *fExif.Get ());
for (index = 0; index < fIFDCount; index++)
{
fIFD [index]->PostParse ();
}
for (index = 0; index < fChainedIFDCount; index++)
{
fChainedIFD [index]->PostParse ();
}
if (fShared->fDNGVersion != 0)
{
// Find main IFD.
fMainIndex = -1;
for (index = 0; index < fIFDCount; index++)
{
if (fIFD [index]->fUsesNewSubFileType &&
fIFD [index]->fNewSubFileType == sfMainImage)
{
if (fMainIndex == -1)
{
fMainIndex = index;
}
#if qDNGValidate
else
{
ReportError ("Multiple IFDs marked as main image");
}
#endif
}
else if (fIFD [index]->fNewSubFileType == sfPreviewImage ||
fIFD [index]->fNewSubFileType == sfAltPreviewImage)
{
// Fill in default color space for DNG previews if not included.
if (fIFD [index]->fPreviewInfo.fColorSpace == previewColorSpace_MaxEnum)
{
if (fIFD [index]->fSamplesPerPixel == 1)
{
fIFD [index]->fPreviewInfo.fColorSpace = previewColorSpace_GrayGamma22;
}
else
{
fIFD [index]->fPreviewInfo.fColorSpace = previewColorSpace_sRGB;
}
}
}
}
// Deal with lossless JPEG bug in early DNG versions.
if (fShared->fDNGVersion < dngVersion_1_1_0_0)
{
if (fMainIndex != -1)
{
fIFD [fMainIndex]->fLosslessJPEGBug16 = true;
}
}
//.........这里部分代码省略.........
示例7: HandleSocketMessage
//.........这里部分代码省略.........
gtk_moz_embed_reload(GTK_MOZ_EMBED(pBrowser->mozEmbed), GTK_MOZ_EMBED_FLAG_RELOADNORMAL);
break;
case JEVENT_STOP:
pBrowser = (GtkBrowser *)gBrowserArray[instance];
NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
gtk_moz_embed_stop_load(GTK_MOZ_EMBED(pBrowser->mozEmbed));
break;
case JEVENT_GETURL:
{
pBrowser = (GtkBrowser *)gBrowserArray[instance];
NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
nsCOMPtr<nsIWebBrowser> webBrowser;
gtk_moz_embed_get_nsIWebBrowser(GTK_MOZ_EMBED(pBrowser->mozEmbed), getter_AddRefs(webBrowser));
nsCOMPtr<nsIWebNavigation> webNavigation(do_QueryInterface(webBrowser));
nsCOMPtr<nsIURI> currentURI;
webNavigation->GetCurrentURI(getter_AddRefs(currentURI));
if (currentURI == NULL)
SendSocketMessage(instance, CEVENT_RETURN_URL, "");
else {
nsEmbedCString uriString;
currentURI->GetAsciiSpec(uriString);
SendSocketMessage(instance, CEVENT_RETURN_URL, uriString.get());
}
}
break;
case JEVENT_FOCUSGAINED:
case JEVENT_FOCUSLOST:
{
pBrowser = (GtkBrowser *)gBrowserArray[instance];
NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
if (!pBrowser->topLevelWindow) {
ReportError("Top level Window is Null!\n");
break;
}
GtkWidget *widget = GTK_WIDGET (pBrowser->topLevelWindow);
GdkEvent event;
GtkWindowClass *parent_class = (GtkWindowClass*) gtk_type_class (GTK_TYPE_WINDOW);
if (!widget) {
ReportError("Failed to get browser's toplevel window !\n");
break;
}
if (!parent_class) {
ReportError("Failed to get gtk window class !\n");
break;
}
event.focus_change.type = GDK_FOCUS_CHANGE;
event.focus_change.window = widget->window;
event.focus_change.send_event = TRUE;
if (type == JEVENT_FOCUSGAINED) {
event.focus_change.in = TRUE;
GTK_WIDGET_CLASS (parent_class)->focus_in_event
(widget, (GdkEventFocus *)&event);
}
else {
event.focus_change.in = FALSE;
GTK_WIDGET_CLASS (parent_class)->focus_out_event
(widget, (GdkEventFocus *)&event);
}
}
示例8: mozembed_main
int
mozembed_main(int argc, char **argv)
{
if (argc > 1) {
if (strstr(argv[1], "-port=")) {
int port = atoi(&(argv[1][6]));
gMessenger.SetPort(port);
gMessenger.CreateServerSocket();
}
else if (strcmp(argv[1], "-test") == 0) {
gTestMode = 1;
}
}
if (!gTestMode && gMessenger.IsFailed()) {
ReportError("Failed to create server socket!");
exit(1);
}
gtk_set_locale();
gtk_init(&argc, &argv);
// force the startup code to be executed because we need to start
// the profile in a different way
gtk_moz_embed_push_startup();
if (NS_FAILED(InitializeProfile())) {
ReportError("Failed to initialize profile!");
exit(1);
}
gMsgLock = PR_NewLock();
if (!gTestMode) {
PRThread *socketListenThread =
PR_CreateThread(PR_USER_THREAD,
PortListening,
(void*)SocketMsgHandler,
PR_PRIORITY_NORMAL,
PR_GLOBAL_THREAD,
PR_UNJOINABLE_THREAD,
0);
if (!socketListenThread) {
ReportError("Failed to create socket listening thread!");
exit(1);
}
// add event source to process socket messages
#ifdef MOZ_WIDGET_GTK
g_source_add (GDK_PRIORITY_EVENTS, TRUE, &event_funcs, NULL, NULL, NULL);
#endif
#ifdef MOZ_WIDGET_GTK2
GSource *newsource = g_source_new(&event_funcs, sizeof(GSource));
g_source_attach(newsource, NULL);
#endif
}
else {
GtkBrowser *browser = new_gtk_browser(GTK_MOZ_EMBED_FLAG_DEFAULTCHROME);
// set our minimum size
gtk_widget_set_usize(browser->mozEmbed, 400, 400);
set_browser_visibility(browser, TRUE);
}
// get the singleton object and hook up to its new window callback
// so we can create orphaned windows.
GtkMozEmbedSingle *single;
single = gtk_moz_embed_single_get();
if (!single) {
ReportError("Failed to get singleton embed object!");
exit(1);
}
gtk_signal_connect(GTK_OBJECT(single), "new_window_orphan",
GTK_SIGNAL_FUNC(new_window_orphan_cb), NULL);
gtk_main();
gtk_moz_embed_pop_startup();
PR_DestroyLock(gMsgLock);
return 0;
}
示例9: ReportError
//----------------------------------------------------------------------------
bool FxCompiler::UpdateShader (Shader* shader, const Program& program,
InputArray& inputs, OutputArray& outputs, ConstantArray& constants,
SamplerArray& samplers)
{
int numInputs = (int)inputs.size();
if (numInputs != shader->GetNumInputs())
{
ReportError("Mismatch in number of inputs.\n");
return false;
}
int numOutputs = (int)outputs.size();
if (numOutputs != shader->GetNumOutputs())
{
ReportError("Mismatch in number of outputs.\n");
return false;
}
int numConstants = (int)constants.size();
if (numConstants != shader->GetNumConstants())
{
ReportError("Mismatch in number of constants.\n");
return false;
}
int numSamplers = (int)samplers.size();
if (numSamplers != shader->GetNumSamplers())
{
ReportError("Mismatch in number of samplers.\n");
return false;
}
std::string message;
int i;
for (i = 0; i < numInputs; ++i)
{
Input& input = inputs[i];
if (input.Name != shader->GetInputName(i))
{
message = "Mismatch in input names '" +
input.Name +
"' and '" +
shader->GetInputName(i);
ReportError(message);
return false;
}
if (input.Type != shader->GetInputType(i))
{
message = "Mismatch in input types '" +
msVTName[input.Type] +
"' and '" +
msVTName[shader->GetInputType(i)];
ReportError(message);
return false;
}
if (input.Semantic != shader->GetInputSemantic(i))
{
message = "Mismatch in input semantics '" +
msVSName[input.Semantic] +
"' and '" +
msVSName[shader->GetInputSemantic(i)];
ReportError(message);
return false;
}
}
for (i = 0; i < numOutputs; ++i)
{
Output& output = outputs[i];
if (output.Name != shader->GetOutputName(i))
{
message = "Mismatch in output names '" +
output.Name +
"' and '" +
shader->GetOutputName(i);
ReportError(message);
return false;
}
if (output.Type != shader->GetOutputType(i))
{
message = "Mismatch in output types '" +
msVTName[output.Type] +
"' and '" +
msVTName[shader->GetOutputType(i)];
ReportError(message);
return false;
}
if (output.Semantic != shader->GetOutputSemantic(i))
{
message = "Mismatch in output semantics '" +
msVSName[output.Semantic] +
"' and '" +
msVSName[shader->GetOutputSemantic(i)];
//.........这里部分代码省略.........
示例10: BOOL
BOOL TPrinter::Print(PTWindowsObject ParentWin, PTPrintout Printout)
{
typedef BOOL (FAR PASCAL *PTAbortProc)( HDC Prn, short Code );
BOOL Banding;
PTAbortProc AbortProcInst;
WORD PageNumber;
BOOL result = FALSE; // Assume error occurred
Error = 0;
if ( Printout == NULL )
return result;
if ( ParentWin == NULL )
return result;
if ( Status != PS_OK )
{
Error = SP_ERROR;
ReportError(Printout);
return result;
}
PrnDC = GetDC();
if ( PrnDC == 0 )
return result;
PTWindowsObject Dlg = GetApplicationObject()->MakeWindow(
new TPrinterAbortDlg(ParentWin, "AbortDialog", Printout->Title, Device, Port) );
if ( Dlg == NULL )
{
DeleteDC(PrnDC);
return result;
}
EnableWindow(ParentWin->HWindow, FALSE);
AbortProcInst = (PTAbortProc) MakeProcInstance( (FARPROC) AbortProc,
GetApplicationObject()->hInstance);
Escape(PrnDC, SETABORTPROC, 0, LPSTR(AbortProcInst), NULL);
// Get the page size
PageSize.x = GetDeviceCaps(PrnDC, HORZRES);
PageSize.y = GetDeviceCaps(PrnDC, VERTRES);
// Only band if the user requests banding and the printer
// supports banding
Banding = ( Printout->Banding ) &&
(GetDeviceCaps(PrnDC, RASTERCAPS) & RC_BANDING);
if ( !Banding )
{
// Set the banding rectangle to full page
BandRect.left = 0;
BandRect.top = 0;
BandRect.right = PageSize.x;
BandRect.bottom = PageSize.y;
}
else
{
// Only use BANDINFO if supported (note: using Flags as a temporary)
Flags = BANDINFO;
// Escape(QUERYESCSUPPORT) returns nonzero for implemented
// escape function, and zero otherwise.
UseBandInfo =
Escape(PrnDC, QUERYESCSUPPORT, sizeof(Flags), (LPSTR) &Flags, NULL);
}
Flags = PF_BOTH;
Error = Escape(PrnDC, STARTDOC, strlen(Printout->Title),
Printout->Title, NULL);
PageNumber = 1;
if ( Error > 0 )
{
do
{
if ( Banding )
{
FirstBand = TRUE;
Error = Escape(PrnDC, NEXTBAND, 0, NULL, (LPSTR) &BandRect);
}
do
{
// Call the abort proc between bands or pages
(*AbortProcInst)(PrnDC, 0);
if ( Banding )
{
CalcBandingFlags();
if ( (Printout->ForceAllBands) &&
( ( Flags & PF_BOTH ) == PF_TEXT ) )
SetPixel(PrnDC, 0, 0, 0);
}
if ( Error > 0 )
{
Printout->PrintPage(PrnDC, PageNumber, PageSize, &BandRect, Flags);
if ( Banding )
//.........这里部分代码省略.........
示例11: inFile
//----------------------------------------------------------------------------
bool FxCompiler::Parse (const std::string& fileName,
const std::string& profileName, Program& program)
{
std::ifstream inFile(fileName.c_str());
if (!inFile)
{
// If the file does not exist, the assumption is that the profile does
// not support the shader (in which case, the Cg compiler failed).
Messages.push_back("Profile " + profileName + " not supported.\n");
return false;
}
program.Text = "";
while (!inFile.eof())
{
std::string line;
getline(inFile, line);
if (line.empty())
{
continue;
}
// Any uncommented lines are part of the program text.
if (line[0] != '/' && line[0] != '#')
{
program.Text += line + "\n";
continue;
}
std::vector<std::string> tokens;
std::string::size_type begin;
// Get a variable line from the Cg output file.
begin = line.find("var", 0);
if (begin != std::string::npos)
{
GetTokens(line, begin, tokens);
if (tokens.size() >= 2 && tokens[0] == "var")
{
std::string used = tokens.back();
if (used == "0" || used == "1")
{
if (used == "1")
{
program.Variables.push_back(tokens);
}
continue;
}
}
inFile.close();
ReportError("Invalid variable line", &tokens);
return false;
}
// Get the profile name.
begin = line.find("profile", 0);
if (begin != std::string::npos)
{
GetTokens(line, begin, tokens);
if (tokens.size() >= 2 && tokens[0] == "profile")
{
// When the user has already compiled the programs, it is
// because a profile is a special one. The "!!ARBfp1.0"
// string and the last token of "#profile specialProfile"
// most likely do not match, so do not compare them.
if (mAlreadyCompiled || tokens[1] == profileName)
{
continue;
}
}
inFile.close();
ReportError("Invalid profile line", &tokens);
return false;
}
// Get the program name.
begin = line.find("program", 0);
if (begin != std::string::npos)
{
GetTokens(line, begin, tokens);
if (tokens.size() >= 2 && tokens[0] == "program")
{
program.Name = tokens[1];
continue;
}
inFile.close();
ReportError("Invalid program line", &tokens);
return false;
}
}
inFile.close();
return true;
}
示例12: Map
//=========================================================================
void Epetra_MapColoring::Print(std::ostream& os) const {
int MyPID = Map().Comm().MyPID();
int NumProc = Map().Comm().NumProc();
if (MyPID==0) os
<< std::endl
<< " *****************************************" << std::endl
<< " Coloring information arranged map element" << std::endl
<< " *****************************************" << std::endl
<< std::endl;
for (int iproc=0; iproc < NumProc; iproc++) {
if (MyPID==iproc) {
int NumMyElements1 =Map(). NumMyElements();
if (MyPID==0) {
os.width(8);
os << " MyPID"; os << " ";
os.width(12);
os << "GID ";
os.width(20);
os << "Color ";
os << std::endl;
}
for (int i=0; i < NumMyElements1; i++) {
os.width(10);
os << MyPID; os << " ";
os.width(10);
if(Map().GlobalIndicesInt()) {
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
int * MyGlobalElements1 = Map().MyGlobalElements();
os << MyGlobalElements1[i] << " ";
#else
throw ReportError("Epetra_MapColoring::Print: ERROR, GlobalIndicesInt but no API for it.",-1);
#endif
}
else if(Map().GlobalIndicesLongLong())
{
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
long long * MyGlobalElements1 = Map().MyGlobalElements64();
os << MyGlobalElements1[i] << " ";
#else
throw ReportError("Epetra_MapColoring::Print: ERROR, GlobalIndicesLongLong but no API for it.",-1);
#endif
}
else
throw ReportError("Epetra_MapColoring::Print: ERROR, Don't know map global index type.",-1);
os.width(20);
os << ElementColors_[i];
os << std::endl;
}
os << std::flush;
}
// Do a few global ops to give I/O a chance to complete
Map().Comm().Barrier();
Map().Comm().Barrier();
Map().Comm().Barrier();
}
if (MyPID==0) os
<< std::endl
<< " **************************************" << std::endl
<< " Coloring information arranged by color" << std::endl
<< " **************************************" << std::endl
<< std::endl;
{for (int iproc=0; iproc < NumProc; iproc++) {
if (MyPID==iproc) {
if (NumColors()==0) os << " No colored elements on processor " << MyPID << std::endl;
else {
os << "Number of colors in map = " << NumColors() << std::endl
<< "Default color = " << DefaultColor() << std::endl << std::endl;
if (MyPID==0) {
os.width(8);
os << " MyPID"; os << " ";
os.width(12);
os << "LID ";
os.width(20);
os << "Color ";
os << std::endl;
}
int * ColorValues = ListOfColors();
for (int ii=0; ii<NumColors(); ii++) {
int CV = ColorValues[ii];
int ColorCount = NumElementsWithColor(CV);
int * LIDList = ColorLIDList(CV);
for (int i=0; i < ColorCount; i++) {
os.width(10);
os << MyPID; os << " ";
os.width(10);
os << LIDList[i] << " ";
os.width(20);
os << CV;
os << std::endl;
}
os << std::flush;
//.........这里部分代码省略.........
示例13: InitTopoMap
/*****************************************************************************
InitTopoMap()
*****************************************************************************/
void InitTopoMap(LISTPTR Input, OPTIONSTRUCT * Options, MAPSIZE * Map,
TOPOPIX *** TopoMap)
{
const char *Routine = "InitTopoMap";
char VarName[BUFSIZE + 1]; /* Variable name */
int i; /* Counter */
int x; /* Counter */
int y; /* Counter */
int flag; /* either or not reverse the matrix */
int NumberType; /* Number type of data set */
unsigned char *Mask = NULL; /* Basin mask */
float *Elev; /* Surface elevation */
STRINIENTRY StrEnv[] = {
{"TERRAIN", "DEM FILE", "", ""},
{"TERRAIN", "BASIN MASK FILE", "", ""},
{NULL, NULL, "", NULL}
};
/* Process the [TERRAIN] section in the input file */
if (!(*TopoMap = (TOPOPIX **) calloc(Map->NY, sizeof(TOPOPIX *))))
ReportError((char *) Routine, 1);
for (y = 0; y < Map->NY; y++) {
if (!((*TopoMap)[y] = (TOPOPIX *) calloc(Map->NX, sizeof(TOPOPIX))))
ReportError((char *) Routine, 1);
}
/* Read the key-entry pairs from the input file */
for (i = 0; StrEnv[i].SectionName; i++) {
GetInitString(StrEnv[i].SectionName, StrEnv[i].KeyName, StrEnv[i].Default,
StrEnv[i].VarStr, (unsigned long) BUFSIZE, Input);
if (IsEmptyStr(StrEnv[i].VarStr))
ReportError(StrEnv[i].KeyName, 51);
}
/* Read the elevation data from the DEM dataset */
GetVarName(001, 0, VarName);
GetVarNumberType(001, &NumberType);
if (!(Elev = (float *) calloc(Map->NX * Map->NY,
SizeOfNumberType(NumberType))))
ReportError((char *) Routine, 1);
flag = Read2DMatrix(StrEnv[demfile].VarStr, Elev, NumberType, Map->NY, Map->NX, 0,
VarName, 0);
/* Assign the attributes to the map pixel */
/* Reverse the matrix is flag = 1 & netcdf option is selected */
if ((Options->FileFormat == NETCDF && flag == 0) || (Options->FileFormat == BIN)){
for (y = 0, i = 0; y < Map->NY; y++) {
for (x = 0; x < Map->NX; x++, i++) {
(*TopoMap)[y][x].Dem = Elev[i]; }
}
}
else if (Options->FileFormat == NETCDF && flag == 1){
for (y = Map->NY - 1, i = 0; y >= 0; y--) {
for (x = 0; x < Map->NX; x++, i++) {
(*TopoMap)[y][x].Dem = Elev[i]; }
}
}
else ReportError((char *) Routine, 57);
free(Elev);
/* find out the minimum grid elevation of the basin */
MINELEV = 9999;
for (y = 0, i = 0; y < Map->NY; y++) {
for (x = 0; x < Map->NX; x++, i++) {
if ((*TopoMap)[y][x].Dem < MINELEV) {
MINELEV = (*TopoMap)[y][x].Dem;
}
}
}
/* Read the mask */
GetVarName(002, 0, VarName);
GetVarNumberType(002, &NumberType);
if (!(Mask = (unsigned char *) calloc(Map->NX * Map->NY,
SizeOfNumberType(NumberType))))
ReportError((char *) Routine, 1);
flag = Read2DMatrix(StrEnv[maskfile].VarStr, Mask, NumberType, Map->NY, Map->NX, 0,
VarName, 0);
if ((Options->FileFormat == NETCDF && flag == 0)
|| (Options->FileFormat == BIN))
{
for (y = 0, i = 0; y < Map->NY; y++) {
for (x = 0; x < Map->NX; x++, i++) {
(*TopoMap)[y][x].Mask = Mask[i]; }
}
}
else if (Options->FileFormat == NETCDF && flag == 1){
for (y = Map->NY - 1, i = 0; y >= 0; y--) {
for (x = 0; x < Map->NX; x++, i++) {
(*TopoMap)[y][x].Mask = Mask[i]; }
}
}
else ReportError((char *) Routine, 57);
//.........这里部分代码省略.........
示例14: Map
void Epetra_IntVector::Print(std::ostream& os) const {
int MyPID = Map().Comm().MyPID();
int NumProc = Map().Comm().NumProc();
for (int iproc=0; iproc < NumProc; iproc++) {
if (MyPID==iproc) {
int NumMyElements1 =Map(). NumMyElements();
int MaxElementSize1 = Map().MaxElementSize();
int * MyGlobalElements1_int = 0;
long long * MyGlobalElements1_LL = 0;
if(Map().GlobalIndicesInt()) {
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
MyGlobalElements1_int = Map().MyGlobalElements();
#else
throw ReportError("Epetra_IntVector::Print: Global indices int but no API for it.",-1);
#endif
}
else if(Map().GlobalIndicesLongLong()) {
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
MyGlobalElements1_LL = Map().MyGlobalElements64();
#else
throw ReportError("Epetra_IntVector::Print: Global indices long long but no API for it.",-1);
#endif
}
int * FirstPointInElementList1=0;
if (MaxElementSize1!=1) FirstPointInElementList1 = Map().FirstPointInElementList();
if (MyPID==0) {
os.width(8);
os << " MyPID"; os << " ";
os.width(12);
if (MaxElementSize1==1)
os << "GID ";
else
os << " GID/Point";
os.width(20);
os << "Value ";
os << std::endl;
}
for (int i=0; i < NumMyElements1; i++) {
for (int ii=0; ii< Map().ElementSize(i); ii++) {
int iii;
os.width(10);
os << MyPID; os << " ";
os.width(10);
if (MaxElementSize1==1) {
if(MyGlobalElements1_int)
os << MyGlobalElements1_int[i] << " ";
if(MyGlobalElements1_LL)
os << MyGlobalElements1_LL[i] << " ";
iii = i;
}
else {
if(MyGlobalElements1_int)
os << MyGlobalElements1_int[i]<< "/" << ii << " ";
if(MyGlobalElements1_LL)
os << MyGlobalElements1_LL[i]<< "/" << ii << " ";
iii = FirstPointInElementList1[i]+ii;
}
os.width(20);
os << Values_[iii];
os << std::endl;
}
}
os << std::flush;
}
// Do a few global ops to give I/O a chance to complete
Map().Comm().Barrier();
Map().Comm().Barrier();
Map().Comm().Barrier();
}
return;
}
示例15: ReportError
wxObject* wxSizerXmlHandler::Handle_sizer()
{
wxXmlNode *parentNode = m_node->GetParent();
if ( !m_parentSizer &&
(!parentNode || parentNode->GetType() != wxXML_ELEMENT_NODE ||
!m_parentAsWindow) )
{
ReportError("sizer must have a window parent");
return NULL;
}
// Create the sizer of the appropriate class.
wxSizer * const sizer = DoCreateSizer(m_class);
// creation of sizer failed for some (already reported) reason, so exit:
if ( !sizer )
return NULL;
wxSize minsize = GetSize(wxT("minsize"));
if (!(minsize == wxDefaultSize))
sizer->SetMinSize(minsize);
// save state
wxSizer *old_par = m_parentSizer;
bool old_ins = m_isInside;
// set new state
m_parentSizer = sizer;
m_isInside = true;
m_isGBS = (m_class == wxT("wxGridBagSizer"));
wxObject* parent = m_parent;
#if wxUSE_STATBOX
// wxStaticBoxSizer's child controls should be parented by the box itself,
// not its parent.
wxStaticBoxSizer* const stsizer = wxDynamicCast(sizer, wxStaticBoxSizer);
if ( stsizer )
parent = stsizer->GetStaticBox();
#endif // wxUSE_STATBOX
CreateChildren(parent, true/*only this handler*/);
// set growable rows and cols for sizers which support this
if ( wxFlexGridSizer *flexsizer = wxDynamicCast(sizer, wxFlexGridSizer) )
{
SetFlexibleMode(flexsizer);
SetGrowables(flexsizer, wxT("growablerows"), true);
SetGrowables(flexsizer, wxT("growablecols"), false);
}
// restore state
m_isInside = old_ins;
m_parentSizer = old_par;
if (m_parentSizer == NULL) // setup window:
{
m_parentAsWindow->SetSizer(sizer);
wxXmlNode *nd = m_node;
m_node = parentNode;
if (GetSize() == wxDefaultSize)
{
if ( wxDynamicCast(m_parentAsWindow, wxScrolledWindow) != NULL )
{
sizer->FitInside(m_parentAsWindow);
}
else
{
sizer->Fit(m_parentAsWindow);
}
}
m_node = nd;
if (m_parentAsWindow->IsTopLevel())
{
sizer->SetSizeHints(m_parentAsWindow);
}
}
return sizer;
}