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


C++ StringWriterClose函数代码示例

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


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

示例1: test_show_object_compound_compact

static void test_show_object_compound_compact(void)
{
    JsonElement *json = JsonObjectCreate(10);

    JsonObjectAppendString(json, "first", "one");
    {
        JsonElement *inner = JsonObjectCreate(10);

        JsonObjectAppendString(inner, "third", "three");

        JsonObjectAppendObject(json, "second", inner);
    }
    {
        JsonElement *inner = JsonObjectCreate(10);

        JsonObjectAppendString(inner, "fifth", "five");

        JsonObjectAppendObject(json, "fourth", inner);
    }

    Writer *writer = StringWriter();

    JsonWriteCompact(writer, json);
    char *output = StringWriterClose(writer);

    assert_string_equal("{\"first\":\"one\",\"second\":{\"third\":\"three\"},\"fourth\":{\"fifth\":\"five\"}}", output);

    JsonDestroy(json);
    free(output);
}
开发者ID:ajlill,项目名称:core,代码行数:30,代码来源:json_test.c

示例2: StringWriter

char *EvalContextStackPath(const EvalContext *ctx)
{
    Writer *path = StringWriter();

    for (size_t i = 0; i < SeqLength(ctx->stack); i++)
    {
        StackFrame *frame = SeqAt(ctx->stack, i);
        switch (frame->type)
        {
        case STACK_FRAME_TYPE_BODY:
            WriterWriteF(path, "/%s", frame->data.body.owner->name);
            break;

        case STACK_FRAME_TYPE_BUNDLE:
            WriterWriteF(path, "/%s", frame->data.bundle.owner->name);
            break;

        case STACK_FRAME_TYPE_PROMISE_ITERATION:
            WriterWriteF(path, "/%s", frame->data.promise.owner->parent_promise_type->name);
            WriterWriteF(path, "/'%s'", frame->data.promise.owner->promiser);
            break;

        case STACK_FRAME_TYPE_PROMISE:
            break;
        }
    }

    return StringWriterClose(path);
}
开发者ID:jeffali,项目名称:core,代码行数:29,代码来源:env_context.c

示例3: ProgrammingError

char *SearchAndReplace(const char *source, const char *search, const char *replace)
{
    const char *source_ptr = source;

    if ((source == NULL) || (search == NULL) || (replace == NULL))
    {
        ProgrammingError("Programming error: NULL argument is passed to SearchAndReplace");
    }

    if (strcmp(search, "") == 0)
    {
        return xstrdup(source);
    }

    Writer *w = StringWriter();

    for (;;)
    {
        const char *found_ptr = strstr(source_ptr, search);

        if (found_ptr == NULL)
        {
            WriterWrite(w, source_ptr);
            return StringWriterClose(w);
        }

        WriterWriteLen(w, source_ptr, found_ptr - source_ptr);
        WriterWrite(w, replace);

        source_ptr += found_ptr - source_ptr + strlen(search);
    }
}
开发者ID:dardevelin,项目名称:core-1,代码行数:32,代码来源:string_lib.c

示例4: test_comment

void test_comment(void **state)
{
    Writer *w = StringWriter();

    XmlComment(w, "foobar");
    assert_string_equal(StringWriterClose(w), "<!-- foobar -->\n");
}
开发者ID:frerich,项目名称:core,代码行数:7,代码来源:xml_writer_test.c

示例5: StringWriter

char *MapNameCopy(const char *s)
{
    Writer *w = StringWriter();

    /* c:\a\b -> /cygdrive/c\a\b */
    if (s[0] && isalpha(s[0]) && s[1] == ':')
    {
        WriterWriteF(w, "/cygdrive/%c", s[0]);
        s += 2;
    }

    for (; *s; s++)
    {
        /* a//b//c -> a/b/c */
        /* a\\b\\c -> a\b\c */
        if (IsFileSep(*s) && IsFileSep(*(s + 1)))
        {
            continue;
        }

        /* a\b\c -> a/b/c */
        WriterWriteChar(w, *s == '\\' ? '/' : *s);
    }

    return StringWriterClose(w);
}
开发者ID:fkoner,项目名称:core,代码行数:26,代码来源:patches.c

示例6: test_no_attr

void test_no_attr(void **state)
{
    Writer *w = StringWriter();

    XmlTag(w, "foobar", NULL, 0);
    assert_string_equal(StringWriterClose(w), "<foobar></foobar>\n");
}
开发者ID:frerich,项目名称:core,代码行数:7,代码来源:xml_writer_test.c

示例7: test_escape

void test_escape(void **state)
{
    Writer *w = StringWriter();

    XmlContent(w, "&>\"'<");
    assert_string_equal(StringWriterClose(w), "&amp;&gt;&quot;&apos;&lt;");
}
开发者ID:frerich,项目名称:core,代码行数:7,代码来源:xml_writer_test.c

示例8: test_show_object_compound

static void test_show_object_compound(void)
{
    JsonElement *json = JsonObjectCreate(10);

    JsonObjectAppendString(json, "first", "one");
    {
        JsonElement *inner = JsonObjectCreate(10);

        JsonObjectAppendString(inner, "third", "three");

        JsonObjectAppendObject(json, "second", inner);
    }
    {
        JsonElement *inner = JsonObjectCreate(10);

        JsonObjectAppendString(inner, "fifth", "five");

        JsonObjectAppendObject(json, "fourth", inner);
    }

    Writer *writer = StringWriter();

    JsonWrite(writer, json, 0);
    char *output = StringWriterClose(writer);

    assert_string_equal(OBJECT_COMPOUND, output);

    JsonDestroy(json);
    free(output);
}
开发者ID:ajlill,项目名称:core,代码行数:30,代码来源:json_test.c

示例9: test_empty

void test_empty(void **state)
{
    Writer *w = StringWriter();
    CsvWriter *c = CsvWriterOpen(w);

    CsvWriterClose(c);
    assert_string_equal(StringWriterClose(w), "");
}
开发者ID:dnaeon,项目名称:core,代码行数:8,代码来源:csv_writer_test.c

示例10: StringWriter

char *ReadTexinfoFileF(const char *source_dir, const char *fmt, ...)
{
    Writer *filenamew = StringWriter();

    struct stat sb;
    char *buffer = NULL;
    FILE *fp = NULL;
    off_t file_size;

    va_list ap;

    va_start(ap, fmt);
    WriterWriteF(filenamew, "%s/", source_dir);
    WriterWriteVF(filenamew, fmt, ap);
    va_end(ap);

    char *filename = StringWriterClose(filenamew);

    if (cfstat(filename, &sb) == -1)
    {
        if (!GenerateStub(filename))
        {
            CfOut(OUTPUT_LEVEL_INFORM, "", "Unable to write down stub for missing texinfo file");
            free(filename);
            return NULL;
        }
    }

    if ((fp = fopen(filename, "r")) == NULL)
    {
        CfOut(OUTPUT_LEVEL_INFORM, "fopen", "Could not read manual source %s\n", filename);
        free(filename);
        return NULL;
    }

    fseek(fp, 0, SEEK_END);
    file_size = ftello(fp);
    fseek(fp, 0, SEEK_SET);

    buffer = (char *) xcalloc(file_size + 1, sizeof(char));
    buffer[file_size] = '\0';
    int cnt = fread(buffer, sizeof(char), file_size, fp);

    if ((ferror(fp)) || (cnt != file_size))
    {
        CfOut(OUTPUT_LEVEL_INFORM, "fread", "Could not read manual source %s\n", filename);
        free(buffer);
        fclose(fp);
        free(filename);
        return NULL;
    }

    fclose(fp);
    free(filename);

    return buffer;
}
开发者ID:FancsalMelinda,项目名称:core,代码行数:57,代码来源:manual.c

示例11: test_tag

void test_tag(void **state)
{
    Writer *w = StringWriter();

    XmlTag(w, "foobar", "some value", 1, (XmlAttribute)
           {
           "a", "b"});
    assert_string_equal(StringWriterClose(w), "<foobar a=\"b\" >some value</foobar>\n");
}
开发者ID:frerich,项目名称:core,代码行数:9,代码来源:xml_writer_test.c

示例12: test_escape

void test_escape(void **state)
{
    Writer *w = StringWriter();
    CsvWriter *c = CsvWriterOpen(w);

    CsvWriterField(c, ",\"\r\n");

    CsvWriterClose(c);
    assert_string_equal(StringWriterClose(w), "\",\"\"\r\n\"\r\n");
}
开发者ID:dnaeon,项目名称:core,代码行数:10,代码来源:csv_writer_test.c

示例13: test_single_field

void test_single_field(void **state)
{
    Writer *w = StringWriter();
    CsvWriter *c = CsvWriterOpen(w);

    CsvWriterField(c, "test");

    CsvWriterClose(c);
    assert_string_equal(StringWriterClose(w), "test\r\n");
}
开发者ID:dnaeon,项目名称:core,代码行数:10,代码来源:csv_writer_test.c

示例14: test_show_string

static void test_show_string(void **state)
{
    JsonElement *str = JsonStringCreate("snookie");

    Writer *writer = StringWriter();

    JsonElementPrint(writer, str, 0);
    assert_string_equal("\"snookie\"", StringWriterClose(writer));

    JsonElementDestroy(str);
}
开发者ID:joegen,项目名称:sipx-externals,代码行数:11,代码来源:json_test.c

示例15: test_empty_last_record

void test_empty_last_record(void **state)
{
    Writer *w = StringWriter();
    CsvWriter *c = CsvWriterOpen(w);

    CsvWriterField(c, "test1");
    CsvWriterNewRecord(c);
    CsvWriterNewRecord(c);

    CsvWriterClose(c);
    assert_string_equal(StringWriterClose(w), "test1\r\n\r\n");
}
开发者ID:dnaeon,项目名称:core,代码行数:12,代码来源:csv_writer_test.c


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