This file is indexed.

/usr/include/libqalculate/Function.h is in libqalculate-dev 0.9.7-9.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
/*
    Qalculate    

    Copyright (C) 2003-2007  Niklas Knutsson (nq@altern.org)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
*/

#ifndef FUNCTION_H
#define FUNCTION_H

#include <libqalculate/ExpressionItem.h>
#include <libqalculate/includes.h>

/** @file */

///Argument types
typedef enum {
	ARGUMENT_TYPE_FREE,
	ARGUMENT_TYPE_SYMBOLIC,
	ARGUMENT_TYPE_TEXT,
	ARGUMENT_TYPE_DATE,
	ARGUMENT_TYPE_FILE,
	ARGUMENT_TYPE_INTEGER,	
	ARGUMENT_TYPE_NUMBER,
	ARGUMENT_TYPE_VECTOR,	
	ARGUMENT_TYPE_MATRIX,
	ARGUMENT_TYPE_EXPRESSION_ITEM,
	ARGUMENT_TYPE_FUNCTION,	
	ARGUMENT_TYPE_UNIT,
	ARGUMENT_TYPE_BOOLEAN,
	ARGUMENT_TYPE_VARIABLE,
	ARGUMENT_TYPE_ANGLE,
	ARGUMENT_TYPE_SET,
	ARGUMENT_TYPE_DATA_OBJECT,
	ARGUMENT_TYPE_DATA_PROPERTY
} ArgumentType;

///Predefined max and min values for number and integer arguments.
typedef enum {
	ARGUMENT_MIN_MAX_NONE,
	ARGUMENT_MIN_MAX_POSITIVE,
	ARGUMENT_MIN_MAX_NONZERO,
	ARGUMENT_MIN_MAX_NONNEGATIVE,
	ARGUMENT_MIN_MAX_NEGATIVE	
} ArgumentMinMaxPreDefinition;

/// Type of mathematical function
typedef enum {
	/// class MathFunction
	SUBTYPE_FUNCTION,
	/// class UseFunction
	SUBTYPE_USER_FUNCTION,
	/// class DataSet
	SUBTYPE_DATA_SET
} FunctionSubtype;

/// Abstract base class for mathematical functions.
/**
* A mathemical function, subclassed from MathFunction, should at least reimplement
* calculate(MathStructure&, const MathStructure&, const EvaluationOptions&) and copy(), and preferably also the represents* functions.
* Argument definitions should be added in the constructor.
*/
class MathFunction : public ExpressionItem {

  protected:

	int argc;
	int max_argc;
	vector<string> default_values;
	Sgi::hash_map<size_t, Argument*> argdefs;
	size_t last_argdef_index;		
	bool testArguments(MathStructure &vargs);
	virtual MathStructure createFunctionMathStructureFromVArgs(const MathStructure &vargs);
	virtual MathStructure createFunctionMathStructureFromSVArgs(vector<string> &svargs);	
	string scondition;
	
  public:
  
	MathFunction(string name_, int argc_, int max_argc_ = 0, string cat_ = "", string title_ = "", string descr_ = "", bool is_active = true);
	MathFunction(const MathFunction *function);
	MathFunction();
	virtual ~MathFunction();	

	virtual ExpressionItem *copy() const = 0;
	virtual void set(const ExpressionItem *item);
	virtual int type() const;
	/** Returns the subtype of the mathematical function,  corresponding to which subsubclass the object belongs to.
	*
	* @returns ::FunctionSubtype.
	*/
	virtual int subtype() const;

	bool testArgumentCount(int itmp);
	virtual MathStructure calculate(const string &eq, const EvaluationOptions &eo = default_evaluation_options);
	virtual MathStructure parse(const string &eq, const ParseOptions &po = default_parse_options);
	virtual int parse(MathStructure &mstruct, const string &eq, const ParseOptions &po = default_parse_options);
	virtual MathStructure calculate(MathStructure &vargs, const EvaluationOptions &eo = default_evaluation_options);
	/**
	* The main function for subclasses to reimplement.
	* Calculates a value from arguments in vargs and puts it in mstruct.
	*
	* This function expects the number of arguments to be equal to the maximum number of arguments, and checked by the argument definitions.
	*
	* If the return value is negative, then argument -(return value) has been evaluated in mstruct.
	* If -(return value) is greater than max arguments, then mstruct is a vector of evaluated argument values.
	*
	* @param[out] mstruct Structure that is set with the result of the calculation.
	* @param vargs Arguments passed to the mathematical function.
	* @param eo Evaluation options.
	* @returns 1 if the calculation was successful.
	*/
	virtual int calculate(MathStructure &mstruct, const MathStructure &vargs, const EvaluationOptions &eo);
	/** Returns the functions condition expression.
	*
	* @returns The function's condition expression 
	*/
	string condition() const;
	/** Print the function's condition expression with argument names.
	*
	* @returns The printed condition 
	*/
	string printCondition();
	/** Sets the functions condition expression.
	*
	* @param expression The function's new condition expression 
	*/
	void setCondition(string expression);
	/** Test if arguments fulfil the function's condition expression.
	*
	* @param vargs Vector with arguments.
	* @returns true if the arguments fulfil the function's condition expression 
	*/
	bool testCondition(const MathStructure &vargs);
	/** Returns the maximum number of arguments that the function accepts or -1 if the number of arguments is unlimited.
	*/
	int args() const;
	/** Returns the minimum number of arguments for the function.
	*/
	int minargs() const;
	/** Returns the maximum number of arguments that the function accepts or -1 if the number of arguments is unlimited.
	*/
	int maxargs() const;
	/** Parses arguments from a text string and places them in a vector. The text string should be a comma separated list of arguments.
	*	
	* @param str The argument string to parse.
	* @param vargs Vector to store parsed arguments in.
	* @param po Parse options.
	* @returns The number of parsed arguments.
	*/
	int args(const string &str, MathStructure &vargs, const ParseOptions &po = default_parse_options);
	/** Returns the index of the last argument definition.
	*
	* @returns The index of the last argument definition 
	*/
	size_t lastArgumentDefinitionIndex() const;
	/** Returns the argument definition for an argument index.
	*
	* @param index Argument index.
	* @returns The argument definition for the index or NULL if no the argument was not defined for the index 
	*/
	Argument *getArgumentDefinition(size_t index);
	/** Removes all argument definitions for the function.
	*/
	void clearArgumentDefinitions();
	/** Set the argument definition for an argument index.
	*
	* @param index Argument index.
	* @param argdef A newly allocated argument definition 
	*/
	void setArgumentDefinition(size_t index, Argument *argdef);
	int stringArgs(const string &str, vector<string> &svargs);
	void setDefaultValue(size_t arg_, string value_);
	const string &getDefaultValue(size_t arg_) const;
	void appendDefaultValues(MathStructure &vargs);
	MathStructure produceVector(const MathStructure &vargs, int begin = -1, int end = -1);
	MathStructure produceArgumentsVector(const MathStructure &vargs, int begin = -1, int end = -1);
	
	virtual bool representsPositive(const MathStructure&, bool = false) const;
	virtual bool representsNegative(const MathStructure&, bool = false) const;
	virtual bool representsNonNegative(const MathStructure&, bool = false) const;
	virtual bool representsNonPositive(const MathStructure&, bool = false) const;
	virtual bool representsInteger(const MathStructure&, bool = false) const;
	virtual bool representsNumber(const MathStructure&, bool = false) const;
	virtual bool representsRational(const MathStructure&, bool = false) const;
	virtual bool representsReal(const MathStructure&, bool = false) const;
	virtual bool representsComplex(const MathStructure&, bool = false) const;
	virtual bool representsNonZero(const MathStructure&, bool = false) const;
	virtual bool representsEven(const MathStructure&, bool = false) const;
	virtual bool representsOdd(const MathStructure&, bool = false) const;
	virtual bool representsUndefined(const MathStructure&) const;
	virtual bool representsBoolean(const MathStructure&) const;
	virtual bool representsNonMatrix(const MathStructure&) const;
	
};

/// A user defined mathematical function.
/**
* User functions are functions defined using expression strings, representing mathematical formulas.
*
* The expression/formula of a function is basically a normal expression with placeholders for arguments.
* These placeholders consists of a backslash and a letter — x, y, z for the 1st, 2nd and 3rd arguments and a to u for argument 4 to 24.
* They are replaced by entered arguments when a function is calculated.
* The placeholders naturally also decide the number of arguments that a function requires.
* For example the function for triangle area ("base * height / 2") has the name triangle and the formula "(\x*\y)/2",
* which gives that "triangle(2, 3)" equals "(2*3) / 2" and returns "3" as result.
* An argument can be used more than one time and all arguments must not necessarily be in order in the formula.
*
* Additionally, optional arguments can be put in the formula with upper-case (X, Y, Z, ...) instead of lower-case letters (x, y, z, ...).
* The default value can be put in brackets after the letter (ex. "\X{2}").
* The default value may be omitted and is then zero. All additional arguments after an optional argument must also be optional.
*
* To simplify the formula and make it more efficient, subfunctions can be used.
* These works just like the main formula, using the arguments of it.
* Subfunctions are referenced in the formula using \index ('\2', '\2', '\3', ...).
* Even though it would be quite meaningless, the formula for triangle function could for example have a subfunction "\x*\y" and the formula "\1/2".
* Subfunctions must be added before the main formula is set.
*/
class UserFunction : public MathFunction {
  protected:
  
	string sformula, sformula_calc;
	vector<string> v_subs;
	vector<bool> v_precalculate;
	
  public:
  
	UserFunction(string cat_, string name_, string formula_, bool is_local = true, int argc_ = -1, string title_ = "", string descr_ = "", int max_argc_ = 0, bool is_active = true);
	UserFunction(const UserFunction *function);
	void set(const ExpressionItem *item);
	ExpressionItem *copy() const;
	/** Returns the external representation of the formula. */
	string formula() const;
	/** Returns the internal representation of the formula. */
	string internalFormula() const;
	int calculate(MathStructure &mstruct, const MathStructure &vargs, const EvaluationOptions &eo);
	/** Sets the formula of the mathematical function.
	*
	* @param new_formula Formula/expression.
	* @param arc_ Minimum number of arguments or -1 to read from formula.
	* @param max_argc_ Maximum number of arguments (ignored if argc_ < 0)
	*/
	void setFormula(string new_formula, int argc_ = -1, int max_argc_ = 0);
	void addSubfunction(string subfunction, bool precalculate = true);
	/** Sets the formula for a subfunction.
	*
	* @param index Index (starting at 1).
	* @param subfunction Formula/expression.
	*/
	void setSubfunction(size_t index, string subfunction);
	void delSubfunction(size_t index);
	void clearSubfunctions();
	size_t countSubfunctions() const;
	void setSubfunctionPrecalculated(size_t index, bool precalculate);
	const string &getSubfunction(size_t index) const;
	bool subfunctionPrecalculated(size_t index) const;
	int subtype() const;
};

/// A mathematical function argument definition with free value and base class for all argument definitions.
/** Free arguments accepts any value.
*/
class Argument {

  protected:
  
  	string sname, scondition;
	bool b_zero, b_test, b_matrix, b_text, b_error, b_rational;
	/** This function is called from Argument::test() and performs validation specific to the argument definition type.
	* Should be reimplemented by all subclasses.
	*
	* @param value Value to test.
	* @param eo Evaluation options to use if the value needs to be evaluated.
	* @returns true if the value is valid for the argument definition.
	*/
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;
	/** This function is called from Argument::printlong() and returns description specific the argument definition type.
	* Should be reimplemented by all subclasses. For example IntegerArgument::subprintlong() might return "an integer"
	* and Argument::printlong() might append " that fulfills the condition: even(\x)".
	*
	* @returns Long description.
	*/
	virtual string subprintlong() const;
	
  public:

	/** Creates a new argument definition.
	*
	* @param name Name/title of the argument definition.
	* @param does_test If argument values will be tested.
	* @param does_error If an error will issued if the value tests false.
	*/
	Argument(string name_ = "", bool does_test = true, bool does_error = true);
	/** Creates a copy of an argument definition.
	*
	* @param arg Argument to copy.
	*/
	Argument(const Argument *arg);
	/** Destructor */
	virtual ~Argument();

	/** Sets the argument to a copy of an argument definition.
	*
	* @param arg Argument to copy.
	*/
	virtual void set(const Argument *arg);
	/** Returns a copy of the argument definition.
	*
	* @returns A copy.
	*/
	virtual Argument *copy() const;

	/** Resturns a short description of the argument definition.
	* Ex. "number" for NumberArgument.
	*
	* @returns Short description.
	*/
	virtual string print() const;
	/** Resturns a long description of the argument definition.
	* Ex. "A real number > 2".
	*
	* @returns Long description.
	*/
	string printlong() const;

	/** Tests if a value fulfils the requirements of the argument definition.
	* The value might change if it has not been fully evaluated.
	*
	* @param value Value to test.
	* @param f Mathematical function that the value is an argument for.
	* @param eo Evaluation options to use if the value needs to be evaluated.
	* @returns true if the value is valid for the argument definition.
	*/
	bool test(MathStructure &value, int index, MathFunction *f, const EvaluationOptions &eo = default_evaluation_options) const;
	/** Parses an expression for an argument value.
	* The default behavior is to use Calculator::parse() directly.
	*
	* @param str Expression.
	* @param po Parse options.
	* @returns A new mathematical structure with the parsed expression.
	*/
	virtual MathStructure parse(const string &str, const ParseOptions &po = default_parse_options) const;
	/** Parses an expression for an argument value.
	* The default behavior is to use Calculator::parse() directly.
	*
	* @param mstruct Mathematical structure to set with the parsed expression.
	* @param str Expression.
	* @param po Parse options.
	*/
	virtual void parse(MathStructure *mstruct, const string &str, const ParseOptions &po = default_parse_options) const;

	/** Returns the name/title of the argument definition.
	*
	* @returns Name/title.
	*/
	string name() const;
	/** Sets the name/title of the argument definition.
	*
	* @param name_ New name/title.
	*/
	void setName(string name_);

	/** Sets a custom condition for argument values.
	* '\x' is replaced by the argument value in the expression.
	*
	* @param condition Condition expression.
	*/
	void setCustomCondition(string condition);
	/** Returns the custom condition expression set for argument values.
	*
	* @returns Custom condition for argument values.
	*/
	string getCustomCondition() const;

	/** If the value for the argument will be tested. If not, the argument only works as an suggestion and any value is allowed.
	*
	* @returns true if the argument value will be tested.
	*/
	bool tests() const;
	void setTests(bool does_error);

	/** If an error message will be presented to the user if the value for the argument is not allowed.
	*
	* @returns true if error messages will be shown.
	*/
	bool alerts() const;
	void setAlerts(bool does_error);

	/** If an argument value of zero is forbidden.
	*
	* @returns true if zero argument value is forbidden.
	*/
	bool zeroForbidden() const;
	/** Sets if a value of zero is forbidden for the argument value.
	*
	* @param forbid_zero If zero shall be forbidden.
	*/	
	void setZeroForbidden(bool forbid_zero);
	
	bool matrixAllowed() const;
	void setMatrixAllowed(bool allow_matrix);

	/** If only rational polynomials are allowed as argument value.
	*
	* @see MathStructure::isRationalPolynomial()
	* @returns true if only rational polynomials is allowed.
	*/
	bool rationalPolynomial() const;
	void setRationalPolynomial(bool rational_polynomial);
	
	virtual bool suggestsQuotes() const;

	/** Returns the type of the argument, corresponding to which subclass the object belongs to.
	*
	* @returns ::ArgumentType.
	*/
	virtual int type() const;

};

/// A definition for numerical arguments.
/** These arguments allows numerical values. The value can be restricted to real or rational numbers (defaults to allow all numbers, including complex), and a max and/or min value.
*/
class NumberArgument : public Argument {

  protected:
  
	Number *fmin, *fmax;
	bool b_incl_min, b_incl_max;
	bool b_complex, b_rational_number;

  protected:
  
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;  
	virtual string subprintlong() const;

  public:
  
  	NumberArgument(string name_ = "", ArgumentMinMaxPreDefinition minmax = ARGUMENT_MIN_MAX_NONE, bool does_test = true, bool does_error = true);
	NumberArgument(const NumberArgument *arg);
	virtual ~NumberArgument();
	
	virtual void set(const Argument *arg);
	virtual Argument *copy() const;

	virtual string print() const;	
	
	void setMin(const Number *nmin);	
	void setIncludeEqualsMin(bool include_equals);
	bool includeEqualsMin() const;	
	const Number *min() const;
	void setMax(const Number *nmax);	
	void setIncludeEqualsMax(bool include_equals);
	bool includeEqualsMax() const;	
	const Number *max() const;	
	
	bool complexAllowed() const;
	void setComplexAllowed(bool allow_complex);
	bool rationalNumber() const;
	void setRationalNumber(bool rational_number);

	virtual int type() const;

};

/// A definition for integer arguments.
/** These arguments allows numerical integer values. The value can be restricted to a max and/or min value.
*/
class IntegerArgument : public Argument {

  protected:
  
	Number *imin, *imax;

  protected:
  
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;
	virtual string subprintlong() const;

  public:
  
  	IntegerArgument(string name_ = "", ArgumentMinMaxPreDefinition minmax = ARGUMENT_MIN_MAX_NONE, bool does_test = true, bool does_error = true);
	IntegerArgument(const IntegerArgument *arg);
	virtual ~IntegerArgument();

	virtual void set(const Argument *arg);
	virtual Argument *copy() const;

	virtual string print() const;	

	void setMin(const Number *nmin);	
	const Number *min() const;
	void setMax(const Number *nmax);	
	const Number *max() const;
	
	virtual int type() const;

};

/// A symbolic argument.
/** Accepts variables and symbolic structures.
*/
class SymbolicArgument : public Argument {

  protected:
  
  	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;  
	virtual string subprintlong() const;

  public:

  	SymbolicArgument(string name_ = "", bool does_test = true, bool does_error = true);
	SymbolicArgument(const SymbolicArgument *arg);
	virtual ~SymbolicArgument();
	virtual int type() const;
	virtual Argument *copy() const;
	virtual string print() const;
};

/// A text argument.
/** Accepts text (symbolic) structures. Argument values are parsed as text, unless surrounded by back slashes (which are then removed). Surrounding Parentheses and first quotation marks are removed.
*/
class TextArgument : public Argument {

  protected:
  
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;  
	virtual string subprintlong() const;

  public:
  
  	TextArgument(string name_ = "", bool does_test = true, bool does_error = true);
	TextArgument(const TextArgument *arg);
	virtual ~TextArgument();
	virtual int type() const;
	virtual Argument *copy() const;
	virtual string print() const;
	virtual bool suggestsQuotes() const;
};

/// A date argument.
/** A text argument representing a date.
*/
class DateArgument : public Argument {

  protected:
  
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;  
	virtual string subprintlong() const;

  public:
  
  	DateArgument(string name_ = "", bool does_test = true, bool does_error = true);
	DateArgument(const DateArgument *arg);
	virtual ~DateArgument();
	virtual int type() const;
	virtual Argument *copy() const;
	virtual string print() const;
};

/// A vector argument.
/**
*/
class VectorArgument : public Argument {

  protected:
  
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;  
	virtual string subprintlong() const;
	vector<Argument*> subargs;
	bool b_argloop;

  public:
  
  	VectorArgument(string name_ = "", bool does_test = true, bool allow_matrix = false, bool does_error = true);
	VectorArgument(const VectorArgument *arg);
	virtual ~VectorArgument();
	virtual int type() const;
	virtual Argument *copy() const;
	virtual string print() const;
	bool reoccuringArguments() const;
	void setReoccuringArguments(bool reocc);
	void addArgument(Argument *arg);
	void delArgument(size_t index);
	size_t countArguments() const;
	Argument *getArgument(size_t index) const;
};

/// A matrix argument.
/**
*/
class MatrixArgument : public Argument {

  protected:
  
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;  
	virtual string subprintlong() const;
	bool b_square;

  public:
  
  	MatrixArgument(string name_ = "", bool does_test = true, bool does_error = true);
	MatrixArgument(const MatrixArgument *arg);
	virtual bool squareDemanded() const;
	virtual void setSquareDemanded(bool square);
	virtual ~MatrixArgument();
	virtual int type() const;
	virtual Argument *copy() const;
	virtual string print() const;
};

/// Argument for functions, variables and units.
/** Text string representing a function, variable or unit name.
*/
class ExpressionItemArgument : public Argument {

  protected:
  
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;  
	virtual string subprintlong() const;

  public:
  
  	ExpressionItemArgument(string name_ = "", bool does_test = true, bool does_error = true);
	ExpressionItemArgument(const ExpressionItemArgument *arg);
	virtual ~ExpressionItemArgument();
	virtual int type() const;
	virtual Argument *copy() const;
	virtual string print() const;
};
/// A function argument.
/**
*/
class FunctionArgument : public Argument {

  protected:
  
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;  
	virtual string subprintlong() const;

  public:
  
  	FunctionArgument(string name_ = "", bool does_test = true, bool does_error = true);
	FunctionArgument(const FunctionArgument *arg);
	virtual ~FunctionArgument();
	virtual int type() const;
	virtual Argument *copy() const;
	virtual string print() const;
};

/// A boolean argument.
/** Accepts zero or one.
*/
class BooleanArgument : public Argument {

  protected:
  
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;  
	virtual string subprintlong() const;

  public:
  
  	BooleanArgument(string name_ = "", bool does_test = true, bool does_error = true);
	BooleanArgument(const BooleanArgument *arg);
	virtual ~BooleanArgument();
	virtual int type() const;
	virtual Argument *copy() const;
	virtual string print() const;
};

class UnitArgument : public Argument {

  protected:
  
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;  
	virtual string subprintlong() const;

  public:
  
  	UnitArgument(string name_ = "", bool does_test = true, bool does_error = true);
	UnitArgument(const UnitArgument *arg);
	virtual ~UnitArgument();
	virtual int type() const;
	virtual Argument *copy() const;
	virtual string print() const;
};
class AngleArgument : public Argument {

  protected:
  
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;  
	virtual string subprintlong() const;

  public:
  
  	AngleArgument(string name_ = "", bool does_test = true, bool does_error = true);
	AngleArgument(const AngleArgument *arg);
	virtual ~AngleArgument();
	virtual int type() const;
	virtual Argument *copy() const;
	virtual string print() const;
	virtual void parse(MathStructure *mstruct, const string &str, const ParseOptions &po = default_parse_options) const;
};
class VariableArgument : public Argument {

  protected:
  
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;  
	virtual string subprintlong() const;

  public:
  
  	VariableArgument(string name_ = "", bool does_test = true, bool does_error = true);
	VariableArgument(const VariableArgument *arg);
	virtual ~VariableArgument();
	virtual int type() const;
	virtual Argument *copy() const;
	virtual string print() const;
};
class FileArgument : public Argument {

  protected:
  
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;  
	virtual string subprintlong() const;

  public:
  
  	FileArgument(string name_ = "", bool does_test = true, bool does_error = true);
	FileArgument(const FileArgument *arg);
	virtual ~FileArgument();
	virtual int type() const;
	virtual Argument *copy() const;
	virtual string print() const;
};

/// A set of accepted arguments.
/** This is used when several different type of argments shall be accepted by a function.
*/
class ArgumentSet : public Argument {

  protected:
  
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;  
	virtual string subprintlong() const;
	vector<Argument*> subargs;

  public:
  
  	ArgumentSet(string name_ = "", bool does_test = true, bool does_error = true);
	ArgumentSet(const ArgumentSet *arg);
	virtual ~ArgumentSet();
	virtual int type() const;
	virtual Argument *copy() const;
	virtual string print() const;
	void addArgument(Argument *arg);
	void delArgument(size_t index);
	size_t countArguments() const;
	Argument *getArgument(size_t index) const;
	
};

#endif