• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ MapError函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MapError函数的典型用法代码示例。如果您正苦于以下问题:C++ MapError函数的具体用法?C++ MapError怎么用?C++ MapError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MapError函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: name

int CEnvironment::setenv(const wchar_t* aName, const wchar_t* aValue, int aReplace, int& anErrno)
	{
	TPtrC16 name((TText16*)aName);
	TUint freeSlot=iCount;
	TEnvVar* ep=iVars;
	for (TUint i=0; i<iCount; ++i,++ep)
		{
		if (ep->NotEmpty())
			{
			const TDesC16* existing=ep->Match(name);
			if (existing)
				{
				TInt err=KErrNone;
				if (aReplace)
					ep->SetValue(aValue);
				return MapError(err,anErrno);
				}
			}
		else
			freeSlot=i;
		}
	if (freeSlot==iCount)	
		{
		// no free slots, time to grow the array
		ep=(TEnvVar*)User::ReAlloc(iVars,(iCount+1)*sizeof(TEnvVar));
		if (ep==0)
			return KErrNoMemory;
		iVars=ep;
		++iCount;
		}
	TRAPD(ret,iVars[freeSlot].ConstructL(name,aValue));
	return MapError(ret,anErrno);
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:33,代码来源:GETENV.CPP


示例2: RWTryLockWrite

rwlock_error_t RWTryLockWrite(rwlock_t *RWLock)
{
    if (!RWLock) return RW_LOCK_ERROR_INVALID;
    
#if RW_LOCK_USES_POSIX_LOCKS
    int err;
    if ((err = pthread_mutex_trylock(&RWLock->monitorLock)))
    {
        if (RWLock->destroyed) return RW_LOCK_ERROR_INVALID;
        return MapError(err);
    }
    
    if (!RWLock->destroyed)
    {
        pthread_t Self = pthread_self();
        if (RWLock->writerThread != Self)
        {
            if ((err = pthread_mutex_trylock(&RWLock->lock)))
            {
                pthread_mutex_unlock(&RWLock->monitorLock);
                if (RWLock->destroyed) return RW_LOCK_ERROR_INVALID;
                return MapError(err);
            }
            
            RWLock->writerThread = Self;
        }
        
        RWLock->lockCount++;
    }
    
    pthread_mutex_unlock(&RWLock->monitorLock);
#endif
    
    return RW_LOCK_SUCCESS; //lies when no locks are supported
}
开发者ID:ScrimpyCat,项目名称:RWLock,代码行数:35,代码来源:RWLock.c


示例3: get_string

STDMETHODIMP CDisk::put_comment(BSTR newVal)
{
	char *buf;
	dsk_err_t err;
	
	buf = get_string(newVal);
	if (!buf) return MapError(DSK_ERR_NOMEM);
	err = dsk_set_comment(m_driver, buf);
	dsk_free(buf);
	return MapError(err);
}
开发者ID:cterron,项目名称:amstrad-toolkit,代码行数:11,代码来源:Disk.cpp


示例4: NPT_SetMemory

/*----------------------------------------------------------------------
|   NPT_Zip::Deflate
+---------------------------------------------------------------------*/
NPT_Result 
NPT_Zip::Deflate(const NPT_DataBuffer& in,
                 NPT_DataBuffer&       out,
                 int                   compression_level,
                 Format                format /* = ZLIB */)
{
    // default return state
    out.SetDataSize(0);
    
    // check parameters
    if (compression_level < NPT_ZIP_COMPRESSION_LEVEL_DEFAULT ||
        compression_level > NPT_ZIP_COMPRESSION_LEVEL_MAX) {
        return NPT_ERROR_INVALID_PARAMETERS;
    }
                
    // setup the stream
    z_stream stream;
    NPT_SetMemory(&stream, 0, sizeof(stream));
    stream.next_in   = (Bytef*)in.GetData();
    stream.avail_in  = (uInt)in.GetDataSize();
    
    // setup the memory functions
    stream.zalloc = (alloc_func)0;
    stream.zfree = (free_func)0;
    stream.opaque = (voidpf)0;

    // initialize the compressor
    int err = deflateInit2(&stream, 
                           compression_level,
                           Z_DEFLATED,
                           15 + (format == GZIP ? 16 : 0),
                           8,
                           Z_DEFAULT_STRATEGY);
    if (err != Z_OK) return MapError(err);

    // reserve an output buffer known to be large enough
    out.Reserve(deflateBound(&stream, stream.avail_in) + (format==GZIP?10:0));
    stream.next_out  = out.UseData();
    stream.avail_out = out.GetBufferSize();

    // decompress
    err = deflate(&stream, Z_FINISH);
    if (err != Z_STREAM_END) {
        deflateEnd(&stream);
        return MapError(err);
    }
    
    // update the output size
    out.SetDataSize(stream.total_out);

    // cleanup
    err = deflateEnd(&stream);
    return MapError(err);
}
开发者ID:NAGAVENDRA,项目名称:GenieForiOS,代码行数:57,代码来源:NptZip.cpp


示例5: NPT_CHECK_WARNING

/*----------------------------------------------------------------------
|   NPT_Zip::Inflate
+---------------------------------------------------------------------*/
NPT_Result
NPT_Zip::Inflate(const NPT_DataBuffer& in,
                 NPT_DataBuffer&       out,
                 bool                  raw)
{
    // assume an output buffer twice the size of the input plus a bit
    NPT_CHECK_WARNING(out.Reserve(32+2*in.GetDataSize()));

    // setup the stream
    z_stream stream;
    stream.next_in   = (Bytef*)in.GetData();
    stream.avail_in  = (uInt)in.GetDataSize();
    stream.next_out  = out.UseData();
    stream.avail_out = (uInt)out.GetBufferSize();

    // setup the memory functions
    stream.zalloc = (alloc_func)0;
    stream.zfree = (free_func)0;
    stream.opaque = (voidpf)0;

    // initialize the decompressor
    int err = inflateInit2(&stream, raw?-15:15+32); // 15 = default window bits, +32 = automatic header
    if (err != Z_OK) return MapError(err);

    // decompress until the end
    do {
        err = inflate(&stream, Z_SYNC_FLUSH);
        if (err == Z_STREAM_END || err == Z_OK || err == Z_BUF_ERROR) {
            out.SetDataSize((NPT_Size)stream.total_out);
            if ((err == Z_OK && stream.avail_out == 0) || err == Z_BUF_ERROR) {
                // grow the output buffer
                out.Reserve(out.GetBufferSize()*2);
                stream.next_out = out.UseData()+stream.total_out;
                stream.avail_out = out.GetBufferSize()-(NPT_Size)stream.total_out;
            }
        }
    } while (err == Z_OK);

    // check for errors
    if (err != Z_STREAM_END) {
        inflateEnd(&stream);
        return MapError(err);
    }

    // cleanup
    err = inflateEnd(&stream);
    return MapError(err);
}
开发者ID:sandalsoft,项目名称:mrmc,代码行数:51,代码来源:NptZip.cpp


示例6: gethostname

/**
Get the internet name of this host. Actually this will always return a null 
string with TCPIP 030 and onwards because the "name" of a mobile host
isn't really very meaningful - in practice the IP address is chosen dynamically
once you start doing real networking, at which time the ISP can resolve the 
IP address into a name of some sort if you really want.
@return 
@param name
@param size
*/
EXPORT_C int gethostname (char *name, size_t size)
	{
	int* perrno=__errno();
	RSocketServ ss;
	TInt err=ss.Connect(1);
	if (err==KErrNone)
		{
		RHostResolver r;
		err=r.Open(ss, AF_INET, KProtocolInetUdp);
		if (err==KErrNone)
			{
			TBuf<128> hostname;
			err=r.GetHostName(hostname);
			if (err==KErrNone)
				{
				if (size>(size_t)hostname.Length())
					{
					TPtr8 retval((TText8*)name,size);
					retval.Copy(hostname);
					retval.PtrZ();
					}
				else
					err=ENAMETOOLONG;
				}
			r.Close();
			}
		ss.Close();
		}
	return MapError(err,*perrno);
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:40,代码来源:NETDB.CPP


示例7: RWLockDestroy

rwlock_error_t RWLockDestroy(rwlock_t *RWLock)
{
    if (!RWLock) return RW_LOCK_ERROR_INVALID;
    
#if RW_LOCK_USES_POSIX_LOCKS
    //don't care about most fails
    int err;
    if ((err = pthread_mutex_lock(&RWLock->monitorLock)))
    {
        if (RWLock->destroyed) return RW_LOCK_ERROR_INVALID;
        return MapError(err);
    }
    
    RWLock->destroyed = TRUE;
    
    //wait and let any locks get finished up
    pthread_mutex_unlock(&RWLock->monitorLock);
    pthread_mutex_lock(&RWLock->lock);
    pthread_mutex_lock(&RWLock->monitorLock);
    pthread_mutex_unlock(&RWLock->lock);
    
    pthread_mutex_destroy(&RWLock->lock);
    
    pthread_mutex_unlock(&RWLock->monitorLock);
    pthread_mutex_destroy(&RWLock->monitorLock);
#endif
    
    return RW_LOCK_SUCCESS; //lies when no locks are supported
}
开发者ID:ScrimpyCat,项目名称:RWLock,代码行数:29,代码来源:RWLock.c


示例8: RWUnlockRead

rwlock_error_t RWUnlockRead(rwlock_t *RWLock)
{
    if (!RWLock) return RW_LOCK_ERROR_INVALID;
    
#if RW_LOCK_USES_POSIX_LOCKS
    int err;
    if ((err = pthread_mutex_lock(&RWLock->monitorLock)))
    {
        if (RWLock->destroyed) return RW_LOCK_ERROR_INVALID;
        return MapError(err);
    }
    
    rwlock_error_t Error = RW_LOCK_SUCCESS;
    //if (!RWLock->destroyed)
    {
        if ((!RWLock->writerThread) || (RWLock->writerThread == pthread_self()))
        {
            if (!--RWLock->lockCount)
            {
                RWLock->writerThread = NULL;
                pthread_mutex_unlock(&RWLock->lock);
            }
        }
        
        else Error = RW_LOCK_ERROR_INVALID;
    }
    
    //else Error = RW_LOCK_ERROR_INVALID;
    
    pthread_mutex_unlock(&RWLock->monitorLock);
    return Error;
#endif
    
    return RW_LOCK_SUCCESS; //lies when no locks are supported
}
开发者ID:ScrimpyCat,项目名称:RWLock,代码行数:35,代码来源:RWLock.c


示例9: dsk_get_retry

STDMETHODIMP CDisk::get_retries(short *pVal)
{
	unsigned r;
	dsk_err_t err = dsk_get_retry(m_driver, &r);
	*pVal = r;
	return MapError(err);
}
开发者ID:cterron,项目名称:amstrad-toolkit,代码行数:7,代码来源:Disk.cpp


示例10: g_to_dg

STDMETHODIMP CDisk::ltrkid(IGeometry *g, long track, short *count, VARIANT *buffer)
{
	DSK_GEOMETRY geom;
	DSK_FORMAT *fmt;
	unsigned char *buf;
	dsk_err_t err;
	dsk_psect_t n, acount = 0;
	HRESULT hr;

	g_to_dg(g, &geom);
	err = dsk_ltrackids(m_driver, &geom, track, &acount, &fmt);
	if (acount)
	{
		if (count) *count = acount;
		buf = new unsigned char[4 * acount];
		for (n = 0; n < acount; n++)
		{
			buf[n*4  ] = fmt[n].fmt_cylinder;
			buf[n*4+1] = fmt[n].fmt_head;
			buf[n*4+2] = fmt[n].fmt_sector;
			buf[n*4+3] = dsk_get_psh(fmt[n].fmt_secsize);
		}
		hr = PutBuffer(buf, buffer, 4 * acount, err);
		delete buf;
		return hr;
	}
	return MapError(err);
}
开发者ID:cterron,项目名称:amstrad-toolkit,代码行数:28,代码来源:Disk.cpp


示例11: MapError

STDMETHODIMP CGeometry::pt2lt(long cyl, short head, long *lsect)
{
	dsk_ltrack_t lt;
	HRESULT hr = MapError(dg_pt2lt(&m_g, cyl, head, &lt));
	*lsect = lt;
	return hr;
}
开发者ID:cterron,项目名称:amstrad-toolkit,代码行数:7,代码来源:Geometry.cpp


示例12: FindFirstFileW

/*----------------------------------------------------------------------
|   NPT_File::ListDir
+---------------------------------------------------------------------*/
NPT_Result 
NPT_File::ListDir(const char*           path, 
                  NPT_List<NPT_String>& entries, 
                  NPT_Ordinal           start /* = 0 */, 
                  NPT_Cardinal          max   /* = 0 */)
{
    NPT_WIN32_USE_CHAR_CONVERSION;

    // default return value
    entries.Clear();

    // check the arguments
    if (path == NULL || path[0] == '\0') return NPT_ERROR_INVALID_PARAMETERS;

    // construct a path name with a \* wildcard at the end
    NPT_String path_pattern = path;
    if (path_pattern.EndsWith("\\") || path_pattern.EndsWith("/")) {
        path_pattern += "*";
    } else {
        path_pattern += "\\*";
    }

    // list the entries
    WIN32_FIND_DATAW find_data;
    HANDLE find_handle = FindFirstFileW(NPT_WIN32_A2W(path_pattern.GetChars()), &find_data);
    if (find_handle == INVALID_HANDLE_VALUE) return MapError(GetLastError());
    NPT_Cardinal count = 0;
    do {
        if (NPT_File_ProcessFindData(&find_data)) {
            // continue if we still have entries to skip
            if (start > 0) {
                --start;
                continue;
            }
            entries.Add(NPT_WIN32_W2A(find_data.cFileName));

            // stop when we have reached the maximum requested
            if (max && ++count == max) return NPT_SUCCESS;
        }
    } while (FindNextFileW(find_handle, &find_data));
    DWORD last_error = GetLastError();
    FindClose(find_handle);
    if (last_error != ERROR_NO_MORE_FILES) return MapError(last_error);

    return NPT_SUCCESS;
}
开发者ID:422053362,项目名称:Neptune_CPP_Runtime_Library,代码行数:49,代码来源:NptWin32File.cpp


示例13: dsk_get_comment

STDMETHODIMP CDisk::get_comment(BSTR *pVal)
{
	char *cmt = NULL;
	dsk_err_t err = dsk_get_comment(m_driver, &cmt);

	if (cmt) *pVal = ret_string(cmt);
	return MapError(err);
}
开发者ID:cterron,项目名称:amstrad-toolkit,代码行数:8,代码来源:Disk.cpp


示例14: RemoveDirectoryW

/*----------------------------------------------------------------------
|   NPT_File::RemoveDir
+---------------------------------------------------------------------*/
NPT_Result
NPT_File::RemoveDir(const char* path)
{
    NPT_WIN32_USE_CHAR_CONVERSION;
    BOOL result = RemoveDirectoryW(NPT_WIN32_A2W(path));
    if (result == 0) {
        return MapError(GetLastError());
    }
    return NPT_SUCCESS;
}
开发者ID:422053362,项目名称:Neptune_CPP_Runtime_Library,代码行数:13,代码来源:NptWin32File.cpp


示例15: MoveFileW

/*----------------------------------------------------------------------
|   NPT_File::Rename
+---------------------------------------------------------------------*/
NPT_Result
NPT_File::Rename(const char* from_path, const char* to_path)
{
    NPT_WIN32_USE_CHAR_CONVERSION;
    BOOL result = MoveFileW(NPT_WIN32_A2W(from_path), NPT_WIN32_A2W(to_path));
    if (result == 0) {
        return MapError(GetLastError());
    }
    return NPT_SUCCESS;
}
开发者ID:422053362,项目名称:Neptune_CPP_Runtime_Library,代码行数:13,代码来源:NptWin32File.cpp


示例16: Error

HRESULT CDisk::GetFormat(VARIANT *buf, DSK_FORMAT **bufout, unsigned length)
{
	long lBound, uBound;
	unsigned char HUGEP* FAR pData;
	SAFEARRAY *psa;
	HRESULT hr;
	unsigned n;
	DSK_FORMAT *fmt;

	if (V_VT(buf) != (VT_ARRAY | VT_UI1)) 
	{
		return Error("Passed parameter must be an array of unsigned characters", IID_IDisk, E_INVALIDARG);
	}
	psa = V_ARRAY(buf);
      // Check dimensions of the array.
	if (SafeArrayGetDim(psa) != 1)
	{
		return Error("Passed parameter must be a 1-dimensional array", IID_IDisk, E_INVALIDARG);
	}

	// Get array bounds.
	hr = SafeArrayGetLBound(psa, 1, &lBound);
	if (FAILED(hr))
	{
		return Error("Could not get array bounds", IID_IDisk, hr);
	}
	hr = SafeArrayGetUBound(psa, 1, &uBound);
	if (FAILED(hr))
	{
		return Error("Could not get array bounds", IID_IDisk, hr);
	}
	if (uBound + 1 - lBound < (long)length*4)
	{
		return Error("Passed array is too short", IID_IDisk, E_INVALIDARG);
	}
	// Get a pointer to the elements of the array.
	hr = SafeArrayAccessData(psa, (void HUGEP * FAR *)&pData);
	if (FAILED(hr))
	{
		return Error("Could not access array data", IID_IDisk, E_INVALIDARG);
	}
	*bufout = (DSK_FORMAT *)dsk_malloc(length * sizeof(DSK_FORMAT));
	if (!bufout) return MapError(DSK_ERR_NOMEM);
	fmt = bufout[0];
	for (n = 0; n < length; n++)
	{
		fmt->fmt_cylinder = *pData++;
		fmt->fmt_head     = *pData++;
		fmt->fmt_sector   = *pData++;
		fmt->fmt_secsize  = 128 << (*pData++);
		++fmt;
	}
	SafeArrayUnaccessData(psa);
	return S_OK;
}
开发者ID:cterron,项目名称:amstrad-toolkit,代码行数:55,代码来源:Disk.cpp


示例17: adjtime

//Makes small adjustments to the system time,
//advancing it by the time specified by the timeval delta
EXPORT_C int adjtime(const struct timeval *delta, struct timeval *olddelta)
{
	//We can make only positive adjutments to the available clock
	//The synchronization to the global time server is provided to us
	//by the User::SetHomeTime api itself
	int retval = -1;
	TTime t;
	TInt err;
	TInt64 microtime;
	long secs = 0;
	suseconds_t usec = 0;
	
	//We expect the user of the library to give us a valid pointer		
	if(delta == NULL)
	{
		errno = EFAULT;
		return retval;
	}
		
	if ((delta->tv_usec) > 1000000) 
	{
		errno = ERANGE;
		return retval;
	}
	//Check for negative of seconds and make it positive
	if((delta->tv_sec) < 0)
		secs = -1*(delta->tv_sec);
	else
		secs = delta->tv_sec;

	//Check for negative of microseconds and make it positive
	if((delta->tv_usec) < 0)
		usec = -1*(delta->tv_usec);
	else
		usec = delta->tv_usec;

	t.HomeTime();
	t+=(TTimeIntervalSeconds)secs;
	microtime = usec;
	t+=(TTimeIntervalMicroSeconds)microtime;        
	err = User::SetHomeTime(t);
	if (!err)
	{
		retval = 0;
	  	//olddelta is always zero in case of success
		olddelta->tv_sec = 0;
		olddelta->tv_usec = 0;
	}
	else
	{
		MapError(err,errno);
		retval = -1;
	}
	return retval;
}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:57,代码来源:clock_funcs.cpp


示例18: MapError

STDMETHODIMP CLibrary::create(BSTR f, BSTR d, BSTR c, IDisk **ppDisk)
{
	DSK_PDRIVER pd;
	dsk_err_t err;
	char *filename;
	char *driver;
	char *compress;

	if (!f || !ppDisk)
	{
		return MapError(DSK_ERR_BADPTR);
	}
	filename = get_string(f);
	driver   = get_string(d);
	compress = get_string(c);

	if (driver[0] == 0)   
	{
		dsk_free(driver);
		driver   = NULL;
	}
	if (compress[0] == 0) 
	{
		dsk_free(compress);
		compress = NULL;
	}
	err = dsk_creat(&pd, filename, driver, compress);
	if (filename) dsk_free(filename);
	if (driver)   dsk_free(driver);
	if (compress) dsk_free(compress);

	if (err)
	{
		return MapError(err);
	}
	HRESULT hr = CDisk::CreateInstance(ppDisk);
	if (FAILED(hr)) return hr;

	((CDisk *)ppDisk[0])->m_driver = pd;

	return hr;
}
开发者ID:lipro,项目名称:libdsk,代码行数:42,代码来源:Library.cpp


示例19: RWLockInit

rwlock_error_t RWLockInit(rwlock_t *RWLock)
{
    if (!RWLock) return RW_LOCK_ERROR_INVALID;
    
    RWLock->destroyed = FALSE;
#if RW_LOCK_USES_POSIX_LOCKS
    int err;
    if ((err = pthread_mutex_init(&RWLock->lock, NULL))) return MapError(err);
    if ((err = pthread_mutex_init(&RWLock->monitorLock, NULL)))
    {
        pthread_mutex_destroy(&RWLock->lock);
        
        return MapError(err);
    }
    
    RWLock->lockCount = 0;
    RWLock->writerThread = NULL;
#endif
    
    return RW_LOCK_SUCCESS; //lies when no locks are supported
}
开发者ID:ScrimpyCat,项目名称:RWLock,代码行数:21,代码来源:RWLock.c



注:本文中的MapError函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MapName函数代码示例发布时间:2022-05-30
下一篇:
C++ MapDialogRect函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap