classutil_1_1FileIO.tex 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. \hypertarget{classutil_1_1FileIO}{}\section{util\+:\+:File\+IO Class Reference}
  2. \label{classutil_1_1FileIO}\index{util\+::\+File\+IO@{util\+::\+File\+IO}}
  3. {\ttfamily \#include $<$File\+I\+O.\+h$>$}
  4. \subsection*{Static Public Member Functions}
  5. \begin{DoxyCompactItemize}
  6. \item
  7. static void \hyperlink{classutil_1_1FileIO_ae31b9e693316483eda89df8463ea0d0a}{Read\+C\+SV} (Vector3d \&values, const std\+::string \&file\+\_\+name, char delimiter)
  8. \item
  9. static void \hyperlink{classutil_1_1FileIO_a49f014af1e0f03d290f00049e082d9c6}{Read\+C\+SV} (Vector2d \&values, const std\+::string \&file\+\_\+name, char delimiter)
  10. \item
  11. static void \hyperlink{classutil_1_1FileIO_a6e290e22083d49619b757bfca96a51fa}{List\+Files} (const std\+::string \&folder, std\+::vector$<$ std\+::string $>$ \&file\+\_\+names, bool sort=true)
  12. \item
  13. static void \hyperlink{classutil_1_1FileIO_a5f2730a95e0801faa32e49dae9b86544}{Write\+C\+S\+V\+Matlab} (Directed\+Graph \&graph, const std\+::string \&file\+\_\+name)
  14. \item
  15. static void \hyperlink{classutil_1_1FileIO_a2833554dcdf4a04f9fe67a324b5815ff}{Write\+C\+S\+V\+Matlab} (Multi\+Predecessor\+Map \&map, Vertex \&source, Vertex \&sink, const std\+::string \&file\+\_\+name)
  16. \item
  17. static void \hyperlink{classutil_1_1FileIO_a642616eb6f07c71bd8dcb1585a532d92}{Read\+C\+SV} (Value\+Map\+Vector \&values, const std\+::string \&file\+\_\+name, char delimiter)
  18. \item
  19. static void \hyperlink{classutil_1_1FileIO_a59b96733490d7b60e4f107da84efb245}{Read\+C\+SV} (Value\+Map\+Vector \&values, const std\+::string \&header, const std\+::string \&file\+\_\+name, char delimiter)
  20. \item
  21. static void \hyperlink{classutil_1_1FileIO_a57059c9b52e86c753db5da6281cf23c6}{Write\+Tracks} (std\+::vector$<$ core\+::\+Tracklet\+Ptr $>$ \&tracks, const std\+::string \&file\+\_\+name, char delimiter)
  22. \item
  23. static void \hyperlink{classutil_1_1FileIO_a82be787051876b0e3d3c4f887c3c27ce}{Read\+Tracks} (std\+::vector$<$ core\+::\+Tracklet\+Ptr $>$ \&tracks, const std\+::string \&file\+\_\+name, char delimiter)
  24. \item
  25. static std\+::vector$<$ std\+::string $>$ \hyperlink{classutil_1_1FileIO_a925a74ff26782b8f64106579c9d54b47}{Split} (const std\+::string \&input, char delimiter)
  26. \end{DoxyCompactItemize}
  27. \subsection{Detailed Description}
  28. Utility class for file in-\/ and output.
  29. \subsection{Member Function Documentation}
  30. \index{util\+::\+File\+IO@{util\+::\+File\+IO}!List\+Files@{List\+Files}}
  31. \index{List\+Files@{List\+Files}!util\+::\+File\+IO@{util\+::\+File\+IO}}
  32. \subsubsection[{\texorpdfstring{List\+Files(const std\+::string \&folder, std\+::vector$<$ std\+::string $>$ \&file\+\_\+names, bool sort=true)}{ListFiles(const std::string \&folder, std::vector< std::string > \&file\_names, bool sort=true)}}]{\setlength{\rightskip}{0pt plus 5cm}void util\+::\+File\+I\+O\+::\+List\+Files (
  33. \begin{DoxyParamCaption}
  34. \item[{const std\+::string \&}]{folder, }
  35. \item[{std\+::vector$<$ std\+::string $>$ \&}]{file\+\_\+names, }
  36. \item[{bool}]{sort = {\ttfamily true}}
  37. \end{DoxyParamCaption}
  38. )\hspace{0.3cm}{\ttfamily [static]}}\hypertarget{classutil_1_1FileIO_a6e290e22083d49619b757bfca96a51fa}{}\label{classutil_1_1FileIO_a6e290e22083d49619b757bfca96a51fa}
  39. Lists all file names in the given folder.
  40. \begin{DoxyParams}{Parameters}
  41. {\em folder} & The folder to look into \\
  42. \hline
  43. {\em file\+\_\+names} & The name of the files in the folder \\
  44. \hline
  45. {\em sort} & True, if the files should be sorted alphabetically \\
  46. \hline
  47. \end{DoxyParams}
  48. \index{util\+::\+File\+IO@{util\+::\+File\+IO}!Read\+C\+SV@{Read\+C\+SV}}
  49. \index{Read\+C\+SV@{Read\+C\+SV}!util\+::\+File\+IO@{util\+::\+File\+IO}}
  50. \subsubsection[{\texorpdfstring{Read\+C\+S\+V(\+Vector3d \&values, const std\+::string \&file\+\_\+name, char delimiter)}{ReadCSV(Vector3d \&values, const std::string \&file\_name, char delimiter)}}]{\setlength{\rightskip}{0pt plus 5cm}void util\+::\+File\+I\+O\+::\+Read\+C\+SV (
  51. \begin{DoxyParamCaption}
  52. \item[{Vector3d \&}]{values, }
  53. \item[{const std\+::string \&}]{file\+\_\+name, }
  54. \item[{char}]{delimiter}
  55. \end{DoxyParamCaption}
  56. )\hspace{0.3cm}{\ttfamily [static]}}\hypertarget{classutil_1_1FileIO_ae31b9e693316483eda89df8463ea0d0a}{}\label{classutil_1_1FileIO_ae31b9e693316483eda89df8463ea0d0a}
  57. Reads a C\+SV file and stores the values in a 3D array. The first dimension is the first value of each row, used as a index to bundle multiple rows with the same first value into a single vector. The second dimension is the row in the row bundle. The third dimension is the value in that row.
  58. \begin{DoxyParams}{Parameters}
  59. {\em values} & The 3D array of values to store the read values in \\
  60. \hline
  61. {\em file\+\_\+name} & The name of the file to read \\
  62. \hline
  63. {\em delimiter} & The value delimiter of the file \\
  64. \hline
  65. \end{DoxyParams}
  66. \index{util\+::\+File\+IO@{util\+::\+File\+IO}!Read\+C\+SV@{Read\+C\+SV}}
  67. \index{Read\+C\+SV@{Read\+C\+SV}!util\+::\+File\+IO@{util\+::\+File\+IO}}
  68. \subsubsection[{\texorpdfstring{Read\+C\+S\+V(\+Vector2d \&values, const std\+::string \&file\+\_\+name, char delimiter)}{ReadCSV(Vector2d \&values, const std::string \&file\_name, char delimiter)}}]{\setlength{\rightskip}{0pt plus 5cm}void util\+::\+File\+I\+O\+::\+Read\+C\+SV (
  69. \begin{DoxyParamCaption}
  70. \item[{Vector2d \&}]{values, }
  71. \item[{const std\+::string \&}]{file\+\_\+name, }
  72. \item[{char}]{delimiter}
  73. \end{DoxyParamCaption}
  74. )\hspace{0.3cm}{\ttfamily [static]}}\hypertarget{classutil_1_1FileIO_a49f014af1e0f03d290f00049e082d9c6}{}\label{classutil_1_1FileIO_a49f014af1e0f03d290f00049e082d9c6}
  75. Reads a C\+SV file and stores the values in a 2D array. The first dimension is the row and the second the value in that row.
  76. \begin{DoxyParams}{Parameters}
  77. {\em values} & The 2D array of values to store the read values in \\
  78. \hline
  79. {\em file\+\_\+name} & The name of the file to read \\
  80. \hline
  81. {\em delimiter} & The value delimiter of the file \\
  82. \hline
  83. \end{DoxyParams}
  84. \index{util\+::\+File\+IO@{util\+::\+File\+IO}!Read\+C\+SV@{Read\+C\+SV}}
  85. \index{Read\+C\+SV@{Read\+C\+SV}!util\+::\+File\+IO@{util\+::\+File\+IO}}
  86. \subsubsection[{\texorpdfstring{Read\+C\+S\+V(\+Value\+Map\+Vector \&values, const std\+::string \&file\+\_\+name, char delimiter)}{ReadCSV(ValueMapVector \&values, const std::string \&file\_name, char delimiter)}}]{\setlength{\rightskip}{0pt plus 5cm}void util\+::\+File\+I\+O\+::\+Read\+C\+SV (
  87. \begin{DoxyParamCaption}
  88. \item[{Value\+Map\+Vector \&}]{values, }
  89. \item[{const std\+::string \&}]{file\+\_\+name, }
  90. \item[{char}]{delimiter}
  91. \end{DoxyParamCaption}
  92. )\hspace{0.3cm}{\ttfamily [static]}}\hypertarget{classutil_1_1FileIO_a642616eb6f07c71bd8dcb1585a532d92}{}\label{classutil_1_1FileIO_a642616eb6f07c71bd8dcb1585a532d92}
  93. Reads a C\+SV file. The first line of the C\+SV file is a header specifying the keys. The values are stored with their specified key into one map per line.
  94. \begin{DoxyParams}{Parameters}
  95. {\em values} & A vector of maps to store the key-\/value pairs into \\
  96. \hline
  97. {\em file\+\_\+name} & The name of the file to read \\
  98. \hline
  99. {\em delimiter} & The value delimiter of the file \\
  100. \hline
  101. \end{DoxyParams}
  102. \index{util\+::\+File\+IO@{util\+::\+File\+IO}!Read\+C\+SV@{Read\+C\+SV}}
  103. \index{Read\+C\+SV@{Read\+C\+SV}!util\+::\+File\+IO@{util\+::\+File\+IO}}
  104. \subsubsection[{\texorpdfstring{Read\+C\+S\+V(\+Value\+Map\+Vector \&values, const std\+::string \&header, const std\+::string \&file\+\_\+name, char delimiter)}{ReadCSV(ValueMapVector \&values, const std::string \&header, const std::string \&file\_name, char delimiter)}}]{\setlength{\rightskip}{0pt plus 5cm}void util\+::\+File\+I\+O\+::\+Read\+C\+SV (
  105. \begin{DoxyParamCaption}
  106. \item[{Value\+Map\+Vector \&}]{values, }
  107. \item[{const std\+::string \&}]{header, }
  108. \item[{const std\+::string \&}]{file\+\_\+name, }
  109. \item[{char}]{delimiter}
  110. \end{DoxyParamCaption}
  111. )\hspace{0.3cm}{\ttfamily [static]}}\hypertarget{classutil_1_1FileIO_a59b96733490d7b60e4f107da84efb245}{}\label{classutil_1_1FileIO_a59b96733490d7b60e4f107da84efb245}
  112. Reads a C\+SV file. The header specifies the keys. The values are stored with their specified key into one map per line.
  113. \begin{DoxyParams}{Parameters}
  114. {\em values} & A vector of maps to store the key-\/value pairs into \\
  115. \hline
  116. {\em header} & A string containing the keys separated by the delimiter \\
  117. \hline
  118. {\em file\+\_\+name} & The name of the file to read \\
  119. \hline
  120. {\em delimiter} & The value delimiter of the file \\
  121. \hline
  122. \end{DoxyParams}
  123. \index{util\+::\+File\+IO@{util\+::\+File\+IO}!Read\+Tracks@{Read\+Tracks}}
  124. \index{Read\+Tracks@{Read\+Tracks}!util\+::\+File\+IO@{util\+::\+File\+IO}}
  125. \subsubsection[{\texorpdfstring{Read\+Tracks(std\+::vector$<$ core\+::\+Tracklet\+Ptr $>$ \&tracks, const std\+::string \&file\+\_\+name, char delimiter)}{ReadTracks(std::vector< core::TrackletPtr > \&tracks, const std::string \&file\_name, char delimiter)}}]{\setlength{\rightskip}{0pt plus 5cm}static void util\+::\+File\+I\+O\+::\+Read\+Tracks (
  126. \begin{DoxyParamCaption}
  127. \item[{std\+::vector$<$ core\+::\+Tracklet\+Ptr $>$ \&}]{tracks, }
  128. \item[{const std\+::string \&}]{file\+\_\+name, }
  129. \item[{char}]{delimiter}
  130. \end{DoxyParamCaption}
  131. )\hspace{0.3cm}{\ttfamily [static]}}\hypertarget{classutil_1_1FileIO_a82be787051876b0e3d3c4f887c3c27ce}{}\label{classutil_1_1FileIO_a82be787051876b0e3d3c4f887c3c27ce}
  132. Reads the tracks from the specified file.
  133. \begin{DoxyParams}{Parameters}
  134. {\em tracks} & A vector for storing the read tracks \\
  135. \hline
  136. {\em file\+\_\+name} & The path of the file to read from \\
  137. \hline
  138. {\em delimiter} & The delimiter used to separate values \\
  139. \hline
  140. \end{DoxyParams}
  141. \index{util\+::\+File\+IO@{util\+::\+File\+IO}!Split@{Split}}
  142. \index{Split@{Split}!util\+::\+File\+IO@{util\+::\+File\+IO}}
  143. \subsubsection[{\texorpdfstring{Split(const std\+::string \&input, char delimiter)}{Split(const std::string \&input, char delimiter)}}]{\setlength{\rightskip}{0pt plus 5cm}std\+::vector$<$ std\+::string $>$ util\+::\+File\+I\+O\+::\+Split (
  144. \begin{DoxyParamCaption}
  145. \item[{const std\+::string \&}]{input, }
  146. \item[{char}]{delimiter}
  147. \end{DoxyParamCaption}
  148. )\hspace{0.3cm}{\ttfamily [static]}}\hypertarget{classutil_1_1FileIO_a925a74ff26782b8f64106579c9d54b47}{}\label{classutil_1_1FileIO_a925a74ff26782b8f64106579c9d54b47}
  149. Splits the input string at the delimiter and store each part into the return vector. If there is nothing between two delimiters the part will be an empty string.
  150. \begin{DoxyParams}{Parameters}
  151. {\em input} & The string to split \\
  152. \hline
  153. {\em delimiter} & The delimiter used to split, the delimiter will not be stored \\
  154. \hline
  155. \end{DoxyParams}
  156. \begin{DoxyReturn}{Returns}
  157. A vector of parts like (for string of length n\+: \mbox{[}0,d)...(d,d)...(d,n))
  158. \end{DoxyReturn}
  159. \index{util\+::\+File\+IO@{util\+::\+File\+IO}!Write\+C\+S\+V\+Matlab@{Write\+C\+S\+V\+Matlab}}
  160. \index{Write\+C\+S\+V\+Matlab@{Write\+C\+S\+V\+Matlab}!util\+::\+File\+IO@{util\+::\+File\+IO}}
  161. \subsubsection[{\texorpdfstring{Write\+C\+S\+V\+Matlab(\+Directed\+Graph \&graph, const std\+::string \&file\+\_\+name)}{WriteCSVMatlab(DirectedGraph \&graph, const std::string \&file\_name)}}]{\setlength{\rightskip}{0pt plus 5cm}void util\+::\+File\+I\+O\+::\+Write\+C\+S\+V\+Matlab (
  162. \begin{DoxyParamCaption}
  163. \item[{Directed\+Graph \&}]{graph, }
  164. \item[{const std\+::string \&}]{file\+\_\+name}
  165. \end{DoxyParamCaption}
  166. )\hspace{0.3cm}{\ttfamily [static]}}\hypertarget{classutil_1_1FileIO_a5f2730a95e0801faa32e49dae9b86544}{}\label{classutil_1_1FileIO_a5f2730a95e0801faa32e49dae9b86544}
  167. Writes the specified graph into a C\+SV file with an format readable by Matlab.
  168. \begin{DoxyParams}{Parameters}
  169. {\em graph} & The graph to write \\
  170. \hline
  171. {\em file\+\_\+name} & The name of the file to write \\
  172. \hline
  173. \end{DoxyParams}
  174. \index{util\+::\+File\+IO@{util\+::\+File\+IO}!Write\+C\+S\+V\+Matlab@{Write\+C\+S\+V\+Matlab}}
  175. \index{Write\+C\+S\+V\+Matlab@{Write\+C\+S\+V\+Matlab}!util\+::\+File\+IO@{util\+::\+File\+IO}}
  176. \subsubsection[{\texorpdfstring{Write\+C\+S\+V\+Matlab(\+Multi\+Predecessor\+Map \&map, Vertex \&source, Vertex \&sink, const std\+::string \&file\+\_\+name)}{WriteCSVMatlab(MultiPredecessorMap \&map, Vertex \&source, Vertex \&sink, const std::string \&file\_name)}}]{\setlength{\rightskip}{0pt plus 5cm}void util\+::\+File\+I\+O\+::\+Write\+C\+S\+V\+Matlab (
  177. \begin{DoxyParamCaption}
  178. \item[{Multi\+Predecessor\+Map \&}]{map, }
  179. \item[{Vertex \&}]{source, }
  180. \item[{Vertex \&}]{sink, }
  181. \item[{const std\+::string \&}]{file\+\_\+name}
  182. \end{DoxyParamCaption}
  183. )\hspace{0.3cm}{\ttfamily [static]}}\hypertarget{classutil_1_1FileIO_a2833554dcdf4a04f9fe67a324b5815ff}{}\label{classutil_1_1FileIO_a2833554dcdf4a04f9fe67a324b5815ff}
  184. Writes the specified multi predecessor map into a C\+SV format readable by Matlab to display all paths in the corresponding graph.
  185. \begin{DoxyParams}{Parameters}
  186. {\em map} & The multi predecessor map to extract the paths from \\
  187. \hline
  188. {\em source} & The sink, this is the vertex where all paths begin \\
  189. \hline
  190. {\em sink} & The sink, this is the vertex where all paths end \\
  191. \hline
  192. {\em file\+\_\+name} & The name of the file to write \\
  193. \hline
  194. \end{DoxyParams}
  195. \index{util\+::\+File\+IO@{util\+::\+File\+IO}!Write\+Tracks@{Write\+Tracks}}
  196. \index{Write\+Tracks@{Write\+Tracks}!util\+::\+File\+IO@{util\+::\+File\+IO}}
  197. \subsubsection[{\texorpdfstring{Write\+Tracks(std\+::vector$<$ core\+::\+Tracklet\+Ptr $>$ \&tracks, const std\+::string \&file\+\_\+name, char delimiter)}{WriteTracks(std::vector< core::TrackletPtr > \&tracks, const std::string \&file\_name, char delimiter)}}]{\setlength{\rightskip}{0pt plus 5cm}void util\+::\+File\+I\+O\+::\+Write\+Tracks (
  198. \begin{DoxyParamCaption}
  199. \item[{std\+::vector$<$ core\+::\+Tracklet\+Ptr $>$ \&}]{tracks, }
  200. \item[{const std\+::string \&}]{file\+\_\+name, }
  201. \item[{char}]{delimiter}
  202. \end{DoxyParamCaption}
  203. )\hspace{0.3cm}{\ttfamily [static]}}\hypertarget{classutil_1_1FileIO_a57059c9b52e86c753db5da6281cf23c6}{}\label{classutil_1_1FileIO_a57059c9b52e86c753db5da6281cf23c6}
  204. Writes the given tracks to the given file.
  205. \begin{DoxyParams}{Parameters}
  206. {\em tracks} & The tracks to store \\
  207. \hline
  208. {\em file\+\_\+name} & The path to the file to store the tracks in \\
  209. \hline
  210. {\em delimiter} & The delimiter used to separate values \\
  211. \hline
  212. \end{DoxyParams}
  213. The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
  214. \item
  215. util/File\+I\+O.\+h\item
  216. util/File\+I\+O.\+cpp\end{DoxyCompactItemize}