本文整理汇总了C++中ptr函数的典型用法代码示例。如果您正苦于以下问题:C++ ptr函数的具体用法?C++ ptr怎么用?C++ ptr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ptr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ASN1_STRING_data
inline const unsigned char* string::data()
{
return ASN1_STRING_data(ptr().get());
}
开发者ID:RushOnline,项目名称:libcryptoplus,代码行数:4,代码来源:string.hpp
示例2: isIdentity
bool isIdentity() const
{
mat2 i = I();
return memcmp( ptr(), i.ptr(), sizeof(GLfloat)*4 ) == 0;
}
开发者ID:cody82,项目名称:simquadcopter,代码行数:5,代码来源:mat2.hpp
示例3: ptr
Worker::ptr Worker::create(boost::asio::io_service& io_srv, boost::asio::ip::address_v4 ip)
{
return ptr(new Worker(io_srv, ip));
}
开发者ID:mystic123,项目名称:Computer-Networks,代码行数:4,代码来源:worker.cpp
示例4: ptr
wxPieChartData::ptr wxPieChartData::make_shared()
{
return ptr(new wxPieChartData());
}
开发者ID:Kvaz1r,项目名称:wxCharts,代码行数:4,代码来源:wxdoughnutandpiechartbase.cpp
示例5: switch
void CTrustSession::DispatchMessageL(const RMessage2& aMessage)
{
switch(aMessage.Function())
{
case EAddTrust:
{
TCertInfo certInfo;
TPckg<TCertInfo> certInfoPckg(certInfo);
aMessage.ReadL(1,certInfoPckg);
TInt err = Server().AddSessionTrustL(certInfo);
TPckg<TInt> result(err);
aMessage.WriteL(0,result);
}
break;
case EGetElementList:
{
RElementIdArray array;
CleanupClosePushL( array);
TElementType type = EPolicySets;
TPckgBuf<TInt> EleTypePkg(type);
aMessage.ReadL(1,EleTypePkg);
type =(TElementType) EleTypePkg();
TInt err = Server().GetElementListL(type,array);
TPckgBuf<TInt> result(err);
TInt count = array.Count();
aMessage.WriteL(0,result);
CleanupStack::PopAndDestroy();
}
break;
case EGetElement:
{
HBufC8* buffer = HBufC8::NewLC( 300 );
TPtr8 ptr( buffer->Des() );
aMessage.ReadL( 0, ptr );
TElementInfo elementInfo(ptr);
TPtrC8 ptrNullDes = elementInfo.GetDescription(); //just to get the code coverage
User::LeaveIfError( Server().GetElementL(elementInfo));
TPtrC8 ptrDes = elementInfo.GetDescription();
TPtrC8 ptrID = elementInfo.GetElementId();
for ( TInt i = 0; i < elementInfo.GetChildElementArray().Count(); i++)
{
RDEBUG_2("CTrustSession::DispatchMessageL Child element ids %S", elementInfo.GetChildElementArray()[i]);
}
CleanupStack::PopAndDestroy(buffer);
}
break;
case EGetXACMLDescription:
{
HBufC8* buffer = HBufC8::NewLC( 300 );
TPtr8 ptr( buffer->Des() );
aMessage.ReadL( 0, ptr );
TElementInfo elementInfo(ptr);
TPtrC8 ptrNullXACML(elementInfo.GetXACML()); //just to get the code coverage
User::LeaveIfError( Server().GetXACMLDescriptionL(elementInfo));
TPtrC8 ptrXACML(elementInfo.GetXACML());
// RDEBUG_2("CTrustSession::DispatchMessageLGetXACML %S", ptrXACML);
CleanupStack::PopAndDestroy(buffer);
}
break;
default:
break;
}
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:77,代码来源:TrustSession.cpp
示例6: ptr
void Item_group::add_item_entry(const Item_tag &itemid, int probability)
{
std::unique_ptr<Item_spawn_data> ptr(new Single_item_creator(itemid, Single_item_creator::S_ITEM, probability));
add_entry(ptr);
}
开发者ID:HolyHemperor,项目名称:Cataclysm-DDA,代码行数:5,代码来源:item_group.cpp
示例7: printf
int Game::loadGamestate(const XMLReader& reader, const sf::String& GSname, const SFG::Pointer<GameState>& included)
{
SFG::Pointer<GameState> GS_ptr;
sf::String GSxmlpath = L"xml/gamestate[" + GSname + L"]";
auto str = reader.getValue(GSxmlpath, 0);
if (str == L"__xml_failure")
{
printf("[Error] Unspecified startup gamestate in %s:%d.\n", __FILE__, __LINE__);
return -2;
}
else
{
if (str == L"#included")
{
//Use default
GS_ptr.reset(included);
if (!GS_ptr.isValid() && included.getElement() != nullptr)
{
printf("[Critical] Failed to allocate memory for \"%s\" in %s:%d\n",GSname.toAnsiString().c_str(), __FILE__, __LINE__);
return -1;
}
}
else
{
//Use specified
//#TODO
STILL_TO_DO(__FILE__, __LINE__);
//We first need an instance of a DLLLoadedGameState
GS_ptr.reset(new DLLLoadedGameState());
//Set the name
GS_ptr->setName(GSname);
if (GS_ptr->getName() == "__xml_failure")
{
SFG::Util::printLog(SFG::Util::Error, __FILE__, __LINE__, "Failed to get Gamestate name, aborting.");
return -1;
}
//Then, load the specified file
if (GS_ptr.cast<DLLLoadedGameState>()->loadFromDll(str.toAnsiString().c_str()) != 0)
{
SFG::Util::printLog(SFG::Util::Error, __FILE__, __LINE__,
"Failed to load gamestate \"%s\" from DLL", str.toAnsiString().c_str());
return -2;
}
//We actually should be done
}
//Get all modules
sf::String uses = reader.getValue(GSxmlpath + L"uses.");
if (uses != L"__xml_failure")
{
//We have specifiers
size_t begin = 0;
size_t last = 0;
//Begin needs to be checked as the last module wouldn't be counted otherwise
while ((last = uses.find(L',', last)) != sf::String::InvalidPos || begin != sf::String::InvalidPos)
{
sf::String string;
if (last == sf::String::InvalidPos)
{
//If the end would otherwise exceed the string length, set it to the maximum (sf::String::end()).
//string = sf::String(uses.begin() + begin, uses.end());
string = uses.substring(begin, uses.getSize() - begin);
}
else
{
//If a ',' was found, use its position
//string = sf::String(uses.begin() + begin, uses.begin() + last);
string = uses.substring(begin, last - begin);
}
//Check for module names
if (string == L"G2D")
{
SFG::Pointer<ModuleG2D> ptr(new ModuleG2D());
if (!ptr.isValid())
{
char buf[512];
#ifdef _WIN32
strerror_s(buf, errno);
#else
strerror_r(errno, buf, 512);
#endif // _WIN32
printf("[Error] Failed to create Module G2D in %s:%d: %s\n", __FILE__, __LINE__, buf);
return -3;
}
GS_ptr->addModule(ptr);
}
else
{
//#TODO: Add more modules (sound etc.)
STILL_TO_DO(__FILE__, __LINE__);
}
if(last != sf::String::InvalidPos) begin = last + 1; //if a ',' was found, go search on for the next one
else begin = last; //Meaning begin is sf::String::npos
//.........这里部分代码省略.........
开发者ID:cwriter,项目名称:SFMLGame,代码行数:101,代码来源:Game.cpp
示例8: main
int main(int argc, char* argv[]) {
using Test = venum::Enum
::Variant<std::string>
::Variant<int>
::Variant<Thing>;
std::vector<Test> v;
v.emplace_back(7);
v.emplace_back("Hello");
v.emplace_back(5);
v.emplace_back(5, 'a');
for(auto& t : v) {
t.match(
[](std::string& s) { std::cout << "string: " << s << std::endl; },
[](int& i) { std::cout << "int: " << i << std::endl; },
[](Thing& t) { std::cout << "thing: " << t.i << ", " << t.c << std::endl; }
);
std::cout << std::endl;
}
venum::Enum::Variant<int>::Variant<std::string>(7).apply([](auto a) { std::cout << a << std::endl; });
using Test2 = venum::Enum::Variant<int*>::Variant<int>::Variant<char>;
int z = 67;
Test2 a(5);
Test2 b('c');
Test2 ptr(&z);
auto c = Test2::construct<char>(47);
a.match(
[](int* i) { std::cout << "int* " << *i << std::endl; },
[](int& i) { std::cout << "int: " << i << std::endl; },
[](char& c) { std::cout << "char: " << c << std::endl; }
);
b.match(
[](int* i) { std::cout << "int* " << *i << std::endl; },
[](int& i) { std::cout << "int: " << i << std::endl; },
[](char& c) { std::cout << "char: " << c << std::endl; }
);
ptr.match(
[](int* i) { std::cout << "int* " << *i << std::endl; },
[](int& i) { std::cout << "int: " << i << std::endl; },
[](char& c) { std::cout << "char: " << c << std::endl; }
);
std::string s2 = a.match(
[](int* i) { std::ostringstream str; str << "int*: " << i; return str.str(); },
[](int i) { std::ostringstream str; str << "int: " << i; return str.str(); },
[](char c) { std::ostringstream str; str << "char: " << c; return str.str(); }
);
c.match(
[](int* i) { std::cout << "int* " << *i << std::endl; },
[](int& i) { std::cout << "int: " << i << std::endl; },
[](char& c) { std::cout << "char: " << c << std::endl; }
);
std::cout << c.which() << " " << c.contains<char>() << " " << c.contains<int>() << std::endl;
try {
std::cout << "not a real int: " << c.get<int>() << std::endl;
} catch(std::exception& e) {
std::cout << e.what() << std::endl;
}
std::cout << "not a real int: " << c.get_unchecked<int>() << std::endl;
// Optional Test
auto o = Optional<int>::Some(6);
if(o) {
std::cout << o.get() << std::endl;
}
try {
Optional<std::string>::None().get();
} catch(std::exception& e) {
std::cout << e.what() << std::endl;
}
std::string s = o.map([](int i) { return std::to_string(i); }).match(
[](None) { return std::string(""); },
[](std::string s) { return s; }
);
std::cout << "result: " << s << std::endl;
o.and_then([](int i) { return Optional<float>::None(); });
std::cout << std::endl;
// Tree Test
Tree<int> tree;
tree.insert(5);
tree.insert(2);
tree.insert(7);
//.........这里部分代码省略.........
开发者ID:phookit,项目名称:cpp-enum-variant,代码行数:101,代码来源:test.cpp
示例9: ptr
CppObject * operator->() { return ptr(); }
开发者ID:GaloMALDONADO,项目名称:pinocchio,代码行数:1,代码来源:handler.hpp
示例10: numval
static jl_value_t *scm_to_julia_(value_t e, int eo)
{
if (fl_isnumber(e)) {
int64_t i64;
if (isfixnum(e)) {
i64 = numval(e);
}
else {
assert(iscprim(e));
cprim_t *cp = (cprim_t*)ptr(e);
numerictype_t nt = cp_numtype(cp);
switch (nt) {
case T_DOUBLE:
return (jl_value_t*)jl_box_float64(*(double*)cp_data(cp));
case T_FLOAT:
return (jl_value_t*)jl_box_float32(*(float*)cp_data(cp));
case T_UINT8:
return (jl_value_t*)jl_box_uint8(*(uint8_t*)cp_data(cp));
case T_UINT16:
return (jl_value_t*)jl_box_uint16(*(uint16_t*)cp_data(cp));
case T_UINT32:
return (jl_value_t*)jl_box_uint32(*(uint32_t*)cp_data(cp));
case T_UINT64:
return (jl_value_t*)jl_box_uint64(*(uint64_t*)cp_data(cp));
default:
;
}
i64 = conv_to_int64(cp_data(cp), nt);
}
if (
#ifdef _P64
jl_compileropts.int_literals==32
#else
jl_compileropts.int_literals!=64
#endif
) {
if (i64 > (int64_t)S32_MAX || i64 < (int64_t)S32_MIN)
return (jl_value_t*)jl_box_int64(i64);
return (jl_value_t*)jl_box_int32((int32_t)i64);
}
else {
return (jl_value_t*)jl_box_int64(i64);
}
}
if (issymbol(e)) {
if (e == true_sym)
return jl_true;
else if (e == false_sym)
return jl_false;
return (jl_value_t*)scmsym_to_julia(e);
}
if (fl_isstring(e)) {
return jl_pchar_to_string((char*)cvalue_data(e), cvalue_len(e));
}
if (e == FL_F) {
return jl_false;
}
if (e == FL_T) {
return jl_true;
}
if (e == FL_NIL) {
return (jl_value_t*)jl_null;
}
if (iscons(e)) {
value_t hd = car_(e);
if (issymbol(hd)) {
jl_sym_t *sym = scmsym_to_julia(hd);
/* tree node types:
goto gotoifnot label return
lambda call = quote
null top method
body file new
line enter leave
*/
size_t n = llength(e)-1;
size_t i;
if (sym == null_sym && n == 0)
return jl_nothing;
if (sym == lambda_sym) {
jl_expr_t *ex = jl_exprn(lambda_sym, n);
e = cdr_(e);
value_t largs = car_(e);
jl_cellset(ex->args, 0, full_list(largs,eo));
e = cdr_(e);
value_t ee = car_(e);
jl_array_t *vinf = jl_alloc_cell_1d(3);
jl_cellset(vinf, 0, full_list(car_(ee),eo));
ee = cdr_(ee);
jl_cellset(vinf, 1, full_list_of_lists(car_(ee),eo));
ee = cdr_(ee);
jl_cellset(vinf, 2, full_list_of_lists(car_(ee),eo));
assert(!iscons(cdr_(ee)));
jl_cellset(ex->args, 1, vinf);
e = cdr_(e);
for(i=2; i < n; i++) {
assert(iscons(e));
jl_cellset(ex->args, i, scm_to_julia_(car_(e), eo));
e = cdr_(e);
//.........这里部分代码省略.........
开发者ID:YellowApple,项目名称:julia-lite,代码行数:101,代码来源:ast.c
示例11: fl_current_julia_module
value_t fl_current_julia_module(value_t *args, uint32_t nargs)
{
value_t opaque = cvalue(jvtype, sizeof(void*));
*(jl_value_t**)cv_data((cvalue_t*)ptr(opaque)) = (jl_value_t*)jl_current_module;
return opaque;
}
开发者ID:YellowApple,项目名称:julia-lite,代码行数:6,代码来源:ast.c
示例12: ASN1_STRING_type
inline int string::type()
{
return ASN1_STRING_type(ptr().get());
}
开发者ID:RushOnline,项目名称:libcryptoplus,代码行数:4,代码来源:string.hpp
示例13: set_data
inline void string::set_data(const char* _data)
{
error::throw_error_if_not(ASN1_STRING_set(ptr().get(), _data, -1) != 0);
}
开发者ID:RushOnline,项目名称:libcryptoplus,代码行数:4,代码来源:string.hpp
示例14: CALL_LISTENERS
void CSourcePython::OnEdictFreed( const edict_t *edict )
{
CALL_LISTENERS(OnEdictFreed, ptr(edict));
}
开发者ID:KirillMysnik,项目名称:Source.Python,代码行数:4,代码来源:sp_main.cpp
示例15: clamp
void Texture::set_pixel(const int32_t x, const int32_t y, const D3DXCOLOR& col)
{
const int32_t safe_x = clamp(x, 0, _width-1);
const int32_t safe_y = clamp(y, 0, _height-1);
*ptr(safe_x, safe_y) = col;
}
开发者ID:mrdooz,项目名称:TextureTjong,代码行数:6,代码来源:Texture.cpp
示例16: t5
void t5 () {
extern char *ptr();
free(ptr()); // no-warning
}
开发者ID:Bekenn,项目名称:clang,代码行数:4,代码来源:free.c
示例17: ptr
// -----------------------------------------------------------------------------
// CSdpOriginField::InternalizeL
// Internalizes from stream
// -----------------------------------------------------------------------------
//
CSdpOriginField* CSdpOriginField::InternalizeL(
RReadStream& aStream )
{
RStringPool pool = SdpCodecStringPool::StringPoolL();
// <username>
TUint32 length = aStream.ReadUint32L();
HBufC8* userName = HBufC8::NewLC( length );
TPtr8 ptr( userName->Des() );
aStream.ReadL( ptr, length );
// <session id>
length = aStream.ReadUint32L();
HBufC8* sessionId = HBufC8::NewLC( length );
ptr.Set( sessionId->Des() );
aStream.ReadL( ptr, length );
// <version>
length = aStream.ReadUint32L();
HBufC8* version = HBufC8::NewLC( length );
ptr.Set( version->Des() );
aStream.ReadL( ptr, length );
// <network type>
length = aStream.ReadUint32L();
HBufC8* netType = HBufC8::NewLC( length );
ptr.Set( netType->Des() );
aStream.ReadL( ptr, length );
// <address type>
length = aStream.ReadUint32L();
HBufC8* addrType = HBufC8::NewLC( length );
ptr.Set( addrType->Des() );
aStream.ReadL( ptr, length );
// <address>
length = aStream.ReadUint32L();
HBufC8* address = HBufC8::NewLC( length );
TPtr8 ptr2( address->Des() );
aStream.ReadL( ptr2, length );
RStringF netTypeStr = pool.OpenFStringL( *netType );
RStringF addrTypeStr = pool.OpenFStringL( *addrType );
CleanupClosePushL( netTypeStr );
CleanupClosePushL( addrTypeStr );
CSdpOriginField* obj = CSdpOriginField::NewLC( *userName, KDummyValue,
KDummyValue, netTypeStr,
addrTypeStr, *address );
// Set the real values
obj->OriginFieldPtrs().SetSessionIdL( *sessionId );
obj->OriginFieldPtrs().SetSessionVersionL( *version );
CleanupStack::Pop( obj );
CleanupStack::Pop( 2 ); // addrTypeStr, netTypeStr
CleanupStack::PopAndDestroy( address );
CleanupStack::PopAndDestroy( addrType );
CleanupStack::PopAndDestroy( netType );
CleanupStack::PopAndDestroy( version );
CleanupStack::PopAndDestroy( sessionId );
CleanupStack::PopAndDestroy( userName );
return obj;
}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:68,代码来源:sdporiginfield.cpp
示例18: inline_through_me
void
inline_through_me (void (*ptr)(void))
{
ptr();
}
开发者ID:AlexMioMio,项目名称:gcc,代码行数:5,代码来源:inline-3.c
示例19: CUdeviceptr
operator CUdeviceptr()
{ return ptr(); }
开发者ID:DirkHaehnel,项目名称:pycuda,代码行数:2,代码来源:mempool.cpp
示例20: t2
// just a sanity test, the same behavior as t1()
char t2 () {
*ptr() = 'c';
return '0';
}
开发者ID:5432935,项目名称:crossbridge,代码行数:5,代码来源:reference.cpp
注:本文中的ptr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论