File: ConnectionUtils.h

package info (click to toggle)
urg 0.8.11-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,212 kB
  • ctags: 1,605
  • sloc: sh: 10,014; cpp: 6,459; ansic: 2,419; makefile: 203
file content (76 lines) | stat: -rw-r--r-- 1,563 bytes parent folder | download | duplicates (2)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef QRK_CONNECTION_UTILS_H
#define QRK_CONNECTION_UTILS_H

/*!
  \file
  \brief Connection p⏕֐

  \author Satofumi KAMIMURA

  $Id: ConnectionUtils.h 1408 2009-10-14 20:55:13Z satofumi $
*/

#include <cstddef>
#include <algorithm>


/*!
  \brief Quick Robot Develoment Kit.
*/
namespace qrk
{
  class Connection;


  /*!
    \brief sR[hԂ

    \retval true LF, CR ̂Ƃ
    \retval false LȊÔƂ
  */
  extern bool isLF(const char ch);


  /*!
    \brief Mf[^ǂݔ΂

    Connection::clear() Ƃ́A^CAEgԂw肵ēǂݔ΂_قȂ

    \param[in,out] con ʐM\[X
    \param[in] total_timeout ^CAEgԂ̏ [msec]
    \param[in] each_timeout Mf[^Ԃɂ^CAEgԂ̏ [msec]
  */
  extern void skip(Connection* con, int total_timeout, int each_timeout = 0);


  /*!
    \brief s܂ł̃f[^ǂݏo

    I[ \\0 tĕԂ

    \param[in,out] con ʐM\[X
    \param[out] buf Mobt@
    \param[in] count Mobt@̍őTCY
    \param[in] timeout ^CAEg [msec]

    \return M (MȂă^CAEgꍇ -1)
  */
  extern int readline(Connection* con, char* buf, const size_t count,
                      const int timeout);


  /*!
    \brief ڑIuWFNǧ

    a  b ̐ڑIuWFNgB
  */
  template <class T>
  void swapConnection(T& a, T& b)
  {
    Connection* t = a.connection();
    a.setConnection(b.connection());
    b.setConnection(t);
  }
}

#endif /* !QRK_CONNECTION_UTILS_H */