当前位置: 首页>>代码示例>>C++>>正文


C++ LOG_ASSERT函数代码示例

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


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


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