InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PDFVTUtils.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Adobe Developer Technologies
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __PDFVTUTILS_H
25 #define __PDFVTUTILS_H
26 
27 #include "IPMUnknown.h"
28 #include "WideString.h"
29 
30 #include <string>
31 #include <sstream>
32 #include <queue>
33 #include <vector>
34 
41 {
42 public:
43 
44  typedef enum {
45  kUTF16LE,
46  kUTF16BE,
47  kUTF8BOM,
48  kUTF8NOBOM,
49  kUnsupportedEncoding
50  } Encoding;
51 
56  template<class T>
57  static std::string ToString(const T& t)
58  {
59  return ToTString<T, char>(t);
60  }
61 
66  static void GetDataSourceKeyList(std::vector<std::string>& keyList, const WideString& filePath);
67 
74  static bool16 ReadDataSource(const WideString& filePath, std::vector<std::string>& keyList, std::queue<std::vector<std::string> >& recordList);
75 
80  static Encoding DetectEncoding(IPMStream* stream);
81 
82 private:
88  static void GetLine(IPMStream* stream, std::string& line, Encoding encoding);
89 
94  static void GetLineUTF16(IPMStream* stream, std::string& line);
95 
100  static void GetLineUTF8(IPMStream* stream, std::string& line);
101 
105  static void StripCRsW(IPMStream* stream);
106 
110  static void StripCRs(IPMStream* stream);
111 
112  template<class T, class CharType>
113  static std::basic_string<CharType> ToTString(const T& t)
114  {
115  std::basic_ostringstream<CharType> o;
116  o << t;
117  return o.str();
118  }
119 };
120 
121 #endif