CUBRID Engine  latest
fileline_location.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 /*
20  * fileline_location.cpp - implementation of file & line location
21  */
22 
23 #include "fileline_location.hpp"
24 
25 #include "porting.h"
26 
27 #include <cstring>
28 
29 namespace cubbase
30 {
31  fileline_location::fileline_location (const char *fn_arg /* = "" */, int l_arg /* = 0 */)
32  : m_file {}
33  , m_line (0)
34  {
35  set (fn_arg, l_arg);
36  }
37 
38  void
39  fileline_location::set (const char *fn_arg, int l_arg)
40  {
41  // find filename from full path; get last character of '\\' or '/'
42  const char *start_chp;
43  for (start_chp = fn_arg + std::strlen (fn_arg); start_chp >= fn_arg; start_chp--)
44  {
45  if (*start_chp == '/' || *start_chp == '\\')
46  {
47  start_chp++;
48  break;
49  }
50  }
51  strncpy_bufsize (m_file, start_chp);
52 
53  m_line = l_arg;
54  }
55 
56  std::ostream &
57  operator<< (std::ostream &os, const fileline_location &fileline)
58  {
59  os << fileline.m_file << ":" << fileline.m_line;
60  return os;
61  }
62 } // namespace cubbase
63 
char m_file[MAX_FILENAME_SIZE]
fileline_location(const char *fn_arg="", int l_arg=0)
#define strncpy_bufsize(buf, str)
Definition: porting.h:340
#define strlen(s1)
Definition: intl_support.c:43
void set(const char *fn_arg, int l_arg)
std::ostream & operator<<(std::ostream &os, const fileline_location &fileline)