Blender V4.3
text_format.hh File Reference
#include "BLI_span.hh"

Go to the source code of this file.

Classes

struct  FlattenString
 
struct  TextFormatType
 

Macros

#define FMT_CONT_ALL    (FMT_CONT_QUOTESINGLE | FMT_CONT_QUOTEDOUBLE | FMT_CONT_TRIPLE | FMT_CONT_COMMENT_C)
 

Enumerations

enum  {
  FMT_CONT_NOP = 0 , FMT_CONT_QUOTESINGLE = (1 << 0) , FMT_CONT_QUOTEDOUBLE = (1 << 1) , FMT_CONT_TRIPLE = (1 << 2) ,
  FMT_CONT_QUOTESINGLE_TRIPLE = (FMT_CONT_TRIPLE | FMT_CONT_QUOTESINGLE) , FMT_CONT_QUOTEDOUBLE_TRIPLE = (FMT_CONT_TRIPLE | FMT_CONT_QUOTEDOUBLE) , FMT_CONT_COMMENT_C = (1 << 3)
}
 
enum  {
  FMT_TYPE_WHITESPACE = '_' , FMT_TYPE_COMMENT = '#' , FMT_TYPE_SYMBOL = '!' , FMT_TYPE_NUMERAL = 'n' ,
  FMT_TYPE_STRING = 'l' , FMT_TYPE_DIRECTIVE = 'd' , FMT_TYPE_SPECIAL = 'v' , FMT_TYPE_RESERVED = 'r' ,
  FMT_TYPE_KEYWORD = 'b' , FMT_TYPE_DEFAULT = 'q'
}
 

Functions

int flatten_string (const SpaceText *st, FlattenString *fs, const char *in)
 
void flatten_string_free (FlattenString *fs)
 
int flatten_string_strlen (FlattenString *fs, const char *str)
 
int text_check_format_len (TextLine *line, unsigned int len)
 
void text_format_fill (const char **str_p, char **fmt_p, char type, int len)
 
void text_format_fill_ascii (const char **str_p, char **fmt_p, char type, int len)
 
TextFormatTypeED_text_format_get (Text *text)
 
void ED_text_format_register (TextFormatType *tft)
 
void ED_text_format_register_glsl ()
 
void ED_text_format_register_py ()
 
void ED_text_format_register_osl ()
 
void ED_text_format_register_pov ()
 
void ED_text_format_register_pov_ini ()
 
int text_format_string_literal_find (Span< const char * > string_literals, const char *text)
 
const bool text_format_string_literals_check_sorted_array (Span< const char * > string_literals)
 

Macro Definition Documentation

◆ FMT_CONT_ALL

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Format continuation flags (stored just after the null terminator).

Enumerator
FMT_CONT_NOP 
FMT_CONT_QUOTESINGLE 
FMT_CONT_QUOTEDOUBLE 
FMT_CONT_TRIPLE 
FMT_CONT_QUOTESINGLE_TRIPLE 
FMT_CONT_QUOTEDOUBLE_TRIPLE 
FMT_CONT_COMMENT_C 

Definition at line 30 of file text_format.hh.

◆ anonymous enum

anonymous enum
Enumerator
FMT_TYPE_WHITESPACE 

White-space

FMT_TYPE_COMMENT 

Comment text

FMT_TYPE_SYMBOL 

Punctuation and other symbols

FMT_TYPE_NUMERAL 

Numerals

FMT_TYPE_STRING 

String letters

FMT_TYPE_DIRECTIVE 

Decorator / Pre-processor directive

FMT_TYPE_SPECIAL 

Special variables (class, def)

FMT_TYPE_RESERVED 

Reserved keywords currently not in use, but still prohibited (OSL -> switch e.g.)

FMT_TYPE_KEYWORD 

Built-in names (return, for, etc.)

FMT_TYPE_DEFAULT 

Regular text (identifiers, etc.)

Definition at line 90 of file text_format.hh.

Function Documentation

◆ ED_text_format_get()

TextFormatType * ED_text_format_get ( Text * text)

◆ ED_text_format_register()

◆ ED_text_format_register_glsl()

◆ ED_text_format_register_osl()

◆ ED_text_format_register_pov()

◆ ED_text_format_register_pov_ini()

◆ ED_text_format_register_py()

◆ flatten_string()

◆ flatten_string_free()

◆ flatten_string_strlen()

int flatten_string_strlen ( FlattenString * fs,
const char * str )

Takes a string within fs->buf and returns its length.

Definition at line 100 of file text_format.cc.

References BLI_assert, FlattenString::buf, int, len, FlattenString::pos, and str.

◆ text_check_format_len()

int text_check_format_len ( TextLine * line,
unsigned int len )

Ensures the format string for the given line is long enough, reallocating as needed. Allocation is done here, alone, to ensure consistency.

Definition at line 107 of file text_format.cc.

References len, MEM_freeN(), and MEM_mallocN.

Referenced by txtfmt_glsl_format_line(), txtfmt_osl_format_line(), txtfmt_pov_format_line(), txtfmt_pov_ini_format_line(), and txtfmt_py_format_line().

◆ text_format_fill()

void text_format_fill ( const char ** str_p,
char ** fmt_p,
char type,
int len )

Fill the string with formatting constant, advancing str_p and fmt_p

Parameters
lenlength in bytes of fmt_p to fill.

Definition at line 128 of file text_format.cc.

References BLI_assert, BLI_str_utf8_size_safe(), len, size(), and str.

Referenced by txtfmt_glsl_format_line(), txtfmt_osl_format_line(), txtfmt_pov_format_line(), txtfmt_pov_ini_format_line(), and txtfmt_py_format_line().

◆ text_format_fill_ascii()

void text_format_fill_ascii ( const char ** str_p,
char ** fmt_p,
char type,
int len )

ASCII version of text_format_fill, use when we no the text being stepped over is ascii (as is the case for most keywords)

Definition at line 150 of file text_format.cc.

References BLI_assert, len, and str.

Referenced by txtfmt_glsl_format_line(), txtfmt_osl_format_line(), txtfmt_pov_format_line(), txtfmt_pov_ini_format_line(), and txtfmt_py_format_line().

◆ text_format_string_literal_find()

int text_format_string_literal_find ( Span< const char * > string_literals,
const char * text )

Checks the specified source string #text for a string literal in #string_literals array. This string literal must start at the beginning of the source string.

If a string literal is found, the length of the string literal is returned. Otherwise, 0.

◆ text_format_string_literals_check_sorted_array()

const bool text_format_string_literals_check_sorted_array ( Span< const char * > string_literals)

Check if #string_literals array is shorted. This validation is required since text formatters do binary search on these string literals arrays. Used only for assertions.