Ruby 1.9.2p136(2010-12-25revision30365)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Defines | Functions | Variables

# ext/syck/emitter.c File Reference

`#include "ruby/ruby.h"`
`#include <stdio.h>`
`#include <string.h>`
`#include "syck.h"`
Include dependency graph for emitter.c:

Go to the source code of this file.

## Defines
#define | DEFAULT_ANCHOR_FORMAT "id%03d"
#define | SCAN_NONE 0
#define | SCAN_NONPRINT 1
#define | SCAN_INDENTED 2
#define | SCAN_WIDE 4
#define | SCAN_WHITEEDGE 8
#define | SCAN_NEWLINE 16
#define | SCAN_SINGLEQ 32
#define | SCAN_DOUBLEQ 64
#define | SCAN_INDIC_S 128
#define | SCAN_INDIC_C 256
#define | SCAN_NONL_E 512
#define | SCAN_MANYNL_E 1024
#define | SCAN_FLOWMAP 2048
#define | SCAN_FLOWSEQ 4096
#define | SCAN_DOCSEP 8192
## Functions
char * | syck_base64enc (char *s, long len)
char * | syck_base64dec (char *s, long len)
SyckEmitter * | syck_new_emitter (void)
int | syck_st_free_anchors (char *key, char *name, char *arg)
void | syck_emitter_st_free (SyckEmitter *e)
SyckLevel * | syck_emitter_current_level (SyckEmitter *e)
SyckLevel * | syck_emitter_parent_level (SyckEmitter *e)
void | syck_emitter_pop_level (SyckEmitter *e)
void | syck_emitter_add_level (SyckEmitter *e, int len, enum syck_level_status status)
void | syck_emitter_reset_levels (SyckEmitter *e)
void | syck_emitter_handler (SyckEmitter *e, SyckEmitterHandler hdlr)
void | syck_output_handler (SyckEmitter *e, SyckOutputHandler hdlr)
void | syck_free_emitter (SyckEmitter *e)
void | syck_emitter_clear (SyckEmitter *e)
void | syck_emitter_write (SyckEmitter *e, const char *str, long len)
void | syck_emitter_flush (SyckEmitter *e, long check_room)
void | syck_emit (SyckEmitter *e, st_data_t n)
void | syck_emit_tag (SyckEmitter *e, const char *tag, const char *ignore)
void | syck_emit_indent (SyckEmitter *e)
int | syck_scan_scalar (int req_width, const char *cursor, long len)
void | syck_emit_scalar (SyckEmitter *e, const char *tag, enum scalar_style force_style, int force_indent, int force_width, char keep_nl, const char *str, long len)
void | syck_emitter_escape (SyckEmitter *e, const char *src, long len)
void | syck_emit_1quoted (SyckEmitter *e, int width, const char *str, long len)
void | syck_emit_2quoted (SyckEmitter *e, int width, const char *str, long len)
void | syck_emit_literal (SyckEmitter *e, char keep_nl, const char *str, long len)
void | syck_emit_folded (SyckEmitter *e, int width, char keep_nl, const char *str, long len)
void | syck_emit_seq (SyckEmitter *e, const char *tag, enum seq_style style)
void | syck_emit_map (SyckEmitter *e, const char *tag, enum map_style style)
void | syck_emit_item (SyckEmitter *e, st_data_t n)
void | syck_emit_end (SyckEmitter *e)
SYMID | syck_emitter_mark_node (SyckEmitter *e, st_data_t n)
## Variables
const char | hex_table [] = "0123456789ABCDEF"
static char | b64_table [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

## Define Documentation

#define DEFAULT_ANCHOR_FORMAT "id%03d"

Definition at line 18 of file emitter.c.

Referenced by syck_emitter_mark_node().

#define SCAN_DOCSEP 8192

Definition at line 535 of file emitter.c.

Referenced by syck_emit_scalar(), and syck_scan_scalar().

#define SCAN_DOUBLEQ 64

Definition at line 521 of file emitter.c.

Referenced by syck_scan_scalar().

#define SCAN_FLOWMAP 2048

Definition at line 531 of file emitter.c.

Referenced by syck_emit_scalar(), and syck_scan_scalar().

#define SCAN_FLOWSEQ 4096

Definition at line 533 of file emitter.c.

Referenced by syck_emit_scalar(), and syck_scan_scalar().

#define SCAN_INDENTED 2

Definition at line 511 of file emitter.c.

Referenced by syck_emit_scalar(), and syck_scan_scalar().

#define SCAN_INDIC_C 256

Definition at line 525 of file emitter.c.

Referenced by syck_emit_scalar(), and syck_scan_scalar().

#define SCAN_INDIC_S 128

Definition at line 523 of file emitter.c.

Referenced by syck_emit_scalar(), and syck_scan_scalar().

#define SCAN_MANYNL_E 1024

Definition at line 529 of file emitter.c.

Referenced by syck_emit_scalar(), and syck_scan_scalar().

#define SCAN_NEWLINE 16

Definition at line 517 of file emitter.c.

Referenced by syck_emit_scalar(), and syck_scan_scalar().

#define SCAN_NONE 0

Definition at line 507 of file emitter.c.

Referenced by syck_scan_scalar().

#define SCAN_NONL_E 512

Definition at line 527 of file emitter.c.

Referenced by syck_emit_scalar(), and syck_scan_scalar().

#define SCAN_NONPRINT 1

Definition at line 509 of file emitter.c.

Referenced by syck_emit_scalar(), and syck_scan_scalar().

#define SCAN_SINGLEQ 32

Definition at line 519 of file emitter.c.

Referenced by syck_scan_scalar().

#define SCAN_WHITEEDGE 8

Definition at line 515 of file emitter.c.

Referenced by syck_emit_scalar(), and syck_scan_scalar().

#define SCAN_WIDE 4

Definition at line 513 of file emitter.c.

Referenced by syck_scan_scalar().

## Function Documentation

char* syck_base64dec | ( | char * | s,
|  | long | len
| ) |  |

Definition at line 60 of file emitter.c.

References b64_table, len, and syck_strndup().

char* syck_base64enc | ( | char * | s,
|  | long | len
| ) |  |

Definition at line 29 of file emitter.c.

References b64_table, and S_ALLOC_N.

void syck_emit | ( | SyckEmitter * | e,
|  | st_data_t | n
| ) |  |

Definition at line 356 of file emitter.c.

References _syck_emitter::anchored, _syck_emitter::anchors, _syck_level::anctag, doc_open, doc_processing, _syck_emitter::emitter_handler, free, _syck_emitter::headless, _syck_emitter::indent, _syck_emitter::lvl_idx, _syck_emitter::markers, NULL, S_ALLOC_N, S_FREE, S_MEMZERO, _syck_level::spaces, st_init_numtable, st_insert, st_lookup, _syck_emitter::stage, syck_emitter_add_level(), syck_emitter_current_level(), syck_emitter_pop_level(), syck_emitter_write(), syck_lvl_open, SYCK_YAML_MAJOR, SYCK_YAML_MINOR, SYMID, _syck_emitter::use_header, and _syck_emitter::use_version.

Referenced by syck_emit_item(), and syck_emitter_emit().

void syck_emit_1quoted | ( | SyckEmitter * | e,
|  | int | width,
|  | const char * | str,
|  | long | len
| ) |  |

Definition at line 806 of file emitter.c.

References syck_emit_indent(), and syck_emitter_write().

Referenced by syck_emit_scalar().

void syck_emit_2quoted | ( | SyckEmitter * | e,
|  | int | width,
|  | const char * | str,
|  | long | len
| ) |  |

Definition at line 854 of file emitter.c.

References syck_emit_indent(), syck_emitter_escape(), and syck_emitter_write().

Referenced by syck_emit_scalar().

void syck_emit_end | ( | SyckEmitter * | e | ) |

Definition at line 1152 of file emitter.c.

References _syck_level::ncount, _syck_level::status, syck_emitter_current_level(), syck_emitter_parent_level(), syck_emitter_write(), syck_lvl_imap, syck_lvl_iseq, syck_lvl_map, syck_lvl_mapx, and syck_lvl_seq.

Referenced by rb_syck_emitter_handler().

void syck_emit_folded | ( | SyckEmitter * | e,
|  | int | width,
|  | char | keep_nl,
|  | const char * | str,
|  | long | len
| ) |  |

Definition at line 951 of file emitter.c.

References _syck_emitter::best_width, NL_CHOMP, NL_KEEP, syck_emit_indent(), and syck_emitter_write().

Referenced by syck_emit_scalar().

void syck_emit_indent | ( | SyckEmitter * | e | ) |

Definition at line 491 of file emitter.c.

References _syck_emitter::buffer, _syck_emitter::bufpos, free, _syck_emitter::marker, S_ALLOC_N, _syck_level::spaces, syck_emitter_current_level(), and syck_emitter_write().

Referenced by syck_emit_1quoted(), syck_emit_2quoted(), syck_emit_folded(), syck_emit_item(), and syck_emit_literal().

void syck_emit_item | ( | SyckEmitter * | e,
|  | st_data_t | n
| ) |  |

Definition at line 1044 of file emitter.c.

References _syck_level::anctag, _syck_level::ncount, S_ALLOC_N, S_FREE, _syck_level::spaces, _syck_level::status, syck_emit(), syck_emit_indent(), syck_emitter_current_level(), syck_emitter_parent_level(), syck_emitter_write(), syck_lvl_imap, syck_lvl_iseq, syck_lvl_map, syck_lvl_mapx, and syck_lvl_seq.

Referenced by rb_syck_emitter_handler().

void syck_emit_literal | ( | SyckEmitter * | e,
|  | char | keep_nl,
|  | const char * | str,
|  | long | len
| ) |  |

Definition at line 915 of file emitter.c.

References len, NL_CHOMP, NL_KEEP, syck_emit_indent(), and syck_emitter_write().

Referenced by syck_emit_scalar().

void syck_emit_map | ( | SyckEmitter * | e,
|  | const char * | tag,
|  | enum map_style | style
| ) |  |

Definition at line 1022 of file emitter.c.

References map_inline, _syck_level::ncount, _syck_level::status, syck_emit_tag(), syck_emitter_current_level(), syck_emitter_parent_level(), syck_emitter_write(), syck_lvl_imap, syck_lvl_iseq, syck_lvl_map, and syck_lvl_mapx.

Referenced by rb_syck_emitter_handler().

void syck_emit_scalar | ( | SyckEmitter * | e,
|  | const char * | tag,
|  | enum scalar_style | force_style,
|  | int | force_indent,
|  | int | force_width,
|  | char | keep_nl,
|  | const char * | str,
|  | long | len
| ) |  |

Definition at line 641 of file emitter.c.

References _syck_emitter::explicit_typing, _syck_emitter::indent, _syck_level::ncount, NL_CHOMP, NL_KEEP, NULL, S_FREE, scalar_1quote, scalar_2quote, scalar_fold, scalar_literal, scalar_none, scalar_plain, SCAN_DOCSEP, SCAN_FLOWMAP, SCAN_FLOWSEQ, SCAN_INDENTED, SCAN_INDIC_C, SCAN_INDIC_S, SCAN_MANYNL_E, SCAN_NEWLINE, SCAN_NONL_E, SCAN_NONPRINT, SCAN_WHITEEDGE, _syck_level::spaces, _syck_level::status, _syck_emitter::style, syck_emit_1quoted(), syck_emit_2quoted(), syck_emit_folded(), syck_emit_literal(), syck_emit_tag(), syck_emitter_current_level(), syck_emitter_parent_level(), syck_emitter_write(), syck_lvl_imap, syck_lvl_iseq, syck_lvl_map, syck_lvl_mapx, syck_match_implicit(), syck_scan_scalar(), syck_tagcmp(), syck_taguri(), and YAML_DOMAIN.

Referenced by rb_syck_emitter_handler().

void syck_emit_seq | ( | SyckEmitter * | e,
|  | const char * | tag,
|  | enum seq_style | style
| ) |  |

Definition at line 1000 of file emitter.c.

References _syck_level::ncount, seq_inline, _syck_level::status, syck_emit_tag(), syck_emitter_current_level(), syck_emitter_parent_level(), syck_emitter_write(), syck_lvl_imap, syck_lvl_iseq, syck_lvl_map, syck_lvl_mapx, and syck_lvl_seq.

Referenced by rb_syck_emitter_handler().

void syck_emit_tag | ( | SyckEmitter * | e,
|  | const char * | tag,
|  | const char * | ignore
| ) |  |

Definition at line 440 of file emitter.c.

References _syck_level::anctag, _syck_emitter::explicit_typing, NULL, syck_emitter_current_level(), syck_emitter_write(), syck_tagcmp(), and YAML_DOMAIN.

Referenced by syck_emit_map(), syck_emit_scalar(), and syck_emit_seq().

void syck_emitter_add_level | ( | SyckEmitter * | e,
|  | int | len,
|  | enum syck_level_status | status
| ) |  |

Definition at line 201 of file emitter.c.

References ALLOC_CT, _syck_level::anctag, ASSERT, _syck_level::domain, len, _syck_emitter::levels, _syck_emitter::lvl_capa, _syck_emitter::lvl_idx, _syck_level::ncount, NULL, S_REALLOC_N, _syck_level::spaces, _syck_level::status, and syck_strndup().

Referenced by syck_emit().

void syck_emitter_clear | ( | SyckEmitter * | e | ) |

Definition at line 268 of file emitter.c.

References _syck_emitter::buffer, _syck_emitter::bufpos, _syck_emitter::bufsize, _syck_emitter::marker, NULL, S_ALLOC_N, and S_MEMZERO.

Referenced by syck_emitter_write().

SyckLevel* syck_emitter_current_level | ( | SyckEmitter * | e | ) |

Definition at line 177 of file emitter.c.

References _syck_emitter::levels, and _syck_emitter::lvl_idx.

Referenced by syck_emit(), syck_emit_end(), syck_emit_indent(), syck_emit_item(), syck_emit_map(), syck_emit_scalar(), syck_emit_seq(), and syck_emit_tag().

void syck_emitter_escape | ( | SyckEmitter * | e,
|  | const char * | src,
|  | long | len
| ) |  |

Definition at line 776 of file emitter.c.

References hex_table, len, and syck_emitter_write().

Referenced by syck_emit_2quoted().

void syck_emitter_flush | ( | SyckEmitter * | e,
|  | long | check_room
| ) |  |

Definition at line 322 of file emitter.c.

References _syck_emitter::buffer, _syck_emitter::bufpos, _syck_emitter::bufsize, _syck_emitter::marker, and _syck_emitter::output_handler.

Referenced by syck_emitter_emit(), and syck_emitter_write().

void syck_emitter_handler | ( | SyckEmitter * | e,
|  | SyckEmitterHandler | hdlr
| ) |  |

Definition at line 239 of file emitter.c.

References _syck_emitter::emitter_handler.

Referenced by syck_emitter_s_alloc().

SYMID syck_emitter_mark_node | ( | SyckEmitter * | e,
|  | st_data_t | n
| ) |  |

Definition at line 1193 of file emitter.c.

References _syck_emitter::anchor_format, _syck_emitter::anchors, DEFAULT_ANCHOR_FORMAT, _syck_emitter::markers, NULL, st_table::num_entries, S_ALLOC_N, S_MEMZERO, st_init_numtable, st_insert, st_lookup, and SYMID.

Referenced by syck_emitter_emit().

SyckLevel* syck_emitter_parent_level | ( | SyckEmitter * | e | ) |

Definition at line 183 of file emitter.c.

References _syck_emitter::levels, and _syck_emitter::lvl_idx.

Referenced by syck_emit_end(), syck_emit_item(), syck_emit_map(), syck_emit_scalar(), and syck_emit_seq().

void syck_emitter_pop_level | ( | SyckEmitter * | e | ) |

Definition at line 189 of file emitter.c.

References ASSERT, _syck_level::domain, free, _syck_emitter::levels, _syck_emitter::lvl_idx, and NULL.

Referenced by syck_emit(), and syck_emitter_reset_levels().

void syck_emitter_reset_levels | ( | SyckEmitter * | e | ) |

Definition at line 220 of file emitter.c.

References _syck_level::anctag, _syck_level::domain, _syck_emitter::levels, _syck_emitter::lvl_idx, _syck_level::ncount, _syck_level::spaces, _syck_level::status, syck_emitter_pop_level(), syck_lvl_header, and syck_strndup().

Referenced by syck_free_emitter(), and syck_new_emitter().

void syck_emitter_st_free | ( | SyckEmitter * | e | ) |

Definition at line 148 of file emitter.c.

References _syck_emitter::anchored, _syck_emitter::anchors, _syck_emitter::markers, NULL, st_foreach, st_free_table, and syck_st_free_anchors().

Referenced by syck_free_emitter().

void syck_emitter_write | ( | SyckEmitter * | e,
|  | const char * | str,
|  | long | len
| ) |  |

Definition at line 284 of file emitter.c.

References ASSERT, _syck_emitter::buffer, _syck_emitter::bufsize, len, _syck_emitter::marker, NULL, S_MEMCPY, syck_emitter_clear(), and syck_emitter_flush().

Referenced by syck_emit(), syck_emit_1quoted(), syck_emit_2quoted(), syck_emit_end(), syck_emit_folded(), syck_emit_indent(), syck_emit_item(), syck_emit_literal(), syck_emit_map(), syck_emit_scalar(), syck_emit_seq(), syck_emit_tag(), and syck_emitter_escape().

void syck_free_emitter | ( | SyckEmitter * | e | ) |

Definition at line 251 of file emitter.c.

References _syck_emitter::buffer, _syck_level::domain, _syck_emitter::levels, NULL, S_FREE, syck_emitter_reset_levels(), and syck_emitter_st_free().

Referenced by rb_syck_free_emitter().

SyckEmitter* syck_new_emitter | ( | void |  | ) |

Definition at line 108 of file emitter.c.

References ALLOC_CT, _syck_emitter::anchor_format, _syck_emitter::anchored, _syck_emitter::anchors, _syck_emitter::best_width, _syck_emitter::bonus, _syck_emitter::buffer, _syck_emitter::bufpos, _syck_emitter::bufsize, doc_open, _syck_emitter::emitter_handler, _syck_emitter::explicit_typing, _syck_emitter::headless, _syck_emitter::indent, _syck_emitter::level, _syck_emitter::levels, _syck_emitter::lvl_capa, _syck_emitter::lvl_idx, _syck_emitter::marker, _syck_emitter::markers, NULL, _syck_emitter::output_handler, S_ALLOC, S_ALLOC_N, scalar_none, _syck_emitter::sort_keys, _syck_emitter::stage, _syck_emitter::style, SYCK_BUFFERSIZE, syck_emitter_reset_levels(), _syck_emitter::use_header, and _syck_emitter::use_version.

Referenced by syck_emitter_s_alloc().

void syck_output_handler | ( | SyckEmitter * | e,
|  | SyckOutputHandler | hdlr
| ) |  |

Definition at line 245 of file emitter.c.

References _syck_emitter::output_handler.

Referenced by syck_emitter_s_alloc().

int syck_scan_scalar | ( | int | req_width,
|  | const char * | cursor,
|  | long | len
| ) |  |

Definition at line 541 of file emitter.c.

References len, SCAN_DOCSEP, SCAN_DOUBLEQ, SCAN_FLOWMAP, SCAN_FLOWSEQ, SCAN_INDENTED, SCAN_INDIC_C, SCAN_INDIC_S, SCAN_MANYNL_E, SCAN_NEWLINE, SCAN_NONE, SCAN_NONL_E, SCAN_NONPRINT, SCAN_SINGLEQ, SCAN_WHITEEDGE, and SCAN_WIDE.

Referenced by syck_emit_scalar().

int syck_st_free_anchors | ( | char * | key,
|  | char * | name,
|  | char * | arg
| ) |  |

Definition at line 141 of file emitter.c.

References S_FREE, and ST_CONTINUE.

Referenced by syck_emitter_st_free().

## Variable Documentation

char b64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"`[static]`

Definition at line 22 of file emitter.c.

Referenced by syck_base64dec(), and syck_base64enc().

const char hex_table[] = "0123456789ABCDEF"

Definition at line 20 of file emitter.c.

Referenced by syck_emitter_escape().