Gin
Loading...
Searching...
No Matches
Files | Namespaces | Classes | Typedefs | Functions | Variables
utilities

Files

file  gin_varianthelpers.h
 Utility functions for working with JUCE var objects and their properties.
 

Namespaces

namespace  macOS
 macOS-specific image conversion utilities.
 
namespace  juce
 

Classes

class  LambdaTimer
 Timer that calls a std::function callback instead of requiring virtual override. More...
 
class  LambdaAsyncUpdater
 Async updater that calls a std::function callback instead of requiring virtual override. More...
 
class  LambdaMouseListener
 Mouse listener that uses std::function callbacks instead of virtual overrides. More...
 
class  CoalescedTimer
 An efficient timer that shares a single juce::Timer between multiple instances. More...
 
class  ComponentMap
 Internal class for mapping component paths to component pointers. More...
 
class  ElevatedFileCopy
 Copies files, creating folders where required requesting admin access only if required. More...
 
class  ConstantsStack
 
class  ConstantsStack::ScopedSave
 
class  Parser
 
class  LayoutSupport
 JSON-based layout system for JUCE components. More...
 
struct  LayoutSupport::Bounds
 
struct  LayoutSupport::JsonFile
 
class  OpenStreetMaps
 Fetches map files from OSM servers. More...
 
class  OpenStreetMaps::Listener
 
class  SystemClipboard
 Utilities for reading and writing images to the system clipboard. More...
 
class  AsyncDownload
 Async Download. More...
 
struct  Property
 Simple key-value pair structure for representing a property. More...
 
struct  juce::VarIterator
 Iterator for a var. More...
 
struct  juce::VarIterator::NamedValue
 

Typedefs

using juce::VarIterator::difference_type = std::ptrdiff_t
 
using juce::VarIterator::value_type = NamedValue
 
using juce::VarIterator::reference = NamedValue &
 
using juce::VarIterator::pointer = NamedValue *
 
using juce::VarIterator::iterator_category = std::forward_iterator_tag
 

Functions

void callOnMainThreadBlocking (std::function< void()> func)
 
juce::Colour goldenRatioColor (int idx)
 Returns the next colour in a set where the hues differ by the golden ratio.
 
void asyncDownload (const juce::URL &, std::function< void(const juce::String &)>)
 
void asyncDownload (const juce::URL &, std::function< void(const juce::MemoryBlock &)>)
 
juce::Image createDesktopSnapshot ()
 
juce::Image createSnapshotOfNativeWindow (juce::Component &c)
 
 Property::Property ()=default
 
 Property::Property (const juce::String &k, const juce::var v)
 Construct a Property with a key and value.
 
juce::var getPropertyWithDefault (const juce::var &v, const juce::Identifier &i, const juce::var &defaultValue)
 Get a property value with a default fallback.
 
void setProperty (juce::var &v, const juce::Identifier &i, const juce::var &value)
 Set a property on a var object.
 
bool setJSONPointer (juce::var &v, juce::String pointer, const juce::var &newValue)
 Given a JSON array/object 'v', a string representing a JSON pointer, and a new property value 'newValue', updates 'v' where the property or array index referenced by the pointer has been set to 'newValue'.
 
juce::var getJSONPointer (const juce::var &v, juce::String pointer, const juce::var &defaultValue)
 Given a JSON array/object 'v', a string representing a JSON pointer, returns the value of the property or array index referenced by the pointer If the pointer cannot be followed, due to referencing missing array indices or fields, then this returns defaultValue.
 
juce::String removeJsonComments (const juce::String &input)
 Remove C-style and C++-style comments from a JSON string.
 
 juce::VarIterator::VarIterator (const juce::var &, bool isEnd)
 
VarIteratorjuce::VarIterator::operator++ ()
 
bool juce::VarIterator::operator== (const VarIterator &) const
 
bool juce::VarIterator::operator!= (const VarIterator &) const
 
NamedValue juce::VarIterator::operator* () const
 
VarIterator juce::begin (const juce::var &)
 
VarIterator juce::end (const juce::var &)
 

Variables

juce::String Property::key
 Property name/key.
 
juce::var Property::value
 Property value.
 
juce::var juce::VarIterator::NamedValue::name
 
juce::var juce::VarIterator::NamedValue::value
 

Detailed Description

Typedef Documentation

◆ difference_type

◆ value_type

◆ reference

◆ pointer

◆ iterator_category

using juce::VarIterator::iterator_category = std::forward_iterator_tag

Function Documentation

◆ callOnMainThreadBlocking()

void callOnMainThreadBlocking ( std::function< void()>  func)

◆ goldenRatioColor()

juce::Colour goldenRatioColor ( int  idx)

Returns the next colour in a set where the hues differ by the golden ratio.

Good for coming up with a random set of colours

◆ asyncDownload() [1/2]

void asyncDownload ( const juce::URL &  ,
std::function< void(const juce::String &)>   
)

◆ asyncDownload() [2/2]

void asyncDownload ( const juce::URL &  ,
std::function< void(const juce::MemoryBlock &)>   
)

◆ createDesktopSnapshot()

juce::Image createDesktopSnapshot ( )

◆ createSnapshotOfNativeWindow()

juce::Image createSnapshotOfNativeWindow ( juce::Component &  c)

◆ Property() [1/2]

Property::Property ( )
default

◆ Property() [2/2]

Property::Property ( const juce::String &  k,
const juce::var  v 
)

Construct a Property with a key and value.

Parameters
kProperty key/name
vProperty value

◆ getPropertyWithDefault()

juce::var getPropertyWithDefault ( const juce::var &  v,
const juce::Identifier &  i,
const juce::var &  defaultValue 
)

Get a property value with a default fallback.

Returns the property value if it exists, otherwise returns the default value. This is a safer alternative to direct property access when the property might not exist.

Parameters
vThe var object to get the property from
iProperty name identifier
defaultValueValue to return if property doesn't exist
Returns
Property value if it exists, otherwise defaultValue
juce::var obj = new juce::DynamicObject();
obj.getDynamicObject()->setProperty ("width", 100);
auto w = getPropertyWithDefault (obj, "width", 50); // Returns 100
auto h = getPropertyWithDefault (obj, "height", 50); // Returns 50 (default)
A lightweight 2D point class for projects that don't use juce_graphics.
Definition gin_point.h:25
juce::var getPropertyWithDefault(const juce::var &v, const juce::Identifier &i, const juce::var &defaultValue)
Get a property value with a default fallback.
Definition gin_varianthelpers.h:156

◆ setProperty()

void setProperty ( juce::var &  v,
const juce::Identifier &  i,
const juce::var &  value 
)

Set a property on a var object.

If the var contains a DynamicObject, sets the property on it. If the var is not a DynamicObject, this function does nothing.

Parameters
vThe var object to set the property on (passed by reference)
iProperty name identifier
valueValue to set for the property
juce::var obj = new juce::DynamicObject();
setProperty (obj, "width", 100);
setProperty (obj, "height", 200);
// obj now has properties: width=100, height=200
void setProperty(juce::var &v, const juce::Identifier &i, const juce::var &value)
Set a property on a var object.
Definition gin_varianthelpers.h:181

◆ setJSONPointer()

bool setJSONPointer ( juce::var &  v,
juce::String  pointer,
const juce::var &  newValue 
)

Given a JSON array/object 'v', a string representing a JSON pointer, and a new property value 'newValue', updates 'v' where the property or array index referenced by the pointer has been set to 'newValue'.

If the pointer cannot be followed, due to referencing missing array indices or fields, then this returns false. For more details, check the JSON Pointer RFC 6901: https://datatracker.ietf.org/doc/html/rfc6901

◆ getJSONPointer()

juce::var getJSONPointer ( const juce::var &  v,
juce::String  pointer,
const juce::var &  defaultValue 
)

Given a JSON array/object 'v', a string representing a JSON pointer, returns the value of the property or array index referenced by the pointer If the pointer cannot be followed, due to referencing missing array indices or fields, then this returns defaultValue.

For more details, check the JSON Pointer RFC 6901: https://datatracker.ietf.org/doc/html/rfc6901

◆ removeJsonComments()

juce::String removeJsonComments ( const juce::String &  input)

Remove C-style and C++-style comments from a JSON string.

This function strips both line comments and block comments from JSON text, allowing you to use commented JSON files. Comments within string literals are preserved.

Supported comment styles:

  • Line comments (until end of line)
  • Block comments (can span multiple lines)

String handling:

  • Comments inside quoted strings are NOT removed
  • Escaped quotes (") are properly handled
  • Backslashes within strings are preserved
Parameters
inputThe JSON string potentially containing comments
Returns
The JSON string with all comments removed
Note
This allows you to use more readable, documented JSON configuration files while still being able to parse them with standard JSON parsers.
See also
https://jsonc.org/ for more about JSON with Comments (JSONC) format

◆ VarIterator()

juce::VarIterator::VarIterator ( const juce::var &  ,
bool  isEnd 
)

◆ operator++()

VarIterator & juce::VarIterator::operator++ ( )

◆ operator==()

bool juce::VarIterator::operator== ( const VarIterator ) const

◆ operator!=()

bool juce::VarIterator::operator!= ( const VarIterator ) const

◆ operator*()

NamedValue juce::VarIterator::operator* ( ) const

◆ begin()

VarIterator juce::begin ( const juce::var &  )

◆ end()

VarIterator juce::end ( const juce::var &  )

Variable Documentation

◆ key

juce::String Property::key

Property name/key.

◆ value [1/2]

juce::var Property::value

Property value.

◆ name

juce::var juce::VarIterator::NamedValue::name

◆ value [2/2]

juce::var juce::VarIterator::NamedValue::value