那麼有一些很棒的參考資料可以用來構建自己的數據庫。由於標準變化緩慢,您可以使用參考文件爲其生成地圖。這是一個很好的c++ reference
很難簡單地在頭文件中搜索,因爲它們通常是使用不希望在代碼中使用的後端位構建的,並且您無法區分它們。
如果我要構建這個,我將使用標準庫引用來構建基本映射,而不是通過頭文件解析;例如在上面的汽車示例中,您應該#include <string>
對不對?
如果您要解析給定編譯器的頭文件<string>
,您可能會發現它只由後端位組成,後端位又包含其他文件;
在G ++版本4.6 <string>
看起來是這樣的:現在
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
// 2005, 2006, 2007, 2009, 2010, 2011
// Free Software Foundation, Inc.
// GPL version 3.1 or later ... etc...
#ifndef _GLIBCXX_STRING
#define _GLIBCXX_STRING 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/stringfwd.h>
#include <bits/char_traits.h> // NB: In turn includes stl_algobase.h
#include <bits/allocator.h>
#include <bits/cpp_type_traits.h>
#include <bits/localefwd.h> // For operators >>, <<, and getline.
#include <bits/ostream_insert.h>
#include <bits/stl_iterator_base_types.h>
#include <bits/stl_iterator_base_funcs.h>
#include <bits/stl_iterator.h>
#include <bits/stl_function.h> // For less
#include <ext/numeric_traits.h>
#include <bits/stl_algobase.h>
#include <bits/range_access.h>
#include <bits/basic_string.h>
#include <bits/basic_string.tcc>
#endif /* _GLIBCXX_STRING */
的問題變得很明顯。例如<string>
規範爲std::ios_base
?很多想法,我可能稍後有一些其他的想法。
對於標準庫,您可以簡單地對其進行硬編碼。對於任意頭文件,您可以使用C++解析器(如Clang的前端)來解析頭文件。如果你像你說的那樣雄心勃勃地開發項目,那麼使用第三方C++解析器應該沒有問題。 – Angew
硬編碼是什麼意思? STL包含數千種類型,我應該怎麼做(而不是手動)? 我喜歡你的第二個建議!你有沒有做過這樣的事情,可以指點一些東西來幫助我在項目中使用Clang解析器? – user1286875
創建一些映射文件或類似的東西。它只需要每3年更新一次,當標準發生變化時。或者,你當然也可以使用標準頭文件的解析器。 – Angew