FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
CNFMessage.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  CNFMessage ver.1.0
7 */
8 
9 #include <stdio.h>
10 #include "CNFMessage.h"
11 
12 static char ERROR_MSG[][80] = {
13  "No error", "Unknown error", "Cannot open NEU file",
14  "Read data error", "Data line required", "Data block required",
15  "Invalid token", "Item required", "A record is required"};
16 
17 static char WARNING_MSG[][80] = {"Non supported data block"};
18 
19 char CNFMessage::msg[256] = "";
20 
21 const char *CNFError::Msg() {
22  char s[256];
23  strcpy(msg, "##Error");
24 
25  if (line >= 0) {
26  sprintf(s, "(line:%d", line);
27  strcat(msg, s);
28 
29  if (column > 0) {
30  sprintf(s, ",col:%d", column);
31  strcat(msg, s);
32  }
33 
34  strcat(msg, ")");
35  }
36 
37  strcat(msg, ": ");
38  strcat(msg, ERROR_MSG[no]);
39  strcat(msg, option_msg);
40  return msg;
41 }
42 
43 const char *CNFWarning::Msg() {
44  char s[256];
45  strcpy(msg, "##Warning");
46 
47  if (line >= 0) {
48  sprintf(s, "(line:%d", line);
49  strcat(msg, s);
50 
51  if (column > 0) {
52  sprintf(s, ",col:%d", column);
53  strcat(msg, s);
54  }
55 
56  strcat(msg, ")");
57  }
58 
59  strcat(msg, ": ");
60  strcat(msg, WARNING_MSG[no]);
61  strcat(msg, option_msg);
62  return msg;
63 }
CNFMessage::line
int line
Definition: CNFMessage.h:39
CNFMessage.h
CNFMessage::option_msg
char option_msg[256]
Definition: CNFMessage.h:41
CNFError::Msg
virtual const char * Msg()
Definition: CNFMessage.cpp:21
ERROR_MSG
const char ERROR_MSG[][80]
Definition: CConvMessage.cpp:9
CNFMessage::no
int no
Definition: CNFMessage.h:38
CNFWarning::Msg
virtual const char * Msg()
Definition: CNFMessage.cpp:43
CNFMessage::column
int column
Definition: CNFMessage.h:40
CNFMessage::msg
static char msg[256]
Definition: CNFMessage.h:35