本文整理汇总了C++中RaiseError函数的典型用法代码示例。如果您正苦于以下问题:C++ RaiseError函数的具体用法?C++ RaiseError怎么用?C++ RaiseError使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RaiseError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkipWhitespace
// Asserts that the rest of the line is empty and moves to the next one.
void SymFile::ExpectEmptyRestOfLine()
{
SkipWhitespace();
if (m_buffer[m_pos] == 0)
{
if (m_pos >= m_size)
RaiseWarning("file doesn't end with newline");
else
RaiseError("unexpected null character");
}
else if (m_buffer[m_pos] == '\n')
{
m_pos++;
m_lineStart = m_pos;
m_lineNum++;
}
else if (m_buffer[m_pos] == '\r')
{
RaiseError("only Unix-style LF newlines are supported");
}
else
{
RaiseError("junk at end of line");
}
}
示例2: FetchData
// S_OK : 성공
// S_FALSE : 데이터는 가져왔지만 Consumer가 원하는 데이터가 아님
// E_FAIL : 실패
static HRESULT FetchData(int hReq, CTablesInfoRow &tirData, int table_type)
{
char *value;
int int_value;
int ind, res;
T_CCI_ERROR err_buf;
res = cci_fetch(hReq, &err_buf);
if(res<0) return RaiseError(E_FAIL, 1, __uuidof(IDBSchemaRowset), err_buf.err_msg);
res = cci_get_data(hReq, 1, CCI_A_TYPE_STR, &value, &ind);
if(res<0) return RaiseError(E_FAIL, 0, __uuidof(IDBSchemaRowset));
wcscpy(tirData.m_szTableName, CA2W(value));
res = cci_get_data(hReq, 2, CCI_A_TYPE_INT, &int_value, &ind);
if(res<0) return RaiseError(E_FAIL, 0, __uuidof(IDBSchemaRowset));
if (table_type >= 0 && table_type != int_value)
return S_FALSE;
if (int_value == 2)
wcscpy(tirData.m_szTableType, L"TABLE");
else if (int_value == 1)
wcscpy(tirData.m_szTableType, L"VIEW");
else if (int_value == 0)
wcscpy(tirData.m_szTableType, L"SYSTEM TABLE");
tirData.m_bBookmarks = ATL_VARIANT_TRUE;
tirData.m_bBookmarkType = DBPROPVAL_BMK_NUMERIC;
tirData.m_bBookmarkDatatype = DBTYPE_BYTES;
tirData.m_bBookmarkMaximumLength = sizeof(DBROWCOUNT);
return S_OK;
}
示例3: TryToSelfElevate
bool TryToSelfElevate(HWND hwnd)
{
HRESULT hRes = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
if (hRes != S_OK)
throw std::runtime_error("Cannot initialize COM library.");
wchar_t szPath[MAX_PATH];
if (::GetModuleFileNameW(NULL, szPath, ARRAYSIZE(szPath)) == 0)
RaiseError("TryToSelfElevate:\n");
SHELLEXECUTEINFOW sei = { sizeof(sei) };
sei.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_UNICODE | SEE_MASK_NOASYNC | SEE_MASK_NO_CONSOLE | /*SEE_MASK_NOCLOSEPROCESS |*/ SEE_MASK_HMONITOR;
sei.lpVerb = L"runas";
sei.lpFile = szPath;
sei.nShow = SW_SHOW;
sei.hMonitor = ::MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY);
if (!ShellExecuteExW(&sei))
{
DWORD dwError = GetLastError();
if (dwError != ERROR_CANCELLED)
RaiseError("TryToSelfElevate:\n");
// The user refused the elevation.
return false;
}
//if (sei.hProcess == nullptr)
// throw std::runtime_error("Cannot start new process.");
//::WaitForSingleObject(sei.hProcess, INFINITE);
return true;
}
示例4: IsRunAsAdmin
bool IsRunAsAdmin()
{
BOOL ret = TRUE;
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup;
ret = ::AllocateAndInitializeSid(
&NtAuthority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&AdministratorsGroup);
if (!ret)
RaiseError("Couldn't AllocateAndInitializeSid:\n");
BOOL check = FALSE;
if (!::CheckTokenMembership(nullptr, AdministratorsGroup, &check))
{
FreeSid(AdministratorsGroup);
RaiseError("Couldn't CheckTokenMembership:\n");
}
FreeSid(AdministratorsGroup);
return (check ? true : false);
}
示例5: EnableDebugPrivileges
void EnableDebugPrivileges()
{
HANDLE hToken;
LUID SeDebugNameValue;
TOKEN_PRIVILEGES TokenPrivileges;
if (!::OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
RaiseError("Couldn't OpenProcessToken:\n");
if (!::LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &SeDebugNameValue))
{
::CloseHandle(hToken);
RaiseError("Couldn't LookupPrivilegeValue:\n");
}
TokenPrivileges.PrivilegeCount = 1;
TokenPrivileges.Privileges[0].Luid = SeDebugNameValue;
TokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (!::AdjustTokenPrivileges(hToken, FALSE, &TokenPrivileges, sizeof(TOKEN_PRIVILEGES), NULL, NULL))
{
::CloseHandle(hToken);
RaiseError("Couldn't AdjustTokenPrivileges:\n");
}
::CloseHandle(hToken);
}
示例6: mLockCnt
QCMutex::QCMutex():
mLockCnt(0),
mOwner(),
mMutex()
{
int theErr;
pthread_mutexattr_t theAttr;
if ((theErr = pthread_mutexattr_init(&theAttr)) != 0)
{
RaiseError("QCMutex: pthread_mutex_attr_init", theErr);
}
if ((theErr = pthread_mutexattr_settype(&theAttr, PTHREAD_MUTEX_RECURSIVE)) != 0)
{
RaiseError("QCMutex: pthread_mutexattr_settype", theErr);
}
if ((theErr = pthread_mutex_init(&mMutex, &theAttr)) != 0)
{
RaiseError("QCMutex: pthread_mutex_init", theErr);
}
if ((theErr = pthread_mutexattr_destroy(&theAttr)) != 0)
{
RaiseError("QCMutex: pthread_mutexattr_destroy", theErr);
}
}
示例7: ConnectHopHTTPSProxy
int ConnectHopHTTPSProxy(STREAM *S, const char *Proxy, const char *Destination)
{
char *Tempstr=NULL, *Token=NULL;
char *Proto=NULL, *Host=NULL, *User=NULL, *Pass=NULL;
const char *ptr=NULL;
int result=FALSE, Port;
ParseConnectDetails(Proxy, &Token, &Host, &Token, &User, &Pass, NULL);
Port=atoi(Token);
if (! (S->State & SS_INITIAL_CONNECT_DONE))
{
if (Port==0) Port=443;
S->in_fd=TCPConnect(Host,Port,0);
S->out_fd=S->in_fd;
if (S->in_fd == -1)
{
RaiseError(0, "ConnectHopHTTPSProxy", "failed to connect to proxy at %s:%d", Host, Port);
return(FALSE);
}
}
ptr=Destination;
if (strncmp(ptr,"tcp:",4)==0) ptr+=4;
Tempstr=FormatStr(Tempstr,"CONNECT %s HTTP/1.1\r\n\r\n",ptr);
STREAMWriteLine(Tempstr,S);
STREAMFlush(S);
Tempstr=STREAMReadLine(Tempstr,S);
if (Tempstr)
{
StripTrailingWhitespace(Tempstr);
ptr=GetToken(Tempstr," ",&Token,0);
ptr=GetToken(ptr," ",&Token,0);
if (*Token=='2') result=TRUE;
else RaiseError(0, "ConnectHopHTTPSProxy", "proxy request to %s:%d failed. %s", Host, Port, Tempstr);
while (StrLen(Tempstr))
{
Tempstr=STREAMReadLine(Tempstr,S);
StripTrailingWhitespace(Tempstr);
}
}
else RaiseError(0, "ConnectHopHTTPSProxy", "proxy request to %s:%d failed. Server Disconnectd.", Host, Port);
DestroyString(Tempstr);
DestroyString(Token);
DestroyString(Host);
DestroyString(User);
DestroyString(Pass);
return(result);
}
示例8: RaiseError
void CCommandLineParser::ProcessCommand(const char* command_str)
{
const s_arg_entry* command;
if (!FindArgument(command_str, false, &command))
RaiseError("unknown command");
if (this->command.id != kNone)
RaiseError("unexpected command.. already got one.");
this->command.SetID(command->id);
ReadParams(command, this->command);
}
示例9: ReadParams
void CCommandLineParser::ReadParams(const s_arg_entry* arg, CArgEntity& out)
{
for (size_t x = 0; x < arg->nargs; x++) {
char* arg_str;
if (!ReadString(&arg_str)) RaiseError("expected arg");
std::string str = arg_str;
if (str.size() > 0){
if (str.at(0) == '-') RaiseError("expected arg");
out.Add(arg_str);
}
}
}
示例10: object
// *cur_ == '{'
JsonValue * JsonParser::ReadObject(JsonValue * parent)
{
std::auto_ptr<JsonObjectValue> object(new JsonObjectValue(parent));
std::string key;
Advance();
SkipSpaces();
if (*cur_ == '}')
{
Advance();
return object.release();
}
while (true)
{
if (*cur_ == '"')
{
ParseStringLiteral(key);
}
else
{
RaiseError("Unexpected symbol, while waiting key of object");
}
SkipSpaces();
if (*cur_ != ':')
{
RaiseError("Colon expected");
}
Advance();
SkipSpaces();
object->Set(key, ReadValue(parent));
SkipSpaces();
if (*cur_ == ',')
{
Advance();
SkipSpaces();
}
else if (*cur_ == '}')
{
Advance();
return object.release();
}
else
{
RaiseError("Comma or end of object expected");
}
}
}
示例11: ImportModule
ErrorState* ImportModule(const std::string& modulePath, ParseResult& parse)
{
ErrorState* errorState = new ErrorState();
FILE* f = fopen(modulePath.c_str(), "rb");
if (!f)
{
RaiseError(errorState, ERROR_MALFORMED_MODULE_INFO, modulePath.c_str(), "Couldn't open file");
return errorState;
}
#define CONSUME(byte)\
if (fgetc(f) != byte)\
{\
RaiseError(errorState, ERROR_MALFORMED_MODULE_INFO, modulePath.c_str(), "Format not followed");\
return errorState;\
}
CONSUME(0x7F);
CONSUME('R');
CONSUME('O');
CONSUME('O');
uint8_t version = Read<uint8_t>(f);
uint32_t typeCount = Read<uint32_t>(f);
uint32_t codeThingCount = Read<uint32_t>(f);
if (version != ROO_MOD_VERSION)
{
RaiseError(errorState, ERROR_MALFORMED_MODULE_INFO, modulePath.c_str(), "Unsupported version");
return errorState;
}
for (size_t i = 0u;
i < typeCount;
i++)
{
parse.types.push_back(Read<TypeDef*>(f));
}
for (size_t i = 0u;
i < codeThingCount;
i++)
{
parse.codeThings.push_back(Read<CodeThing*>(f));
}
fclose(f);
return errorState;
}
示例12: FetchData
// S_OK : 성공
// S_FALSE : 데이터는 가져왔지만 Consumer가 원하는 데이터가 아님
// E_FAIL : 실패
static HRESULT FetchData(int hReq, CStatisticsRow &tprData)
{
char *value;
int ind, res;
T_CCI_ERROR err_buf;
res = cci_fetch(hReq, &err_buf);
if(res<0) return RaiseError(E_FAIL, 1, __uuidof(IDBSchemaRowset), err_buf.err_msg);
res = cci_get_data(hReq, 1, CCI_A_TYPE_STR, &value, &ind);
if(res<0) return RaiseError(E_FAIL, 0, __uuidof(IDBSchemaRowset));
wcscpy(tprData.m_szTableName, CA2W(value));
return S_OK;
}
示例13: ATLASSERT
// CLitMultiLock
CLitMultiLock::CLitMultiLock(CLitSyncObject* pObjects[], DWORD dwCount,
BOOL bInitialLock)
{
ATLASSERT(dwCount > 0 && dwCount <= MAXIMUM_WAIT_OBJECTS);
ATLASSERT(pObjects != NULL);
if(pObjects == NULL)
{
RaiseError(cstMTErrorCode,_T("argument error."));
}
m_ppObjectArray = pObjects;
m_dwCount = dwCount;
// as an optimization, skip allocating array if
// we can use a small, preallocated bunch of handles
if (m_dwCount > _countof(m_hPreallocated))
{
ATL::CAutoVectorPtr<HANDLE> spHandleArray(new HANDLE[m_dwCount]);
ATL::CAutoVectorPtr<BOOL> spLockedArray(new BOOL[m_dwCount]);
m_pHandleArray = spHandleArray.Detach();
m_bLockedArray = spLockedArray.Detach();
}
else
{
m_pHandleArray = m_hPreallocated;
m_bLockedArray = m_bPreallocated;
}
// get list of handles from array of objects passed
for (DWORD i = 0; i <m_dwCount; i++)
{
if(pObjects[i] == NULL)
{
RaiseError(cstMTErrorCode,_T("argument error."));
}
// can't wait for critical sections
ATLASSERT(pObjects[i]->m_objectType != enmSyncObjectCriticalSection);
m_pHandleArray[i] = pObjects[i]->m_hObject;
m_bLockedArray[i] = FALSE;
}
if (bInitialLock)
Lock();
}
示例14: MPITypeConv
MPI_Datatype MPITypeConv( Type_tag t, size_t tsize ) {
/* Check arguments make sense */
if( t != TYPE_IFloat && t != TYPE_int )
RaiseError("SCUMPITypeConv: unknown data type!");
if( tsize <= 0 )
RaiseError("SCUMPITypeConv: size of data type is <= 0!");
MPI_Datatype int_types[N_INT_TYPES] = { MPI_CHAR, MPI_SHORT, MPI_INT, MPI_LONG };
MPI_Datatype IFloat_types[N_FLOAT_TYPES] = { MPI_FLOAT, MPI_DOUBLE, MPI_LONG_DOUBLE };
char err_str[STRING_MAX_LEN];
int i, mpisize;
/* Go through int OR IFloat types */
if( t == TYPE_int ) {
for( i=0; i < N_INT_TYPES; i++ ) {
MPI_Type_size( int_types[i], &mpisize ); /* Get size of this MPI type */
if( tsize == mpisize ) // If we have a match
return( int_types[i] ); // return the matched type.
}
/* if this executes, no suitable type has not been found, so raise an error */
sprintf(err_str,"SCUMPITypeConv: no suitable %i-byte int type among MPI primitive types",tsize);
RaiseError(err_str);
/* IFloat types */
} else if( t == TYPE_IFloat ) {
for( i=0; i < N_FLOAT_TYPES; i++ ) {
MPI_Type_size( IFloat_types[i], &mpisize ); /* Get size of this MPI type */
if( tsize == mpisize ) // If we have a match
return( IFloat_types[i] ); // return the matched type.
}
/* if this executes, no suitable type has not been found, so raise an error */
sprintf(err_str,"no suitable %i-byte IFloat type among MPI primitive types",tsize);
RaiseError(err_str);
}
/* This statement should never execute, however just to check, and keep
the compiler happy, we shall say: */
RaiseError("SCUMPITypeConv: running unrunnable section of SCUMPITypeConv! Possible memory access problem?");
return(( MPI_Datatype)0 );
}
示例15: array
// *cur_ == '['
JsonValue * JsonParser::ReadArray(JsonValue * parent)
{
std::auto_ptr<JsonArrayValue> array(new JsonArrayValue(parent));
Advance();
SkipSpaces();
if (*cur_ == ']')
{
Advance();
return array.release();
}
while (true)
{
array->PushBack(ReadValue(parent));
SkipSpaces();
if (*cur_ == ',')
{
Advance();
SkipSpaces();
continue;
}
else if (*cur_ == ']')
{
Advance();
return array.release();
}
else
{
RaiseError("Comma or end of array expected");
}
}
}