-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSubFunction.cpp
More file actions
56 lines (44 loc) · 951 Bytes
/
Copy pathSubFunction.cpp
File metadata and controls
56 lines (44 loc) · 951 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
51
52
53
54
55
// -*-C++-*-
/*!
* @file SubFunction.cpp
* @brief 文字列の操作等
*
*/
#include "SubFunction.h"
using namespace std;
/**
*@brief セルの番号を数値に変換する関数
* @param m_str セルの番号(アルファベット)
* @return 対応する数値
*/
int convertStrToVal(std::string m_str)
{
char m_c = m_str.c_str()[0] - 64;
if(m_str.length() == 1)
{
return int(m_c);
}
else
{
if(m_str.c_str()[1] < 91 && m_str.c_str()[1] > 64)
{
char m_c2 = m_str.c_str()[1] - 64;
return int(m_c2) + int(m_c)*26;
}
else
return int(m_c);
}
}
/**
*@brief System::Stringをstd::stringに変換する関数
* @param s 変換前の文字列
* @return 変換後の文字列
*/
std::string MarshalString ( System::String ^ s) {
using namespace System::Runtime::InteropServices;
const char* chars =
(const char*)(Marshal::StringToHGlobalAnsi(s)).ToPointer();
std::string os = chars;
Marshal::FreeHGlobal(System::IntPtr((void*)chars));
return os;
}