FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
HECDB_util.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2019 FrontISTR Commons
3  * This software is released under the MIT License, see LICENSE.txt
4  *****************************************************************************/
5 /*
6  Utility for CHECDB Ver.1.0
7 */
8 
9 #include <string.h>
10 #include <ctype.h>
11 #include "CHECDB.h"
12 #include "hecd_util.h"
13 
14 using namespace hecd_util;
15 
16 CHECDataBlock *CreateHECDataBlock(const char *header_name) {
17  char name[80];
18  char *np = name;
19  char *p = (char *)header_name;
20 
21  if (*p == '!') p++;
22 
23  *np = (char)toupper(*p);
24  p++;
25  np++;
26 
27  while (*p) {
28  *np = (char)tolower(*p);
29  p++;
30  np++;
31  }
32 
33  *np = 0;
34 #define GENERATE_CODE(x) \
35  else if (strcmp(#x, name) == 0) { \
36  return new CHECDB_##x(); \
37  }
38 
39  if (false)
40  ; // dummy
41 
42  GENERATE_CODE(Header)
43  GENERATE_CODE(Node)
44  GENERATE_CODE(Element)
45  GENERATE_CODE(Material)
46  GENERATE_CODE(Section)
47  GENERATE_CODE(NGroup)
48  GENERATE_CODE(EGroup)
49  GENERATE_CODE(SGroup)
50  GENERATE_CODE(Amplitude)
51  GENERATE_CODE(Zero)
52  GENERATE_CODE(Visual)
53 #undef GENERATE_CODE
54  return 0;
55 }
56 
57 bool IsHECDataBlockName(const char *name) {
58  char s[256];
59 
60  if (name[0] == '!')
61  toupper(&name[1], s);
62 
63  else
64  toupper(name, s);
65 
66 #define GENERATE_CODE(x) \
67  else if (strcmp(#x, name) == 0) { \
68  return true; \
69  }
70 
71  if (false)
72  ; // dummy
73 
75  GENERATE_CODE(NODE)
76  GENERATE_CODE(ELEMENT)
77  GENERATE_CODE(MATERIAL)
78  GENERATE_CODE(SECTION)
79  GENERATE_CODE(NGROUP)
80  GENERATE_CODE(EGROUP)
81  GENERATE_CODE(SGROUP)
82  GENERATE_CODE(AMPLITUDE)
83  GENERATE_CODE(ZERO)
84  GENERATE_CODE(VISUAL)
85 #undef GENERATE_CODE
86  return false;
87 }
CHECDataBlock
Definition: CHECDataBlock.h:17
IsHECDataBlockName
bool IsHECDataBlockName(const char *name)
Definition: HECDB_util.cpp:57
hecd_util::toupper
void toupper(char *s)
Definition: hecd_util.cpp:40
CreateHECDataBlock
CHECDataBlock * CreateHECDataBlock(const char *header_name)
Definition: HECDB_util.cpp:16
hecd_util::tolower
void tolower(char *s)
Definition: hecd_util.cpp:59
CHECDB.h
hecd_util.h
hecd_util
Definition: hecd_util.cpp:11
GENERATE_CODE
#define GENERATE_CODE(x)
HEADER
#define HEADER
Definition: hecmw_ablex.c:1633