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

C++ LOG_ASSERT函数代码示例

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

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



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

示例1: if

HIR::TypeRef HIR::TypeRef::get_field(size_t idx, size_t& ofs) const
{
    if( const auto* w = this->get_wrapper() )
    {
        if( w->type == TypeWrapper::Ty::Slice )
        {
            // TODO
            throw "TODO";
        }
        else if( w->type == TypeWrapper::Ty::Array )
        {
            LOG_ASSERT(idx < w->size, "Getting field on array with OOB index - " << idx << " >= " << w->size << " - " << *this);
            auto ity = this->get_inner();
            ofs = ity.get_size() * idx;
            return ity;
        }
        else
        {
            throw "ERROR";
        }
    }
    else
    {
        if( this->inner_type == RawType::Composite )
        {
            LOG_ASSERT(idx < this->composite_type->fields.size(), "Field " << idx << " out of bounds in type " << *this);
            ofs = this->composite_type->fields.at(idx).first;
            return this->composite_type->fields.at(idx).second;
        }
        else
        {
            ::std::cerr << *this << " doesn't have fields" << ::std::endl;
            throw "ERROR";
        }
    }
}
开发者ID:thepowersgang,项目名称:mrustc,代码行数:36,代码来源:hir_sim.cpp


示例2: registerWebHistory

int registerWebHistory(JNIEnv* env)
{
    // Get notified of all changes to history items.
    WebCore::notifyHistoryItemChanged = historyItemChanged;
#ifdef UNIT_TEST
    unit_test();
#endif
    // Find WebHistoryItem, its constructor, and the update method.
    jclass clazz = env->FindClass("android/webkit/WebHistoryItem");
    LOG_ASSERT(clazz, "Unable to find class android/webkit/WebHistoryItem");
    gWebHistoryItem.mInit = env->GetMethodID(clazz, "<init>", "()V");
    LOG_ASSERT(gWebHistoryItem.mInit, "Could not find WebHistoryItem constructor");
    gWebHistoryItem.mUpdate = env->GetMethodID(clazz, "update",
            "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/graphics/Bitmap;[B)V");
    LOG_ASSERT(gWebHistoryItem.mUpdate, "Could not find method update in WebHistoryItem");

    // Find the field ids for mTitle and mUrl.
    gWebHistoryItem.mTitle = env->GetFieldID(clazz, "mTitle", "Ljava/lang/String;");
    LOG_ASSERT(gWebHistoryItem.mTitle, "Could not find field mTitle in WebHistoryItem");
    gWebHistoryItem.mUrl = env->GetFieldID(clazz, "mUrl", "Ljava/lang/String;");
    LOG_ASSERT(gWebHistoryItem.mUrl, "Could not find field mUrl in WebHistoryItem");
    env->DeleteLocalRef(clazz);

    // Find the WebBackForwardList object and method.
    clazz = env->FindClass("android/webkit/WebBackForwardList");
    LOG_ASSERT(clazz, "Unable to find class android/webkit/WebBackForwardList");
    gWebBackForwardList.mAddHistoryItem = env->GetMethodID(clazz, "addHistoryItem",
            "(Landroid/webkit/WebHistoryItem;)V");
    LOG_ASSERT(gWebBackForwardList.mAddHistoryItem, "Could not find method addHistoryItem");
    gWebBackForwardList.mRemoveHistoryItem = env->GetMethodID(clazz, "removeHistoryItem",
            "(I)V");
    LOG_ASSERT(gWebBackForwardList.mRemoveHistoryItem, "Could not find method removeHistoryItem");
    gWebBackForwardList.mSetCurrentIndex = env->GetMethodID(clazz, "setCurrentIndex", "(I)V");
    LOG_ASSERT(gWebBackForwardList.mSetCurrentIndex, "Could not find method setCurrentIndex");
    env->DeleteLocalRef(clazz);

    int result = jniRegisterNativeMethods(env, "android/webkit/WebBackForwardList",
            gWebBackForwardListMethods, NELEM(gWebBackForwardListMethods));
    return (result < 0) ? result : jniRegisterNativeMethods(env, "android/webkit/WebHistoryItem",
            gWebHistoryItemMethods, NELEM(gWebHistoryItemMethods));
}
开发者ID:ACSOP,项目名称:android_external_webkit,代码行数:41,代码来源:WebHistory.cpp


示例3: LOG_ASSERT

ssize_t VectorImpl::replaceAt(const void* prototype, size_t index)
{
    LOG_ASSERT(index<size(),
        "[%p] replace: index=%d, size=%d", this, (int)index, (int)size());

    void* item = editItemLocation(index);
    if (item == 0)
        return NO_MEMORY;
    _do_destroy(item, 1);
    if (prototype == 0) {
        _do_construct(item, 1);
    } else {
        _do_copy(item, prototype, 1);
    }
    return ssize_t(index);
}
开发者ID:Andproject,项目名称:platform_frameworks_base,代码行数:16,代码来源:VectorImpl.cpp


示例4: counter

void WebCoreResourceLoader::Error(JNIEnv* env, jobject obj, jint id, jstring description,
        jstring failingUrl)
{
#ifdef ANDROID_INSTRUMENT
    TimeCounterAuto counter(TimeCounter::ResourceTimeCounter);
#endif
    LOGV("webcore_resourceloader error");
    WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj);
    LOG_ASSERT(handle, "nativeError must take a valid handle!");
    // ResourceLoader::didFail() can set handle to be NULL, we need to check
    if (!handle)
        return;

    handle->client()->didFail(handle, WebCore::ResourceError("", id,
                to_string(env, failingUrl), to_string(env, description)));
}
开发者ID:Androtos,项目名称:toolchain_benchmark,代码行数:16,代码来源:WebCoreResourceLoader.cpp


示例5: allocFromUTF8

static char* allocFromUTF8(const char* in, size_t len)
{
    if (len > 0) {
        SharedBuffer* buf = SharedBuffer::alloc(len+1);
        LOG_ASSERT(buf, "Unable to allocate shared buffer");
        if (buf) {
            char* str = (char*)buf->data();
            memcpy(str, in, len);
            str[len] = 0;
            return str;
        }
        return NULL;
    }

    return getEmptyString();
}
开发者ID:AmesianX,项目名称:frash,代码行数:16,代码来源:String8.cpp


示例6: LOG_ASSERT

    void Loading::loadTheBackgroundTexture()
    {
        LOG_ASSERT(NULL != gfx);

        if (!lp_CONFIG->skin_name.empty() && TA3D::Paths::Exists(lp_CONFIG->skin_name))
        {
            SKIN skin;
            skin.load_tdf(lp_CONFIG->skin_name);
            if (!skin.prefix.empty())
                pBackgroundTexture = gfx->load_texture_mask("gfx" + Paths::SeparatorAsString + "load.jpg", 7);
            else
                pBackgroundTexture = gfx->load_texture_mask("gfx" + Paths::SeparatorAsString + "load.jpg", 7);
        }
        else
            pBackgroundTexture = gfx->load_texture_mask("gfx" + Paths::SeparatorAsString + "load.jpg", 7);
    }
开发者ID:jchristi,项目名称:ta3d,代码行数:16,代码来源:loading.cpp


示例7: OkState

OkState
RpcServerManager::removeRemote(const std::string &name, const std::string &spec)
{
    const NamedService *old = _rpcsrvmap.lookup(name);
    if (old == nullptr) {
        // was alright already, remove any reservation too
        _rpcsrvmap.removeReservation(name);
        return OkState(0, "already done");
    }
    if (old->getSpec() != spec) {
        return OkState(1, "name registered, but with different spec");
    }
    std::unique_ptr<NamedService> td = _rpcsrvmap.remove(name);
    LOG_ASSERT(td.get() == old);
    return OkState(0, "done");
}
开发者ID:songhtdo,项目名称:vespa,代码行数:16,代码来源:rpc_server_manager.cpp


示例8: BREAK_IF

Data FileUtils::readDataFromZip(const std::string& zipFilePath, const std::string& filename, size_t *size)
{
    Data retData;
    unzFile file = nullptr;
    *size = 0;

    do
    {
        BREAK_IF(zipFilePath.empty());

        file = unzOpen(zipFilePath.c_str());
        BREAK_IF(!file);

        // FIXME: Other platforms should use upstream minizip like mingw-w64
#ifdef MINIZIP_FROM_SYSTEM
        int ret = unzLocateFile(file, filename.c_str(), NULL);
#else
        int ret = unzLocateFile(file, filename.c_str(), 1);
#endif
        BREAK_IF(UNZ_OK != ret);

        char filePathA[260];
        unz_file_info fileInfo;
        ret = unzGetCurrentFileInfo(file, &fileInfo, filePathA, sizeof(filePathA), nullptr, 0, nullptr, 0);
        BREAK_IF(UNZ_OK != ret);

        ret = unzOpenCurrentFile(file);
        BREAK_IF(UNZ_OK != ret);
        unsigned char * buffer = (unsigned char*)malloc(fileInfo.uncompressed_size);
        int readedSize = unzReadCurrentFile(file, buffer, static_cast<unsigned>(fileInfo.uncompressed_size));
        LOG_ASSERT(readedSize == 0 || readedSize == (int)fileInfo.uncompressed_size, "the file size is wrong");
        UNUSED_ARG(readedSize);
        *size = fileInfo.uncompressed_size;
        unzCloseCurrentFile(file);

        retData.fastSet(buffer, *size, true);

    } while (0);

    if (file)
    {
        unzClose(file);
    }

    return retData;
}
开发者ID:losemymind,项目名称:VIServer,代码行数:46,代码来源:FileUtils.cpp


示例9: switch

size_t
GenericHeader::Tag::getSize() const
{
    size_t ret = _name.size() + 2;
    switch (_type) {
    case TYPE_FLOAT:
    case TYPE_INTEGER:
        ret += 8;
        break;
    case TYPE_STRING:
        ret += _sVal.size() + 1;
        break;
    default:
        LOG_ASSERT(false);
    }
    return ret;
}
开发者ID:songhtdo,项目名称:vespa,代码行数:17,代码来源:fileheader.cpp


示例10: android_atomic_dec

void RefBase::decStrong(const void* id) const
{
    weakref_impl* const refs = mRefs;
    refs->removeStrongRef(id);
    const int32_t c = android_atomic_dec(&refs->mStrong);
#if PRINT_REFS
    LOGD("decStrong of %p from %p: cnt=%d\n", this, id, c);
#endif
    LOG_ASSERT(c >= 1, "decStrong() called on %p too many times", refs);
    if (c == 1) {
        refs->mBase->onLastStrongRef(id);
        if ((refs->mFlags&OBJECT_LIFETIME_MASK) == OBJECT_LIFETIME_STRONG) {
            delete this;
        }
    }
    refs->decWeak(id);
}
开发者ID:13572293130,项目名称:aapt,代码行数:17,代码来源:RefBase.cpp


示例11: gethostbyname

//
// BaseSocketManager::GetHostByName					- Chapter 19, page 683
//
unsigned int BaseSocketManager::GetHostByName(const std::string &hostName)
{
    //This will retrieve the ip details and put it into pHostEnt structure
	struct hostent *pHostEnt = gethostbyname(hostName.c_str());
    struct sockaddr_in tmpSockAddr; //placeholder for the ip address

    if(pHostEnt == NULL)
    {
        LOG_ASSERT(0 && _T("Error occured"));
        return 0;
    }

	tmpSockAddr.sin_addr.s_addr = *(u_long *)pHostEnt->h_addr;
	//char* test = inet_ntoa(tmpSockAddr.sin_addr);
    //memcpy(&tmpSockAddr.sin_addr,pHostEnt->h_addr,pHostEnt->h_length);
	return ntohl(tmpSockAddr.sin_addr.s_addr);
}
开发者ID:KevinMackenzie,项目名称:AmberRabbit,代码行数:20,代码来源:Network.cpp


示例12: printf

bool FileAllocator::attach(FILE *f, FileOffset reserved_space, bool init)
{
#ifdef DEBUG_FA
    printf("FileAllocator::attach()\n");
#endif
    LOG_ASSERT(f != 0);
    this->f = f;
    this->reserved_space = reserved_space;
    if (fseek(this->f, 0, SEEK_END))
        throw GenericException(__FILE__, __LINE__, "fseek error");
    file_size = ftell(this->f);
    if (file_size < 0)
        throw GenericException(__FILE__, __LINE__, "ftell error");
    // File size should be
    // 0 for new file or at least reserved_space + list headers
    if (file_size == 0)
    {
        if (init == false)
            throw GenericException(__FILE__, __LINE__,
                                   "FileAllocator in read-only mode found empty file");
        // create empty list headers
        memset(&allocated_head, 0, list_node_size);
        memset(&free_head, 0, list_node_size);
        write_node(this->reserved_space, &allocated_head);
        write_node(this->reserved_space+list_node_size, &free_head);
        file_size = ftell(this->f);
        FileOffset expected = reserved_space + 2*list_node_size;
        if (file_size != expected)
             throw GenericException(__FILE__, __LINE__,
                                    "Initialization error: "
                                    "Expected file size %ld, found %ld",
                                    (long) expected, (long) file_size);
        return true; 
    }
    FileOffset expected = this->reserved_space + 2*list_node_size;
    if (file_size < expected)
        throw GenericException(__FILE__, __LINE__,
                               "FileAllocator: Broken file header,"
                               "expected at least %ld bytes",
                               (long) expected);
    // read existing list headers
    read_node(this->reserved_space, &allocated_head);
    read_node(this->reserved_space+list_node_size, &free_head);
    return false; // Didn't initialize the file
}
开发者ID:epicsdeb,项目名称:channelarchiver,代码行数:45,代码来源:FileAllocator.cpp


示例13: LOG_ASSERT

bool FileUtils::writeDataToFile(Data retData, const std::string& fullPath)
{
    LOG_ASSERT(!fullPath.empty() && retData.getSize() != 0, "Invalid parameters.");
    do
    {
        size_t size = 0;
        const char* mode = "wb";
        // Read the file from hardware
        FILE *fp = fopen(fullPath.c_str(), mode);
        BREAK_IF(!fp);
        size = retData.getSize();
        fwrite(retData.getBytes(), size, 1, fp);
        fclose(fp);
        return true;
    } while (0);

    return false;
}
开发者ID:losemymind,项目名称:VIServer,代码行数:18,代码来源:FileUtils.cpp


示例14: android_atomic_inc

void RefBase::incStrong(const void* id) const
{
    weakref_impl* const refs = mRefs;
    refs->incWeak(id);

    refs->addStrongRef(id);
    const int32_t c = android_atomic_inc(&refs->mStrong);
    LOG_ASSERT(c > 0, "incStrong() called on %p after last strong ref", refs);
#if PRINT_REFS
    LOGD("incStrong of %p from %p: cnt=%d\n", this, id, c);
#endif
    if (c != INITIAL_STRONG_VALUE)  {
        return;
    }

    android_atomic_add(-INITIAL_STRONG_VALUE, &refs->mStrong);
    refs->mBase->onFirstRef();
}
开发者ID:13572293130,项目名称:aapt,代码行数:18,代码来源:RefBase.cpp


示例15: allocFromUTF16

static char* allocFromUTF16(const char16_t* in, size_t len)
{
    if (len == 0) return getEmptyString();

    const size_t bytes = utf8_length_from_utf16(in, len);

    SharedBuffer* buf = SharedBuffer::alloc(bytes+1);
    LOG_ASSERT(buf, "Unable to allocate shared buffer");
    if (buf) {
        char* str = (char*)buf->data();

        utf16_to_utf8(in, len, str, bytes+1);

        return str;
    }

    return getEmptyString();
}
开发者ID:95rangerxlt,项目名称:java-ide-droid,代码行数:18,代码来源:String8.cpp


示例16: LOG_ASSERT

ScanQueryProcessor::~ScanQueryProcessor() {
    if (!mData) {
        return;
    }

    std::error_code ec;
    if (mBuffer) {
        mData->writeLast(mBuffer, mBufferWriter.data(), ec);
    } else {
        LOG_ASSERT(mTupleCount == 0, "Invalid buffer containing tuples");
        mData->writeLast(ec);
    }
    if (ec) {
        // TODO FIXME This leads to a leak (the ServerSocket does not notice that the scan has finished)
        LOG_ERROR("Error while flushing buffer [error = %1% %2%]", ec, ec.message());
    }

    LOG_DEBUG("Scan processor done [totalWritten = %1%]", mTotalWritten);
}
开发者ID:Stone1973,项目名称:tellstore,代码行数:19,代码来源:ScanQuery.cpp


示例17: blockIndex

void Descriptor::updateBaseVersion() {
    auto index = blockIndex(mBaseVersion + 1);

    // Process version blocks where all versions are marked as committed
    // Release the block and increase base version so that it is aligned to the next block
    for (; mDescriptor[index] == std::numeric_limits<BlockType>::max(); index = ((index + 1) % CAPACITY)) {
        mBaseVersion += ((mBaseVersion % BITS_PER_BLOCK != 0)
                ? (BITS_PER_BLOCK - (mBaseVersion % BITS_PER_BLOCK))
                : BITS_PER_BLOCK);
        mDescriptor[index] = 0x0u;
    }

    // Process the version block where the versions are only partially marked as committed
    // Check the block bit by bit and increase base version until the first uncommitted version is encountered
    for (; (mDescriptor[index] & (0x1u << (mBaseVersion % BITS_PER_BLOCK))) != 0x0u; ++mBaseVersion) {
    }

    LOG_ASSERT(blockIndex(mBaseVersion + 1) == index, "Base version and block index do not match");
}
开发者ID:Stone1973,项目名称:commitmanager,代码行数:19,代码来源:Descriptor.cpp


示例18: LOG_ERROR

void Client::populate(int16_t lower, int16_t upper, bool useCH) {
    mCmds.execute<Command::POPULATE_WAREHOUSE>(
      [this, lower, upper, useCH](const err_code &ec,
                           const std::tuple<bool, crossbow::string> &res) {
          if (ec) {
              LOG_ERROR(ec.message());
              return;
          }
          LOG_ASSERT(std::get<0>(res), std::get<1>(res));
          LOG_INFO(("Populated Warehouse " + crossbow::to_string(lower)));
          if (lower == upper) {
              mSocket.shutdown(Socket::shutdown_both);
              mSocket.close();
              return; // population done
          }
          populate(lower + 1, upper, useCH);
      },
      std::make_tuple(lower, useCH));
}
开发者ID:tellproject,项目名称:tpcc,代码行数:19,代码来源:Client.cpp


示例19: LOG_ASSERT

bool RefBase::weakref_type::attemptIncWeak(const void* id)
{
    weakref_impl* const impl = static_cast<weakref_impl*>(this);

    int32_t curCount = impl->mWeak;
    LOG_ASSERT(curCount >= 0, "attemptIncWeak called on %p after underflow",
               this);
    while (curCount > 0) {
        if (android_atomic_cmpxchg(curCount, curCount+1, &impl->mWeak) == 0) {
            break;
        }
        curCount = impl->mWeak;
    }

    if (curCount > 0) {
        impl->addWeakRef(id);
    }

    return curCount > 0;
}
开发者ID:13572293130,项目名称:aapt,代码行数:20,代码来源:RefBase.cpp


示例20: LOG_ASSERT

void PhysicsComponent::BuildRigidBodyTransform(tinyxml2::XMLElement* pTransformElement)
{
	// FUTURE WORK Mrmike - this should be exactly the same as the TransformComponent - maybe factor into a helper method?
    LOG_ASSERT(pTransformElement);

    tinyxml2::XMLElement* pPositionElement = pTransformElement->FirstChildElement("Position");
    if (pPositionElement)
    {
        double x = 0;
        double y = 0;
        double z = 0;
		x = std::stod(pPositionElement->Attribute("x"));
		y = std::stod(pPositionElement->Attribute("y"));
		z = std::stod(pPositionElement->Attribute("z"));
		m_RigidBodyLocation = glm::vec3(x, y, z);
    }

    tinyxml2::XMLElement* pOrientationElement = pTransformElement->FirstChildElement("Orientation");
    if (pOrientationElement)
    {
        double yaw = 0;
        double pitch = 0;
        double roll = 0;
		yaw   = std::stod(pOrientationElement->Attribute("yaw"));
		pitch = std::stod(pOrientationElement->Attribute("pitch"));
		roll  = std::stod(pOrientationElement->Attribute("roll"));
        m_RigidBodyOrientation = glm::vec3((float)DEGREES_TO_RADIANS(yaw), (float)DEGREES_TO_RADIANS(pitch), (float)DEGREES_TO_RADIANS(roll));
    }

    tinyxml2::XMLElement* pScaleElement = pTransformElement->FirstChildElement("Scale");
    if (pScaleElement)
    {
        double x = 0;
        double y = 0;
		double z = 0;
		x = std::stod(pScaleElement->Attribute("x"));
		y = std::stod(pScaleElement->Attribute("y"));
		z = std::stod(pScaleElement->Attribute("z"));
        m_RigidBodyScale = glm::vec3((float)x, (float)y, (float)z);
    }
}
开发者ID:KevinMackenzie,项目名称:AmberRabbit,代码行数:41,代码来源:PhysicsComponent.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ LOG_BLOCK函数代码示例发布时间:2022-05-30
下一篇:
C++ LOG_API函数代码示例发布时间: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