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

C++ Error_set_str函数代码示例

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

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



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

示例1: discover_repository

PyObject *
discover_repository(PyObject *self, PyObject *args)
{
    git_buf repo_path = {NULL};
    const char *path;
    PyObject *py_repo_path;
    int across_fs = 0;
    const char *ceiling_dirs = NULL;
    int err;

    if (!PyArg_ParseTuple(args, "s|Is", &path, &across_fs, &ceiling_dirs))
        return NULL;

    memset(&repo_path, 0, sizeof(git_buf));
    err = git_repository_discover(&repo_path, path, across_fs, ceiling_dirs);
    if (err == GIT_ENOTFOUND)
        Py_RETURN_NONE;
    if (err < 0)
        return Error_set_str(err, path);

    py_repo_path = to_path(repo_path.ptr);
    git_buf_dispose(&repo_path);

    return py_repo_path;
};
开发者ID:PKRoma,项目名称:pygit2,代码行数:25,代码来源:pygit2.c


示例2: init_file_backend

PyObject *
init_file_backend(PyObject *self, PyObject *args)
{
    const char* path = NULL;
    int err = GIT_OK;
    git_repository *repository = NULL;
    if (!PyArg_ParseTuple(args, "s", &path)) {
        return NULL;
    }

    err = git_repository_open(&repository, path);
    if (err < 0) {
        Error_set_str(err, path);
        goto cleanup;
    }

    return PyCapsule_New(repository, "backend", NULL);

cleanup:
    if (repository) {
        git_repository_free(repository);
    }

    if (err == GIT_ENOTFOUND) {
        PyErr_Format(GitError, "Repository not found at %s", path);
    }

    return NULL;
}
开发者ID:PKRoma,项目名称:pygit2,代码行数:29,代码来源:pygit2.c


示例3: Index_add

PyObject *
Index_add(Index *self, PyObject *args)
{
    int err;
    const char *path;
    IndexEntry *py_entry;

    if (PyArg_ParseTuple(args, "O!", &IndexEntryType, &py_entry)) {
        err = git_index_add(self->index, &py_entry->entry);
        if (err < 0)
            return Error_set(err);

        Py_RETURN_NONE;
    }
    PyErr_Clear();

    if (!PyArg_ParseTuple(args, "s", &path))
        return NULL;

    err = git_index_add_bypath(self->index, path);
    if (err < 0)
        return Error_set_str(err, path);

    Py_RETURN_NONE;
}
开发者ID:flowroute,项目名称:pygit2,代码行数:25,代码来源:index.c


示例4: Repository_head__set__

int
Repository_head__set__(Repository *self, PyObject *py_val)
{
    int err;
    if (PyObject_TypeCheck(py_val, &OidType)) {
        git_oid oid;
        py_oid_to_git_oid(py_val, &oid);
        err = git_repository_set_head_detached(self->repo, &oid, NULL, NULL);
        if (err < 0) {
            Error_set(err);
            return -1;
        }
    } else {
        const char *refname;
        PyObject *trefname;

        refname = py_str_borrow_c_str(&trefname, py_val, NULL);
        if (refname == NULL)
            return -1;

        err = git_repository_set_head(self->repo, refname, NULL, NULL);
        Py_DECREF(trefname);
        if (err < 0) {
            Error_set_str(err, refname);
            return -1;
        }
    }

    return 0;
}
开发者ID:ArnoVanLumig,项目名称:pygit2,代码行数:30,代码来源:repository.c


示例5: Repository_revparse_single

PyObject *
Repository_revparse_single(Repository *self, PyObject *py_spec)
{
    git_object *c_obj;
    char *c_spec;
    char *encoding = "ascii";
    int err;

    /* 1- Get the C revision spec */
    c_spec = py_str_to_c_str(py_spec, encoding);
    if (c_spec == NULL)
        return NULL;

    /* 2- Lookup */
    err = git_revparse_single(&c_obj, self->repo, c_spec);

    if (err < 0) {
        PyObject *err_obj = Error_set_str(err, c_spec);
        free(c_spec);
        return err_obj;
    }
    free(c_spec);

    return wrap_object(c_obj, self);
}
开发者ID:cboos,项目名称:pygit2,代码行数:25,代码来源:repository.c


示例6: Index_get_position

/* This is an internal function, used by Index_getitem and Index_setitem */
int
Index_get_position(Index *self, PyObject *value)
{
    char *path;
    int idx;

    /* Case 1: integer */
    if (PyInt_Check(value)) {
        idx = (int)PyInt_AsLong(value);
        if (idx == -1 && PyErr_Occurred())
            return -1;
        if (idx < 0) {
            PyErr_SetObject(PyExc_ValueError, value);
            return -1;
        }
        return idx;
    }

    /* Case 2: byte or text string */
    path = py_path_to_c_str(value);
    if (!path)
        return -1;
    idx = git_index_find(self->index, path);
    if (idx < 0) {
        Error_set_str(idx, path);
        free(path);
        return -1;
    }
    free(path);
    return idx;
}
开发者ID:guocb,项目名称:pygit2,代码行数:32,代码来源:index.c


示例7: Config_init

int
Config_init(Config *self, PyObject *args, PyObject *kwds)
{
    char *path;
    int err;

    if (kwds) {
        PyErr_SetString(PyExc_TypeError,
                        "Repository takes no keyword arguments");
        return -1;
    }

    if (PySequence_Length(args) > 0) {
        if (!PyArg_ParseTuple(args, "s", &path)) {
            return -1;
        }
        err = git_config_open_ondisk(&self->config, path);
        if (err < 0) {
            Error_set_str(err, path);
            return -1;
        }
    } else {
        err = git_config_new(&self->config);
        if (err < 0) {
            Error_set(err);
            return -1;
        }
    }
    return 0;
}
开发者ID:guocb,项目名称:pygit2,代码行数:30,代码来源:config.c


示例8: Repository_revparse_single

PyObject *
Repository_revparse_single(Repository *self, PyObject *py_spec)
{
    git_object *c_obj;
    const char *c_spec;
    PyObject *tspec;
    int err;

    /* 1- Get the C revision spec */
    c_spec = py_str_borrow_c_str(&tspec, py_spec, NULL);
    if (c_spec == NULL)
        return NULL;

    /* 2- Lookup */
    err = git_revparse_single(&c_obj, self->repo, c_spec);

    if (err < 0) {
        PyObject *err_obj = Error_set_str(err, c_spec);
        Py_DECREF(tspec);
        return err_obj;
    }
    Py_DECREF(tspec);

    return wrap_object(c_obj, self);
}
开发者ID:cjwatson,项目名称:pygit2,代码行数:25,代码来源:repository.c


示例9: init_repository

PyObject *
init_repository(PyObject *self, PyObject *args)
{
    git_repository *repo;
    Repository *py_repo;
    const char *path;
    unsigned int bare;
    int err;

    if (!PyArg_ParseTuple(args, "sI", &path, &bare))
        return NULL;

    err = git_repository_init(&repo, path, bare);
    if (err < 0)
        return Error_set_str(err, path);

    py_repo = PyObject_GC_New(Repository, &RepositoryType);
    if (py_repo) {
        py_repo->repo = repo;
        py_repo->index = NULL;
        PyObject_GC_Track(py_repo);
        return (PyObject*)py_repo;
    }

    git_repository_free(repo);
    return NULL;
};
开发者ID:delanne,项目名称:pygit2,代码行数:27,代码来源:pygit2.c


示例10: Repository_init

int
Repository_init(Repository *self, PyObject *args, PyObject *kwds)
{
    char *path;
    int err;

    if (kwds && PyDict_Size(kwds) > 0) {
        PyErr_SetString(PyExc_TypeError,
                        "Repository takes no keyword arguments");
        return -1;
    }

    if (!PyArg_ParseTuple(args, "s", &path))
        return -1;

    err = git_repository_open(&self->repo, path);
    if (err < 0) {
        Error_set_str(err, path);
        return -1;
    }

    self->owned = 1;
    self->config = NULL;
    self->index = NULL;

    return 0;
}
开发者ID:cjwatson,项目名称:pygit2,代码行数:27,代码来源:repository.c


示例11: Error_set_oid

PyObject* Error_set_oid(int err, const git_oid *oid, size_t len)
{
    char hex[GIT_OID_HEXSZ + 1];

    git_oid_fmt(hex, oid);
    hex[len] = '\0';
    return Error_set_str(err, hex);
}
开发者ID:alex179ohm,项目名称:pygit2,代码行数:8,代码来源:error.c


示例12: Index_add

PyObject *
Index_add(Index *self, PyObject *args)
{
    int err;
    const char *path;

    if (!PyArg_ParseTuple(args, "s", &path))
        return NULL;

    err = git_index_add_from_workdir(self->index, path);
    if (err < 0)
        return Error_set_str(err, path);

    Py_RETURN_NONE;
}
开发者ID:guocb,项目名称:pygit2,代码行数:15,代码来源:index.c


示例13: Index_add

PyObject *
Index_add(Index *self, PyObject *args)
{
    int err;
    const char *path;
    int stage=0;

    if (!PyArg_ParseTuple(args, "s|i", &path, &stage))
        return NULL;

    err = git_index_add(self->index, path, stage);
    if (err < 0)
        return Error_set_str(err, path);

    Py_RETURN_NONE;
}
开发者ID:Ferengee,项目名称:pygit2,代码行数:16,代码来源:index.c


示例14: Index_find

PyObject *
Index_find(Index *self, PyObject *py_path)
{
    char *path;
    long idx;

    path = PyString_AsString(py_path);
    if (!path)
        return NULL;

    idx = (long)git_index_find(self->index, path);
    if (idx < 0)
        return Error_set_str(idx, path);

    return PyInt_FromLong(idx);
}
开发者ID:guocb,项目名称:pygit2,代码行数:16,代码来源:index.c


示例15: Index__find

PyObject *
Index__find(Index *self, PyObject *py_path)
{
    char *path;
    size_t idx;
    int err;

    path = PyBytes_AsString(py_path);
    if (!path)
        return NULL;

    err = git_index_find(&idx, self->index, path);
    if (err < 0)
        return Error_set_str(err, path);

    return PyLong_FromSize_t(idx);
}
开发者ID:flowroute,项目名称:pygit2,代码行数:17,代码来源:index.c


示例16: init_repository

PyObject *
init_repository(PyObject *self, PyObject *args) {
    git_repository *repo;
    const char *path;
    unsigned int bare;
    int err;

    if (!PyArg_ParseTuple(args, "sI", &path, &bare))
        return NULL;

    err = git_repository_init(&repo, path, bare);
    if (err < 0)
        return Error_set_str(err, path);

    git_repository_free(repo);
    Py_RETURN_NONE;
};
开发者ID:takluyver,项目名称:pygit2,代码行数:17,代码来源:pygit2.c


示例17: Config_add_file

PyObject *
Config_add_file(Config *self, PyObject *args)
{
    int err;
    char *path;
    int priority;

    if (!PyArg_ParseTuple(args, "si", &path, &priority))
        return NULL;

    err = git_config_add_file_ondisk(self->config, path, priority);
    if (err < 0) {
        Error_set_str(err, path);
        return NULL;
    }

    Py_RETURN_NONE;
}
开发者ID:Ferengee,项目名称:pygit2,代码行数:18,代码来源:config.c


示例18: discover_repository

PyObject *
discover_repository(PyObject *self, PyObject *args)
{
    const char *path;
    int across_fs = 0;
    const char *ceiling_dirs = NULL;
    char repo_path[MAXPATHLEN];
    int err;

    if (!PyArg_ParseTuple(args, "s|Is", &path, &across_fs, &ceiling_dirs))
        return NULL;

    err = git_repository_discover(repo_path, sizeof(repo_path),
            path, across_fs, ceiling_dirs);
    if (err < 0)
        return Error_set_str(err, path);

    return to_path(repo_path);
};
开发者ID:takluyver,项目名称:pygit2,代码行数:19,代码来源:pygit2.c


示例19: Config_add_file

PyObject *
Config_add_file(Config *self, PyObject *args, PyObject *kwds)
{
    char *keywords[] = {"path", "level", "force", NULL};
    int err;
    char *path;
    unsigned int level = 0;
    int force = 0;

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|Ii", keywords,
                                     &path, &level, &force))
        return NULL;

    err = git_config_add_file_ondisk(self->config, path, level, force);
    if (err < 0)
        return Error_set_str(err, path);

    Py_RETURN_NONE;
}
开发者ID:carlosmn,项目名称:pygit2,代码行数:19,代码来源:config.c


示例20: Repository_status_file

PyObject *
Repository_status_file(Repository *self, PyObject *value)
{
    char *path;
    unsigned int status;
    int err;

    path = py_path_to_c_str(value);
    if (!path)
        return NULL;

    err = git_status_file(&status, self->repo, path);
    if (err < 0) {
        PyObject *err_obj =  Error_set_str(err, path);
        free(path);
        return err_obj;
    }
    return PyLong_FromLong(status);
}
开发者ID:cjwatson,项目名称:pygit2,代码行数:19,代码来源:repository.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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