File: GeneralFunctions.hh

package info (click to toggle)
eclipse-titan 7.2.0-1.1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 103,144 kB
  • sloc: cpp: 264,784; ansic: 33,124; yacc: 23,073; makefile: 14,730; lex: 9,190; java: 4,849; perl: 3,783; sh: 2,298; xml: 1,378; javascript: 85; awk: 48; php: 32; python: 13
file content (91 lines) | stat: -rw-r--r-- 3,378 bytes parent folder | download
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
/******************************************************************************
 * Copyright (c) 2000-2020 Ericsson Telecom AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Balasko, Jeno
 *   Godar, Marton
 *   Raduly, Csaba
 *   Szabo, Bence Janos
 *
 ******************************************************************************/
#ifndef GENERALFUNCTIONS_HH_
#define GENERALFUNCTIONS_HH_

#include "Mstring.hh"
#include "List.hh"
#include "GeneralTypes.hh"

typedef List<QualifiedName> QualifiedNames;

enum modeType {
    type_reference_name, type_name, field_name, enum_id_name
};

void XSDName2TTCN3Name(const Mstring& in, const Mstring& in_namespace,
        QualifiedNames & used_names, modeType type_of_the_name,
        Mstring & res, Mstring & variant, bool no_replace = false);

class ReferenceData;


bool isBuiltInType(const Mstring& in);
bool isStringType(const Mstring& in);
bool isIntegerType(const Mstring& in);
bool isFloatType(const Mstring& in);
bool isTimeType(const Mstring& in);
bool isSequenceType(const Mstring& in);
bool isBooleanType(const Mstring& in);
bool isQNameType(const Mstring& in);
bool isAnyType(const Mstring& in);

bool matchDates(const char * string, const char * type);
bool matchRegexp(const char * string, const char * pattern);

void printWarning(const Mstring& filename, int lineNumber, const Mstring& text);
void printWarning(const Mstring& filename, const Mstring& typeName, const Mstring& text);
void printError(const Mstring& filename, int lineNumber, const Mstring& text);
void printError(const Mstring& filename, const Mstring& typeName, const Mstring& text);
void indent(FILE * file, const unsigned int x);

// Converts an XML float value as string to a correct ttcn float value as string
Mstring xmlFloat2TTCN3FloatStr(const Mstring& xmlFloat);

long double stringToLongDouble(const char * input);

class RootType;
class SimpleType;
class TTCN3Module;

const Mstring& getNameSpaceByPrefix(const RootType * root, const Mstring& prefix);
const Mstring& getPrefixByNameSpace(const RootType * root, const Mstring& namespace_);

const Mstring findBuiltInType(const RootType * ref, Mstring type);

/// Lookup in a list of modules
RootType * lookup(const List<TTCN3Module*> mods,
        const SimpleType * reference, wanted w, ConstructType construct);
/// Lookup in a list of modules
RootType * lookup(const List<TTCN3Module*> mods,
        const Mstring& name, const Mstring& nsuri, const RootType *reference, wanted w, ConstructType construct);
/// Lookup inside one module
RootType *lookup1(const TTCN3Module *module,
        const Mstring& name, const Mstring& nsuri, const RootType *reference, wanted w, ConstructType construct);

int multi(const TTCN3Module *module, ReferenceData const& outside_reference,
        const RootType *obj);

void generate_TTCN3_header(FILE * file, const char* modulename, const bool timestamp = true);

inline unsigned long long llmin(unsigned long long l, unsigned long long r) {
    return l < r ? l : r;
}

inline unsigned long long llmax(unsigned long long l, unsigned long long r) {
    return l > r ? l : r;
}

#endif /* GENERALFUNCTIONS_HH_ */