-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharff_utils.cpp
More file actions
executable file
·50 lines (45 loc) · 994 Bytes
/
Copy patharff_utils.cpp
File metadata and controls
executable file
·50 lines (45 loc) · 994 Bytes
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
#include <stdexcept>
#include <stdio.h>
#include "arff_utils.h"
#define STR_LENGTH 2048
void throw_ex(const char* file, int64 line, const char* fmt, ...)
{
char msg[STR_LENGTH];
va_list va;
va_start(va, fmt);
vsprintf(msg, fmt, va);
va_end(va);
std::string err(file);
err += ":" + num2str<int64>(line) + " -- ";
err += msg;
std::runtime_error ex(err);
throw ex;
}
#undef STR_LENGTH
char to_lower(char c)
{
if((c >= 'A') && (c <= 'Z'))
{
return ((c - 'A') + 'a');
}
return c;
}
bool icompare(const std::string& str, const std::string& ref)
{
size_t s1 = str.size();
size_t s2 = ref.size();
if(s1 != s2)
{
return false;
}
const char* ch1 = str.c_str();
const char* ch2 = ref.c_str();
for(size_t i=0; i<s1; ++i)
{
if(to_lower(ch1[i]) != to_lower(ch2[i]))
{
return false;
}
}
return true;
}