我想提取注释,并想知道它们是哪些函数.我有很多这样的C文件如下:
输入:
void main()
{
//sdgs
call A;
/*
sdfgs
dfhdfh
*/
call b;
some code;
}
/* this function adds
something */
int add()
{
//sgsd
some code;
//more comments
some code;
}
Run Code Online (Sandbox Code Playgroud)
输出应该是:
void main()
{
//sdgs
/*
sdfgs
dfhdfh
*/
}
/* this function adds
something */
int add()
{
//sgsd
//more comments
}
Run Code Online (Sandbox Code Playgroud)
输入代码格式整齐,"功能代码" {在下一行后开始.基本上,我只需要知道哪个"评论"来自哪个函数.此外,它还应包括功能名称或其他地方的任何其他注释.注意:这是不同的,因为顶层的函数名称应该在那里.
为了简化我的要求:
(在第一行上的块,其中一行仅包含{一到三行后的第一列,并打印上面的行.我正在尝试检索存储在手机中的联系人的姓名和类型,但获得此异常.我以前得到的名字,但得到例外
android.database.CursorIndexOutOfBoundsException:请求索引为-1,大小为10
当试图一起检索名称和类型时.请帮忙.提前致谢.
package application.test;
import android.app.Activity;
import android.content.ContentResolver;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
import android.util.Log;
public class TestActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String[] projection = new String[] {ContactsContract.Contacts.DISPLAY_NAME};
String[] projection1=new String[]{Phone.TYPE};
String[] projection2=new String[]{ContactsContract.Contacts._ID};
ContentResolver cr = getContentResolver();
ContentResolver ncr=getContentResolver();
ContentResolver icr=getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, projection,null, null, Contacts.DISPLAY_NAME + " ASC");
Cursor ncur=ncr.query(ContactsContract.Data.CONTENT_URI, projection1, null, null,null);
Cursor …Run Code Online (Sandbox Code Playgroud) 我有一个包含多个子对象的小部件,用户可以通过单击它们来选择它们.
我想在用户点击窗口小部件时清除当前选择,我想知道如何最好地检测这些点击.
一些限制:
mousePressEvents周围物体并不是真的可行eventFilter.grabMouse(),我想,因为来自文档的这个警告:
警告:抓取鼠标的应用程序中的错误通常会锁定终端.请谨慎使用此功能,并在调试时考虑使用-nograb命令行选项.
这会让我有其他选择吗?
注意:此应用程序将跨平台部署(至少Windows和Ubuntu)
我一直试图解决这个问题,但我无法弄明白.所以,我有一个带有元组的列表,例如:
[("Mary", 10), ("John", 45), ("Bradley", 30), ("Mary", 15), ("John", 10)]
Run Code Online (Sandbox Code Playgroud)
我想得到的是一个带有元组的列表,如果名称相同,则应添加这些元组的数量,如果不是,那个元组也必须是最终列表的一部分,举例说明:
[("Mary",25), ("John", 55), ("Bradley", 30)]
Run Code Online (Sandbox Code Playgroud)
我不知道我是否真的很好地解释了自己,但我想你可能会理解这些例子.
我试过这个,但它不起作用:
test ((a,b):[]) = [(a,b)]
test ((a,b):(c,d):xs) | a == c = (a,b+d):test((a,b):xs)
| otherwise = (c,d):test((a,b):xs)
Run Code Online (Sandbox Code Playgroud) 可能重复:
为单个KVC更改接收2个KVO通知
我很困惑,我应该使用willChangeValueForKey:和didChangeValueForKey:.
我有一个具有属性的对象,该属性需要自定义setter方法.根据Apple文档,我使用will/didChangeValueForKey::
要实现手动观察者通知,请在更改值之前调用willChangeValueForKey:和更改值后调用didChangeValueForKey :. 清单3中的示例实现了opensBalance属性的手动通知.
清单3 实现手动通知的示例访问器方法
Run Code Online (Sandbox Code Playgroud)- (void)setOpeningBalance:(double)theBalance { [self willChangeValueForKey:@"openingBalance"]; _openingBalance = theBalance; [self didChangeValueForKey:@"openingBalance"]; }
这使我的对象看起来像下面这样:
@interface cObject
@property (readwrite, nonatomic) BOOL Property;
@end
@implementation cObject
- (void)setProperty:(BOOL)Property
{
[self willChangeValueForKey:@"Property"];
_Property = Property;
[self didChangeValueForKey:@"Property"];
//Do some other stuff
}
@end
Run Code Online (Sandbox Code Playgroud)
我混淆的原因是,如果我设置另一个对象来观察Property一个实例,cObject然后调用[myObject setProperty:],我的观察者的回调函数会被击中两次.看堆栈:第一次命中是因为我调用didChangeValueForKey:,第二次命中是我调用的直接结果setProperty:(即我的自定义setter没有出现在堆栈中).
为了进一步增加混乱,如果我_Property在其他地方改变了另一个功能cObject,我的观察者将不会得到通知(did/willChangeValueForKey:当然,除非我使用!).
编辑:即使我没有更改 …
所以这就是我所拥有的:
<?php
$db_host = "localhost";
$db_username = "root";
$db_pass = "";
$db_name = "OnlineBulletinBoardDB";
@mysql_connect("$db_host","$db_username","$db_pass") or die ("Could no connect to MySQL");
@mysql_select_db("$db_name") or die ("No database");
$query="SELECT PostSubject, FROM postings;";
$result=mysql_query($query);
mysql_close();
?>
<H1>Post Subject</H1>
<?php echo mysql_num_rows($result); ?>
Run Code Online (Sandbox Code Playgroud)
但它不起作用,当我尝试运行它时,在最后一行给出了一些错误.
有任何想法吗?
我在应用程序主窗口的顶部有一个操作表,然后我提示一个NSAlert.
该NSAlert含有抑制复选框和布局("不再显示此消息"),这是我没有手动添加的,我想从删除它NSAlert.
我怎么能这样做?
我写这段代码:
运行时,行中发生错误
cout<<it2->first;
Run Code Online (Sandbox Code Playgroud)
test3.exe中0x00411edd处的未处理异常:0xC0000005:访问冲突读取位置0x00000004."
我有Visual Studio Express 2008和Boost 1_47_0;
这是我的完整代码:
#include "stdafx.h"
#include <iostream>
#include <boost/unordered_map.hpp>
using namespace std;
typedef boost::unordered_map<int,int > MAP;
MAP map2;
boost::unordered_map<int,int>::iterator it2;
void gen_random(char *s ,char *p,int* r,const int len);
void inline insert2(int i_key,int i_value);
void print();
//-----------main------------------------------------
void main()
{
char* s_key=new char[8];
char* s_value=new char[8];
int i_value=0, size_random=8;
for(int i=0;i<12;i++)
{
gen_random(s_key,s_value,&i_value,size_random);
insert2(i_value,i_value);
}
print();
int a;
std::cin>>a;
}
//-------------end main--------------------------------
//--------my function ---------------------------
//-------random--------------
void gen_random(char* s,char* p,int *r, const int len) …Run Code Online (Sandbox Code Playgroud)