Blender  V3.3
text_format.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2009 Blender Foundation. All rights reserved. */
3 
8 #pragma once
9 
10 /* *** Flatten String *** */
11 typedef struct FlattenString {
12  char fixedbuf[256];
13  int fixedaccum[256];
14 
15  char *buf;
16  int *accum;
17  int pos, len;
19 
23 enum {
24  FMT_CONT_NOP = 0, /* no continuation */
25  FMT_CONT_QUOTESINGLE = (1 << 0), /* single quotes */
26  FMT_CONT_QUOTEDOUBLE = (1 << 1), /* double quotes */
27  FMT_CONT_TRIPLE = (1 << 2), /* triplets of quotes: """ or ''' */
30  FMT_CONT_COMMENT_C = (1 << 3) /* multi-line comments, OSL only (C style) */
31 };
32 #define FMT_CONT_ALL \
33  (FMT_CONT_QUOTESINGLE | FMT_CONT_QUOTEDOUBLE | FMT_CONT_TRIPLE | FMT_CONT_COMMENT_C)
34 
35 int flatten_string(const struct SpaceText *st, FlattenString *fs, const char *in);
40 int flatten_string_strlen(FlattenString *fs, const char *str);
41 
46 int text_check_format_len(TextLine *line, unsigned int len);
53 void text_format_fill(const char **str_p, char **fmt_p, char type, int len);
58 void text_format_fill_ascii(const char **str_p, char **fmt_p, char type, int len);
59 
60 /* *** Generalize Formatting *** */
61 typedef struct TextFormatType {
63 
64  char (*format_identifier)(const char *string);
65 
66  /* Formats the specified line. If do_next is set, the process will move on to
67  * the succeeding line if it is affected (eg. multi-line strings). Format strings
68  * may contain any of the following characters:
69  *
70  * It is terminated with a null-terminator '\0' followed by a continuation
71  * flag indicating whether the line is part of a multi-line string.
72  *
73  * See: FMT_TYPE_ enums below
74  */
75  void (*format_line)(SpaceText *st, TextLine *line, bool do_next);
76 
77  const char **ext; /* NULL terminated extensions */
79 
80 enum {
101 };
102 
105 
106 /* formatters */
107 void ED_text_format_register_py(void);
108 void ED_text_format_register_osl(void);
109 void ED_text_format_register_lua(void);
110 void ED_text_format_register_pov(void);
112 
113 #define STR_LITERAL_STARTSWITH(str, str_literal, len_var) \
114  (strncmp(str, str_literal, len_var = (sizeof(str_literal) - 1)) == 0)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
SyclQueue void void size_t num_bytes void
int len
Definition: draw_manager.c:108
#define str(s)
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
int fixedaccum[256]
Definition: text_format.h:13
char fixedbuf[256]
Definition: text_format.h:12
struct TextFormatType * prev
Definition: text_format.h:62
struct TextFormatType * next
Definition: text_format.h:62
char(* format_identifier)(const char *string)
Definition: text_format.h:64
const char ** ext
Definition: text_format.h:77
void(* format_line)(SpaceText *st, TextLine *line, bool do_next)
Definition: text_format.h:75
struct TextFormatType TextFormatType
int flatten_string_strlen(FlattenString *fs, const char *str)
Definition: text_format.c:99
void text_format_fill(const char **str_p, char **fmt_p, char type, int len)
Definition: text_format.c:127
void ED_text_format_register_lua(void)
void flatten_string_free(FlattenString *fs)
Definition: text_format.c:89
int flatten_string(const struct SpaceText *st, FlattenString *fs, const char *in)
void ED_text_format_register_osl(void)
@ FMT_CONT_QUOTEDOUBLE
Definition: text_format.h:26
@ FMT_CONT_QUOTESINGLE_TRIPLE
Definition: text_format.h:28
@ FMT_CONT_QUOTEDOUBLE_TRIPLE
Definition: text_format.h:29
@ FMT_CONT_QUOTESINGLE
Definition: text_format.h:25
@ FMT_CONT_TRIPLE
Definition: text_format.h:27
@ FMT_CONT_NOP
Definition: text_format.h:24
@ FMT_CONT_COMMENT_C
Definition: text_format.h:30
void ED_text_format_register_py(void)
TextFormatType * ED_text_format_get(Text *text)
Definition: text_format.c:172
void ED_text_format_register_pov_ini(void)
struct FlattenString FlattenString
@ FMT_TYPE_DIRECTIVE
Definition: text_format.h:92
@ FMT_TYPE_STRING
Definition: text_format.h:90
@ FMT_TYPE_COMMENT
Definition: text_format.h:84
@ FMT_TYPE_SPECIAL
Definition: text_format.h:94
@ FMT_TYPE_DEFAULT
Definition: text_format.h:100
@ FMT_TYPE_KEYWORD
Definition: text_format.h:98
@ FMT_TYPE_WHITESPACE
Definition: text_format.h:82
@ FMT_TYPE_NUMERAL
Definition: text_format.h:88
@ FMT_TYPE_RESERVED
Definition: text_format.h:96
@ FMT_TYPE_SYMBOL
Definition: text_format.h:86
void ED_text_format_register_pov(void)
void text_format_fill_ascii(const char **str_p, char **fmt_p, char type, int len)
Definition: text_format.c:149
void ED_text_format_register(TextFormatType *tft)
Definition: text_format.c:167
int text_check_format_len(TextLine *line, unsigned int len)
Definition: text_format.c:106