GW2GetAllIdInfo
Mỗi vấn đề được Glasswall engine xác định và báo cáo đều có một issue ID duy nhất đi kèm. API này cung cấp bản tóm tắt của tất cả các số issue ID có thể có và các mô tả cấp cao tương ứng.
Đối với một session, hàm GW2GetAllIdInfo đặt dữ liệu XML được điền với mô tả Glasswall Issue ID và các khoảng giá trị vào một buffer đầu ra.
- C++
- C#
- Java
- Python
- JavaScript
Tóm tắt
Đối với session session, hàm GW2GetAllIdInfo đặt vào đối tượng được trỏ tới bởi outputBuffer một con trỏ tới dữ liệu XML được điền với mô tả Glasswall Issue ID và các khoảng giá trị. Độ dài, tính bằng byte, của buffer đầu ra đã được điền được đặt trong đối tượng size_t được trỏ tới bởi bufferLength.
#include "glasswall.core2.api.h"
int GW2GetAllIdInfo(
Session session,
size_t *bufferLength,
char **outputBuffer);
Giá trị trả về
Trả về một giá trị enum số nguyên GW2_RetStatus. Các số âm biểu thị lỗi. Nếu thành công, buffer đầu ra
chứa tệp XML.
Ví dụ
#include "glasswall.core2.api.h"
...
char *outbuf = NULL;
size_t buflen = 0;
if (GW2OpenSession())
/* error opening session*/
else
{
int status = GW2GetAllIdInfo(session, &buflen, &outbuf);
/* Buffer contains the XML file.
* Either process the data pointed to, or copy the data and process it
* after the session is closed
*/
if (GW2CloseSession())
/* error closing session */
}
Tóm tắt
public int GetAllIdInfo(
int session,
ref UIntPtr bufferLength,
out IntPtr outputBuffer)
Giá trị trả về
Trả về một giá trị enum số nguyên GW2_RetStatus. Các số âm biểu thị lỗi. Nếu thành công, buffer đầu ra
chứa tệp XML.
Ví dụ
...
UIntPtr bufferLength = UIntPtr.Zero;
IntPtr buffer = new IntPtr();
int session = glasswall.OpenSession();
int returnStatus = glasswall.GetAllIdInfo(session, ref bufferLength, out buffer);
using (StreamWriter writer = new StreamWriter(fileStream))
{
writer.WriteLine($"GW2GetAllIdInfo completed with status code {returnStatus}");
if ((int)bufferLength != 0)
{
WriteBytesToFile(Path.Combine(di.FullName, $"22 - GW2GetAllIdInfo.xml"),
glasswall.CreateArrayFromBuffer(buffer, bufferLength)
);
}
}
import com.glasswall.core2javabridge.*;
public String GW2GetAllIdInfoString(int session) throws GlasswallException
Lưu ý
Chức năng này trước đây yêu cầu hai lệnh gọi hàm riêng biệt để truy xuất dữ liệu ID. Hiện nay, quy trình này đã được tinh gọn để trả về các thiết lập dưới dạng String. Hai hàm gốc hiện đã bị ngừng dùng.
Giá trị trả về
Hàm GW2GetAllIdInfoString trả về một String chứa mô tả của tất cả Glasswall ID.
Một ngoại lệ GlasswallException sẽ được đưa ra nếu session không hợp lệ hoặc nếu không thể truy xuất toàn bộ thông tin ID.
Tóm tắt - Các hàm không còn được dùng
import com.glasswall.core2javabridge.*;
(Deprecated)
public int GW2GetAllIdInfo(int session) throws GlasswallException
public byte[] GetAllIDBuffer(int session) throws GlasswallException
Mô tả - Các hàm đã ngừng dùng
Hàm GW2GetAllIdInfo xuất mô tả của tất cả Glasswall ID cho phiên được chỉ định bởi session vào All ID Buffer nội bộ. Truy xuất dữ liệu này bằng cách sử dụng hàm GetAllIDBuffer.
Giá trị trả về - Các hàm không còn được dùng
Hàm GW2GetAllIdInfo trả về một giá trị liệt kê GW2_RetStatus được chuyển đổi thành int. Giá trị sẽ là số âm nếu xảy ra lỗi. 0 cho biết thành công. Tham khảo API Overview/Return types để biết chi tiết.
GetAllIDBuffer trả về một mảng byte chứa các mô tả Glasswall ID. Giá trị này sẽ là null nếu GW2GetAllIdInfo chưa được gọi.
Một ngoại lệ GlasswallException sẽ được đưa ra nếu session không hợp lệ hoặc nếu không thể truy xuất toàn bộ thông tin ID.
Tóm tắt
Truy xuất XML chứa tất cả các dải Issue ID cùng với mô tả nhóm của chúng.
def get_all_id_info(self, output_file: Optional[str] = None, raise_unsupported: bool = True) -> str:
""" Retrieves the XML containing all the Issue ID ranges with their group descriptions
Args:
output_file (Optional[str], optional): The output file path where the analysis file will be written.
raise_unsupported (bool, optional): Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.
Returns:
all_id_info (str): A string XML analysis report containing all id info.
"""
Giá trị trả về
Báo cáo phân tích XML dạng chuỗi chứa toàn bộ thông tin id.
Tóm tắt
/**
* This function places a pointer in a specified location to XML data populated with
* Glasswall Issue ID descriptions and value ranges, for a specified session.
*
* @param {number} session The ID of the session.
* @param {number} bufferLength The length of the buffer.
* @param {string} outputBuffer The location of the output buffer.
*/
GW2GetAllIdInfo(
session,
bufferLength,
outputBuffer)
Giá trị trả về
Trả về một giá trị enum GW2_RetStatus dạng số nguyên. Các số âm cho biết thất bại.
Ví dụ
const ref = require('ref-napi');
...
function buffer_to_string(buffer, buffer_size) {
if (!buffer.isNull() && ref.deref(buffer_size) > 0) {
return Buffer.from(ref.reinterpret(ref.deref(buffer), ref.deref(buffer_size), 0)).toString();
}
else {
return "";
}
}
...
let output_file_buffer = ref.alloc(ref.refType(ref.types.CString));
let output_buffer_size = ref.alloc(ref.types.size_t, 0);
let return_status = gw.GW2GetAllIdInfo(session_id, output_buffer_size, output_file_buffer);
let xml_string = buffer_to_string(output_file_buffer, output_buffer_size);
...