我需要浏览一个 C/C++ 文件并提取类和方法的列表以及它们在文件中的位置。
libclang 是最佳选择吗?还是任务“太多”了?
只寻找配对括号会更好吗?
如果选择 libclang:有没有办法从 C# 调用它?
谢谢!
最佳答案
你可以考虑ctags ,可在许多平台上使用。输出很容易解析,并且包含您需要的全部信息。
更多信息 对于您的问题,我不得不查看许多可用的选项,过了一会儿我找到了。例如:
ctags -N -x --c-kinds=+p crowd.*
产生这个输出
CrowdSim class 44 crowd.h class CrowdSim
CrowdSim function 47 crowd.h CrowdSim( const std::string& contentDir ) : _contentDir( contentDir ) {}
Particle function 35 crowd.h Particle()
Particle struct 25 crowd.h struct Particle
_contentDir member 56 crowd.h std::string _contentDir;
_crowd_H_ macro 18 crowd.h #define _crowd_H_
_particles member 57 crowd.h std::vector< Particle > _particles;
animTime member 32 crowd.h float animTime;
chooseDestination function 24 crowd.cpp void CrowdSim::chooseDestination( Particle &p )
chooseDestination prototype 53 crowd.h void chooseDestination( Particle &p );
dx member 28 crowd.h float dx, dz; // Destination position
dz member 28 crowd.h float dx, dz; // Destination position
fx member 29 crowd.h float fx, fz; // Force on particle
fz member 29 crowd.h float fx, fz; // Force on particle
init function 35 crowd.cpp void CrowdSim::init()
init prototype 49 crowd.h void init();
node member 31 crowd.h H3DNode node;
ox member 30 crowd.h float ox, oz; // Orientation vector
oz member 30 crowd.h float ox, oz; // Orientation vector
px member 27 crowd.h float px, pz; // Current postition
pz member 27 crowd.h float px, pz; // Current postition
update function 68 crowd.cpp void CrowdSim::update( float fps )
update prototype 50 crowd.h void update( float fps );
(注:-x只是为了方便用户检查)
关于c++ - 如何从 C# 解析/简单分析 C/C++ 代码以获取方法列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8817712/
我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div
总的来说,我对ruby还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用
我有一个字符串input="maybe(thisis|thatwas)some((nice|ugly)(day|night)|(strange(weather|time)))"Ruby中解析该字符串的最佳方法是什么?我的意思是脚本应该能够像这样构建句子:maybethisissomeuglynightmaybethatwassomenicenightmaybethiswassomestrangetime等等,你明白了......我应该一个字符一个字符地读取字符串并构建一个带有堆栈的状态机来存储括号值以供以后计算,还是有更好的方法?也许为此目的准备了一个开箱即用的库?
类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc
我正在尝试设置一个puppet节点,但rubygems似乎不正常。如果我通过它自己的二进制文件(/usr/lib/ruby/gems/1.8/gems/facter-1.5.8/bin/facter)在cli上运行facter,它工作正常,但如果我通过由rubygems(/usr/bin/facter)安装的二进制文件,它抛出:/usr/lib/ruby/1.8/facter/uptime.rb:11:undefinedmethod`get_uptime'forFacter::Util::Uptime:Module(NoMethodError)from/usr/lib/ruby
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
我想了解Ruby方法methods()是如何工作的。我尝试使用“ruby方法”在Google上搜索,但这不是我需要的。我也看过ruby-doc.org,但我没有找到这种方法。你能详细解释一下它是如何工作的或者给我一个链接吗?更新我用methods()方法做了实验,得到了这样的结果:'labrat'代码classFirstdeffirst_instance_mymethodenddefself.first_class_mymethodendendclassSecond使用类#returnsavailablemethodslistforclassandancestorsputsSeco