Nuke binary plugins 15.0.5
 
Loading...
Searching...
No Matches
DD::Image::Knob::cstring Class Reference

#include <Knob.h>

Public Member Functions

 cstring (const char *s, int n=-1)
 
 cstring (const std::string &s)
 

Static Public Member Functions

static bool needQuotes (const char *s)
 
static bool needQuotes (const char *s, size_t n)
 
static bool needQuotes (const std::string &s)
 

Public Attributes

const char * contents
 
size_t length
 

Detailed Description

This "class" will print a string in script notation to an ostream. Writing a series of these separated by spaces will produce output that can later be split apart with Split_List. This can be used by a Knob::to_script() method.

You use it by doing "o << cstring(s)" where s is a const char*.

You can also output an arbitrary length of characters with "o << cstring(s,length)". This is useful for truncating the string. It should be useful for writing arbitrary binary data, but in the current version if you write a null the script parser will turn it into the illegal UTF-8 2-byte sequence 0xc0,0x80.

The current version puts double quotes around it if is contains any characters that tcl does not handle and adds backslash quoting. Therefore "foo123" prints unchanged, but "foo bar \baz" prints as "foo bar \\baz" with quotes around it.

Member Function Documentation

◆ needQuotes()

bool Knob::cstring::needQuotes ( const char *  s)
static

Returns true if <<cstring(w) will put quotes around the string. This always returns true if the string has a '{' in it.

Referenced by DD::Image::escape().



©2024 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.foundry.com