我看到一些bash/shell注释使用了表示法
# Some comment block that starts on line 1, but then
#+ continues on line 2 with this silly plus sign.
# And this is another comment line that is not related to the ones above
Run Code Online (Sandbox Code Playgroud)
"#+"是否对任何类型的解析器都有帮助(比如Doxygen样式的注释如何用于自动生成文档)?
这是一种常见做法吗?我知道,就实际的脚本执行而言,包含/排除它并没有任何损害,但我很好奇采用这种评论方式是否有优势.
在阅读了STL文件格式的规范之后,我想编写一些测试来确保文件实际上是有效的二进制文件或ASCII文件.
可以通过在字节0处查找文本" solid ",然后是空格(十六进制值\x20),然后是可选的文本字符串,后跟换行符来确定基于ASCII的STL文件.
二进制STL文件具有保留的80字节头,后跟4字节无符号整数(NumberOfTriangles),然后指定每个NumberOfTriangles构面的50字节数据.
每个三角形面的长度为50个字节:12个单精度(4字节)浮点数,后跟无符号短(2字节)无符号整数.
如果二进制文件正好是84 + NumberOfTriangles*50字节长,则通常可以将其视为有效的二进制文件.
不幸的是,二进制文件可以在80字节头的内容中包含从字节0开始的文本" solid ".因此,仅对该关键字进行测试不能正确地确定文件是ASCII还是二进制.
这是我到目前为止:
STL_STATUS getStlFileFormat(const QString &path)
{
// Each facet contains:
// - Normals: 3 floats (4 bytes)
// - Vertices: 3x floats (4 bytes each, 12 bytes total)
// - AttributeCount: 1 short (2 bytes)
// Total: 50 bytes per facet
const size_t facetSize = 3*sizeof(float_t) + 3*3*sizeof(float_t) …Run Code Online (Sandbox Code Playgroud) 我已经使用3个按钮定义了一个QtQuick对话框:Apply,OK和Cancel:
Dialog {
id: myDialog
standardButtons: StandardButton.Apply | StandardButton.Ok | StandardButton.Cancel
onApply: console.log("Applying data")
onAccepted: console.log("Saving data")
onRejected: console.log("Cancel changes to data")
Item { ... }
}
Run Code Online (Sandbox Code Playgroud)
单击"确定"和"取消"时,对话框将按预期关闭.当我单击"应用"按钮时,我希望对话框保持打开状态,但它也会关闭.
有没有办法挂钩它所以对话框保持打开该按钮,而关闭其他两个?
我今天从https://github.com/facebook/facebook-ios-sdk.git克隆,并注意到代码中有两个有这个结构的位置:
(id) init {
if ((self == [super init])) {
...
}
}
Run Code Online (Sandbox Code Playgroud)
我希望self在这里被分配,而不是为了平等而进行测试:
(id) init {
if ((self = [super init])) {
...
}
}
Run Code Online (Sandbox Code Playgroud)
或者至少:
(id) init {
self = [super init];
if (self) {
...
}
}
Run Code Online (Sandbox Code Playgroud)
这是在src/FBDialog.m和sample/Hackbook/Hackbook/DataSet.m.
(对不起,如果这应该在bug跟踪器中 ;找不到实际提交任何东西的方法......: - /
函数或脚本返回时0,表示没有错误.
如果用户想要查看特定功能/脚本的用法,例如使用foo -h或foo --help,则通常显示"使用"屏幕(其中描述参数并解释每个工作的方式),然后退出.在某些情况下,如果需要参数但没有给出参数,则会显示使用情况屏幕,就像-h提供了一样.
功能或脚本在显示使用时是返还0还是不返回0?它是否被视为显示用法的预期行为(特别是如果从其他函数/脚本中调用)?