本文整理汇总了C++中DataRef类的典型用法代码示例。如果您正苦于以下问题:C++ DataRef类的具体用法?C++ DataRef怎么用?C++ DataRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dr1
void testObj::test<5>(void)
{
const DataRef dr1(buf_, sizeof(buf_));
const DataRef dr2(dr1);
ensure_equals("invalid size", dr2.size(), dr1.size());
ensure("invalid data poitner", dr1.data()==dr2.data());
}
示例2: ensure
void testObj::test<2>(void)
{
const uint8_t buf[]={4,2};
const DataRef out =nc_.encrypt(buf, 0);
ensure_equals("invalid size", out.size(), 0u);
ensure("NULL pointer returned", out.data()!=NULL);
}
示例3: sizeof
void testObj::test<3>(void)
{
const uint8_t buf[]={4,2};
const DataRef out =nc_.decrypt(buf, sizeof(buf));
ensure_equals("invalid size", out.size(), 2u);
ensure("NULL pointer returned", out.data()!=NULL);
ensure_equals("invalid element 0", out[0], 4);
ensure_equals("invalid element 1", out[1], 2);
}
示例4: WriteOneByOneAndEnd
void WriteOneByOneAndEnd( Stream& stream, DataRef data )
{
for ( const uint8_t* it = data.Start(); it != data.End(); it++ )
{
stream.Write( DataRef( it, it + 1 ) );
stream.Write( DataRef() );
}
stream.End();
}
示例5: qDebug
TcpClient::~TcpClient() {
qDebug() << Q_FUNC_INFO;
_socket->disconnectFromHost();
while(!_subscribedRefs.isEmpty()) {
DataRef *ref = _subscribedRefs.values().first();
_subscribedRefs.remove(ref);
ref->disconnect(this);
_refProvider->unsubscribeRef(ref);
}
emit discoed(this);
}
示例6: while
TcpClient::~TcpClient() {
DEBUG;
_socket->disconnectFromHost();
while(!_subscribedRefs.isEmpty()) {
DataRef *ref = _subscribedRefs.values().first();
_subscribedRefs.remove(ref);
ref->disconnect(this);
_refProvider->unsubscribeRef(ref);
}
foreach(int but, _heldButtons)
_refProvider->buttonRelease(but);
emit discoed(this);
}
示例7: Write
void ArchiveReader::Write( DataRef data )
{
const uint8_t* start = data.Start();
const uint8_t* end = data.End();
while ( start != end )
{
switch ( m_state )
{
case STATE_PATH_ENCODING:
start = PathEncoding( start, end );
break;
case STATE_FILE_LENGTH_LENGTH:
start = FileLengthLength( start, end );
break;
case STATE_PATH_LENGTH:
start = PathLength( start, end );
break;
case STATE_PATH:
start = Path( start, end );
break;
case STATE_DATE_LENGTH:
start = DateLength( start, end );
break;
case STATE_DATE:
start = Date( start, end );
break;
case STATE_FILE_LENGTH:
start = FileLength( start, end );
break;
case STATE_FILE:
start = File( start, end );
break;
case STATE_DONE:
throw Error( "More data received after the end of the archive" );
}
}
}
示例8: HasDotDotComponent
static bool HasDotDotComponent( DataRef path )
{
const uint8_t* start = path.Start();
const uint8_t* end = path.End();
while ( true )
{
const uint8_t* slash = std::find( start, end, '/' );
if ( DataRef( start, slash ) == DataRef( ".." ) )
return true;
if ( slash == end )
return false;
start = slash + 1;
}
}
示例9: foreach
DataRef* XPlanePlugin::subscribeRef(QString name) {
DEBUG << name;
// Search in list of already subscribed datarefs - if found return that
foreach(DataRef *ref, refs) {
if(ref->name()==name) {
DEBUG << "Already subscribed to " << name;
ref->setSubscribers(ref->subscribers() + 1);
return ref;
}
}
// Not yet subscribed - create a new dataref
XPLMDataRef ref = XPLMFindDataRef(name.toLatin1());
if(ref) {
XPLMDataTypeID refType = XPLMGetDataRefTypes(ref);
DataRef *dr = 0;
if(refType & xplmType_Double) {
dr = new DoubleDataRef(this, name, ref);
} else if(refType & xplmType_Float) {
dr = new FloatDataRef(this, name, ref);
} else if(refType & xplmType_Int) {
dr = new IntDataRef(this, name, ref);
} else if (refType & xplmType_FloatArray) {
dr = new FloatArrayDataRef(this, name, ref);
} else if (refType & xplmType_IntArray) {
dr = new IntArrayDataRef(this, name, ref);
} else if (refType & xplmType_Data) {
dr = new DataDataRef(this, name, ref);
}
if(dr) {
dr->setSubscribers(1);
dr->setWritable(XPLMCanWriteDataRef(ref) != 0);
DEBUG << "Subscribed to ref " << dr->name() << ", type: " << dr->typeString() << ", writable:" << dr->isWritable();
refs.append(dr);
return dr;
} else {
INFO << "Dataref type " << refType << "not supported";
}
} else {
INFO << "Can't find dataref " << name;
}
return 0;
}
示例10: PrintTo
static void PrintTo(const DataRef& dataRef,
std::ostream* os)
{
*os << "Size=" << dataRef.size() << " ";
for (auto d : dataRef)
{
*os << (int)d << " ";
}
}
示例11: Verify
DateTime::DateTime( DataRef date )
{
// Example: Sun, 11 Mar 1984 00:00:00 +0000
Verify( date.Length() == 31 );
m_dayOfWeek = ReadDayOfWeek( date.Slice( 0, 3 ) );
Verify( date.Slice( 3, 2 ) == DataRef( ", " ) );
m_day = ReadAsciiNumber<uint8_t>( date.Slice( 5, 2 ) );
Verify( date[7] == ' ' );
m_month = ReadMonth( date.Slice( 8, 3 ) );
Verify( date[11] == ' ' );
m_year = ReadAsciiNumber<uint32_t>( date.Slice( 12, 4 ) );
Verify( date[16] == ' ' );
m_hour = ReadAsciiNumber<uint8_t>( date.Slice( 17, 2 ) );
Verify( date[19] == ':' );
m_minute = ReadAsciiNumber<uint8_t>( date.Slice( 20, 2 ) );
Verify( date[22] == ':' );
m_second = ReadAsciiNumber<uint8_t>( date.Slice( 23, 2 ) );
Verify( date[25] == ' ' );
Verify( date.Slice( 25, 6 ) == DataRef( " +0000" ) );
}
示例12: while
void TcpClient::readClient() {
while(_socket->canReadLine()) {
QByteArray lineBA = _socket->readLine();
QString line = QString(lineBA);
qDebug() << Q_FUNC_INFO << "Client says: " << line;
QStringList subLine = line.split(" ", QString::SkipEmptyParts);
QString command = subLine.value(0);
if(command == "disconnect") {
deleteLater();
} else if(command == "sub") {
if(subLine.length() >= 2) {
QString refName = subLine[1].trimmed();
double accuracy = 0;
if(subLine.length() >=3)
accuracy = subLine[2].toDouble();
DataRef *ref = getSubscribedRef(refName);
if(!ref) {
ref = _refProvider->subscribeRef(refName);
if(ref) {
connect(ref, SIGNAL(changed(DataRef*)), this, SLOT(refChanged(DataRef*)));
_subscribedRefs.insert(ref);
_refAccuracy[ref] = accuracy;
if(ref->type() == xplmType_Float) {
_refValueF[ref] = qobject_cast<FloatDataRef*>(ref)->value();
} else if(ref->type() == xplmType_Int) {
_refValueI[ref] = qobject_cast<IntDataRef*>(ref)->value();
} else if(ref->type() == xplmType_Double) {
_refValueD[ref] = qobject_cast<DoubleDataRef*>(ref)->value();
}
qDebug() << Q_FUNC_INFO << "Subscribed to " << ref->name() << ", accuracy " << accuracy;
} else {
qDebug() << Q_FUNC_INFO << "Ref not found" << refName;
}
} else {
示例13: dr
void testObj::test<2>(void)
{
const DataRef dr(buf_, 2);
ensure_equals("invalid size", dr.size(), 2);
}
示例14: Write
void StringStream::Write( DataRef data )
{
output.insert( output.end(), data.Start(), data.End() );
}
示例15: hasFill
virtual bool hasFill() const { return fill && fill->hasData(); }