Specifier Name-Value Pairs

Name Value Pairs are used in order to allow arbitrary data specification into the Plot Data Constructor. A Name Value pair object is exactly as it sounds – a struct containing a name, and an arbitrary data type associated with that name.

Usage

Name-Value Pairs can either be constructed explicitly

#include <iostream>
#include "JSL.h"
int main(int argc, char * argv[])
{
        using namespace JSL;
        Vector x = Vector::linspace(0,10,100)
        auto y = x + 10;

        gnuplot gp;
        gp.Plot(x,y,NameValuePair(PenSize,10),NameValuePair(Colour,"red"));
        gp.Show();
}

Or, they can be constructed by one of the constructors provided within the JSL::LineProperty namespace:

#include <iostream>
#include "JSL.h"
int main(int argc, char * argv[])
{
        using namespace JSL;
        Vector x = Vector::linspace(0,10,100)
        auto y = x + 10;

        gnuplot gp;
        gp.Plot(x,y,LineProperty::Colour("green"),LineProperty::Legend("Straight Line"));
        gp.Show();
}

The full list of constructors is listed below.

Permitted Names

Whilst arbitrary names (i.e. strings) would be possible, we limit the names to members of the following enum group, and hence ensure that all NV-pairs are associated with a valid line property.

enum JSL::Property

Values:

enumerator Colour
enumerator PenSize
enumerator PenType
enumerator Legend

NameValue Pair Object

template<typename T>
struct JSL::NameValuePair

A simple struct for associating a datatype a member of JSL::Property.

Public Functions

inline NameValuePair(Property name, T value)

Boring constructor.

Public Members

Property Name

Informs JSL::PlotData which internal property the Value is associated with.

T Value

An arbitrary datum, which JSL::PlotData will try to interpret using one of its many template functions.

LineProperty Functions

template<typename T>
inline NameValuePair<T> JSL::LineProperties::Colour(T c)

Auto constructs single-argument colour specifier. Has to be template because can use either string or std::vector types to specify.

inline NameValuePair<int> JSL::LineProperties::PenSize(int w)

Auto constructs pensize specifier.

inline NameValuePair<LineType> JSL::LineProperties::PenType(LineType c)

Auto constructs pentype specifier.

inline NameValuePair<JSL::ScatterType> JSL::LineProperties::ScatterType(JSL::ScatterType c)

Auto constructs scattertype specifier.

inline NameValuePair<std::string> JSL::LineProperties::Legend(std::string s)

Auto constructs legend specifier.